summaryrefslogtreecommitdiffhomepage
path: root/svr-main.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2007-02-22 14:53:49 +0000
committerMatt Johnston <matt@ucc.asn.au>2007-02-22 14:53:49 +0000
commitb01a74a9d757ce2b83465214bde1fa07d3e2d3ea (patch)
tree092cac6797947f7b23fcdcc2c081b19c390c5bc4 /svr-main.c
parent66643fa5c723da2dc781c5eeae2e008c280a7b1c (diff)
parent7f12251fbb2acefac04e13a7c6a95ca4dd4b5578 (diff)
merge of 'a9b0496634cdd25647b65e585cc3240f3fa699ee'
and 'c22be8b8f570b48e9662dac32c7b3e7148a42206' --HG-- extra : convert_revision : 066f6aef2791d54b9ec6a0c3033fd28fa946251f
Diffstat (limited to 'svr-main.c')
-rw-r--r--svr-main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/svr-main.c b/svr-main.c
index 13a4ebf..0b65a45 100644
--- a/svr-main.c
+++ b/svr-main.c
@@ -28,6 +28,7 @@
#include "buffer.h"
#include "signkey.h"
#include "runopts.h"
+#include "random.h"
static size_t listensockets(int *sock, size_t sockcount, int *maxfd);
static void sigchld_handler(int dummy);
@@ -51,6 +52,8 @@ int main(int argc, char ** argv)
_dropbear_exit = svr_dropbear_exit;
_dropbear_log = svr_dropbear_log;
+ disallow_core();
+
/* get commandline options */
svr_getopts(argc, argv);
@@ -122,6 +125,11 @@ void main_noinetd() {
int childsock;
int childpipe[2];
+ /* Note: commonsetup() must happen before we daemon()ise. Otherwise
+ daemon() will chdir("/"), and we won't be able to find local-dir
+ hostkeys. */
+ commonsetup();
+
/* fork */
if (svr_opts.forkbg) {
int closefds = 0;
@@ -135,8 +143,6 @@ void main_noinetd() {
}
}
- commonsetup();
-
/* should be done after syslog is working */
if (svr_opts.forkbg) {
dropbear_log(LOG_INFO, "Running in background");
@@ -145,7 +151,7 @@ void main_noinetd() {
}
/* 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);
@@ -188,7 +194,7 @@ void main_noinetd() {
val = select(maxsock+1, &fds, NULL, NULL, &seltimeout);
if (exitflag) {
- unlink(DROPBEAR_PIDFILE);
+ unlink(svr_opts.pidfile);
dropbear_exit("Terminated by signal");
}