diff options
author | Stef Walter <stef@memberwebs.com> | 2004-09-03 03:08:59 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-09-03 03:08:59 +0000 |
commit | 5ffcde771f80f20d560180a631bf0b9aa363b318 (patch) | |
tree | 32b1dc6c8ccf0caff69644c1ded22822ded665a8 | |
parent | 6a250c8a1e581287d7ff3c88582ab337e21ac50f (diff) |
pidfile should be an argument not a configuration option
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | common/smtppass.c | 29 | ||||
-rw-r--r-- | common/smtppass.h | 1 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | doc/clamsmtpd.8 | 7 | ||||
-rw-r--r-- | doc/clamsmtpd.conf | 2 | ||||
-rw-r--r-- | doc/clamsmtpd.conf.5 | 6 | ||||
-rw-r--r-- | src/clamsmtpd.c | 29 | ||||
-rw-r--r-- | src/clamsmtpd.h | 1 | ||||
-rw-r--r-- | src/clstate.c | 5 |
10 files changed, 43 insertions, 45 deletions
@@ -1,3 +1,7 @@ +0.8 + - clamsmtpd now uses a configuration file + - Compile option -Wall only enabled on debug builds + 0.7 - Added support for ESMTP [Andreas Steinmetz] - Fixed crash when too many connections established diff --git a/common/smtppass.c b/common/smtppass.c index e985fa3..42548ca 100644 --- a/common/smtppass.c +++ b/common/smtppass.c @@ -138,7 +138,7 @@ unsigned int g_unique_id = 0x00100000; /* For connection ids */ static void usage(); static void on_quit(int signal); -static void pid_file(int write); +static void pid_file(const char* pidfile, int write); static void connection_loop(int sock); static void* thread_main(void* arg); static int smtp_passthru(clamsmtp_context_t* ctx); @@ -162,6 +162,7 @@ static void read_junk(clamsmtp_context_t* ctx, int fd); int main(int argc, char* argv[]) { const char* configfile = DEFAULT_CONFIG; + const char* pidfile = NULL; int warnargs = 0; int sock; int true = 1; @@ -231,7 +232,7 @@ int main(int argc, char* argv[]) /* Write out a pid file */ case 'p': - g_state.pidfile = optarg; + pidfile = optarg; break; /* The timeout */ @@ -347,15 +348,15 @@ int main(int argc, char* argv[]) siginterrupt(SIGINT, 1); siginterrupt(SIGTERM, 1); - if(g_state.pidfile) - pid_file(1); + if(pidfile) + pid_file(pidfile, 1); messagex(NULL, LOG_DEBUG, "accepting connections"); connection_loop(sock); - if(g_state.pidfile) - pid_file(0); + if(pidfile) + pid_file(pidfile, 0); messagex(NULL, LOG_DEBUG, "stopped"); @@ -375,37 +376,37 @@ static void on_quit(int signal) static void usage() { - fprintf(stderr, "usage: clamsmtpd [-d debuglevel] [-f configfile] \n"); + fprintf(stderr, "usage: clamsmtpd [-d debuglevel] [-f configfile] [-p pidfile]\n"); fprintf(stderr, " clamsmtpd -v\n"); exit(2); } -static void pid_file(int write) +static void pid_file(const char* pidfile, int write) { if(write) { - FILE* f = fopen(g_state.pidfile, "w"); + FILE* f = fopen(pidfile, "w"); if(f == NULL) { - message(NULL, LOG_ERR, "couldn't open pid file: %s", g_state.pidfile); + message(NULL, LOG_ERR, "couldn't open pid file: %s", pidfile); } else { fprintf(f, "%d\n", (int)getpid()); if(ferror(f)) - message(NULL, LOG_ERR, "couldn't write to pid file: %s", g_state.pidfile); + message(NULL, LOG_ERR, "couldn't write to pid file: %s", pidfile); fclose(f); } - messagex(NULL, LOG_DEBUG, "wrote pid file: %s", g_state.pidfile); + messagex(NULL, LOG_DEBUG, "wrote pid file: %s", pidfile); } else { - unlink(g_state.pidfile); - messagex(NULL, LOG_DEBUG, "removed pid file: %s", g_state.pidfile); + unlink(pidfile); + messagex(NULL, LOG_DEBUG, "removed pid file: %s", pidfile); } } diff --git a/common/smtppass.h b/common/smtppass.h index deb2cfb..2fc6f9e 100644 --- a/common/smtppass.h +++ b/common/smtppass.h @@ -119,7 +119,6 @@ typedef struct clstate const char* header; /* The header to add to email */ const char* directory; /* The directory for temp files */ - const char* pidfile; /* The process id file */ int bounce; /* Send back a reject line */ int quarantine; /* Leave virus files in temp dir */ int debug_files; /* Leave all files in temp dir */ diff --git a/configure.in b/configure.in index de40fb5..636ebbf 100644 --- a/configure.in +++ b/configure.in @@ -36,8 +36,8 @@ dnl Nate Nielsen <nielsen@memberwebs.com> dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT(clamsmtp, 0.7, nielsen@memberwebs.com) -AM_INIT_AUTOMAKE(clamsmtp, 0.7) +AC_INIT(clamsmtp, 0.7.90, nielsen@memberwebs.com) +AM_INIT_AUTOMAKE(clamsmtp, 0.7.90) LDFLAGS="$LDFLAGS -L/usr/local/lib" CFLAGS="$CFLAGS -I/usr/local/include" diff --git a/doc/clamsmtpd.8 b/doc/clamsmtpd.8 index 8ee3d80..2317b59 100644 --- a/doc/clamsmtpd.8 +++ b/doc/clamsmtpd.8 @@ -44,6 +44,7 @@ .Nm .Op Fl d Ar level .Op Fl f Ar configfile +.Op Fl p Ar pidfile .Nm .Fl v .Sh DESCRIPTION @@ -79,6 +80,12 @@ specifies an alternate location for the configuration file. See .Xr clamsmtpd.conf 5 for more details on where the configuration file is located by default. +.It Fl p +.Ar pidfile +specifies a location for the a process id file to be written to. This file +contains the process id of +.Nm +and can be used to stop the daemon. .It Fl v Prints the clamsmtp version number and exits. .El diff --git a/doc/clamsmtpd.conf b/doc/clamsmtpd.conf index 979103c..18ff33a 100644 --- a/doc/clamsmtpd.conf +++ b/doc/clamsmtpd.conf @@ -35,6 +35,4 @@ OutAddress: 10026 # Whether or not to keep virus files #Quarantine: off -# The location for a pid file for stopping clamsmtpd -#PidFile: (none) diff --git a/doc/clamsmtpd.conf.5 b/doc/clamsmtpd.conf.5 index 5a7e521..1a6cd99 100644 --- a/doc/clamsmtpd.conf.5 +++ b/doc/clamsmtpd.conf.5 @@ -96,12 +96,6 @@ character or number): .It Ar MaxConnections Specifies the maximum number of connections to accept at once. [ Default: 64 ] -.It Ar PidFile -This option causes -.Xr clamsmtpd 8 -to write a file with the daemon's process id, which can be used to stop the -daemon. -[ Optional ] .It Ar ScanHeader A header to add to scanned messages. Put an empty value to supress adding a header. diff --git a/src/clamsmtpd.c b/src/clamsmtpd.c index e985fa3..42548ca 100644 --- a/src/clamsmtpd.c +++ b/src/clamsmtpd.c @@ -138,7 +138,7 @@ unsigned int g_unique_id = 0x00100000; /* For connection ids */ static void usage(); static void on_quit(int signal); -static void pid_file(int write); +static void pid_file(const char* pidfile, int write); static void connection_loop(int sock); static void* thread_main(void* arg); static int smtp_passthru(clamsmtp_context_t* ctx); @@ -162,6 +162,7 @@ static void read_junk(clamsmtp_context_t* ctx, int fd); int main(int argc, char* argv[]) { const char* configfile = DEFAULT_CONFIG; + const char* pidfile = NULL; int warnargs = 0; int sock; int true = 1; @@ -231,7 +232,7 @@ int main(int argc, char* argv[]) /* Write out a pid file */ case 'p': - g_state.pidfile = optarg; + pidfile = optarg; break; /* The timeout */ @@ -347,15 +348,15 @@ int main(int argc, char* argv[]) siginterrupt(SIGINT, 1); siginterrupt(SIGTERM, 1); - if(g_state.pidfile) - pid_file(1); + if(pidfile) + pid_file(pidfile, 1); messagex(NULL, LOG_DEBUG, "accepting connections"); connection_loop(sock); - if(g_state.pidfile) - pid_file(0); + if(pidfile) + pid_file(pidfile, 0); messagex(NULL, LOG_DEBUG, "stopped"); @@ -375,37 +376,37 @@ static void on_quit(int signal) static void usage() { - fprintf(stderr, "usage: clamsmtpd [-d debuglevel] [-f configfile] \n"); + fprintf(stderr, "usage: clamsmtpd [-d debuglevel] [-f configfile] [-p pidfile]\n"); fprintf(stderr, " clamsmtpd -v\n"); exit(2); } -static void pid_file(int write) +static void pid_file(const char* pidfile, int write) { if(write) { - FILE* f = fopen(g_state.pidfile, "w"); + FILE* f = fopen(pidfile, "w"); if(f == NULL) { - message(NULL, LOG_ERR, "couldn't open pid file: %s", g_state.pidfile); + message(NULL, LOG_ERR, "couldn't open pid file: %s", pidfile); } else { fprintf(f, "%d\n", (int)getpid()); if(ferror(f)) - message(NULL, LOG_ERR, "couldn't write to pid file: %s", g_state.pidfile); + message(NULL, LOG_ERR, "couldn't write to pid file: %s", pidfile); fclose(f); } - messagex(NULL, LOG_DEBUG, "wrote pid file: %s", g_state.pidfile); + messagex(NULL, LOG_DEBUG, "wrote pid file: %s", pidfile); } else { - unlink(g_state.pidfile); - messagex(NULL, LOG_DEBUG, "removed pid file: %s", g_state.pidfile); + unlink(pidfile); + messagex(NULL, LOG_DEBUG, "removed pid file: %s", pidfile); } } diff --git a/src/clamsmtpd.h b/src/clamsmtpd.h index deb2cfb..2fc6f9e 100644 --- a/src/clamsmtpd.h +++ b/src/clamsmtpd.h @@ -119,7 +119,6 @@ typedef struct clstate const char* header; /* The header to add to email */ const char* directory; /* The directory for temp files */ - const char* pidfile; /* The process id file */ int bounce; /* Send back a reject line */ int quarantine; /* Leave virus files in temp dir */ int debug_files; /* Leave all files in temp dir */ diff --git a/src/clstate.c b/src/clstate.c index 3c6084c..0a166f9 100644 --- a/src/clstate.c +++ b/src/clstate.c @@ -86,7 +86,6 @@ #define CFG_BOUNCE "Bounce" #define CFG_QUARANTINE "Quarantine" #define CFG_DEBUGFILES "DebugFiles" -#define CFG_PIDFILE "PidFile" /* The set of delimiters that can be present between config and value */ #define CFG_DELIMS ": \t" @@ -231,8 +230,6 @@ int clstate_parse_config(clstate_t* state, const char* configfile) else if(PARSE(CFG_DIRECTORY)) state->directory = VAL; - else if(PARSE(CFG_PIDFILE)) - state->pidfile = VAL; else if(PARSE(CFG_BOUNCE)) state->bounce = strtob(VAL); @@ -288,8 +285,6 @@ void clstate_validate(clstate_t* state) if(strlen(state->directory) == 0) errx(2, "invalid setting: " CFG_DIRECTORY); - if(state->pidfile && strlen(state->pidfile) == 0) - errx(2, "invalid setting: " CFG_PIDFILE); if(state->header) { |