version 1.46, 1999/11/10 22:24:01 |
version 1.47, 1999/11/10 23:36:45 |
|
|
/* Flag indicating that the daemon is being started from inetd. */ |
/* Flag indicating that the daemon is being started from inetd. */ |
int inetd_flag = 0; |
int inetd_flag = 0; |
|
|
|
/* debug goes to stderr unless inetd_flag is set */ |
|
int log_stderr = 0; |
|
|
/* argv[0] without path. */ |
/* argv[0] without path. */ |
char *av0; |
char *av0; |
|
|
|
|
break; |
break; |
case 'd': |
case 'd': |
debug_flag = 1; |
debug_flag = 1; |
|
options.log_level = SYSLOG_LEVEL_DEBUG; |
break; |
break; |
case 'i': |
case 'i': |
inetd_flag = 1; |
inetd_flag = 1; |
|
|
silentrsa = 1; |
silentrsa = 1; |
break; |
break; |
case 'q': |
case 'q': |
options.quiet_mode = 1; |
options.log_level = SYSLOG_LEVEL_QUIET; |
break; |
break; |
case 'b': |
case 'b': |
options.server_key_bits = atoi(optarg); |
options.server_key_bits = atoi(optarg); |
|
|
} |
} |
|
|
/* Initialize the log (it is reinitialized below in case we forked). */ |
/* Initialize the log (it is reinitialized below in case we forked). */ |
log_init(av0, debug_flag && !inetd_flag, |
|
debug_flag || options.fascist_logging, |
|
options.quiet_mode, options.log_facility); |
|
|
|
|
if (debug_flag && !inetd_flag) |
|
log_stderr = 1; |
|
|
|
log_init(av0, options.log_level, options.log_facility, log_stderr); |
|
|
debug("sshd version %.100s", SSH_VERSION); |
debug("sshd version %.100s", SSH_VERSION); |
|
|
sensitive_data.host_key = RSA_new(); |
sensitive_data.host_key = RSA_new(); |
|
|
else |
else |
{ |
{ |
int err = errno; |
int err = errno; |
log_init(av0, !inetd_flag, 1, 0, options.log_facility); |
/* force logging */ |
|
log_init(av0, SYSLOG_LEVEL_DEBUG, options.log_facility, log_stderr); |
error("Could not load host key: %.200s: %.100s", |
error("Could not load host key: %.200s: %.100s", |
options.host_key_file, strerror(err)); |
options.host_key_file, strerror(err)); |
} |
} |
|
|
} |
} |
|
|
/* Reinitialize the log (because of the fork above). */ |
/* Reinitialize the log (because of the fork above). */ |
log_init(av0, debug_flag && !inetd_flag, |
log_init(av0, options.log_level, options.log_facility, log_stderr); |
debug_flag || options.fascist_logging, |
|
options.quiet_mode, options.log_facility); |
|
|
|
/* Check that server and host key lengths differ sufficiently. This is |
/* Check that server and host key lengths differ sufficiently. This is |
necessary to make double encryption work with rsaref. Oh, I hate |
necessary to make double encryption work with rsaref. Oh, I hate |
|
|
close(listen_sock); |
close(listen_sock); |
sock_in = newsock; |
sock_in = newsock; |
sock_out = newsock; |
sock_out = newsock; |
log_init(av0, debug_flag && !inetd_flag, |
log_init(av0, options.log_level, options.log_facility, log_stderr); |
options.fascist_logging || debug_flag, |
|
options.quiet_mode, options.log_facility); |
|
break; |
break; |
} |
} |
} |
} |
|
|
if ((pid = fork()) == 0) |
if ((pid = fork()) == 0) |
{ |
{ |
/* Child. Reinitialize the log since the pid has changed. */ |
/* Child. Reinitialize the log since the pid has changed. */ |
log_init(av0, debug_flag && !inetd_flag, debug_flag, |
log_init(av0, options.log_level, options.log_facility, log_stderr); |
options.quiet_mode, options.log_facility); |
|
|
|
/* Create a new session and process group since the 4.4BSD setlogin() |
/* Create a new session and process group since the 4.4BSD setlogin() |
affects the entire process group. */ |
affects the entire process group. */ |
|
|
pid = getpid(); |
pid = getpid(); |
|
|
/* Child. Reinitialize the log because the pid has changed. */ |
/* Child. Reinitialize the log because the pid has changed. */ |
log_init(av0, debug_flag && !inetd_flag, debug_flag, options.quiet_mode, |
log_init(av0, options.log_level, options.log_facility, log_stderr); |
options.log_facility); |
|
|
|
/* Close the master side of the pseudo tty. */ |
/* Close the master side of the pseudo tty. */ |
close(ptyfd); |
close(ptyfd); |