summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/ssh/ssh-keyscan.c15
-rw-r--r--usr.bin/ssh/ssh.c17
-rw-r--r--usr.bin/ssh/sshd.c27
3 files changed, 20 insertions, 39 deletions
diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c
index a6687786b81..9b3baa938f9 100644
--- a/usr.bin/ssh/ssh-keyscan.c
+++ b/usr.bin/ssh/ssh-keyscan.c
@@ -8,7 +8,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-keyscan.c,v 1.2 2000/12/06 19:57:48 markus Exp $");
+RCSID("$OpenBSD: ssh-keyscan.c,v 1.3 2000/12/12 22:30:01 markus Exp $");
#include <sys/queue.h>
#include <errno.h>
@@ -36,7 +36,7 @@ int timeout = 5;
int maxfd;
#define maxcon (maxfd - 10)
-char *prog;
+extern char *__progname;
fd_set read_wait;
int ncon;
@@ -540,7 +540,7 @@ nexthost(int argc, char **argv)
static void
usage(void)
{
- fatal("usage: %s [-t timeout] { [--] host | -f file } ...\n", prog);
+ fatal("usage: %s [-t timeout] { [--] host | -f file } ...\n", __progname);
return;
}
@@ -551,11 +551,6 @@ main(int argc, char **argv)
TAILQ_INIT(&tq);
- if ((prog = strrchr(argv[0], '/')))
- prog++;
- else
- prog = argv[0];
-
if (argc <= argno)
usage();
@@ -576,11 +571,11 @@ main(int argc, char **argv)
maxfd = fdlim_get(1);
if (maxfd < 0)
- fatal("%s: fdlim_get: bad value\n", prog);
+ fatal("%s: fdlim_get: bad value\n", __progname);
if (maxfd > MAXMAXFD)
maxfd = MAXMAXFD;
if (maxcon <= 0)
- fatal("%s: not enough file descriptors\n", prog);
+ fatal("%s: not enough file descriptors\n", __progname);
if (maxfd > fdlim_get(0))
fdlim_set(maxfd);
fdcon = xmalloc(maxfd * sizeof(con));
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index a1e9846c5fc..7c8dd17fffa 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -39,7 +39,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.75 2000/11/30 07:02:35 markus Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.76 2000/12/12 22:30:01 markus Exp $");
#include <openssl/evp.h>
#include <openssl/dsa.h>
@@ -113,9 +113,6 @@ struct sockaddr_storage hostaddr;
*/
volatile int received_window_change_signal = 0;
-/* Value of argv[0] (set in the main program). */
-char *av0;
-
/* Flag indicating whether we have a valid host private key loaded. */
int host_private_key_loaded = 0;
@@ -133,7 +130,7 @@ Buffer command;
void
usage()
{
- fprintf(stderr, "Usage: %s [options] host [command]\n", av0);
+ fprintf(stderr, "Usage: %s [options] host [command]\n", __progname);
fprintf(stderr, "Options:\n");
fprintf(stderr, " -l user Log in using this user name.\n");
fprintf(stderr, " -n Redirect input from /dev/null.\n");
@@ -161,7 +158,7 @@ usage()
fprintf(stderr, " -p port Connect to this port. Server must be on the same port.\n");
fprintf(stderr, " -L listen-port:host:port Forward local port to remote address\n");
fprintf(stderr, " -R listen-port:host:port Forward remote port to local address\n");
- fprintf(stderr, " These cause %s to listen for connections on a port, and\n", av0);
+ fprintf(stderr, " These cause %s to listen for connections on a port, and\n", __progname);
fprintf(stderr, " forward them to the other side by connecting to host:port.\n");
fprintf(stderr, " -C Enable compression.\n");
fprintf(stderr, " -N Do not execute a shell or command.\n");
@@ -260,9 +257,6 @@ main(int ac, char **av)
*/
umask(022);
- /* Save our own name. */
- av0 = av[0];
-
/* Initialize option structure to indicate that no values have been set. */
initialize_options(&options);
@@ -270,10 +264,7 @@ main(int ac, char **av)
host = NULL;
/* If program name is not one of the standard names, use it as host name. */
- if (strchr(av0, '/'))
- cp = strrchr(av0, '/') + 1;
- else
- cp = av0;
+ cp = __progname;
if (strcmp(cp, "rsh") && strcmp(cp, "ssh") && strcmp(cp, "rlogin") &&
strcmp(cp, "slogin") && strcmp(cp, "remsh"))
host = cp;
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index c34b58b7bcd..15ee05b6642 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.137 2000/12/12 21:45:21 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.138 2000/12/12 22:30:02 markus Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -78,6 +78,8 @@ int deny_severity = LOG_WARNING;
#define O_NOCTTY 0
#endif
+extern char *__progname;
+
/* Server configuration options. */
ServerOptions options;
@@ -107,9 +109,6 @@ int no_daemon_flag = 0;
/* debug goes to stderr unless inetd_flag is set */
int log_stderr = 0;
-/* argv[0] without path. */
-char *av0;
-
/* Saved arguments to main(). */
char **saved_argv;
@@ -204,7 +203,7 @@ sighup_restart()
log("Received SIGHUP; restarting.");
close_listen_socks();
execv(saved_argv[0], saved_argv);
- log("RESTART FAILED: av0='%s', error: %s.", av0, strerror(errno));
+ log("RESTART FAILED: av[0]='%.100s', error: %.100s.", saved_argv[0], strerror(errno));
exit(1);
}
@@ -560,12 +559,8 @@ main(int ac, char **av)
int startup_p[2];
int startups = 0;
- /* Save argv[0]. */
+ /* Save argv. */
saved_argv = av;
- if (strchr(av[0], '/'))
- av0 = strrchr(av[0], '/') + 1;
- else
- av0 = av[0];
/* Initialize configuration options to their default values. */
initialize_server_options(&options);
@@ -640,7 +635,7 @@ main(int ac, char **av)
case '?':
default:
fprintf(stderr, "sshd version %s\n", SSH_VERSION);
- fprintf(stderr, "Usage: %s [options]\n", av0);
+ fprintf(stderr, "Usage: %s [options]\n", __progname);
fprintf(stderr, "Options:\n");
fprintf(stderr, " -f file Configuration file (default %s)\n", SERVER_CONFIG_FILE);
fprintf(stderr, " -d Debugging mode (multiple -d means more debugging)\n");
@@ -663,7 +658,7 @@ main(int ac, char **av)
* Force logging to stderr until we have loaded the private host
* key (unless started from inetd)
*/
- log_init(av0,
+ log_init(__progname,
options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level,
options.log_facility == -1 ? SYSLOG_FACILITY_AUTH : options.log_facility,
!silent && !inetd_flag);
@@ -749,7 +744,7 @@ main(int ac, char **av)
/* Initialize the log (it is reinitialized below in case we forked). */
if (debug_flag && !inetd_flag)
log_stderr = 1;
- log_init(av0, options.log_level, options.log_facility, log_stderr);
+ log_init(__progname, options.log_level, options.log_facility, log_stderr);
/*
* If not in debugging mode, and not started from inetd, disconnect
@@ -773,7 +768,7 @@ main(int ac, char **av)
#endif /* TIOCNOTTY */
}
/* Reinitialize the log (because of the fork above). */
- log_init(av0, options.log_level, options.log_facility, log_stderr);
+ log_init(__progname, options.log_level, options.log_facility, log_stderr);
/* Initialize the random number generator. */
arc4random_stir();
@@ -1011,7 +1006,7 @@ main(int ac, char **av)
close_listen_socks();
sock_in = newsock;
sock_out = newsock;
- log_init(av0, options.log_level, options.log_facility, log_stderr);
+ log_init(__progname, options.log_level, options.log_facility, log_stderr);
break;
}
}
@@ -1077,7 +1072,7 @@ main(int ac, char **av)
{
struct request_info req;
- request_init(&req, RQ_DAEMON, av0, RQ_FILE, sock_in, NULL);
+ request_init(&req, RQ_DAEMON, __progname, RQ_FILE, sock_in, NULL);
fromhost(&req);
if (!hosts_access(&req)) {