New command line option --maildir (-m). Register mbox_record at startup.
Showing
2 changed files
with
37 additions
and
5 deletions
... | @@ -25,6 +25,7 @@ FILE *ofile; | ... | @@ -25,6 +25,7 @@ FILE *ofile; |
25 | unsigned int timeout = 1800; /* RFC2060: 30 minutes, if enable. */ | 25 | unsigned int timeout = 1800; /* RFC2060: 30 minutes, if enable. */ |
26 | mailbox_t mbox; | 26 | mailbox_t mbox; |
27 | char *homedir; | 27 | char *homedir; |
28 | char *maildir = _PATH_MAILDIR; | ||
28 | int state = STATE_NONAUTH; | 29 | int state = STATE_NONAUTH; |
29 | 30 | ||
30 | /* Number of child processes. */ | 31 | /* Number of child processes. */ |
... | @@ -35,6 +36,7 @@ static struct option long_options[] = | ... | @@ -35,6 +36,7 @@ static struct option long_options[] = |
35 | {"daemon", optional_argument, 0, 'd'}, | 36 | {"daemon", optional_argument, 0, 'd'}, |
36 | {"help", no_argument, 0, 'h'}, | 37 | {"help", no_argument, 0, 'h'}, |
37 | {"inetd", no_argument, 0, 'i'}, | 38 | {"inetd", no_argument, 0, 'i'}, |
39 | {"maildir", required_argument, 0, 'm'}, | ||
38 | {"port", required_argument, 0, 'p'}, | 40 | {"port", required_argument, 0, 'p'}, |
39 | {"other-namespace", required_argument, 0, 'O'}, | 41 | {"other-namespace", required_argument, 0, 'O'}, |
40 | {"shared-namespace", required_argument, 0, 'S'}, | 42 | {"shared-namespace", required_argument, 0, 'S'}, |
... | @@ -43,7 +45,7 @@ static struct option long_options[] = | ... | @@ -43,7 +45,7 @@ static struct option long_options[] = |
43 | {0, 0, 0, 0} | 45 | {0, 0, 0, 0} |
44 | }; | 46 | }; |
45 | 47 | ||
46 | const char *short_options ="d::hip:t:vO:P:S:"; | 48 | const char *short_options ="d::him:p:t:vO:P:S:"; |
47 | 49 | ||
48 | static int imap4d_mainloop __P ((int, int)); | 50 | static int imap4d_mainloop __P ((int, int)); |
49 | static void imap4d_daemon_init __P ((void)); | 51 | static void imap4d_daemon_init __P ((void)); |
... | @@ -90,6 +92,10 @@ main (int argc, char **argv) | ... | @@ -90,6 +92,10 @@ main (int argc, char **argv) |
90 | mode = INTERACTIVE; | 92 | mode = INTERACTIVE; |
91 | break; | 93 | break; |
92 | 94 | ||
95 | case 'm': | ||
96 | maildir = optarg; | ||
97 | break; | ||
98 | |||
93 | case 'p': | 99 | case 'p': |
94 | mode = DAEMON; | 100 | mode = DAEMON; |
95 | port = strtoul (optarg, NULL, 10); | 101 | port = strtoul (optarg, NULL, 10); |
... | @@ -117,6 +123,13 @@ main (int argc, char **argv) | ... | @@ -117,6 +123,13 @@ main (int argc, char **argv) |
117 | } | 123 | } |
118 | } | 124 | } |
119 | 125 | ||
126 | maildir = mu_normalize_maildir (maildir); | ||
127 | if (!maildir) | ||
128 | { | ||
129 | mu_error ("Badly formed maildir: %s", maildir); | ||
130 | exit (1); | ||
131 | } | ||
132 | |||
120 | /* First we want our group to be mail so we can access the spool. */ | 133 | /* First we want our group to be mail so we can access the spool. */ |
121 | gr = getgrnam ("mail"); | 134 | gr = getgrnam ("mail"); |
122 | if (gr == NULL) | 135 | if (gr == NULL) |
... | @@ -135,7 +148,7 @@ main (int argc, char **argv) | ... | @@ -135,7 +148,7 @@ main (int argc, char **argv) |
135 | { | 148 | { |
136 | list_t bookie; | 149 | list_t bookie; |
137 | registrar_get_list (&bookie); | 150 | registrar_get_list (&bookie); |
138 | /* list_append (bookie, mbox_record); */ | 151 | list_append (bookie, mbox_record); |
139 | list_append (bookie, path_record); | 152 | list_append (bookie, path_record); |
140 | } | 153 | } |
141 | 154 | ||
... | @@ -347,13 +360,18 @@ imap4d_usage (char *argv0) | ... | @@ -347,13 +360,18 @@ imap4d_usage (char *argv0) |
347 | { | 360 | { |
348 | printf ("Usage: %s [OPTIONS]\n", argv0); | 361 | printf ("Usage: %s [OPTIONS]\n", argv0); |
349 | printf ("Runs the GNU IMAP4 daemon.\n\n"); | 362 | printf ("Runs the GNU IMAP4 daemon.\n\n"); |
350 | printf (" -d, --daemon=MAXCHILDREN runs in daemon mode with a maximum\n"); | 363 | printf (" -d, --daemon[=MAXCHILDREN] runs in daemon mode with a maximum\n"); |
351 | printf (" of MAXCHILDREN child processes\n"); | 364 | printf (" of MAXCHILDREN child processes\n"); |
365 | printf (" MAXCHILDREN defaults to %d\n", | ||
366 | DEFMAXCHILDREN); | ||
352 | printf (" -h, --help display this help and exit\n"); | 367 | printf (" -h, --help display this help and exit\n"); |
353 | printf (" -i, --inetd runs in inetd mode (default)\n"); | 368 | printf (" -i, --inetd runs in inetd mode (default)\n"); |
354 | printf (" -p, --port=PORT specifies port to listen on, implies -d\n" | 369 | printf (" -p, --port=PORT specifies port to listen on, implies -d\n" |
355 | ); | 370 | ); |
356 | printf (" defaults to 143, which need not be specified\n"); | 371 | printf (" defaults to 143, which need not be specified\n"); |
372 | printf (" -m, --maildir=PATH set path to the mailspool directory\n"); | ||
373 | printf (" -O, --other-namespace=PATHLIST sets the `other' namespace\n"); | ||
374 | printf (" -S, --shared-namespace=PATHLIST sets the `shared' namespace\n"); | ||
357 | printf (" -t, --timeout=TIMEOUT sets idle timeout to TIMEOUT seconds\n"); | 375 | printf (" -t, --timeout=TIMEOUT sets idle timeout to TIMEOUT seconds\n"); |
358 | printf (" TIMEOUT default is 1800 (30 minutes)\n"); | 376 | printf (" TIMEOUT default is 1800 (30 minutes)\n"); |
359 | printf (" -v, --version display version information and exit\n"); | 377 | printf (" -v, --version display version information and exit\n"); | ... | ... |
... | @@ -25,6 +25,7 @@ mailbox_t mbox; | ... | @@ -25,6 +25,7 @@ mailbox_t mbox; |
25 | unsigned int timeout; | 25 | unsigned int timeout; |
26 | int state; | 26 | int state; |
27 | char *username; | 27 | char *username; |
28 | char *maildir = _PATH_MAILDIR; | ||
28 | FILE *ifile; | 29 | FILE *ifile; |
29 | FILE *ofile; | 30 | FILE *ofile; |
30 | char *md5shared; | 31 | char *md5shared; |
... | @@ -36,13 +37,14 @@ static struct option long_options[] = | ... | @@ -36,13 +37,14 @@ static struct option long_options[] = |
36 | {"daemon", optional_argument, 0, 'd'}, | 37 | {"daemon", optional_argument, 0, 'd'}, |
37 | {"help", no_argument, 0, 'h'}, | 38 | {"help", no_argument, 0, 'h'}, |
38 | {"inetd", no_argument, 0, 'i'}, | 39 | {"inetd", no_argument, 0, 'i'}, |
40 | {"maildir", required_argument, 0, 'm'}, | ||
39 | {"port", required_argument, 0, 'p'}, | 41 | {"port", required_argument, 0, 'p'}, |
40 | {"timeout", required_argument, 0, 't'}, | 42 | {"timeout", required_argument, 0, 't'}, |
41 | {"version", no_argument, 0, 'v'}, | 43 | {"version", no_argument, 0, 'v'}, |
42 | {0, 0, 0, 0} | 44 | {0, 0, 0, 0} |
43 | }; | 45 | }; |
44 | 46 | ||
45 | const char *short_options = "d::hip:t:v"; | 47 | const char *short_options = "d::him:p:t:v"; |
46 | 48 | ||
47 | static int pop3d_mainloop __P ((int, int)); | 49 | static int pop3d_mainloop __P ((int, int)); |
48 | static void pop3d_daemon_init __P ((void)); | 50 | static void pop3d_daemon_init __P ((void)); |
... | @@ -87,6 +89,10 @@ main (int argc, char **argv) | ... | @@ -87,6 +89,10 @@ main (int argc, char **argv) |
87 | mode = INTERACTIVE; | 89 | mode = INTERACTIVE; |
88 | break; | 90 | break; |
89 | 91 | ||
92 | case 'm': | ||
93 | maildir = optarg; | ||
94 | break; | ||
95 | |||
90 | case 'p': | 96 | case 'p': |
91 | mode = DAEMON; | 97 | mode = DAEMON; |
92 | port = strtoul (optarg, NULL, 10); | 98 | port = strtoul (optarg, NULL, 10); |
... | @@ -106,6 +112,13 @@ main (int argc, char **argv) | ... | @@ -106,6 +112,13 @@ main (int argc, char **argv) |
106 | } | 112 | } |
107 | } | 113 | } |
108 | 114 | ||
115 | maildir = mu_normalize_maildir (maildir); | ||
116 | if (!maildir) | ||
117 | { | ||
118 | mu_error ("Badly formed maildir: %s", maildir); | ||
119 | exit (1); | ||
120 | } | ||
121 | |||
109 | /* First we want our group to be mail so we can access the spool. */ | 122 | /* First we want our group to be mail so we can access the spool. */ |
110 | gr = getgrnam ("mail"); | 123 | gr = getgrnam ("mail"); |
111 | if (gr == NULL) | 124 | if (gr == NULL) |
... | @@ -124,7 +137,7 @@ main (int argc, char **argv) | ... | @@ -124,7 +137,7 @@ main (int argc, char **argv) |
124 | { | 137 | { |
125 | list_t bookie; | 138 | list_t bookie; |
126 | registrar_get_list (&bookie); | 139 | registrar_get_list (&bookie); |
127 | /* list_append (bookie, mbox_record); */ | 140 | list_append (bookie, mbox_record); |
128 | list_append (bookie, path_record); | 141 | list_append (bookie, path_record); |
129 | } | 142 | } |
130 | 143 | ||
... | @@ -449,6 +462,7 @@ pop3d_usage (char *argv0) | ... | @@ -449,6 +462,7 @@ pop3d_usage (char *argv0) |
449 | printf (" of MAXCHILDREN child processes\n"); | 462 | printf (" of MAXCHILDREN child processes\n"); |
450 | printf (" -h, --help display this help and exit\n"); | 463 | printf (" -h, --help display this help and exit\n"); |
451 | printf (" -i, --inetd runs in inetd mode (default)\n"); | 464 | printf (" -i, --inetd runs in inetd mode (default)\n"); |
465 | printf (" -m, --maildir=PATH sets path to the mailspool directory\n"); | ||
452 | printf (" -p, --port=PORT specifies port to listen on, implies -d\n" | 466 | printf (" -p, --port=PORT specifies port to listen on, implies -d\n" |
453 | ); | 467 | ); |
454 | printf (" defaults to 110, which need not be specified\n"); | 468 | printf (" defaults to 110, which need not be specified\n"); | ... | ... |
-
Please register or sign in to post a comment