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