summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2000-11-17 03:47:20 +0000
committerBen Lindstrom <mouring@eviladmin.org>2000-11-17 03:47:20 +0000
commit49a79c09762613f29601ef2470d13952168021be (patch)
tree140539420c10c5b358481cadcec495a5a41103fd
parentbaaa2c05dd789bdce64fa7eb5697a5f969d68288 (diff)
- (stevek) Reworked progname support.
- (bal) Misplaced #include "includes.h" in bsd-setproctitle.c. Patch by Shinichi Maruyama <marya@st.jip.co.jp> I assume the progname patch was finished. I believe stevek is on vacation, but it passes compiling under Linux and NeXTStep.
-rw-r--r--ChangeLog3
-rw-r--r--bsd-misc.c20
-rw-r--r--bsd-misc.h3
-rw-r--r--bsd-setproctitle.c8
-rw-r--r--log-server.c7
-rw-r--r--scp.c8
-rw-r--r--session.c19
-rw-r--r--sftp-server.c7
-rw-r--r--ssh-add.c7
-rw-r--r--ssh-agent.c7
-rw-r--r--ssh-keygen.c7
-rw-r--r--ssh.c7
-rw-r--r--sshconnect.c4
-rw-r--r--sshd.c7
-rw-r--r--uidswap.c11
15 files changed, 78 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index a6f5f04ef..77bb2e5fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
120001117 120001117
2 - (bal) Changed from 'primes' to 'primes.out' for consistancy sake. It 2 - (bal) Changed from 'primes' to 'primes.out' for consistancy sake. It
3 has no affect the output. Patch by Corinna Vinschen <vinschen@redhat.com> 3 has no affect the output. Patch by Corinna Vinschen <vinschen@redhat.com>
4 - (stevek) Reworked progname support.
5 - (bal) Misplaced #include "includes.h" in bsd-setproctitle.c. Patch by
6 Shinichi Maruyama <marya@st.jip.co.jp>
4 7
520001116 820001116
6 - (bal) Added in MAXSYMLINK test in bsd-realpath.c. Required for some SCO 9 - (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 @@
26#include "xmalloc.h" 26#include "xmalloc.h"
27#include "ssh.h" 27#include "ssh.h"
28 28
29char *get_progname(char *argv0)
30{
31#ifdef HAVE___PROGNAME
32 extern char *__progname;
33
34 return __progname;
35#else
36 char *p;
37
38 if (argv0 == NULL)
39 return "unknown"; /* XXX */
40 p = strrchr(argv0, '/');
41 if (p == NULL)
42 p = argv0;
43 else
44 p++;
45 return p;
46#endif
47}
48
29#ifndef HAVE_SETLOGIN 49#ifndef HAVE_SETLOGIN
30int setlogin(const char *name) 50int setlogin(const char *name)
31{ 51{
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 @@
27 27
28#include "config.h" 28#include "config.h"
29 29
30char *get_progname(char *argv0);
31
30#ifndef HAVE_SETSID 32#ifndef HAVE_SETSID
31#define setsid() setpgrp(0, getpid()) 33#define setsid() setpgrp(0, getpid())
32#endif /* !HAVE_SETSID */ 34#endif /* !HAVE_SETSID */
33 35
34
35#ifndef HAVE_SETENV 36#ifndef HAVE_SETENV
36int setenv(const char *name, const char *value, int overwrite); 37int setenv(const char *name, const char *value, int overwrite);
37#endif /* !HAVE_SETENV */ 38#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 @@
38static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.7 1999/02/25 22:10:12 art Exp $"; 38static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.7 1999/02/25 22:10:12 art Exp $";
39#endif /* LIBC_SCCS and not lint */ 39#endif /* LIBC_SCCS and not lint */
40 40
41#ifndef HAVE_SETPROCTITLE
42
43#include "includes.h" 41#include "includes.h"
44 42
43#ifndef HAVE_SETPROCTITLE
44
45#define SPT_NONE 0 45#define SPT_NONE 0
46#define SPT_PSTAT 1 46#define SPT_PSTAT 1
47 47
@@ -56,11 +56,7 @@ static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.7 1999/02/25 22:10:12 art Ex
56 56
57#define MAX_PROCTITLE 2048 57#define MAX_PROCTITLE 2048
58 58
59#ifdef HAVE___PROGNAME
60extern char *__progname; 59extern char *__progname;
61#else
62static const char *__progname = "sshd";
63#endif /* HAVE___PROGNAME */
64 60
65/* 61/*
66 * Set Process Title (SPT) defines. Modeled after sendmail's 62 * 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 $");
43#include "xmalloc.h" 43#include "xmalloc.h"
44#include "ssh.h" 44#include "ssh.h"
45 45
46#ifdef HAVE___PROGNAME
47extern char *__progname;
48#else /* HAVE___PROGNAME */
49static const char *__progname = "sshd";
50#endif /* HAVE___PROGNAME */
51
52static LogLevel log_level = SYSLOG_LEVEL_INFO; 46static LogLevel log_level = SYSLOG_LEVEL_INFO;
53static int log_on_stderr = 0; 47static int log_on_stderr = 0;
54static int log_facility = LOG_AUTH; 48static int log_facility = LOG_AUTH;
@@ -129,6 +123,7 @@ do_log(LogLevel level, const char *fmt, va_list args)
129 char fmtbuf[MSGBUFSIZ]; 123 char fmtbuf[MSGBUFSIZ];
130 char *txt = NULL; 124 char *txt = NULL;
131 int pri = LOG_INFO; 125 int pri = LOG_INFO;
126 extern char *__progname;
132 127
133 if (level > log_level) 128 if (level > log_level)
134 return; 129 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 $");
84#define _PATH_CP "cp" 84#define _PATH_CP "cp"
85#endif 85#endif
86 86
87#ifdef HAVE___PROGNAME
88extern char *__progname;
89#else
90char *__progname;
91#endif
92
87/* For progressmeter() -- number of seconds before xfer considered "stalled" */ 93/* For progressmeter() -- number of seconds before xfer considered "stalled" */
88#define STALLTIME 5 94#define STALLTIME 5
89 95
@@ -249,6 +255,8 @@ main(argc, argv)
249 extern char *optarg; 255 extern char *optarg;
250 extern int optind; 256 extern int optind;
251 257
258 __progname = get_progname(argv[0]);
259
252 args.list = NULL; 260 args.list = NULL;
253 addargs("ssh"); /* overwritten with ssh_program */ 261 addargs("ssh"); /* overwritten with ssh_program */
254 addargs("-x"); 262 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 $");
57#endif /* WITH_IRIX_PROJECT */ 57#endif /* WITH_IRIX_PROJECT */
58#ifdef WITH_IRIX_JOBS 58#ifdef WITH_IRIX_JOBS
59#include <sys/resource.h> 59#include <sys/resource.h>
60#endif 60#endif
61#ifdef WITH_IRIX_AUDIT
62#include <sat.h>
63#endif /* WITH_IRIX_AUDIT */
61 64
62#if defined(HAVE_USERSEC_H) 65#if defined(HAVE_USERSEC_H)
63#include <usersec.h> 66#include <usersec.h>
@@ -131,12 +134,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
131 134
132/* import */ 135/* import */
133extern ServerOptions options; 136extern ServerOptions options;
134#ifdef HAVE___PROGNAME
135extern char *__progname; 137extern char *__progname;
136#else /* HAVE___PROGNAME */
137static const char *__progname = "sshd";
138#endif /* HAVE___PROGNAME */
139
140extern int log_stderr; 138extern int log_stderr;
141extern int debug_flag; 139extern int debug_flag;
142extern unsigned int utmp_len; 140extern unsigned int utmp_len;
@@ -1104,7 +1102,6 @@ do_child(const char *command, struct passwd * pw, const char *term,
1104 strerror(errno)); 1102 strerror(errno));
1105 } 1103 }
1106# endif /* WITH_IRIX_JOBS */ 1104# endif /* WITH_IRIX_JOBS */
1107
1108# ifdef WITH_IRIX_ARRAY 1105# ifdef WITH_IRIX_ARRAY
1109 /* initialize array session */ 1106 /* initialize array session */
1110 if (jid == 0) { 1107 if (jid == 0) {
@@ -1123,6 +1120,14 @@ do_child(const char *command, struct passwd * pw, const char *term,
1123 fatal("Failed to initialize project %d for %s: %.100s", 1120 fatal("Failed to initialize project %d for %s: %.100s",
1124 (int)projid, pw->pw_name, strerror(errno)); 1121 (int)projid, pw->pw_name, strerror(errno));
1125# endif /* WITH_IRIX_PROJECT */ 1122# endif /* WITH_IRIX_PROJECT */
1123#ifdef WITH_IRIX_AUDIT
1124 if (sysconf(_SC_AUDIT)) {
1125 debug("Setting sat id to %d", (int) pw->pw_uid);
1126 if (satsetid(pw->pw_uid))
1127 debug("error setting satid: %.100s", strerror(errno));
1128 }
1129#endif /* WITH_IRIX_AUDIT */
1130
1126 /* Permanently switch to the desired uid. */ 1131 /* Permanently switch to the desired uid. */
1127 permanently_set_uid(pw->pw_uid); 1132 permanently_set_uid(pw->pw_uid);
1128# endif /* HAVE_LOGIN_CAP */ 1133# 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 $");
90#define get_string(lenp) buffer_get_string(&iqueue, lenp); 90#define get_string(lenp) buffer_get_string(&iqueue, lenp);
91#define TRACE log 91#define TRACE log
92 92
93#ifdef HAVE___PROGNAME
94extern char *__progname;
95#else
96char *__progname;
97#endif
98
93/* input and output queue */ 99/* input and output queue */
94Buffer iqueue; 100Buffer iqueue;
95Buffer oqueue; 101Buffer oqueue;
@@ -1015,6 +1021,7 @@ main(int ac, char **av)
1015 int in, out, max; 1021 int in, out, max;
1016 ssize_t len, olen; 1022 ssize_t len, olen;
1017 1023
1024 __progname = get_progname(av[0]);
1018 handle_init(); 1025 handle_init();
1019 1026
1020 in = dup(STDIN_FILENO); 1027 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 $");
50 50
51#ifdef HAVE___PROGNAME 51#ifdef HAVE___PROGNAME
52extern char *__progname; 52extern char *__progname;
53#else /* HAVE___PROGNAME */ 53#else
54static const char *__progname = "ssh-add"; 54char *__progname;
55#endif /* HAVE___PROGNAME */ 55#endif
56 56
57void 57void
58delete_file(AuthenticationConnection *ac, const char *filename) 58delete_file(AuthenticationConnection *ac, const char *filename)
@@ -249,6 +249,7 @@ main(int argc, char **argv)
249 int i; 249 int i;
250 int deleting = 0; 250 int deleting = 0;
251 251
252 __progname = get_progname(argv[0]);
252 init_rng(); 253 init_rng();
253 254
254 SSLeay_add_all_algorithms(); 255 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];
93 93
94#ifdef HAVE___PROGNAME 94#ifdef HAVE___PROGNAME
95extern char *__progname; 95extern char *__progname;
96#else /* HAVE___PROGNAME */ 96#else
97static const char *__progname = "ssh-agent"; 97char *__progname;
98#endif /* HAVE___PROGNAME */ 98#endif
99 99
100void 100void
101idtab_init(void) 101idtab_init(void)
@@ -672,6 +672,7 @@ main(int ac, char **av)
672 char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid]; 672 char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid];
673 extern int optind; 673 extern int optind;
674 674
675 __progname = get_progname(av[0]);
675 init_rng(); 676 init_rng();
676 677
677#ifdef __GNU_LIBRARY__ 678#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;
74/* argv0 */ 74/* argv0 */
75#ifdef HAVE___PROGNAME 75#ifdef HAVE___PROGNAME
76extern char *__progname; 76extern char *__progname;
77#else /* HAVE___PROGNAME */ 77#else
78static const char *__progname = "ssh-keygen"; 78char *__progname;
79#endif /* HAVE___PROGNAME */ 79#endif
80 80
81char hostname[MAXHOSTNAMELEN]; 81char hostname[MAXHOSTNAMELEN];
82 82
@@ -610,6 +610,7 @@ main(int ac, char **av)
610 extern int optind; 610 extern int optind;
611 extern char *optarg; 611 extern char *optarg;
612 612
613 __progname = get_progname(av[0]);
613 init_rng(); 614 init_rng();
614 615
615 SSLeay_add_all_algorithms(); 616 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 $");
62 62
63#ifdef HAVE___PROGNAME 63#ifdef HAVE___PROGNAME
64extern char *__progname; 64extern char *__progname;
65#else /* HAVE___PROGNAME */ 65#else
66static const char *__progname = "ssh"; 66char *__progname;
67#endif /* HAVE___PROGNAME */ 67#endif
68 68
69/* Flag indicating whether IPv4 or IPv6. This can be set on the command line. 69/* Flag indicating whether IPv4 or IPv6. This can be set on the command line.
70 Default value is AF_UNSPEC means both IPv4 and IPv6. */ 70 Default value is AF_UNSPEC means both IPv4 and IPv6. */
@@ -237,6 +237,7 @@ main(int ac, char **av)
237 int dummy; 237 int dummy;
238 uid_t original_effective_uid; 238 uid_t original_effective_uid;
239 239
240 __progname = get_progname(av[0]);
240 init_rng(); 241 init_rng();
241 242
242 /* 243 /*
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;
35char *server_version_string = NULL; 35char *server_version_string = NULL;
36 36
37extern Options options; 37extern Options options;
38#ifdef HAVE___PROGNAME
39extern char *__progname; 38extern char *__progname;
40#else /* HAVE___PROGNAME */
41static const char *__progname = "ssh";
42#endif /* HAVE___PROGNAME */
43 39
44/* 40/*
45 * Connect to the given ssh server using a proxy command. 41 * 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;
78#define O_NOCTTY 0 78#define O_NOCTTY 0
79#endif 79#endif
80 80
81#ifdef HAVE___PROGNAME
82extern char *__progname;
83#else
84char *__progname;
85#endif
86
81/* Server configuration options. */ 87/* Server configuration options. */
82ServerOptions options; 88ServerOptions options;
83 89
@@ -562,6 +568,7 @@ main(int ac, char **av)
562 int startup_p[2]; 568 int startup_p[2];
563 int startups = 0; 569 int startups = 0;
564 570
571 __progname = get_progname(av[0]);
565 init_rng(); 572 init_rng();
566 573
567 /* Save argv[0]. */ 574 /* 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 $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "uidswap.h" 18#include "uidswap.h"
19#ifdef WITH_IRIX_AUDIT
20#include <sat.h>
21#endif /* WITH_IRIX_AUDIT */
22 19
23/* 20/*
24 * Note: all these functions must work in all of the following cases: 21 * Note: all these functions must work in all of the following cases:
@@ -91,14 +88,6 @@ restore_uid()
91void 88void
92permanently_set_uid(uid_t uid) 89permanently_set_uid(uid_t uid)
93{ 90{
94#ifdef WITH_IRIX_AUDIT
95 if (sysconf(_SC_AUDIT)) {
96 debug("Setting sat id to %d", (int) uid);
97 if (satsetid(uid))
98 debug("error setting satid: %.100s", strerror(errno));
99 }
100#endif /* WITH_IRIX_AUDIT */
101
102 if (setuid(uid) < 0) 91 if (setuid(uid) < 0)
103 debug("setuid %u: %.100s", (u_int) uid, strerror(errno)); 92 debug("setuid %u: %.100s", (u_int) uid, strerror(errno));
104} 93}