mirror of
http://galexander.org/git/simplesshd.git
synced 2025-01-03 19:50:55 +00:00
parent
760d17ddf7
commit
781af9c467
@ -106,6 +106,7 @@ typedef struct svr_runopts {
|
||||
int num_hostkey_files;
|
||||
|
||||
buffer * banner;
|
||||
char * pidfile;
|
||||
|
||||
} svr_runopts;
|
||||
|
||||
|
@ -111,6 +111,7 @@ void main_noinetd() {
|
||||
int maxsock = -1;
|
||||
int listensocks[MAX_LISTEN_ADDR];
|
||||
size_t listensockcount = 0;
|
||||
FILE *pidfile = NULL;
|
||||
|
||||
int childpipes[MAX_UNAUTH_CLIENTS];
|
||||
char * preauth_addrs[MAX_UNAUTH_CLIENTS];
|
||||
@ -161,6 +162,13 @@ void main_noinetd() {
|
||||
dropbear_log(LOG_INFO, "Not backgrounding");
|
||||
}
|
||||
|
||||
/* create a PID file so that we can be killed easily */
|
||||
pidfile = fopen(svr_opts.pidfile, "w");
|
||||
if (pidfile) {
|
||||
fprintf(pidfile, "%d\n", getpid());
|
||||
fclose(pidfile);
|
||||
}
|
||||
|
||||
/* incoming connection select loop */
|
||||
for(;;) {
|
||||
|
||||
@ -182,6 +190,7 @@ void main_noinetd() {
|
||||
val = select(maxsock+1, &fds, NULL, NULL, NULL);
|
||||
|
||||
if (exitflag) {
|
||||
unlink(svr_opts.pidfile);
|
||||
dropbear_exit("Terminated by signal");
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,8 @@ static void printhelp(const char * progname) {
|
||||
" Listen on specified tcp port (and optionally address),\n"
|
||||
" up to %d can be specified\n"
|
||||
" (default port is %s if none specified)\n"
|
||||
"-P PidFile Create pid file PidFile\n"
|
||||
" (default %s)\n"
|
||||
#ifdef INETD_MODE
|
||||
"-i Start for inetd\n"
|
||||
#endif
|
||||
@ -104,7 +106,7 @@ static void printhelp(const char * progname) {
|
||||
#ifdef DROPBEAR_ECDSA
|
||||
ECDSA_PRIV_FILENAME,
|
||||
#endif
|
||||
DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT,
|
||||
DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE,
|
||||
DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT);
|
||||
}
|
||||
|
||||
@ -131,6 +133,7 @@ void svr_getopts(int argc, char ** argv) {
|
||||
svr_opts.portcount = 0;
|
||||
svr_opts.hostkey = NULL;
|
||||
svr_opts.delay_hostkey = 0;
|
||||
svr_opts.pidfile = DROPBEAR_PIDFILE;
|
||||
#ifdef ENABLE_SVR_LOCALTCPFWD
|
||||
svr_opts.nolocaltcp = 0;
|
||||
#endif
|
||||
@ -220,6 +223,9 @@ void svr_getopts(int argc, char ** argv) {
|
||||
case 'p':
|
||||
nextisport = 1;
|
||||
break;
|
||||
case 'P':
|
||||
next = &svr_opts.pidfile;
|
||||
break;
|
||||
#ifdef DO_MOTD
|
||||
/* motd is displayed by default, -m turns it off */
|
||||
case 'm':
|
||||
|
Loading…
Reference in New Issue
Block a user