# HG changeset patch # User Matt Johnston # Date 1149689421 0 # Node ID 3bfbe95f9a144103f2833764a95388e48b4779f0 # Parent 84aa4e60bd3c9476a13171c98dc3184d25c8b86d Add -P pidfile patch from Swen Schillig diff -r 84aa4e60bd3c -r 3bfbe95f9a14 runopts.h --- a/runopts.h Wed Jun 07 13:41:19 2006 +0000 +++ b/runopts.h Wed Jun 07 14:10:21 2006 +0000 @@ -83,6 +83,7 @@ sign_key *hostkey; buffer * banner; + char * pidfile; } svr_runopts; diff -r 84aa4e60bd3c -r 3bfbe95f9a14 svr-main.c --- a/svr-main.c Wed Jun 07 13:41:19 2006 +0000 +++ b/svr-main.c Wed Jun 07 14:10:21 2006 +0000 @@ -146,7 +146,7 @@ } /* create a PID file so that we can be killed easily */ - pidfile = fopen(DROPBEAR_PIDFILE, "w"); + pidfile = fopen(svr_opts.pidfile, "w"); if (pidfile) { fprintf(pidfile, "%d\n", getpid()); fclose(pidfile); @@ -189,7 +189,7 @@ val = select(maxsock+1, &fds, NULL, NULL, &seltimeout); if (exitflag) { - unlink(DROPBEAR_PIDFILE); + unlink(svr_opts.pidfile); dropbear_exit("Terminated by signal"); } diff -r 84aa4e60bd3c -r 3bfbe95f9a14 svr-runopts.c --- a/svr-runopts.c Wed Jun 07 13:41:19 2006 +0000 +++ b/svr-runopts.c Wed Jun 07 14:10:21 2006 +0000 @@ -72,6 +72,8 @@ #endif "-p port Listen on specified tcp port, up to %d can be specified\n" " (default %s if none specified)\n" + "-P PidFile Create pid file PidFile\n" + " (default %s)\n" #ifdef INETD_MODE "-i Start for inetd\n" #endif @@ -85,7 +87,7 @@ #ifdef DROPBEAR_RSA RSA_PRIV_FILENAME, #endif - DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT); + DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE); } void svr_getopts(int argc, char ** argv) { @@ -105,6 +107,7 @@ svr_opts.inetdmode = 0; svr_opts.portcount = 0; svr_opts.hostkey = NULL; + svr_opts.pidfile = DROPBEAR_PIDFILE; #ifdef ENABLE_SVR_LOCALTCPFWD svr_opts.nolocaltcp = 0; #endif @@ -185,6 +188,9 @@ svr_opts.portcount++; } break; + case 'P': + next = &svr_opts.pidfile; + break; #ifdef DO_MOTD /* motd is displayed by default, -m turns it off */ case 'm':