diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | ssh-keyscan.c | 18 | ||||
-rw-r--r-- | ssh.c | 15 | ||||
-rw-r--r-- | sshd.c | 23 |
4 files changed, 24 insertions, 36 deletions
@@ -1,6 +1,10 @@ | |||
1 | 20001213 | 1 | 20001213 |
2 | - (djm) Make sure we reset the SIGPIPE disposition after we fork. Report | 2 | - (djm) Make sure we reset the SIGPIPE disposition after we fork. Report |
3 | from Andreas M. Kirchwitz <amk@krell.zikzak.de> | 3 | from Andreas M. Kirchwitz <amk@krell.zikzak.de> |
4 | - (stevesk) OpenSSH CVS update: | ||
5 | - markus@cvs.openbsd.org 2000/12/12 15:30:02 | ||
6 | [ssh-keyscan.c ssh.c sshd.c] | ||
7 | consistently use __progname; from stevesk@pobox.com | ||
4 | 8 | ||
5 | 20001211 | 9 | 20001211 |
6 | - (bal) Applied patch to include ssh-keyscan into Redhat's package, and | 10 | - (bal) Applied patch to include ssh-keyscan into Redhat's package, and |
diff --git a/ssh-keyscan.c b/ssh-keyscan.c index 19f57b7e4..13f9673b5 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c | |||
@@ -40,7 +40,11 @@ int timeout = 5; | |||
40 | int maxfd; | 40 | int maxfd; |
41 | #define maxcon (maxfd - 10) | 41 | #define maxcon (maxfd - 10) |
42 | 42 | ||
43 | char *prog; | 43 | #ifdef HAVE___PROGNAME |
44 | extern char *__progname; | ||
45 | #else | ||
46 | char *__progname; | ||
47 | #endif | ||
44 | fd_set read_wait; | 48 | fd_set read_wait; |
45 | int ncon; | 49 | int ncon; |
46 | 50 | ||
@@ -544,7 +548,7 @@ nexthost(int argc, char **argv) | |||
544 | static void | 548 | static void |
545 | usage(void) | 549 | usage(void) |
546 | { | 550 | { |
547 | fatal("usage: %s [-t timeout] { [--] host | -f file } ...\n", prog); | 551 | fatal("usage: %s [-t timeout] { [--] host | -f file } ...\n", __progname); |
548 | return; | 552 | return; |
549 | } | 553 | } |
550 | 554 | ||
@@ -553,13 +557,9 @@ main(int argc, char **argv) | |||
553 | { | 557 | { |
554 | char *host = NULL; | 558 | char *host = NULL; |
555 | 559 | ||
560 | __progname = get_progname(argv[0]); | ||
556 | TAILQ_INIT(&tq); | 561 | TAILQ_INIT(&tq); |
557 | 562 | ||
558 | if ((prog = strrchr(argv[0], '/'))) | ||
559 | prog++; | ||
560 | else | ||
561 | prog = argv[0]; | ||
562 | |||
563 | if (argc <= argno) | 563 | if (argc <= argno) |
564 | usage(); | 564 | usage(); |
565 | 565 | ||
@@ -580,11 +580,11 @@ main(int argc, char **argv) | |||
580 | 580 | ||
581 | maxfd = fdlim_get(1); | 581 | maxfd = fdlim_get(1); |
582 | if (maxfd < 0) | 582 | if (maxfd < 0) |
583 | fatal("%s: fdlim_get: bad value\n", prog); | 583 | fatal("%s: fdlim_get: bad value\n", __progname); |
584 | if (maxfd > MAXMAXFD) | 584 | if (maxfd > MAXMAXFD) |
585 | maxfd = MAXMAXFD; | 585 | maxfd = MAXMAXFD; |
586 | if (maxcon <= 0) | 586 | if (maxcon <= 0) |
587 | fatal("%s: not enough file descriptors\n", prog); | 587 | fatal("%s: not enough file descriptors\n", __progname); |
588 | if (maxfd > fdlim_get(0)) | 588 | if (maxfd > fdlim_get(0)) |
589 | fdlim_set(maxfd); | 589 | fdlim_set(maxfd); |
590 | fdcon = xmalloc(maxfd * sizeof(con)); | 590 | fdcon = xmalloc(maxfd * sizeof(con)); |
@@ -121,9 +121,6 @@ struct sockaddr_storage hostaddr; | |||
121 | */ | 121 | */ |
122 | volatile int received_window_change_signal = 0; | 122 | volatile int received_window_change_signal = 0; |
123 | 123 | ||
124 | /* Value of argv[0] (set in the main program). */ | ||
125 | char *av0; | ||
126 | |||
127 | /* Flag indicating whether we have a valid host private key loaded. */ | 124 | /* Flag indicating whether we have a valid host private key loaded. */ |
128 | int host_private_key_loaded = 0; | 125 | int host_private_key_loaded = 0; |
129 | 126 | ||
@@ -141,7 +138,7 @@ Buffer command; | |||
141 | void | 138 | void |
142 | usage() | 139 | usage() |
143 | { | 140 | { |
144 | fprintf(stderr, "Usage: %s [options] host [command]\n", av0); | 141 | fprintf(stderr, "Usage: %s [options] host [command]\n", __progname); |
145 | fprintf(stderr, "Options:\n"); | 142 | fprintf(stderr, "Options:\n"); |
146 | fprintf(stderr, " -l user Log in using this user name.\n"); | 143 | fprintf(stderr, " -l user Log in using this user name.\n"); |
147 | fprintf(stderr, " -n Redirect input from /dev/null.\n"); | 144 | fprintf(stderr, " -n Redirect input from /dev/null.\n"); |
@@ -169,7 +166,7 @@ usage() | |||
169 | fprintf(stderr, " -p port Connect to this port. Server must be on the same port.\n"); | 166 | fprintf(stderr, " -p port Connect to this port. Server must be on the same port.\n"); |
170 | fprintf(stderr, " -L listen-port:host:port Forward local port to remote address\n"); | 167 | fprintf(stderr, " -L listen-port:host:port Forward local port to remote address\n"); |
171 | fprintf(stderr, " -R listen-port:host:port Forward remote port to local address\n"); | 168 | fprintf(stderr, " -R listen-port:host:port Forward remote port to local address\n"); |
172 | fprintf(stderr, " These cause %s to listen for connections on a port, and\n", av0); | 169 | fprintf(stderr, " These cause %s to listen for connections on a port, and\n", __progname); |
173 | fprintf(stderr, " forward them to the other side by connecting to host:port.\n"); | 170 | fprintf(stderr, " forward them to the other side by connecting to host:port.\n"); |
174 | fprintf(stderr, " -C Enable compression.\n"); | 171 | fprintf(stderr, " -C Enable compression.\n"); |
175 | fprintf(stderr, " -N Do not execute a shell or command.\n"); | 172 | fprintf(stderr, " -N Do not execute a shell or command.\n"); |
@@ -273,9 +270,6 @@ main(int ac, char **av) | |||
273 | */ | 270 | */ |
274 | umask(022); | 271 | umask(022); |
275 | 272 | ||
276 | /* Save our own name. */ | ||
277 | av0 = av[0]; | ||
278 | |||
279 | /* Initialize option structure to indicate that no values have been set. */ | 273 | /* Initialize option structure to indicate that no values have been set. */ |
280 | initialize_options(&options); | 274 | initialize_options(&options); |
281 | 275 | ||
@@ -283,10 +277,7 @@ main(int ac, char **av) | |||
283 | host = NULL; | 277 | host = NULL; |
284 | 278 | ||
285 | /* If program name is not one of the standard names, use it as host name. */ | 279 | /* If program name is not one of the standard names, use it as host name. */ |
286 | if (strchr(av0, '/')) | 280 | cp = __progname; |
287 | cp = strrchr(av0, '/') + 1; | ||
288 | else | ||
289 | cp = av0; | ||
290 | #ifdef HAVE_CYGWIN | 281 | #ifdef HAVE_CYGWIN |
291 | if (strcasecmp(cp, "rsh") && strcasecmp(cp, "ssh") && | 282 | if (strcasecmp(cp, "rsh") && strcasecmp(cp, "ssh") && |
292 | strcasecmp(cp, "rlogin") && strcasecmp(cp, "slogin") && | 283 | strcasecmp(cp, "rlogin") && strcasecmp(cp, "slogin") && |
@@ -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)) { |