summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-09-03 03:08:59 +0000
committerStef Walter <stef@memberwebs.com>2004-09-03 03:08:59 +0000
commit5ffcde771f80f20d560180a631bf0b9aa363b318 (patch)
tree32b1dc6c8ccf0caff69644c1ded22822ded665a8 /src
parent6a250c8a1e581287d7ff3c88582ab337e21ac50f (diff)
pidfile should be an argument not a configuration option
Diffstat (limited to 'src')
-rw-r--r--src/clamsmtpd.c29
-rw-r--r--src/clamsmtpd.h1
-rw-r--r--src/clstate.c5
3 files changed, 15 insertions, 20 deletions
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)
{