comparison svr-main.c @ 379:b66a00272a90

Load hostkeys before daemon(), since daemon()'s chdir("/") will prevent us finding keys in $PWD.
author Matt Johnston <matt@ucc.asn.au>
date Thu, 04 Jan 2007 02:01:09 +0000
parents 3bfbe95f9a14
children 1afa503e33f5
comparison
equal deleted inserted replaced
378:a124aff0cbf1 379:b66a00272a90
121 char * preauth_addrs[MAX_UNAUTH_CLIENTS]; 121 char * preauth_addrs[MAX_UNAUTH_CLIENTS];
122 122
123 int childsock; 123 int childsock;
124 int childpipe[2]; 124 int childpipe[2];
125 125
126 // Note: commonsetup() must happen before we daemon()ise. Otherwise
127 // daemon() will chdir("/"), and we won't be able to find local-dir hostkeys.
128 commonsetup();
129
126 /* fork */ 130 /* fork */
127 if (svr_opts.forkbg) { 131 if (svr_opts.forkbg) {
128 int closefds = 0; 132 int closefds = 0;
129 #ifndef DEBUG_TRACE 133 #ifndef DEBUG_TRACE
130 if (!svr_opts.usingsyslog) { 134 if (!svr_opts.usingsyslog) {
133 #endif 137 #endif
134 if (daemon(0, closefds) < 0) { 138 if (daemon(0, closefds) < 0) {
135 dropbear_exit("Failed to daemonize: %s", strerror(errno)); 139 dropbear_exit("Failed to daemonize: %s", strerror(errno));
136 } 140 }
137 } 141 }
138
139 commonsetup();
140 142
141 /* should be done after syslog is working */ 143 /* should be done after syslog is working */
142 if (svr_opts.forkbg) { 144 if (svr_opts.forkbg) {
143 dropbear_log(LOG_INFO, "Running in background"); 145 dropbear_log(LOG_INFO, "Running in background");
144 } else { 146 } else {