From: Simon 'corecode' Schubert Date: Fri, 17 Oct 2008 07:32:26 +0000 (+0200) Subject: dma: Re-arrange argument consistency checks. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d291e4d8eebba2c601fbf588e35c7968d3c4850;p=people%2Fms%2Fdma.git dma: Re-arrange argument consistency checks. --- diff --git a/dma.c b/dma.c index 4d30153..57237f4 100644 --- a/dma.c +++ b/dma.c @@ -256,6 +256,7 @@ add_recp(struct queue *queue, const char *str, const char *sender, int expand) pw = getpwnam(it->addr); if (pw == NULL) goto out; + /* XXX read .forward */ endpwent(); } } @@ -1140,15 +1141,22 @@ main(int argc, char **argv) argv += optind; opterr = 1; + if (argc != 0 && (showq || doqueue)) + errx(1, "sending mail and queue operations are mutually exclusive"); + + if (showq + doqueue > 1) + errx(1, "conflicting queue operations"); + + /* XXX fork root here */ + skipopts: openlog(tag, LOG_PID, LOG_MAIL); set_username(); - config = malloc(sizeof(struct config)); + config = calloc(1, sizeof(*config)); if (config == NULL) err(1, NULL); - memset(config, 0, sizeof(struct config)); if (parse_conf(CONF_PATH, config) < 0) { free(config); err(1, "can not read config file"); @@ -1163,17 +1171,12 @@ skipopts: err(1, "can not read SMTP authentication file"); if (showq) { - if (argc != 0) - errx(1, "sending mail and displaying queue is" - " mutually exclusive"); load_queue(&lqueue, 1); show_queue(&lqueue); return (0); } if (doqueue) { - if (argc != 0) - errx(1, "sending mail and queue pickup is mutually exclusive"); load_queue(&lqueue, 0); run_queue(&lqueue); return (0);