diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2011-11-15 23:06:40 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2011-11-15 23:06:40 +0000 |
commit | 4750e43ff9929776128462d977467310317d3f0e (patch) | |
tree | 0aeffd560c1bbbc320208d05891fe83c15a850e1 /usr.sbin/smtpd/smtpctl.c | |
parent | 807ff6be05a018ad5c4922a914f22a3b42dd97bf (diff) |
Qwalk, our API to linearly walk over the persistent queue, did not take the
queue_backend into account and assumed a filesystem with a specific layout.
This commit does plenty of things:
- make qwalk an abstraction in the queue_backend API, and impose queue
drivers to implement qwalk_open(), qwalk() and qwalk_close();
- move previous qwalk_open(), qwalk() and qwalk_close() to the fsqueue
driver since they were fsqueue specific ...
- make qwalk API work with msgid/evpid instead of pathnames since we're
going to use the queue_backend API to load envelopes by evpid anyway;
- makes smtpd use *solely* the queue_backend API when manipulating the
queue. pathnames were removed from smtpd.h and moved into the fsqueue
which means we can now store a queue anywhere ... as long as we write
the ten functions or so required for a queue driver ;-)
ok eric@, ok chl@
Diffstat (limited to 'usr.sbin/smtpd/smtpctl.c')
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 654f47ff15c..f71c96000c6 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.70 2011/10/26 20:47:31 gilles Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.71 2011/11/15 23:06:39 gilles Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -30,6 +30,7 @@ #include <errno.h> #include <event.h> #include <imsg.h> +#include <pwd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -81,20 +82,34 @@ main(int argc, char *argv[]) else if (strcmp(__progname, "mailq") == 0) { if (geteuid()) errx(1, "need root privileges"); - show_queue(PATH_QUEUE, 0); + show_queue(Q_QUEUE, 0); return 0; } else if (strcmp(__progname, "smtpctl") == 0) { + struct smtpd smtpd; + /* check for root privileges */ if (geteuid()) errx(1, "need root privileges"); + bzero(&smtpd, sizeof (smtpd)); + env = &smtpd; + if ((env->sc_pw = getpwnam(SMTPD_USER)) == NULL) + errx(1, "unknown user %s", SMTPD_USER); + + env->sc_queue = queue_backend_lookup(QT_FS); + if (env->sc_queue == NULL) + errx(1, "could not find queue backend"); + + if (!env->sc_queue->init()) + errx(1, "invalid directory permissions"); + if ((res = parse(argc - 1, argv + 1)) == NULL) exit(1); /* handle "disconnected" commands */ switch (res->action) { case SHOW_QUEUE: - show_queue(PATH_QUEUE, 0); + show_queue(Q_QUEUE, 0); break; case SHOW_RUNQUEUE: break; |