From 4750e43ff9929776128462d977467310317d3f0e Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Tue, 15 Nov 2011 23:06:40 +0000 Subject: 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@ --- usr.sbin/smtpd/smtpctl.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'usr.sbin/smtpd/smtpctl.c') 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 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -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; -- cgit v1.2.3