summaryrefslogtreecommitdiffhomepage
path: root/svr-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'svr-main.c')
-rw-r--r--svr-main.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/svr-main.c b/svr-main.c
index e00de6b..e228acf 100644
--- a/svr-main.c
+++ b/svr-main.c
@@ -123,6 +123,10 @@ 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;
@@ -136,8 +140,6 @@ void main_noinetd() {
}
}
- commonsetup();
-
/* should be done after syslog is working */
if (svr_opts.forkbg) {
dropbear_log(LOG_INFO, "Running in background");
@@ -146,7 +148,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);
@@ -189,7 +191,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");
}