]> code.citadel.org Git - citadel.git/blob - citadel/imap_acl.c
Worked on GETACL a little bit
[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                         /* Known, zapped, etc. mailboxes can probably be LIST-ed */
129                         /* FIXME don't give away hidden rooms */
130                         if (ra & UA_GOTOALLOWED)        strcat(rights, "l");
131
132                         /* Known rooms can be LSUB-ed */
133                         if (ra & UA_KNOWN)              strcat(rights, "r");
134
135                         /* FIXME do the rest */
136
137                         if (strlen(rights) > 0) {
138                                 cprintf(" ");
139                                 imap_strout(temp.fullname);
140                                 cprintf(" %s", rights);
141                         }
142                 }
143         }
144
145         cprintf("\r\n");
146
147         /*
148          * If another folder is selected, go back to that room so we can resume
149          * our happy day without violent explosions.
150          */
151         if (IMAP->selected) {
152                 usergoto(savedroom, 0, 0, &msgs, &new);
153         }
154
155         cprintf("%s OK GETACL completed\r\n", parms[0]);
156 }
157
158
159 /*
160  * Implements the LISTRIGHTS command.
161  */
162 void imap_listrights(int num_parms, char *parms[]) {
163
164         cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
165         return;
166 }
167
168
169 /*
170  * Implements the MYRIGHTS command.
171  */
172 void imap_myrights(int num_parms, char *parms[]) {
173
174         cprintf("%s BAD not yet implemented FIXME\r\n", parms[0]);
175         return;
176 }
177
178