diff --git a/ChangeLog b/ChangeLog index a6f5f04ef..77bb2e5fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ 20001117 - (bal) Changed from 'primes' to 'primes.out' for consistancy sake. It has no affect the output. Patch by Corinna Vinschen + - (stevek) Reworked progname support. + - (bal) Misplaced #include "includes.h" in bsd-setproctitle.c. Patch by + Shinichi Maruyama 20001116 - (bal) Added in MAXSYMLINK test in bsd-realpath.c. Required for some SCO diff --git a/bsd-misc.c b/bsd-misc.c index 59814946c..2a0596593 100644 --- a/bsd-misc.c +++ b/bsd-misc.c @@ -26,6 +26,26 @@ #include "xmalloc.h" #include "ssh.h" +char *get_progname(char *argv0) +{ +#ifdef HAVE___PROGNAME + extern char *__progname; + + return __progname; +#else + char *p; + + if (argv0 == NULL) + return "unknown"; /* XXX */ + p = strrchr(argv0, '/'); + if (p == NULL) + p = argv0; + else + p++; + return p; +#endif +} + #ifndef HAVE_SETLOGIN int setlogin(const char *name) { diff --git a/bsd-misc.h b/bsd-misc.h index ae2b3ffff..d8376562a 100644 --- a/bsd-misc.h +++ b/bsd-misc.h @@ -27,11 +27,12 @@ #include "config.h" +char *get_progname(char *argv0); + #ifndef HAVE_SETSID #define setsid() setpgrp(0, getpid()) #endif /* !HAVE_SETSID */ - #ifndef HAVE_SETENV int setenv(const char *name, const char *value, int overwrite); #endif /* !HAVE_SETENV */ diff --git a/bsd-setproctitle.c b/bsd-setproctitle.c index 51a642e85..38eca9ad7 100644 --- a/bsd-setproctitle.c +++ b/bsd-setproctitle.c @@ -38,10 +38,10 @@ static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.7 1999/02/25 22:10:12 art Exp $"; #endif /* LIBC_SCCS and not lint */ -#ifndef HAVE_SETPROCTITLE - #include "includes.h" +#ifndef HAVE_SETPROCTITLE + #define SPT_NONE 0 #define SPT_PSTAT 1 @@ -56,11 +56,7 @@ static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.7 1999/02/25 22:10:12 art Ex #define MAX_PROCTITLE 2048 -#ifdef HAVE___PROGNAME extern char *__progname; -#else -static const char *__progname = "sshd"; -#endif /* HAVE___PROGNAME */ /* * Set Process Title (SPT) defines. Modeled after sendmail's diff --git a/log-server.c b/log-server.c index 270a3c698..de3d5cfeb 100644 --- a/log-server.c +++ b/log-server.c @@ -43,12 +43,6 @@ RCSID("$OpenBSD: log-server.c,v 1.17 2000/09/12 20:53:10 markus Exp $"); #include "xmalloc.h" #include "ssh.h" -#ifdef HAVE___PROGNAME -extern char *__progname; -#else /* HAVE___PROGNAME */ -static const char *__progname = "sshd"; -#endif /* HAVE___PROGNAME */ - static LogLevel log_level = SYSLOG_LEVEL_INFO; static int log_on_stderr = 0; static int log_facility = LOG_AUTH; @@ -129,6 +123,7 @@ do_log(LogLevel level, const char *fmt, va_list args) char fmtbuf[MSGBUFSIZ]; char *txt = NULL; int pri = LOG_INFO; + extern char *__progname; if (level > log_level) return; diff --git a/scp.c b/scp.c index 86276d6de..9af5c54dd 100644 --- a/scp.c +++ b/scp.c @@ -84,6 +84,12 @@ RCSID("$OpenBSD: scp.c,v 1.43 2000/10/18 18:23:02 markus Exp $"); #define _PATH_CP "cp" #endif +#ifdef HAVE___PROGNAME +extern char *__progname; +#else +char *__progname; +#endif + /* For progressmeter() -- number of seconds before xfer considered "stalled" */ #define STALLTIME 5 @@ -249,6 +255,8 @@ main(argc, argv) extern char *optarg; extern int optind; + __progname = get_progname(argv[0]); + args.list = NULL; addargs("ssh"); /* overwritten with ssh_program */ addargs("-x"); diff --git a/session.c b/session.c index b94c8e84d..890e16d59 100644 --- a/session.c +++ b/session.c @@ -57,7 +57,10 @@ RCSID("$OpenBSD: session.c,v 1.43 2000/11/06 23:04:56 markus Exp $"); #endif /* WITH_IRIX_PROJECT */ #ifdef WITH_IRIX_JOBS #include -#endif +#endif +#ifdef WITH_IRIX_AUDIT +#include +#endif /* WITH_IRIX_AUDIT */ #if defined(HAVE_USERSEC_H) #include @@ -131,12 +134,7 @@ do_child(const char *command, struct passwd * pw, const char *term, /* import */ extern ServerOptions options; -#ifdef HAVE___PROGNAME extern char *__progname; -#else /* HAVE___PROGNAME */ -static const char *__progname = "sshd"; -#endif /* HAVE___PROGNAME */ - extern int log_stderr; extern int debug_flag; extern unsigned int utmp_len; @@ -1104,7 +1102,6 @@ do_child(const char *command, struct passwd * pw, const char *term, strerror(errno)); } # endif /* WITH_IRIX_JOBS */ - # ifdef WITH_IRIX_ARRAY /* initialize array session */ if (jid == 0) { @@ -1123,6 +1120,14 @@ do_child(const char *command, struct passwd * pw, const char *term, fatal("Failed to initialize project %d for %s: %.100s", (int)projid, pw->pw_name, strerror(errno)); # endif /* WITH_IRIX_PROJECT */ +#ifdef WITH_IRIX_AUDIT + if (sysconf(_SC_AUDIT)) { + debug("Setting sat id to %d", (int) pw->pw_uid); + if (satsetid(pw->pw_uid)) + debug("error setting satid: %.100s", strerror(errno)); + } +#endif /* WITH_IRIX_AUDIT */ + /* Permanently switch to the desired uid. */ permanently_set_uid(pw->pw_uid); # endif /* HAVE_LOGIN_CAP */ diff --git a/sftp-server.c b/sftp-server.c index 538e5e267..fb6f0131b 100644 --- a/sftp-server.c +++ b/sftp-server.c @@ -90,6 +90,12 @@ RCSID("$OpenBSD: sftp-server.c,v 1.6 2000/09/07 20:27:53 deraadt Exp $"); #define get_string(lenp) buffer_get_string(&iqueue, lenp); #define TRACE log +#ifdef HAVE___PROGNAME +extern char *__progname; +#else +char *__progname; +#endif + /* input and output queue */ Buffer iqueue; Buffer oqueue; @@ -1015,6 +1021,7 @@ main(int ac, char **av) int in, out, max; ssize_t len, olen; + __progname = get_progname(av[0]); handle_init(); in = dup(STDIN_FILENO); diff --git a/ssh-add.c b/ssh-add.c index f49d13fb5..857f3d741 100644 --- a/ssh-add.c +++ b/ssh-add.c @@ -50,9 +50,9 @@ RCSID("$OpenBSD: ssh-add.c,v 1.23 2000/11/12 19:50:38 markus Exp $"); #ifdef HAVE___PROGNAME extern char *__progname; -#else /* HAVE___PROGNAME */ -static const char *__progname = "ssh-add"; -#endif /* HAVE___PROGNAME */ +#else +char *__progname; +#endif void delete_file(AuthenticationConnection *ac, const char *filename) @@ -249,6 +249,7 @@ main(int argc, char **argv) int i; int deleting = 0; + __progname = get_progname(argv[0]); init_rng(); SSLeay_add_all_algorithms(); diff --git a/ssh-agent.c b/ssh-agent.c index 9f61aec3b..f5f87cca3 100644 --- a/ssh-agent.c +++ b/ssh-agent.c @@ -93,9 +93,9 @@ char socket_dir[1024]; #ifdef HAVE___PROGNAME extern char *__progname; -#else /* HAVE___PROGNAME */ -static const char *__progname = "ssh-agent"; -#endif /* HAVE___PROGNAME */ +#else +char *__progname; +#endif void idtab_init(void) @@ -672,6 +672,7 @@ main(int ac, char **av) char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid]; extern int optind; + __progname = get_progname(av[0]); init_rng(); #ifdef __GNU_LIBRARY__ diff --git a/ssh-keygen.c b/ssh-keygen.c index 76edc5301..3653fc244 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c @@ -74,9 +74,9 @@ char *key_type_name = NULL; /* argv0 */ #ifdef HAVE___PROGNAME extern char *__progname; -#else /* HAVE___PROGNAME */ -static const char *__progname = "ssh-keygen"; -#endif /* HAVE___PROGNAME */ +#else +char *__progname; +#endif char hostname[MAXHOSTNAMELEN]; @@ -610,6 +610,7 @@ main(int ac, char **av) extern int optind; extern char *optarg; + __progname = get_progname(av[0]); init_rng(); SSLeay_add_all_algorithms(); diff --git a/ssh.c b/ssh.c index ab32e3b8d..a1cedc7e0 100644 --- a/ssh.c +++ b/ssh.c @@ -62,9 +62,9 @@ RCSID("$OpenBSD: ssh.c,v 1.72 2000/11/12 19:50:38 markus Exp $"); #ifdef HAVE___PROGNAME extern char *__progname; -#else /* HAVE___PROGNAME */ -static const char *__progname = "ssh"; -#endif /* HAVE___PROGNAME */ +#else +char *__progname; +#endif /* Flag indicating whether IPv4 or IPv6. This can be set on the command line. Default value is AF_UNSPEC means both IPv4 and IPv6. */ @@ -237,6 +237,7 @@ main(int ac, char **av) int dummy; uid_t original_effective_uid; + __progname = get_progname(av[0]); init_rng(); /* diff --git a/sshconnect.c b/sshconnect.c index 12ca69fd6..b33f20958 100644 --- a/sshconnect.c +++ b/sshconnect.c @@ -35,11 +35,7 @@ char *client_version_string = NULL; char *server_version_string = NULL; extern Options options; -#ifdef HAVE___PROGNAME extern char *__progname; -#else /* HAVE___PROGNAME */ -static const char *__progname = "ssh"; -#endif /* HAVE___PROGNAME */ /* * Connect to the given ssh server using a proxy command. diff --git a/sshd.c b/sshd.c index 56a39bd01..4a5f66278 100644 --- a/sshd.c +++ b/sshd.c @@ -78,6 +78,12 @@ int deny_severity = LOG_WARNING; #define O_NOCTTY 0 #endif +#ifdef HAVE___PROGNAME +extern char *__progname; +#else +char *__progname; +#endif + /* Server configuration options. */ ServerOptions options; @@ -562,6 +568,7 @@ main(int ac, char **av) int startup_p[2]; int startups = 0; + __progname = get_progname(av[0]); init_rng(); /* Save argv[0]. */ diff --git a/uidswap.c b/uidswap.c index 48026b9b4..76cbd6c40 100644 --- a/uidswap.c +++ b/uidswap.c @@ -16,9 +16,6 @@ RCSID("$OpenBSD: uidswap.c,v 1.9 2000/09/07 20:27:55 deraadt Exp $"); #include "ssh.h" #include "uidswap.h" -#ifdef WITH_IRIX_AUDIT -#include -#endif /* WITH_IRIX_AUDIT */ /* * Note: all these functions must work in all of the following cases: @@ -91,14 +88,6 @@ restore_uid() void permanently_set_uid(uid_t uid) { -#ifdef WITH_IRIX_AUDIT - if (sysconf(_SC_AUDIT)) { - debug("Setting sat id to %d", (int) uid); - if (satsetid(uid)) - debug("error setting satid: %.100s", strerror(errno)); - } -#endif /* WITH_IRIX_AUDIT */ - if (setuid(uid) < 0) debug("setuid %u: %.100s", (u_int) uid, strerror(errno)); }