From e866b3e47fe92eafc9d6d40a579993c8919b9842 Mon Sep 17 00:00:00 2001 From: John Denker Date: Sun, 3 Jun 2012 00:00:54 -0700 Subject: pass config-file in environment, since can't pass it as arg --- tools/hi-q.c | 24 +++++++++++++++++++++--- tools/qmail | 14 ++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/hi-q.c b/tools/hi-q.c index f0e107a..1edf8f0 100644 --- a/tools/hi-q.c +++ b/tools/hi-q.c @@ -103,6 +103,13 @@ int Execve(char const * fn, return execve(fn, (char*const*) argv, (char*const*) env); } +void usage() { + cerr << "Usage:\n" +" hi-q filter.conf\n" +"or\n" +" HI_Q_CONF=filter.conf hi-q\n"; +} + //////////////////////////////////////// // we have data coming in on fd 0. // and control coming in on fd 1. @@ -136,12 +143,22 @@ int main(int argc, char** argv, char const * const * env) { typedef vector VS; vector filter; - if (argc != 2) { - cerr << "Usage: hi-q filter.conf" << endl; + char* conf_name; + + if (argc == 1) { + conf_name = getenv("HI_Q_CONF"); + if (!conf_name) { + usage(); + exit(1); + } + } + else if (argc == 2) { + conf_name = argv[1]; + } else { + usage(); exit(1); } - char* conf_name = argv[1]; ifstream conf; conf.open(conf_name); if (! conf.good()) { @@ -165,6 +182,7 @@ int main(int argc, char** argv, char const * const * env) { } if (verbose) for (vector::const_iterator job = filter.begin(); job != filter.end(); job++) { + cerr << "Filter: "; for (VS::const_iterator token = job->begin(); token != job->end(); token++){ cerr << *token << " "; diff --git a/tools/qmail b/tools/qmail index e49ac96..73a872c 100755 --- a/tools/qmail +++ b/tools/qmail @@ -12,6 +12,8 @@ tcps=$( which tcpserver ) qmaild=$(id -u qmaild ) nofiles=$(id -g qmaild ) + +filters=/var/qmail/control/filters.conf smtpconf=/etc/stunnel/smtp.conf pop3conf=/etc/stunnel/pop3.conf @@ -154,7 +156,8 @@ case "$verb" in else echo -n " SMTP-server " /bin/rm -f /var/run/$proc.pid - QMAILQUEUE="/var/qmail/bin/hi-q asdf/var/qmail/control/filters.conf" \ + HI_Q_CONF="$filters" \ + QMAILQUEUE="/var/qmail/bin/hi-q" \ $PIDO /var/run/$proc.pid \ $tcps -R -x/etc/tcpserver/smtp.cdb \ -u$qmaild -g$nofiles $mailhost smtp \ @@ -243,9 +246,12 @@ case "$verb" in echo " down. $pid" fi done - if ! test -r '/etc/tcpserver/smtp.cdb' ; then - echo "Beware: /etc/tcpserver/smtp.cdb is missing." - fi + for file in $pop3conf $smtpconf $filters \ + /etc/tcpserver/smtp.cdb ; do + if ! test -r "$file" ; then + echo "Beware: file '$file' is missing." + fi + done ;; *) echo "Usage: $0 {start|stop|reload|zap|restart|status}" -- cgit v1.2.3