From 89c7cc9a5e434e25bfcbd06ea633a8b411f0e6de Mon Sep 17 00:00:00 2001 From: Sunil Nimmagadda Date: Thu, 10 Apr 2014 17:58:37 +0500 Subject: Simplify maildrop path handling. Regardless of the order of options path is now correctly handled. --- pop3d.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'pop3d.c') 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"); -- cgit v1.2.3