summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@sunilnimmagadda.com>2014-04-10 17:58:37 +0500
committerSunil Nimmagadda <sunil@sunilnimmagadda.com>2014-04-10 17:58:37 +0500
commit89c7cc9a5e434e25bfcbd06ea633a8b411f0e6de (patch)
treea044f5e7dc86b32a610e438c826f2654d81328e8
parent178fb764cf7835f3e0090b1a970742678333f8af (diff)
Simplify maildrop path handling. Regardless of the order of options path is now correctly handled.
-rw-r--r--pop3d.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/pop3d.c b/pop3d.c
index 77cbfa0..d047b42 100644
--- a/pop3d.c
+++ b/pop3d.c
@@ -48,7 +48,7 @@ static void usage(void);
static struct imsgev iev_pop3e;
static pid_t pop3e_pid;
-static const char *mpath = MBOX_PATH;
+static const char *mpath;
static int mtype = M_MBOX;
int
@@ -56,7 +56,7 @@ main(int argc, char *argv[])
{
struct passwd *pw;
struct event ev_sigint, ev_sigterm, ev_sighup, ev_sigchld;
- const char *mtype_str = "mbox";
+ const char *path = NULL, *mtype_str = "mbox";
int ch, d = 0, pair[2];
while ((ch = getopt(argc, argv, "dp:t:")) != -1) {
@@ -65,13 +65,11 @@ main(int argc, char *argv[])
d = 1;
break;
case 'p':
- mpath = optarg;
+ path = optarg;
break;
case 't':
if ((mtype = m_type(optarg)) == -1)
errx(1, "%s invalid argument", optarg);
- if (mtype == M_MAILDIR)
- mpath = MAILDIR_PATH;
mtype_str = optarg;
break;
default:
@@ -84,6 +82,11 @@ main(int argc, char *argv[])
if (argc > 0 || *argv)
usage();
+ if (path)
+ mpath = path;
+ else
+ mpath = (mtype == M_MAILDIR) ? MAILDIR_PATH : MBOX_PATH;
+
log_init(d);
if (geteuid())
fatalx("need root privileges");