Added --maildir option.
Showing
1 changed file
with
16 additions
and
6 deletions
... | @@ -25,9 +25,6 @@ | ... | @@ -25,9 +25,6 @@ |
25 | #ifndef PATH_TTY_PFX | 25 | #ifndef PATH_TTY_PFX |
26 | # define PATH_TTY_PFX PATH_DEV | 26 | # define PATH_TTY_PFX PATH_DEV |
27 | #endif | 27 | #endif |
28 | #ifndef _PATH_MAILDIR | ||
29 | # define _PATH_MAILDIR "/var/spool/mail" | ||
30 | #endif | ||
31 | 28 | ||
32 | #ifdef HAVE_UTMP_H | 29 | #ifdef HAVE_UTMP_H |
33 | # include <utmp.h> | 30 | # include <utmp.h> |
... | @@ -50,13 +47,14 @@ typedef struct utmp UTMP; | ... | @@ -50,13 +47,14 @@ typedef struct utmp UTMP; |
50 | 47 | ||
51 | #define MAX_TTY_SIZE (sizeof (PATH_TTY_PFX) + sizeof (((UTMP*)0)->ut_line)) | 48 | #define MAX_TTY_SIZE (sizeof (PATH_TTY_PFX) + sizeof (((UTMP*)0)->ut_line)) |
52 | 49 | ||
53 | static char short_options[] = "c:dhip:t:v"; | 50 | static char short_options[] = "c:dhim:p:t:v"; |
54 | static struct option long_options[] = | 51 | static struct option long_options[] = |
55 | { | 52 | { |
56 | {"config", required_argument, 0, 'c'}, | 53 | {"config", required_argument, 0, 'c'}, |
57 | {"daemon", no_argument, 0, 'd'}, | 54 | {"daemon", no_argument, 0, 'd'}, |
58 | {"help", no_argument, 0, 'h'}, | 55 | {"help", no_argument, 0, 'h'}, |
59 | {"inetd", no_argument, 0, 'i'}, | 56 | {"inetd", no_argument, 0, 'i'}, |
57 | {"maildir", required_argument, 0, 'm'}, | ||
60 | {"port", required_argument, 0, 'p'}, | 58 | {"port", required_argument, 0, 'p'}, |
61 | {"timeout", required_argument, 0, 't'}, | 59 | {"timeout", required_argument, 0, 't'}, |
62 | {"version", no_argument, 0, 'v'}, | 60 | {"version", no_argument, 0, 'v'}, |
... | @@ -80,6 +78,7 @@ int timeout = 0; | ... | @@ -80,6 +78,7 @@ int timeout = 0; |
80 | int maxlines = 5; | 78 | int maxlines = 5; |
81 | char hostname[MAXHOSTNAMELEN]; | 79 | char hostname[MAXHOSTNAMELEN]; |
82 | const char *username; | 80 | const char *username; |
81 | const char *maildir = MU_PATH_MAILDIR; | ||
83 | 82 | ||
84 | static void comsat_init (void); | 83 | static void comsat_init (void); |
85 | static void comsat_daemon_init (void); | 84 | static void comsat_daemon_init (void); |
... | @@ -121,6 +120,10 @@ main(int argc, char **argv) | ... | @@ -121,6 +120,10 @@ main(int argc, char **argv) |
121 | mode = MODE_INETD; | 120 | mode = MODE_INETD; |
122 | break; | 121 | break; |
123 | 122 | ||
123 | case 'm': | ||
124 | maildir = optarg; | ||
125 | break; | ||
126 | |||
124 | case 'p': | 127 | case 'p': |
125 | port = strtoul (optarg, NULL, 10); | 128 | port = strtoul (optarg, NULL, 10); |
126 | break; | 129 | break; |
... | @@ -139,6 +142,13 @@ main(int argc, char **argv) | ... | @@ -139,6 +142,13 @@ main(int argc, char **argv) |
139 | } | 142 | } |
140 | } | 143 | } |
141 | 144 | ||
145 | maildir = mu_normalize_maildir (maildir); | ||
146 | if (!maildir) | ||
147 | { | ||
148 | mu_error ("Badly formed maildir: %s", maildir); | ||
149 | exit (1); | ||
150 | } | ||
151 | |||
142 | if (timeout > 0 && mode == MODE_DAEMON) | 152 | if (timeout > 0 && mode == MODE_DAEMON) |
143 | { | 153 | { |
144 | fprintf (stderr, "--timeout and --daemon are incompatible\n"); | 154 | fprintf (stderr, "--timeout and --daemon are incompatible\n"); |
... | @@ -612,9 +622,9 @@ mailbox_path (const char *user) | ... | @@ -612,9 +622,9 @@ mailbox_path (const char *user) |
612 | 622 | ||
613 | if (!mu_virtual_domain) | 623 | if (!mu_virtual_domain) |
614 | { | 624 | { |
615 | mailbox_name = calloc (strlen (_PATH_MAILDIR) + 1 | 625 | mailbox_name = calloc (strlen (maildir) + 1 |
616 | + strlen (pw->pw_name) + 1, 1); | 626 | + strlen (pw->pw_name) + 1, 1); |
617 | sprintf (mailbox_name, "%s/%s", _PATH_MAILDIR, pw->pw_name); | 627 | sprintf (mailbox_name, "%s%s", maildir, pw->pw_name); |
618 | } | 628 | } |
619 | else | 629 | else |
620 | { | 630 | { | ... | ... |
-
Please register or sign in to post a comment