diff options
Diffstat (limited to 'sshd.c')
-rw-r--r-- | sshd.c | 23 |
1 files changed, 8 insertions, 15 deletions
@@ -117,9 +117,6 @@ int no_daemon_flag = 0; | |||
117 | /* debug goes to stderr unless inetd_flag is set */ | 117 | /* debug goes to stderr unless inetd_flag is set */ |
118 | int log_stderr = 0; | 118 | int log_stderr = 0; |
119 | 119 | ||
120 | /* argv[0] without path. */ | ||
121 | char *av0; | ||
122 | |||
123 | /* Saved arguments to main(). */ | 120 | /* Saved arguments to main(). */ |
124 | char **saved_argv; | 121 | char **saved_argv; |
125 | int saved_argc; | 122 | int saved_argc; |
@@ -215,7 +212,7 @@ sighup_restart() | |||
215 | log("Received SIGHUP; restarting."); | 212 | log("Received SIGHUP; restarting."); |
216 | close_listen_socks(); | 213 | close_listen_socks(); |
217 | execv(saved_argv[0], saved_argv); | 214 | execv(saved_argv[0], saved_argv); |
218 | log("RESTART FAILED: av0='%s', error: %s.", av0, strerror(errno)); | 215 | log("RESTART FAILED: av[0]='%.100s', error: %.100s.", saved_argv[0], strerror(errno)); |
219 | exit(1); | 216 | exit(1); |
220 | } | 217 | } |
221 | 218 | ||
@@ -574,13 +571,9 @@ main(int ac, char **av) | |||
574 | __progname = get_progname(av[0]); | 571 | __progname = get_progname(av[0]); |
575 | init_rng(); | 572 | init_rng(); |
576 | 573 | ||
577 | /* Save argv[0]. */ | 574 | /* Save argv. */ |
578 | saved_argc = ac; | 575 | saved_argc = ac; |
579 | saved_argv = av; | 576 | saved_argv = av; |
580 | if (strchr(av[0], '/')) | ||
581 | av0 = strrchr(av[0], '/') + 1; | ||
582 | else | ||
583 | av0 = av[0]; | ||
584 | 577 | ||
585 | /* Initialize configuration options to their default values. */ | 578 | /* Initialize configuration options to their default values. */ |
586 | initialize_server_options(&options); | 579 | initialize_server_options(&options); |
@@ -655,7 +648,7 @@ main(int ac, char **av) | |||
655 | case '?': | 648 | case '?': |
656 | default: | 649 | default: |
657 | fprintf(stderr, "sshd version %s\n", SSH_VERSION); | 650 | fprintf(stderr, "sshd version %s\n", SSH_VERSION); |
658 | fprintf(stderr, "Usage: %s [options]\n", av0); | 651 | fprintf(stderr, "Usage: %s [options]\n", __progname); |
659 | fprintf(stderr, "Options:\n"); | 652 | fprintf(stderr, "Options:\n"); |
660 | fprintf(stderr, " -f file Configuration file (default %s)\n", SERVER_CONFIG_FILE); | 653 | fprintf(stderr, " -f file Configuration file (default %s)\n", SERVER_CONFIG_FILE); |
661 | fprintf(stderr, " -d Debugging mode (multiple -d means more debugging)\n"); | 654 | fprintf(stderr, " -d Debugging mode (multiple -d means more debugging)\n"); |
@@ -678,7 +671,7 @@ main(int ac, char **av) | |||
678 | * Force logging to stderr until we have loaded the private host | 671 | * Force logging to stderr until we have loaded the private host |
679 | * key (unless started from inetd) | 672 | * key (unless started from inetd) |
680 | */ | 673 | */ |
681 | log_init(av0, | 674 | log_init(__progname, |
682 | options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, | 675 | options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, |
683 | options.log_facility == -1 ? SYSLOG_FACILITY_AUTH : options.log_facility, | 676 | options.log_facility == -1 ? SYSLOG_FACILITY_AUTH : options.log_facility, |
684 | !silent && !inetd_flag); | 677 | !silent && !inetd_flag); |
@@ -768,7 +761,7 @@ main(int ac, char **av) | |||
768 | /* Initialize the log (it is reinitialized below in case we forked). */ | 761 | /* Initialize the log (it is reinitialized below in case we forked). */ |
769 | if (debug_flag && !inetd_flag) | 762 | if (debug_flag && !inetd_flag) |
770 | log_stderr = 1; | 763 | log_stderr = 1; |
771 | log_init(av0, options.log_level, options.log_facility, log_stderr); | 764 | log_init(__progname, options.log_level, options.log_facility, log_stderr); |
772 | 765 | ||
773 | /* | 766 | /* |
774 | * If not in debugging mode, and not started from inetd, disconnect | 767 | * If not in debugging mode, and not started from inetd, disconnect |
@@ -792,7 +785,7 @@ main(int ac, char **av) | |||
792 | #endif /* TIOCNOTTY */ | 785 | #endif /* TIOCNOTTY */ |
793 | } | 786 | } |
794 | /* Reinitialize the log (because of the fork above). */ | 787 | /* Reinitialize the log (because of the fork above). */ |
795 | log_init(av0, options.log_level, options.log_facility, log_stderr); | 788 | log_init(__progname, options.log_level, options.log_facility, log_stderr); |
796 | 789 | ||
797 | /* Initialize the random number generator. */ | 790 | /* Initialize the random number generator. */ |
798 | arc4random_stir(); | 791 | arc4random_stir(); |
@@ -1031,7 +1024,7 @@ main(int ac, char **av) | |||
1031 | close_listen_socks(); | 1024 | close_listen_socks(); |
1032 | sock_in = newsock; | 1025 | sock_in = newsock; |
1033 | sock_out = newsock; | 1026 | sock_out = newsock; |
1034 | log_init(av0, options.log_level, options.log_facility, log_stderr); | 1027 | log_init(__progname, options.log_level, options.log_facility, log_stderr); |
1035 | break; | 1028 | break; |
1036 | } | 1029 | } |
1037 | } | 1030 | } |
@@ -1098,7 +1091,7 @@ main(int ac, char **av) | |||
1098 | { | 1091 | { |
1099 | struct request_info req; | 1092 | struct request_info req; |
1100 | 1093 | ||
1101 | request_init(&req, RQ_DAEMON, av0, RQ_FILE, sock_in, NULL); | 1094 | request_init(&req, RQ_DAEMON, __progname, RQ_FILE, sock_in, NULL); |
1102 | fromhost(&req); | 1095 | fromhost(&req); |
1103 | 1096 | ||
1104 | if (!hosts_access(&req)) { | 1097 | if (!hosts_access(&req)) { |