Improve registrar/url interaction. Fix SMTP URLs to comply to draft-earhart-url…
…-smtp-00. Minor fix in maidag (url mode). * include/mailutils/registrar.h (MU_RECORD_DEFAULT) (MU_RECORD_LOCAL): New flags. (_mu_record) <flags,url_may_have,url_must_have>: New members. Remove unnecessary externs. (mu_record_set_.*): Remove all protos. (mu_record_check_url, mu_registrar_test_local_url): New protos. * include/mailutils/sys/url.h (_mu_url) <flags>: New member. (MU_URL_USER, MU_URL_SECRET, MU_URL_AUTH) (MU_URL_HOST, MU_URL_PORT, MU_URL_PATH) (MU_URL_PARAM, MU_URL_QUERY) (MU_URL_CRED, MU_URL_INET, MU_URL_ALL): New flags. (mu_url_get_flags, mu_url_has_flag): New protos. * libmailutils/base/registrar.c (mu_record_set_.*): Remove all. (mu_record_check_url): New function. (mu_registrar_test_local_url): New function. * libmailutils/base/url.c (mu_url_copy0): Copy flags. (mu_url_parse): Use flags intead of inspecting each structure member. Set flags. (mu_url_get_flags, mu_url_has_flag): New functions. * libmailutils/diag/errors (MU_ERR_URL_MISS_PARTS) (MU_ERR_URL_EXTRA_PARTS): New error codes. * libmailutils/mailbox/folder.c (mu_folder_create_from_record): Check the URL using mu_record_check_url. * libproto/imap/folder.c (_imap_record, _imaps_record): Initialize new fields. * libproto/maildir/folder.c (_maildir_record): Likewise. * libproto/mbox/folder.c (_mbox_record): Likewise. * libproto/mh/folder.c (_mh_record): Likewise. * libproto/nntp/folder.c (_nntp_record): Likewise. * libproto/pop/folder.c (_pop_record, _pops_record): Likewise. * libproto/mailer/prog.c (_prog_record): Likewise. (_url_prog_init): Remove extra checks, rely on mu_record_check_url. * libproto/mailer/remote.c (_mu_remote_smtp_record) (_mu_remote_sendmail_record,_mu_remote_prog_record): Initialize new fields. * libproto/mailer/sendmail.c (_url_sendmail_init): Remove extra checks, rely on mu_record_check_url. (_sendmail_record): Initialize new fields. * libproto/nntp/url.c (url_nntp_destroy): Remove. (_nntp_url_init): Remove extra checks. * libproto/pop/url.c (url_pop_destroy): Remove. (_url_pop_init, _url_pops_init): Remove extra checks. * libproto/mailer/smtp.c (_url_smtp_init): Remove extra checks. (_smtp_record): Initialize new fields. (smtp_mailer_add_auth_mech): New function. (smtp_open): Allow for auth= part before the host name. * maidag/deliver.c (is_remote_url): New function. (do_delivery): Do not try to switch user privileges if the URL refers to a remote mailbox. * maidag/maidag.c (main): Initialize TLS.
Showing
21 changed files
with
238 additions
and
223 deletions
... | @@ -25,11 +25,21 @@ | ... | @@ -25,11 +25,21 @@ |
25 | extern "C" { | 25 | extern "C" { |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #define MU_RECORD_DEFAULT 0 | ||
29 | #define MU_RECORD_LOCAL 0x0001 | ||
30 | /* This record represents a "local entity", e.g. a UNIX or MH mailbox */ | ||
31 | |||
32 | |||
28 | /* Public Interface, to allow static initialization. */ | 33 | /* Public Interface, to allow static initialization. */ |
29 | struct _mu_record | 34 | struct _mu_record |
30 | { | 35 | { |
31 | int priority; /* Higher priority records are scanned first */ | 36 | int priority; /* Higher priority records are scanned first */ |
32 | const char *scheme; | 37 | const char *scheme; |
38 | int flags; /* MU_RECORD_ flags */ | ||
39 | int url_may_have; /* MU_URL_ flags (see url.h) describing what an URL | ||
40 | for this record may have */ | ||
41 | int url_must_have;/* MU_URL_ flags telling what such an URL must have */ | ||
42 | |||
33 | int (*_url) (mu_url_t); | 43 | int (*_url) (mu_url_t); |
34 | int (*_mailbox) (mu_mailbox_t); | 44 | int (*_mailbox) (mu_mailbox_t); |
35 | int (*_mailer) (mu_mailer_t); | 45 | int (*_mailer) (mu_mailer_t); |
... | @@ -47,54 +57,40 @@ struct _mu_record | ... | @@ -47,54 +57,40 @@ struct _mu_record |
47 | }; | 57 | }; |
48 | 58 | ||
49 | /* Defaults */ | 59 | /* Defaults */ |
50 | extern int mu_registrar_set_default_scheme (const char *scheme); | 60 | int mu_registrar_set_default_scheme (const char *scheme); |
51 | extern const char *mu_registrar_get_default_scheme (void); | 61 | const char *mu_registrar_get_default_scheme (void); |
52 | extern int mu_registrar_get_default_record (mu_record_t *prec); | 62 | int mu_registrar_get_default_record (mu_record_t *prec); |
53 | extern void mu_registrar_set_default_record (mu_record_t record); | 63 | void mu_registrar_set_default_record (mu_record_t record); |
54 | 64 | ||
55 | /* Registration. */ | 65 | /* Registration. */ |
56 | extern int mu_registrar_get_iterator (mu_iterator_t *); | 66 | int mu_registrar_get_iterator (mu_iterator_t *); |
57 | extern int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated)); | 67 | int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated)); |
58 | 68 | ||
59 | extern int mu_registrar_lookup_scheme (const char *scheme, | 69 | int mu_registrar_lookup_scheme (const char *scheme, |
60 | mu_record_t *precord); | 70 | mu_record_t *precord); |
61 | 71 | ||
62 | extern int mu_registrar_lookup (const char *name, int flags, | 72 | int mu_registrar_lookup (const char *name, int flags, |
63 | mu_record_t *precord, int *pflags); | 73 | mu_record_t *precord, int *pflags); |
64 | extern int mu_registrar_lookup_url (mu_url_t url, int flags, | 74 | int mu_registrar_lookup_url (mu_url_t url, int flags, |
65 | mu_record_t *precord, int *pflags); | 75 | mu_record_t *precord, int *pflags); |
66 | extern int mu_registrar_record (mu_record_t); | 76 | int mu_registrar_record (mu_record_t); |
67 | extern int mu_unregistrar_record (mu_record_t); | 77 | int mu_unregistrar_record (mu_record_t); |
68 | 78 | ||
69 | /* Scheme. */ | 79 | /* Scheme. */ |
70 | extern int mu_record_is_scheme (mu_record_t, mu_url_t, int flags); | 80 | int mu_record_is_scheme (mu_record_t, mu_url_t, int flags); |
71 | extern int mu_record_set_scheme (mu_record_t, const char *); | ||
72 | extern int mu_record_set_is_scheme (mu_record_t, | ||
73 | int (*_is_scheme) (mu_record_t, mu_url_t, int)); | ||
74 | 81 | ||
75 | /* Url. */ | 82 | /* Url. */ |
76 | extern int mu_record_get_url (mu_record_t, int (*(*)) (mu_url_t)); | 83 | int mu_record_get_url (mu_record_t, int (*(*)) (mu_url_t)); |
77 | extern int mu_record_set_url (mu_record_t, int (*) (mu_url_t)); | 84 | int mu_record_check_url (mu_record_t record, mu_url_t url, int *pmask); |
78 | extern int mu_record_set_get_url (mu_record_t, | 85 | int mu_registrar_test_local_url (mu_url_t url, int *pres); |
79 | int (*_get_url) (mu_record_t, int (*(*)) (mu_url_t))); | ||
80 | /* Mailbox. */ | 86 | /* Mailbox. */ |
81 | extern int mu_record_get_mailbox (mu_record_t, int (*(*)) (mu_mailbox_t)); | 87 | int mu_record_get_mailbox (mu_record_t, int (*(*)) (mu_mailbox_t)); |
82 | extern int mu_record_set_mailbox (mu_record_t, int (*) (mu_mailbox_t)); | ||
83 | extern int mu_record_set_get_mailbox (mu_record_t, | ||
84 | int (*_get_mailbox) (mu_record_t, int (*(*)) (mu_mailbox_t))); | ||
85 | /* Mailer. */ | 88 | /* Mailer. */ |
86 | extern int mu_record_get_mailer (mu_record_t, | 89 | int mu_record_get_mailer (mu_record_t, int (*(*)) (mu_mailer_t)); |
87 | int (*(*)) (mu_mailer_t)); | ||
88 | extern int mu_record_set_mailer (mu_record_t, int (*) (mu_mailer_t)); | ||
89 | extern int mu_record_set_get_mailer (mu_record_t, | ||
90 | int (*_get_mailer) (mu_record_t, int (*(*)) (mu_mailer_t))); | ||
91 | /* Folder. */ | 90 | /* Folder. */ |
92 | extern int mu_record_get_folder (mu_record_t, int (*(*)) (mu_folder_t)); | 91 | int mu_record_get_folder (mu_record_t, int (*(*)) (mu_folder_t)); |
93 | extern int mu_record_set_folder (mu_record_t, int (*) (mu_folder_t)); | 92 | |
94 | extern int mu_record_set_get_folder (mu_record_t, | 93 | int mu_record_list_p (mu_record_t record, const char *name, int); |
95 | int (*_get_folder) (mu_record_t, int (*(*)) (mu_folder_t))); | ||
96 | |||
97 | extern int mu_record_list_p (mu_record_t record, const char *name, int); | ||
98 | 94 | ||
99 | /* Records provided by the library. */ | 95 | /* Records provided by the library. */ |
100 | 96 | ... | ... |
... | @@ -25,10 +25,33 @@ | ... | @@ -25,10 +25,33 @@ |
25 | extern "C" { | 25 | extern "C" { |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #define MU_URL_USER 0x0001 /* Has a user part */ | ||
29 | #define MU_URL_SECRET 0x0002 /* Has a secret (password) part */ | ||
30 | #define MU_URL_AUTH 0x0004 /* Has auth part */ | ||
31 | #define MU_URL_HOST 0x0008 /* Has host part */ | ||
32 | #define MU_URL_PORT 0x0010 /* Has port part */ | ||
33 | #define MU_URL_PATH 0x0020 /* Has path */ | ||
34 | #define MU_URL_PARAM 0x0040 /* Has parameters */ | ||
35 | #define MU_URL_QUERY 0x0080 /* Has query */ | ||
36 | |||
37 | #define MU_URL_CRED (MU_URL_USER | MU_URL_SECRET | MU_URL_AUTH) | ||
38 | /* Has some of authentication credentials */ | ||
39 | #define MU_URL_INET (MU_URL_HOST | MU_URL_PORT) | ||
40 | /* Has Inet address */ | ||
41 | #define MU_URL_ALL \ | ||
42 | (MU_URL_CRED | \ | ||
43 | MU_URL_HOST | \ | ||
44 | MU_URL_PATH | \ | ||
45 | MU_URL_PARAM | \ | ||
46 | MU_URL_QUERY) | ||
47 | |||
28 | int mu_url_create (mu_url_t *, const char *name); | 48 | int mu_url_create (mu_url_t *, const char *name); |
29 | int mu_url_dup (mu_url_t old_url, mu_url_t *new_url); | 49 | int mu_url_dup (mu_url_t old_url, mu_url_t *new_url); |
30 | int mu_url_uplevel (mu_url_t url, mu_url_t *upurl); | 50 | int mu_url_uplevel (mu_url_t url, mu_url_t *upurl); |
31 | 51 | ||
52 | int mu_url_get_flags (mu_url_t, int *); | ||
53 | int mu_url_has_flag (mu_url_t, int); | ||
54 | |||
32 | void mu_url_destroy (mu_url_t *); | 55 | void mu_url_destroy (mu_url_t *); |
33 | int mu_url_parse (mu_url_t); | 56 | int mu_url_parse (mu_url_t); |
34 | 57 | ... | ... |
... | @@ -281,25 +281,6 @@ mu_record_is_scheme (mu_record_t record, mu_url_t url, int flags) | ... | @@ -281,25 +281,6 @@ mu_record_is_scheme (mu_record_t record, mu_url_t url, int flags) |
281 | } | 281 | } |
282 | 282 | ||
283 | int | 283 | int |
284 | mu_record_set_scheme (mu_record_t record, const char *scheme) | ||
285 | { | ||
286 | if (record == NULL) | ||
287 | return EINVAL; | ||
288 | record->scheme = scheme; | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | int | ||
293 | mu_record_set_is_scheme (mu_record_t record, | ||
294 | int (*_is_scheme) (mu_record_t, mu_url_t, int)) | ||
295 | { | ||
296 | if (record == NULL) | ||
297 | return EINVAL; | ||
298 | record->_is_scheme = _is_scheme; | ||
299 | return 0; | ||
300 | } | ||
301 | |||
302 | int | ||
303 | mu_record_get_url (mu_record_t record, int (*(*_purl)) (mu_url_t)) | 284 | mu_record_get_url (mu_record_t record, int (*(*_purl)) (mu_url_t)) |
304 | { | 285 | { |
305 | if (record == NULL) | 286 | if (record == NULL) |
... | @@ -314,25 +295,6 @@ mu_record_get_url (mu_record_t record, int (*(*_purl)) (mu_url_t)) | ... | @@ -314,25 +295,6 @@ mu_record_get_url (mu_record_t record, int (*(*_purl)) (mu_url_t)) |
314 | } | 295 | } |
315 | 296 | ||
316 | int | 297 | int |
317 | mu_record_set_url (mu_record_t record, int (*_mu_url) (mu_url_t)) | ||
318 | { | ||
319 | if (record == NULL) | ||
320 | return EINVAL; | ||
321 | record->_url = _mu_url; | ||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | int | ||
326 | mu_record_set_get_url (mu_record_t record, int (*_get_url) | ||
327 | (mu_record_t, int (*(*)) (mu_url_t))) | ||
328 | { | ||
329 | if (record == NULL) | ||
330 | return EINVAL; | ||
331 | record->_get_url = _get_url; | ||
332 | return 0; | ||
333 | } | ||
334 | |||
335 | int | ||
336 | mu_record_get_mailbox (mu_record_t record, int (*(*_pmailbox)) (mu_mailbox_t)) | 298 | mu_record_get_mailbox (mu_record_t record, int (*(*_pmailbox)) (mu_mailbox_t)) |
337 | { | 299 | { |
338 | if (record == NULL) | 300 | if (record == NULL) |
... | @@ -347,25 +309,6 @@ mu_record_get_mailbox (mu_record_t record, int (*(*_pmailbox)) (mu_mailbox_t)) | ... | @@ -347,25 +309,6 @@ mu_record_get_mailbox (mu_record_t record, int (*(*_pmailbox)) (mu_mailbox_t)) |
347 | } | 309 | } |
348 | 310 | ||
349 | int | 311 | int |
350 | mu_record_set_mailbox (mu_record_t record, int (*_mu_mailbox) (mu_mailbox_t)) | ||
351 | { | ||
352 | if (record) | ||
353 | return EINVAL; | ||
354 | record->_mailbox = _mu_mailbox; | ||
355 | return 0; | ||
356 | } | ||
357 | |||
358 | int | ||
359 | mu_record_set_get_mailbox (mu_record_t record, | ||
360 | int (*_get_mailbox) (mu_record_t, int (*(*)) (mu_mailbox_t))) | ||
361 | { | ||
362 | if (record) | ||
363 | return EINVAL; | ||
364 | record->_get_mailbox = _get_mailbox; | ||
365 | return 0; | ||
366 | } | ||
367 | |||
368 | int | ||
369 | mu_record_get_mailer (mu_record_t record, int (*(*_pmailer)) (mu_mailer_t)) | 312 | mu_record_get_mailer (mu_record_t record, int (*(*_pmailer)) (mu_mailer_t)) |
370 | { | 313 | { |
371 | if (record == NULL) | 314 | if (record == NULL) |
... | @@ -380,25 +323,6 @@ mu_record_get_mailer (mu_record_t record, int (*(*_pmailer)) (mu_mailer_t)) | ... | @@ -380,25 +323,6 @@ mu_record_get_mailer (mu_record_t record, int (*(*_pmailer)) (mu_mailer_t)) |
380 | } | 323 | } |
381 | 324 | ||
382 | int | 325 | int |
383 | mu_record_set_mailer (mu_record_t record, int (*_mu_mailer) (mu_mailer_t)) | ||
384 | { | ||
385 | if (record) | ||
386 | return EINVAL; | ||
387 | record->_mailer = _mu_mailer; | ||
388 | return 0; | ||
389 | } | ||
390 | |||
391 | int | ||
392 | mu_record_set_get_mailer (mu_record_t record, | ||
393 | int (*_get_mailer) (mu_record_t, int (*(*)) (mu_mailer_t))) | ||
394 | { | ||
395 | if (record == NULL) | ||
396 | return EINVAL; | ||
397 | record->_get_mailer = _get_mailer; | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | int | ||
402 | mu_record_get_folder (mu_record_t record, int (*(*_pfolder)) (mu_folder_t)) | 326 | mu_record_get_folder (mu_record_t record, int (*(*_pfolder)) (mu_folder_t)) |
403 | { | 327 | { |
404 | if (record == NULL) | 328 | if (record == NULL) |
... | @@ -413,30 +337,64 @@ mu_record_get_folder (mu_record_t record, int (*(*_pfolder)) (mu_folder_t)) | ... | @@ -413,30 +337,64 @@ mu_record_get_folder (mu_record_t record, int (*(*_pfolder)) (mu_folder_t)) |
413 | } | 337 | } |
414 | 338 | ||
415 | int | 339 | int |
416 | mu_record_set_folder (mu_record_t record, int (*_mu_folder) (mu_folder_t)) | 340 | mu_record_list_p (mu_record_t record, const char *name, int flags) |
417 | { | 341 | { |
418 | if (record == NULL) | 342 | if (record == NULL) |
419 | return EINVAL; | 343 | return EINVAL; |
420 | record->_folder = _mu_folder; | 344 | return record == NULL |
421 | return 0; | 345 | || !record->_list_p |
346 | || record->_list_p (record, name, flags); | ||
422 | } | 347 | } |
423 | 348 | ||
424 | int | 349 | int |
425 | mu_record_set_get_folder (mu_record_t record, | 350 | mu_record_check_url (mu_record_t record, mu_url_t url, int *pmask) |
426 | int (*_get_folder) (mu_record_t, int (*(*)) (mu_folder_t))) | ||
427 | { | 351 | { |
428 | if (record == NULL) | 352 | int mask; |
353 | int flags; | ||
354 | int rc; | ||
355 | |||
356 | if (!record || !url) | ||
429 | return EINVAL; | 357 | return EINVAL; |
430 | record->_get_folder = _get_folder; | 358 | |
359 | rc = mu_url_get_flags (url, &flags); | ||
360 | if (rc) | ||
361 | return rc; | ||
362 | |||
363 | mask = flags & record->url_must_have; | ||
364 | if (mask != record->url_must_have) | ||
365 | { | ||
366 | if (pmask) | ||
367 | *pmask = record->url_must_have & ~mask; | ||
368 | return MU_ERR_URL_MISS_PARTS; | ||
369 | } | ||
370 | mask = flags & ~(record->url_may_have | record->url_must_have); | ||
371 | if (mask) | ||
372 | { | ||
373 | if (pmask) | ||
374 | *pmask = mask; | ||
375 | return MU_ERR_URL_EXTRA_PARTS; | ||
376 | } | ||
431 | return 0; | 377 | return 0; |
432 | } | 378 | } |
433 | 379 | ||
380 | /* Test if URL corresponds to a local record. | ||
381 | Return: | ||
382 | 0 - OK, the result is stored in *pres; | ||
383 | MU_ERR_NOENT - don't know: there's no matching record; | ||
384 | EINVAL - some of the arguments is not valid; | ||
385 | other - URL lookup failed. | ||
386 | */ | ||
434 | int | 387 | int |
435 | mu_record_list_p (mu_record_t record, const char *name, int flags) | 388 | mu_registrar_test_local_url (mu_url_t url, int *pres) |
436 | { | 389 | { |
437 | if (record == NULL) | 390 | int rc; |
391 | mu_record_t rec; | ||
392 | |||
393 | if (!url || !pres) | ||
438 | return EINVAL; | 394 | return EINVAL; |
439 | return record == NULL | 395 | rc = mu_registrar_lookup_url (url, MU_FOLDER_ATTRIBUTE_ALL, &rec, NULL); |
440 | || !record->_list_p | 396 | if (rc) |
441 | || record->_list_p (record, name, flags); | 397 | return rc; |
398 | *pres = rec->flags & MU_RECORD_LOCAL; | ||
399 | return 0; | ||
442 | } | 400 | } | ... | ... |
... | @@ -176,6 +176,7 @@ mu_url_copy0 (mu_url_t old_url, mu_url_t new_url) | ... | @@ -176,6 +176,7 @@ mu_url_copy0 (mu_url_t old_url, mu_url_t new_url) |
176 | return ENOMEM; | 176 | return ENOMEM; |
177 | new_url->qargc = argc; | 177 | new_url->qargc = argc; |
178 | } | 178 | } |
179 | new_url->flags = old_url->flags; | ||
179 | return 0; | 180 | return 0; |
180 | #undef URLCOPY | 181 | #undef URLCOPY |
181 | } | 182 | } |
... | @@ -292,8 +293,7 @@ mu_url_parse (mu_url_t url) | ... | @@ -292,8 +293,7 @@ mu_url_parse (mu_url_t url) |
292 | 293 | ||
293 | memset (&u, 0, sizeof u); | 294 | memset (&u, 0, sizeof u); |
294 | /* can't have been parsed already */ | 295 | /* can't have been parsed already */ |
295 | if (url->scheme || url->user || url->secret || url->auth || | 296 | if (url->flags) |
296 | url->host || url->path || url->qargc) | ||
297 | return EINVAL; | 297 | return EINVAL; |
298 | 298 | ||
299 | n = strdup (url->name); | 299 | n = strdup (url->name); |
... | @@ -331,21 +331,25 @@ mu_url_parse (mu_url_t url) | ... | @@ -331,21 +331,25 @@ mu_url_parse (mu_url_t url) |
331 | though. | 331 | though. |
332 | */ | 332 | */ |
333 | 333 | ||
334 | #define UALLOC(X) \ | 334 | #define UALLOC(X,f) \ |
335 | if (u.X && u.X[0] && \ | 335 | if (u.X && u.X[0]) \ |
336 | !(url->X = (want_decode ? mu_url_decode (u.X) : strdup (u.X)))) \ | ||
337 | { \ | 336 | { \ |
338 | err = ENOMEM; \ | 337 | url->X = want_decode ? mu_url_decode (u.X) : strdup (u.X); \ |
339 | goto CLEANUP; \ | 338 | if (!url->X) \ |
339 | { \ | ||
340 | err = ENOMEM; \ | ||
341 | goto CLEANUP; \ | ||
342 | } \ | ||
343 | url->flags |= f; \ | ||
340 | } \ | 344 | } \ |
341 | else \ | 345 | else \ |
342 | { \ | 346 | { \ |
343 | /* Set zero-length strings to NULL. */ \ | 347 | /* Set zero-length strings to NULL. */ \ |
344 | u.X = NULL; \ | 348 | url->X = NULL; \ |
345 | } | 349 | } |
346 | 350 | ||
347 | UALLOC (scheme); | 351 | UALLOC (scheme, 0); |
348 | UALLOC (user); | 352 | UALLOC (user, MU_URL_USER); |
349 | 353 | ||
350 | if (u.secret) | 354 | if (u.secret) |
351 | { | 355 | { |
... | @@ -357,20 +361,27 @@ mu_url_parse (mu_url_t url) | ... | @@ -357,20 +361,27 @@ mu_url_parse (mu_url_t url) |
357 | goto CLEANUP; | 361 | goto CLEANUP; |
358 | 362 | ||
359 | url->secret = newsec; | 363 | url->secret = newsec; |
364 | url->flags |= MU_URL_SECRET; | ||
360 | } | 365 | } |
361 | 366 | ||
362 | UALLOC (auth); | 367 | UALLOC (auth, MU_URL_AUTH); |
363 | UALLOC (host); | 368 | UALLOC (host, MU_URL_HOST); |
364 | UALLOC (path); | 369 | UALLOC (path, MU_URL_PATH); |
365 | 370 | ||
366 | #undef UALLOC | 371 | #undef UALLOC |
367 | url->fvcount = u.fvcount; | 372 | url->fvcount = u.fvcount; |
368 | url->fvpairs = u.fvpairs; | 373 | url->fvpairs = u.fvpairs; |
369 | 374 | if (u.fvcount) | |
375 | url->flags |= MU_URL_PARAM; | ||
376 | |||
370 | url->qargc = u.qargc; | 377 | url->qargc = u.qargc; |
371 | url->qargv = u.qargv; | 378 | url->qargv = u.qargv; |
379 | if (u.qargc) | ||
380 | url->flags |= MU_URL_QUERY; | ||
372 | 381 | ||
373 | url->port = u.port; | 382 | url->port = u.port; |
383 | if (u.port) | ||
384 | url->flags |= MU_URL_PORT; | ||
374 | } | 385 | } |
375 | 386 | ||
376 | CLEANUP: | 387 | CLEANUP: |
... | @@ -1189,3 +1200,21 @@ mu_url_expand_path (mu_url_t url) | ... | @@ -1189,3 +1200,21 @@ mu_url_expand_path (mu_url_t url) |
1189 | 1200 | ||
1190 | return 0; | 1201 | return 0; |
1191 | } | 1202 | } |
1203 | |||
1204 | int | ||
1205 | mu_url_get_flags (mu_url_t url, int *pf) | ||
1206 | { | ||
1207 | if (!url || !pf) | ||
1208 | return EINVAL; | ||
1209 | *pf = url->flags; | ||
1210 | return 0; | ||
1211 | } | ||
1212 | |||
1213 | int | ||
1214 | mu_url_has_flag (mu_url_t url, int flags) | ||
1215 | { | ||
1216 | if (!url) | ||
1217 | return 0; | ||
1218 | return url->flags & flags; | ||
1219 | } | ||
1220 | ... | ... |
... | @@ -92,3 +92,6 @@ MU_ERR_READ _("Read error") | ... | @@ -92,3 +92,6 @@ MU_ERR_READ _("Read error") |
92 | 92 | ||
93 | MU_ERR_NO_TRANSPORT _("Transport stream not set") | 93 | MU_ERR_NO_TRANSPORT _("Transport stream not set") |
94 | MU_ERR_AUTH_NO_CRED _("No credentials supplied") | 94 | MU_ERR_AUTH_NO_CRED _("No credentials supplied") |
95 | |||
96 | MU_ERR_URL_MISS_PARTS _("URL missing required parts") | ||
97 | MU_ERR_URL_EXTRA_PARTS _("URL has parts not allowed by its scheme") | ... | ... |
... | @@ -76,10 +76,15 @@ mu_folder_create_from_record (mu_folder_t *pfolder, mu_url_t url, | ... | @@ -76,10 +76,15 @@ mu_folder_create_from_record (mu_folder_t *pfolder, mu_url_t url, |
76 | mu_record_get_folder (record, &f_init); | 76 | mu_record_get_folder (record, &f_init); |
77 | if (f_init) | 77 | if (f_init) |
78 | { | 78 | { |
79 | int status; | 79 | int status, mask; |
80 | mu_folder_t folder; | 80 | mu_folder_t folder; |
81 | int (*u_init) (mu_url_t) = NULL; | 81 | int (*u_init) (mu_url_t) = NULL; |
82 | 82 | ||
83 | status = mu_record_check_url (record, url, &mask); | ||
84 | if (status) | ||
85 | /* FIXME: mask would provide more info */ | ||
86 | return status; | ||
87 | |||
83 | mu_record_get_url (record, &u_init); | 88 | mu_record_get_url (record, &u_init); |
84 | if (u_init) | 89 | if (u_init) |
85 | { | 90 | { | ... | ... |
... | @@ -66,6 +66,9 @@ static struct _mu_record _imap_record = | ... | @@ -66,6 +66,9 @@ static struct _mu_record _imap_record = |
66 | { | 66 | { |
67 | MU_IMAP_PRIO, | 67 | MU_IMAP_PRIO, |
68 | MU_IMAP_SCHEME, | 68 | MU_IMAP_SCHEME, |
69 | MU_RECORD_DEFAULT, | ||
70 | MU_URL_CRED | MU_URL_INET | MU_URL_PATH, | ||
71 | MU_URL_HOST, | ||
69 | _url_imap_init, /* url entry. */ | 72 | _url_imap_init, /* url entry. */ |
70 | _mailbox_imap_init, /* Mailbox entry. */ | 73 | _mailbox_imap_init, /* Mailbox entry. */ |
71 | NULL, /* Mailer entry. */ | 74 | NULL, /* Mailer entry. */ |
... | @@ -87,6 +90,9 @@ static struct _mu_record _imaps_record = | ... | @@ -87,6 +90,9 @@ static struct _mu_record _imaps_record = |
87 | { | 90 | { |
88 | MU_IMAP_PRIO, | 91 | MU_IMAP_PRIO, |
89 | MU_IMAPS_SCHEME, | 92 | MU_IMAPS_SCHEME, |
93 | MU_RECORD_DEFAULT, | ||
94 | MU_URL_CRED | MU_URL_INET | MU_URL_PATH | MU_URL_PARAM, | ||
95 | MU_URL_HOST, | ||
90 | _url_imaps_init, /* url entry. */ | 96 | _url_imaps_init, /* url entry. */ |
91 | _mailbox_imaps_init, /* Mailbox entry. */ | 97 | _mailbox_imaps_init, /* Mailbox entry. */ |
92 | NULL, /* Mailer entry. */ | 98 | NULL, /* Mailer entry. */ | ... | ... |
... | @@ -98,6 +98,9 @@ static struct _mu_record _maildir_record = | ... | @@ -98,6 +98,9 @@ static struct _mu_record _maildir_record = |
98 | { | 98 | { |
99 | MU_MAILDIR_PRIO, | 99 | MU_MAILDIR_PRIO, |
100 | MU_MAILDIR_SCHEME, | 100 | MU_MAILDIR_SCHEME, |
101 | MU_RECORD_LOCAL, | ||
102 | MU_URL_PATH, | ||
103 | MU_URL_PATH, | ||
101 | mu_url_expand_path, /* Url init. */ | 104 | mu_url_expand_path, /* Url init. */ |
102 | _mailbox_maildir_init, /* Mailbox init. */ | 105 | _mailbox_maildir_init, /* Mailbox init. */ |
103 | NULL, /* Mailer init. */ | 106 | NULL, /* Mailer init. */ | ... | ... |
... | @@ -44,6 +44,11 @@ static struct _mu_record _prog_record = | ... | @@ -44,6 +44,11 @@ static struct _mu_record _prog_record = |
44 | { | 44 | { |
45 | MU_PROG_PRIO, | 45 | MU_PROG_PRIO, |
46 | MU_PROG_SCHEME, | 46 | MU_PROG_SCHEME, |
47 | MU_RECORD_DEFAULT, | ||
48 | /* FIXME: MU_URL_USER could be used to request running with this | ||
49 | user privileges. */ | ||
50 | MU_URL_PATH | MU_URL_QUERY, | ||
51 | MU_URL_PATH, | ||
47 | _url_prog_init, /* url init. */ | 52 | _url_prog_init, /* url init. */ |
48 | _mu_mailer_mailbox_init, /* Mailbox entry. */ | 53 | _mu_mailer_mailbox_init, /* Mailbox entry. */ |
49 | _mu_mailer_prog_init, /* Mailer entry. */ | 54 | _mu_mailer_prog_init, /* Mailer entry. */ |
... | @@ -68,11 +73,6 @@ _url_prog_uplevel (const mu_url_t orig, mu_url_t *up) | ... | @@ -68,11 +73,6 @@ _url_prog_uplevel (const mu_url_t orig, mu_url_t *up) |
68 | static int | 73 | static int |
69 | _url_prog_init (mu_url_t url) | 74 | _url_prog_init (mu_url_t url) |
70 | { | 75 | { |
71 | /* not valid in a prog url */ | ||
72 | if (url->secret || url->auth || url->host || url->port) | ||
73 | return EINVAL; | ||
74 | if (!url->path) | ||
75 | return EINVAL; | ||
76 | url->_uplevel = _url_prog_uplevel; | 76 | url->_uplevel = _url_prog_uplevel; |
77 | return 0; | 77 | return 0; |
78 | } | 78 | } | ... | ... |
... | @@ -75,6 +75,9 @@ _url_remote_smtp_init (mu_url_t url) | ... | @@ -75,6 +75,9 @@ _url_remote_smtp_init (mu_url_t url) |
75 | static struct _mu_record _mu_remote_smtp_record = { | 75 | static struct _mu_record _mu_remote_smtp_record = { |
76 | MU_SMTP_PRIO, | 76 | MU_SMTP_PRIO, |
77 | "remote+smtp", | 77 | "remote+smtp", |
78 | MU_RECORD_DEFAULT, | ||
79 | MU_URL_CRED | MU_URL_INET | MU_URL_PATH | MU_URL_PARAM, | ||
80 | MU_URL_HOST, | ||
78 | _url_remote_smtp_init, /* url init. */ | 81 | _url_remote_smtp_init, /* url init. */ |
79 | _mu_mailer_mailbox_init, /* Mailbox init. */ | 82 | _mu_mailer_mailbox_init, /* Mailbox init. */ |
80 | NULL, /* Mailer init. */ | 83 | NULL, /* Mailer init. */ |
... | @@ -104,6 +107,9 @@ static struct _mu_record _mu_remote_sendmail_record = | ... | @@ -104,6 +107,9 @@ static struct _mu_record _mu_remote_sendmail_record = |
104 | { | 107 | { |
105 | MU_SENDMAIL_PRIO, | 108 | MU_SENDMAIL_PRIO, |
106 | "remote+sendmail", | 109 | "remote+sendmail", |
110 | MU_RECORD_DEFAULT, | ||
111 | MU_URL_PATH, | ||
112 | MU_URL_PATH, | ||
107 | _url_remote_sendmail_init, /* url init. */ | 113 | _url_remote_sendmail_init, /* url init. */ |
108 | _mu_mailer_mailbox_init, /* Mailbox entry. */ | 114 | _mu_mailer_mailbox_init, /* Mailbox entry. */ |
109 | _mu_mailer_sendmail_init, /* Mailer entry. */ | 115 | _mu_mailer_sendmail_init, /* Mailer entry. */ |
... | @@ -130,6 +136,9 @@ static struct _mu_record _mu_remote_prog_record = | ... | @@ -130,6 +136,9 @@ static struct _mu_record _mu_remote_prog_record = |
130 | { | 136 | { |
131 | MU_PROG_PRIO, | 137 | MU_PROG_PRIO, |
132 | "remote+prog", | 138 | "remote+prog", |
139 | MU_RECORD_DEFAULT, | ||
140 | MU_URL_CRED | MU_URL_PATH | MU_URL_QUERY, | ||
141 | MU_URL_PATH, | ||
133 | _url_remote_prog_init, /* url init. */ | 142 | _url_remote_prog_init, /* url init. */ |
134 | _mu_mailer_mailbox_init, /* Mailbox entry. */ | 143 | _mu_mailer_mailbox_init, /* Mailbox entry. */ |
135 | _mu_mailer_prog_init, /* Mailer entry. */ | 144 | _mu_mailer_prog_init, /* Mailer entry. */ | ... | ... |
... | @@ -53,12 +53,7 @@ static int sendmail_send_message (mu_mailer_t, mu_message_t, mu_address_t, | ... | @@ -53,12 +53,7 @@ static int sendmail_send_message (mu_mailer_t, mu_message_t, mu_address_t, |
53 | static int | 53 | static int |
54 | _url_sendmail_init (mu_url_t url) | 54 | _url_sendmail_init (mu_url_t url) |
55 | { | 55 | { |
56 | /* not valid in a sendmail url */ | 56 | if (url->path == NULL) |
57 | if (url->user || url->secret || url->auth || url->qargc | ||
58 | || url->host || url->port) | ||
59 | return EINVAL; | ||
60 | |||
61 | if (url->path == 0) | ||
62 | if ((url->path = strdup (PATH_SENDMAIL)) == 0) | 57 | if ((url->path = strdup (PATH_SENDMAIL)) == 0) |
63 | return ENOMEM; | 58 | return ENOMEM; |
64 | 59 | ||
... | @@ -275,6 +270,10 @@ static struct _mu_record _sendmail_record = | ... | @@ -275,6 +270,10 @@ static struct _mu_record _sendmail_record = |
275 | { | 270 | { |
276 | MU_SENDMAIL_PRIO, | 271 | MU_SENDMAIL_PRIO, |
277 | MU_SENDMAIL_SCHEME, | 272 | MU_SENDMAIL_SCHEME, |
273 | MU_RECORD_DEFAULT, | ||
274 | MU_URL_PATH, | ||
275 | 0, /* Nothing is required in the URL, except scheme. Missing path means | ||
276 | using PATH_SENDMAIL. */ | ||
278 | _url_sendmail_init, /* url init. */ | 277 | _url_sendmail_init, /* url init. */ |
279 | _mu_mailer_mailbox_init, /* Mailbox entry. */ | 278 | _mu_mailer_mailbox_init, /* Mailbox entry. */ |
280 | _mu_mailer_sendmail_init, /* Mailer entry. */ | 279 | _mu_mailer_sendmail_init, /* Mailer entry. */ | ... | ... |
... | @@ -56,26 +56,17 @@ static int _mailer_smtp_init (mu_mailer_t); | ... | @@ -56,26 +56,17 @@ static int _mailer_smtp_init (mu_mailer_t); |
56 | static int | 56 | static int |
57 | _url_smtp_init (mu_url_t url) | 57 | _url_smtp_init (mu_url_t url) |
58 | { | 58 | { |
59 | /* host isn't optional */ | ||
60 | if (!url->host) | ||
61 | return EINVAL; | ||
62 | |||
63 | /* accept url->user, pass, and auth | ||
64 | for the ESMTP authentication */ | ||
65 | |||
66 | /* all other fields must be NULL */ | ||
67 | if (url->path || url->qargc) | ||
68 | return EINVAL; | ||
69 | |||
70 | if (url->port == 0) | 59 | if (url->port == 0) |
71 | url->port = MU_SMTP_PORT; | 60 | url->port = MU_SMTP_PORT; |
72 | |||
73 | return 0; | 61 | return 0; |
74 | } | 62 | } |
75 | 63 | ||
76 | static struct _mu_record _smtp_record = { | 64 | static struct _mu_record _smtp_record = { |
77 | MU_SMTP_PRIO, | 65 | MU_SMTP_PRIO, |
78 | MU_SMTP_SCHEME, | 66 | MU_SMTP_SCHEME, |
67 | MU_RECORD_DEFAULT, | ||
68 | MU_URL_CRED | MU_URL_INET | MU_URL_PARAM, | ||
69 | MU_URL_HOST, | ||
79 | _url_smtp_init, /* url init. */ | 70 | _url_smtp_init, /* url init. */ |
80 | _mu_mailer_mailbox_init, /* Mailbox init. */ | 71 | _mu_mailer_mailbox_init, /* Mailbox init. */ |
81 | _mailer_smtp_init, /* Mailer init. */ | 72 | _mailer_smtp_init, /* Mailer init. */ |
... | @@ -101,10 +92,27 @@ struct _smtp_mailer | ... | @@ -101,10 +92,27 @@ struct _smtp_mailer |
101 | mu_address_t rcpt_bcc; | 92 | mu_address_t rcpt_bcc; |
102 | }; | 93 | }; |
103 | 94 | ||
95 | static void | ||
96 | smtp_mailer_add_auth_mech (struct _smtp_mailer *smtp_mailer, const char *str) | ||
97 | { | ||
98 | int mc, i, rc; | ||
99 | char **mv; | ||
100 | |||
101 | rc = mu_argcv_get_np (str, strlen (str), | ||
102 | ",", NULL, | ||
103 | 0, | ||
104 | &mc, &mv, NULL); | ||
105 | if (rc == 0) | ||
106 | for (i = 0; i < mc; i++) | ||
107 | mu_smtp_add_auth_mech (smtp_mailer->smtp, mv[i]); | ||
108 | |||
109 | free (mv); | ||
110 | } | ||
111 | |||
104 | static int | 112 | static int |
105 | smtp_open (mu_mailer_t mailer, int flags) | 113 | smtp_open (mu_mailer_t mailer, int flags) |
106 | { | 114 | { |
107 | const char *host; | 115 | const char *host, *auth; |
108 | long port; | 116 | long port; |
109 | struct _smtp_mailer *smtp_mailer = mailer->data; | 117 | struct _smtp_mailer *smtp_mailer = mailer->data; |
110 | int rc; | 118 | int rc; |
... | @@ -134,6 +142,9 @@ smtp_open (mu_mailer_t mailer, int flags) | ... | @@ -134,6 +142,9 @@ smtp_open (mu_mailer_t mailer, int flags) |
134 | if (mu_url_get_port (mailer->url, &port)) | 142 | if (mu_url_get_port (mailer->url, &port)) |
135 | port = 25; | 143 | port = 25; |
136 | 144 | ||
145 | if (mu_url_sget_auth (mailer->url, &auth) == 0) | ||
146 | smtp_mailer_add_auth_mech (smtp_mailer, auth); | ||
147 | |||
137 | /* Additional information is supplied in the arguments */ | 148 | /* Additional information is supplied in the arguments */ |
138 | if (mu_url_sget_fvpairs (mailer->url, &parmc, &parmv) == 0) | 149 | if (mu_url_sget_fvpairs (mailer->url, &parmc, &parmv) == 0) |
139 | { | 150 | { |
... | @@ -146,20 +157,7 @@ smtp_open (mu_mailer_t mailer, int flags) | ... | @@ -146,20 +157,7 @@ smtp_open (mu_mailer_t mailer, int flags) |
146 | else if (strcmp (parmv[i], "noauth") == 0) | 157 | else if (strcmp (parmv[i], "noauth") == 0) |
147 | noauth = 1; | 158 | noauth = 1; |
148 | else if (strncmp (parmv[i], "auth=", 5) == 0) | 159 | else if (strncmp (parmv[i], "auth=", 5) == 0) |
149 | { | 160 | smtp_mailer_add_auth_mech (smtp_mailer, parmv[i] + 5); |
150 | int mc, j; | ||
151 | char **mv; | ||
152 | |||
153 | rc = mu_argcv_get_np (parmv[i] + 5, strlen (parmv[i] + 5), | ||
154 | ",", NULL, | ||
155 | 0, | ||
156 | &mc, &mv, NULL); | ||
157 | if (rc == 0) | ||
158 | for (j = 0; j < mc; j++) | ||
159 | mu_smtp_add_auth_mech (smtp_mailer->smtp, mv[j]); | ||
160 | |||
161 | free (mv); | ||
162 | } | ||
163 | /* unrecognized arguments silently ignored */ | 161 | /* unrecognized arguments silently ignored */ |
164 | } | 162 | } |
165 | } | 163 | } | ... | ... |
... | @@ -100,6 +100,9 @@ static struct _mu_record _mbox_record = | ... | @@ -100,6 +100,9 @@ static struct _mu_record _mbox_record = |
100 | { | 100 | { |
101 | MU_MBOX_PRIO, | 101 | MU_MBOX_PRIO, |
102 | MU_MBOX_SCHEME, | 102 | MU_MBOX_SCHEME, |
103 | MU_RECORD_LOCAL, | ||
104 | MU_URL_PATH, | ||
105 | MU_URL_PATH, | ||
103 | mu_url_expand_path, /* URL init. */ | 106 | mu_url_expand_path, /* URL init. */ |
104 | _mailbox_mbox_init, /* Mailbox init. */ | 107 | _mailbox_mbox_init, /* Mailbox init. */ |
105 | NULL, /* Mailer init. */ | 108 | NULL, /* Mailer init. */ | ... | ... |
... | @@ -138,6 +138,9 @@ static struct _mu_record _mh_record = | ... | @@ -138,6 +138,9 @@ static struct _mu_record _mh_record = |
138 | { | 138 | { |
139 | MU_MH_PRIO, | 139 | MU_MH_PRIO, |
140 | MU_MH_SCHEME, | 140 | MU_MH_SCHEME, |
141 | MU_RECORD_LOCAL, | ||
142 | MU_URL_PATH, | ||
143 | MU_URL_PATH, | ||
141 | mu_url_expand_path, /* Url init. */ | 144 | mu_url_expand_path, /* Url init. */ |
142 | _mailbox_mh_init, /* Mailbox init. */ | 145 | _mailbox_mh_init, /* Mailbox init. */ |
143 | NULL, /* Mailer init. */ | 146 | NULL, /* Mailer init. */ | ... | ... |
... | @@ -45,6 +45,9 @@ static struct _mu_record _nntp_record = | ... | @@ -45,6 +45,9 @@ static struct _mu_record _nntp_record = |
45 | { | 45 | { |
46 | MU_NNTP_PRIO, | 46 | MU_NNTP_PRIO, |
47 | MU_NNTP_URL_SCHEME, | 47 | MU_NNTP_URL_SCHEME, |
48 | MU_RECORD_DEFAULT, | ||
49 | MU_URL_CRED | MU_URL_INET | MU_URL_PATH, | ||
50 | MU_URL_HOST, | ||
48 | _nntp_url_init, /* Url init. */ | 51 | _nntp_url_init, /* Url init. */ |
49 | _nntp_mailbox_init, /* Mailbox init. */ | 52 | _nntp_mailbox_init, /* Mailbox init. */ |
50 | NULL, /* Mailer init. */ | 53 | NULL, /* Mailer init. */ | ... | ... |
... | @@ -33,13 +33,6 @@ | ... | @@ -33,13 +33,6 @@ |
33 | 33 | ||
34 | #include <mailutils/sys/url.h> | 34 | #include <mailutils/sys/url.h> |
35 | 35 | ||
36 | static void url_nntp_destroy (mu_url_t url); | ||
37 | |||
38 | static void | ||
39 | url_nntp_destroy (mu_url_t url MU_ARG_UNUSED) | ||
40 | { | ||
41 | } | ||
42 | |||
43 | /* | 36 | /* |
44 | POP URL: | 37 | POP URL: |
45 | nntp://<host>:<port>/<newsgroup-name>/<article-number> | 38 | nntp://<host>:<port>/<newsgroup-name>/<article-number> |
... | @@ -48,23 +41,6 @@ url_nntp_destroy (mu_url_t url MU_ARG_UNUSED) | ... | @@ -48,23 +41,6 @@ url_nntp_destroy (mu_url_t url MU_ARG_UNUSED) |
48 | int | 41 | int |
49 | _nntp_url_init (mu_url_t url) | 42 | _nntp_url_init (mu_url_t url) |
50 | { | 43 | { |
51 | int status = 0; | ||
52 | |||
53 | url->_destroy = url_nntp_destroy; | ||
54 | |||
55 | status = mu_url_parse(url); | ||
56 | |||
57 | if(status) | ||
58 | return status; | ||
59 | |||
60 | /* is it nntp? */ | ||
61 | if (strcmp (MU_NNTP_URL_SCHEME, url->scheme) != 0) | ||
62 | return EINVAL; | ||
63 | |||
64 | /* not valid in a nntp url */ | ||
65 | if (!url->host || !url->path) | ||
66 | return EINVAL; | ||
67 | |||
68 | if (url->port == 0) | 44 | if (url->port == 0) |
69 | url->port = MU_NNTP_DEFAULT_PORT; | 45 | url->port = MU_NNTP_DEFAULT_PORT; |
70 | 46 | ... | ... |
... | @@ -47,6 +47,9 @@ static struct _mu_record _pop_record = | ... | @@ -47,6 +47,9 @@ static struct _mu_record _pop_record = |
47 | { | 47 | { |
48 | MU_POP_PRIO, | 48 | MU_POP_PRIO, |
49 | MU_POP_SCHEME, | 49 | MU_POP_SCHEME, |
50 | MU_RECORD_DEFAULT, | ||
51 | MU_URL_CRED | MU_URL_INET, | ||
52 | MU_URL_HOST, | ||
50 | _url_pop_init, /* Url init. */ | 53 | _url_pop_init, /* Url init. */ |
51 | _mailbox_pop_init, /* Mailbox init. */ | 54 | _mailbox_pop_init, /* Mailbox init. */ |
52 | NULL, /* Mailer init. */ | 55 | NULL, /* Mailer init. */ |
... | @@ -65,6 +68,9 @@ static struct _mu_record _pops_record = | ... | @@ -65,6 +68,9 @@ static struct _mu_record _pops_record = |
65 | { | 68 | { |
66 | MU_POP_PRIO, | 69 | MU_POP_PRIO, |
67 | MU_POPS_SCHEME, | 70 | MU_POPS_SCHEME, |
71 | MU_RECORD_DEFAULT, | ||
72 | MU_URL_CRED | MU_URL_INET, | ||
73 | MU_URL_HOST, | ||
68 | _url_pops_init, /* Url init. */ | 74 | _url_pops_init, /* Url init. */ |
69 | _mailbox_pops_init, /* Mailbox init. */ | 75 | _mailbox_pops_init, /* Mailbox init. */ |
70 | NULL, /* Mailer init. */ | 76 | NULL, /* Mailer init. */ | ... | ... |
... | @@ -33,13 +33,6 @@ | ... | @@ -33,13 +33,6 @@ |
33 | #include <mailutils/sys/url.h> | 33 | #include <mailutils/sys/url.h> |
34 | #include <mailutils/sys/registrar.h> | 34 | #include <mailutils/sys/registrar.h> |
35 | 35 | ||
36 | static void url_pop_destroy (mu_url_t url); | ||
37 | |||
38 | static void | ||
39 | url_pop_destroy (mu_url_t url MU_ARG_UNUSED) | ||
40 | { | ||
41 | } | ||
42 | |||
43 | /* | 36 | /* |
44 | POP URLs: | 37 | POP URLs: |
45 | pop://[<user>[;AUTH=<auth>]@]<host>[:<port>] | 38 | pop://[<user>[;AUTH=<auth>]@]<host>[:<port>] |
... | @@ -51,13 +44,6 @@ _url_pop_init (mu_url_t url) | ... | @@ -51,13 +44,6 @@ _url_pop_init (mu_url_t url) |
51 | { | 44 | { |
52 | if (url->port == 0) | 45 | if (url->port == 0) |
53 | url->port = MU_POP_PORT; | 46 | url->port = MU_POP_PORT; |
54 | |||
55 | url->_destroy = url_pop_destroy; | ||
56 | |||
57 | /* not valid in pop url */ | ||
58 | if (url->path || url->qargc || !url->host) | ||
59 | return EINVAL; | ||
60 | |||
61 | return 0; | 47 | return 0; |
62 | } | 48 | } |
63 | 49 | ||
... | @@ -72,13 +58,6 @@ _url_pops_init (mu_url_t url) | ... | @@ -72,13 +58,6 @@ _url_pops_init (mu_url_t url) |
72 | { | 58 | { |
73 | if (url->port == 0) | 59 | if (url->port == 0) |
74 | url->port = MU_POPS_PORT; | 60 | url->port = MU_POPS_PORT; |
75 | |||
76 | url->_destroy = url_pop_destroy; | ||
77 | |||
78 | /* not valid in pops url */ | ||
79 | if (url->path || url->qargc || !url->host) | ||
80 | return EINVAL; | ||
81 | |||
82 | return 0; | 61 | return 0; |
83 | } | 62 | } |
84 | 63 | ... | ... |
... | @@ -314,13 +314,25 @@ deliver_to_mailbox (mu_mailbox_t mbox, mu_message_t msg, | ... | @@ -314,13 +314,25 @@ deliver_to_mailbox (mu_mailbox_t mbox, mu_message_t msg, |
314 | } | 314 | } |
315 | 315 | ||
316 | static int | 316 | static int |
317 | is_remote_url (mu_url_t url) | ||
318 | { | ||
319 | int rc, res; | ||
320 | |||
321 | if (!url) | ||
322 | return 0; | ||
323 | |||
324 | rc = mu_registrar_test_local_url (url, &res); | ||
325 | return rc == 0 && res == 0; | ||
326 | } | ||
327 | |||
328 | static int | ||
317 | do_delivery (mu_url_t url, mu_message_t msg, const char *name, char **errp) | 329 | do_delivery (mu_url_t url, mu_message_t msg, const char *name, char **errp) |
318 | { | 330 | { |
319 | struct mu_auth_data *auth = NULL; | 331 | struct mu_auth_data *auth = NULL; |
320 | mu_mailbox_t mbox; | 332 | mu_mailbox_t mbox; |
321 | int status; | 333 | int status; |
322 | 334 | ||
323 | if (name) | 335 | if (name && !is_remote_url (url)) |
324 | { | 336 | { |
325 | auth = mu_get_auth_by_name (name); | 337 | auth = mu_get_auth_by_name (name); |
326 | if (!auth) | 338 | if (!auth) | ... | ... |
... | @@ -564,6 +564,9 @@ main (int argc, char *argv[]) | ... | @@ -564,6 +564,9 @@ main (int argc, char *argv[]) |
564 | maidag_cfg_init (); | 564 | maidag_cfg_init (); |
565 | 565 | ||
566 | /* Parse command line */ | 566 | /* Parse command line */ |
567 | #ifdef WITH_TLS | ||
568 | mu_gocs_register ("tls", mu_tls_module_init); | ||
569 | #endif | ||
567 | mu_argp_init (NULL, NULL); | 570 | mu_argp_init (NULL, NULL); |
568 | 571 | ||
569 | mu_m_server_create (&server, program_version); | 572 | mu_m_server_create (&server, program_version); | ... | ... |
-
Please register or sign in to post a comment