]> code.citadel.org Git - citadel.git/blob - citadel/imap_acl.c
Fixed a syntax error
[citadel.git] / citadel / imap_acl.c
1 /*
2  * $Id:  $
3  *
4  * Functions which implement RFC2086/RFC4314 (IMAP ACL extension)
5  *
6  */
7
8
9 #include "sysdep.h"
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <stdio.h>
13 #include <fcntl.h>
14 #include <signal.h>
15 #include <pwd.h>
16 #include <errno.h>
17 #include <sys/types.h>
18
19 #if TIME_WITH_SYS_TIME
20 # include <sys/time.h>
21 # include <time.h>
22 #else
23 # if HAVE_SYS_TIME_H
24 #  include <sys/time.h>
25 # else
26 #  include <time.h>
27 # endif
28 #endif
29
30 #include <sys/wait.h>
31 #include <ctype.h>
32 #include <string.h>
33 #include <limits.h>
34 #include "citadel.h"
35 #include "server.h"
36 #include "sysdep_decls.h"
37 #include "citserver.h"
38 #include "support.h"
39 #include "config.h"
40 #include "serv_extensions.h"
41 #include "room_ops.h"
42 #include "user_ops.h"
43 #include "policy.h"
44 #include "database.h"
45 #include "msgbase.h"
46 #include "tools.h"
47 #include "internet_addressing.h"
48 #include "serv_imap.h"
49 #include "imap_tools.h"
50 #include "imap_fetch.h"
51 #include "imap_misc.h"
52 #include "genstamp.h"
53
54
55
56 /*
57  * Implements the SETACL command.
58  */
59 void imap_setacl(int num_parms, char *parms[]) {
60
61         cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
62         return;
63 }
64
65
66 /*
67  * Implements the DELETEACL command.
68  */
69 void imap_deleteacl(int num_parms, char *parms[]) {
70
71         cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
72         return;
73 }
74
75
76
77 /*
78  * Implements the GETACL command.
79  */
80 void imap_getacl(int num_parms, char *parms[]) {
81         char roomname[ROOMNAMELEN];
82         char savedroom[ROOMNAMELEN];
83         int msgs, new;
84         int ret;
85         struct ctdluser temp;
86         struct cdbdata *cdbus;
87         int ra;
88         char rights[32];
89
90         if (num_parms != 3) {
91                 cprintf("%s BAD usage error\r\n", parms[0]);
92                 return;
93         }
94
95         ret = imap_grabroom(roomname, parms[2], 0);
96         if (ret != 0) {
97                 cprintf("%s NO Invalid mailbox name or access denied\r\n",
98                         parms[0]);
99                 return;
100         }
101
102         /*
103          * usergoto() formally takes us to the desired room.  (If another
104          * folder is selected, save its name so we can return there!!!!!)
105          */
106         if (IMAP->selected) {
107                 strcpy(savedroom, CC->room.QRname);
108         }
109         usergoto(roomname, 0, 0, &msgs, &new);
110
111         cprintf("* ACL");
112         cprintf(" ");
113         imap_strout(parms[2]);
114
115         /*
116          * Traverse the userlist
117          */
118         cdb_rewind(CDB_USERS);
119         while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
120                 memset(&temp, 0, sizeof temp);
121                 memcpy(&temp, cdbus->ptr, sizeof temp);
122                 cdb_free(cdbus);
123
124                 CtdlRoomAccess(&CC->room, &temp, &ra, NULL);
125                 if (strlen(temp.fullname) > 0) {
126                         strcpy(rights, "");
127
128                         /* l - lookup (mailbox is visible to LIST/LSUB commands, SUBSCRIBE mailbox)
129                          * r - read (SELECT the mailbox, perform STATUS)
130                          * s - keep seen/unseen information across sessions (set or clear \SEEN flag
131                          *     via STORE, also set \SEEN during APPEND/COPY/ FETCH BODY[...])
132                          */
133                         if (    (ra & UA_KNOWN)                                 /* known rooms */
134                            ||   ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED))     /* zapped rooms */
135                            ) {
136                                                         strcat(rights, "l");
137                                                         strcat(rights, "r");
138                                                         strcat(rights, "s");
139                         }
140
141                         /* w - write (set or clear flags other than \SEEN and \DELETED via
142                          * STORE, also set them during APPEND/COPY)
143                          */
144                         /* Never granted in Citadel because our store doesn't support other flags */
145
146                         /* i - insert (perform APPEND, COPY into mailbox)
147                          * p - post (send mail to submission address for mailbox, not enforced by IMAP)
148                          */
149                         if (ra & UA_POSTALLOWED) {
150                                                         strcat(rights, "i");
151                                                         strcat(rights, "p");
152                         }
153
154                         /* k - create mailboxes (CREATE new sub-mailboxes in any
155                          * implementation-defined hierarchy, parent mailbox for the new
156                          * mailbox name in RENAME) */
157
158                         /* x - delete mailbox (DELETE mailbox, old mailbox name in RENAME) */
159
160                         /* t - delete messages (set or clear \DELETED flag via STORE, set
161                          * \DELETED flag during APPEND/COPY) */
162
163                         /* e - perform EXPUNGE and expunge as a part of CLOSE */
164
165                         /* a - administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS) */
166
167                         if (strlen(rights) > 0) {
168                                 cprintf(" ");
169                                 imap_strout(temp.fullname);
170                                 cprintf(" %s", rights);
171                         }
172                 }
173         }
174
175         cprintf("\r\n");
176
177         /*
178          * If another folder is selected, go back to that room so we can resume
179          * our happy day without violent explosions.
180          */
181         if (IMAP->selected) {
182                 usergoto(savedroom, 0, 0, &msgs, &new);
183         }
184
185         cprintf("%s OK GETACL completed\r\n", parms[0]);
186 }
187
188
189 /*
190  * Implements the LISTRIGHTS command.
191  */
192 void imap_listrights(int num_parms, char *parms[]) {
193
194         cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
195         return;
196 }
197
198
199 /*
200  * Implements the MYRIGHTS command.
201  */
202 void imap_myrights(int num_parms, char *parms[]) {
203
204         cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
205         return;
206 }
207
208