diff options
| -rw-r--r-- | common/smtppass.c | 29 | ||||
| -rw-r--r-- | common/smtppass.h | 1 | 
2 files changed, 15 insertions, 15 deletions
| 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 */ | 
