(read_capa): New function.
(check_capa): Call read_capa. (authenticate_imap_login): Check for LOGINDISABLED. (tls): Reread the capabilities after successfull TLS negotiation.
Showing
1 changed file
with
25 additions
and
3 deletions
... | @@ -223,18 +223,33 @@ parse_capa (f_imap_t f_imap, char *str) | ... | @@ -223,18 +223,33 @@ parse_capa (f_imap_t f_imap, char *str) |
223 | } | 223 | } |
224 | 224 | ||
225 | static int | 225 | static int |
226 | check_capa (f_imap_t f_imap, char *capa) | 226 | read_capa (f_imap_t f_imap, int force) |
227 | { | 227 | { |
228 | int i; | 228 | int status = 0; |
229 | |||
230 | if (force) | ||
231 | { | ||
232 | argcv_free (f_imap->capac, f_imap->capav); | ||
233 | f_imap->capac = 0; | ||
234 | f_imap->capav = NULL; | ||
235 | } | ||
229 | 236 | ||
230 | if (!f_imap->capav) | 237 | if (!f_imap->capav) |
231 | { | 238 | { |
232 | int status; | ||
233 | status = imap_writeline (f_imap, "g%u CAPABILITY\r\n", | 239 | status = imap_writeline (f_imap, "g%u CAPABILITY\r\n", |
234 | f_imap->seq++); | 240 | f_imap->seq++); |
235 | status = imap_send (f_imap); | 241 | status = imap_send (f_imap); |
236 | status = imap_parse (f_imap); | 242 | status = imap_parse (f_imap); |
237 | } | 243 | } |
244 | return status; | ||
245 | } | ||
246 | |||
247 | static int | ||
248 | check_capa (f_imap_t f_imap, char *capa) | ||
249 | { | ||
250 | int i; | ||
251 | |||
252 | read_capa (f_imap, 0); | ||
238 | for (i = 0; i < f_imap->capac; i++) | 253 | for (i = 0; i < f_imap->capac; i++) |
239 | if (strcasecmp (f_imap->capav[i], capa) == 0) | 254 | if (strcasecmp (f_imap->capav[i], capa) == 0) |
240 | return 0; | 255 | return 0; |
... | @@ -268,6 +283,7 @@ tls (folder_t folder) | ... | @@ -268,6 +283,7 @@ tls (folder_t folder) |
268 | folder->stream = str; | 283 | folder->stream = str; |
269 | FOLDER_DEBUG1 (folder, MU_DEBUG_PROT, "TLS negotiation %s\n", | 284 | FOLDER_DEBUG1 (folder, MU_DEBUG_PROT, "TLS negotiation %s\n", |
270 | status == 0 ? "succeeded" : "failed"); | 285 | status == 0 ? "succeeded" : "failed"); |
286 | read_capa (f_imap, 1); | ||
271 | } | 287 | } |
272 | return status; | 288 | return status; |
273 | #else | 289 | #else |
... | @@ -284,6 +300,12 @@ authenticate_imap_login (authority_t auth) | ... | @@ -284,6 +300,12 @@ authenticate_imap_login (authority_t auth) |
284 | ticket_t ticket; | 300 | ticket_t ticket; |
285 | int status = 0; | 301 | int status = 0; |
286 | 302 | ||
303 | if (check_capa (f_imap, "LOGINDISABLED") == 0) | ||
304 | { | ||
305 | FOLDER_DEBUG0 (folder, MU_DEBUG_PROT, "LOGIN command disabled\n"); | ||
306 | return ENOSYS; | ||
307 | } | ||
308 | |||
287 | switch (f_imap->state) | 309 | switch (f_imap->state) |
288 | { | 310 | { |
289 | case IMAP_AUTH: | 311 | case IMAP_AUTH: | ... | ... |
-
Please register or sign in to post a comment