suggested bsd-setproctitle.c
Ben Lindstrom
mouring at pconline.com
Wed Nov 8 12:52:26 EST 2000
On Tue, 7 Nov 2000, David Terrell wrote:
> On Mon, Nov 06, 2000 at 06:52:02AM +0100, Kevin Steves wrote:
> >
> > I'll do this patch unless someone points out what it will break :)
>
> It breaks the actual functionality of __progname, which is roughly
> equivelent to basename(argv[0]).
>
Hmm...It's technically broken as it is.
Most of the patch is right. Just the section for ssh-add, sshd, ssh, scp,
ssh-agent, etc are wrong.
Is this much more to everyone's liking?
It moves the assignment of the value of __progname to the main() and only
use if it HAVE__PROGNAME is fault..
Ermm.. I just noticed I missed scp.c =) Which I'm fixing now.
- Ben
-------------- next part --------------
diff -u openssh/ChangeLog ossh/ChangeLog
--- openssh/ChangeLog Tue Nov 7 19:58:00 2000
+++ ossh/ChangeLog Tue Nov 7 20:43:06 2000
@@ -5,6 +5,8 @@
Jarno Huuskonen <jhuuskon at messi.uku.fi>
- (bal) fixpaths fixed to stop it from quitely failing. Patch by
Mark D. Roth <roth at feep.net>
+ - (stevesk & bal) Clean up __progname definations w/ suggestion from
+ David Terrell <dbt at meat.net>
20001106
- (djm) Use Jim's new 1.0.3 askpass in Redhat RPMs
diff -u openssh/bsd-setproctitle.c ossh/bsd-setproctitle.c
--- openssh/bsd-setproctitle.c Mon Nov 6 02:07:18 2000
+++ ossh/bsd-setproctitle.c Tue Nov 7 20:22:25 2000
@@ -56,11 +56,7 @@
#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 -u openssh/log-server.c ossh/log-server.c
--- openssh/log-server.c Fri Sep 15 21:29:09 2000
+++ ossh/log-server.c Tue Nov 7 20:22:25 2000
@@ -43,12 +43,6 @@
#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 @@
char fmtbuf[MSGBUFSIZ];
char *txt = NULL;
int pri = LOG_INFO;
+ extern char *__progname;
if (level > log_level)
return;
diff -u openssh/session.c ossh/session.c
--- openssh/session.c Fri Oct 27 22:19:58 2000
+++ ossh/session.c Tue Nov 7 20:22:25 2000
@@ -128,12 +128,7 @@
/* 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;
diff -u openssh/sftp-server.c ossh/sftp-server.c
--- openssh/sftp-server.c Fri Sep 22 22:58:32 2000
+++ ossh/sftp-server.c Tue Nov 7 20:39:14 2000
@@ -90,6 +90,12 @@
#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;
@@ -1014,6 +1020,9 @@
fd_set rset, wset;
int in, out, max;
ssize_t len, olen;
+#ifndef HAVE___PROGNAME
+ __progname = xstrdup(basename(argv[0]);
+#endif
handle_init();
diff -u openssh/ssh-add.c ossh/ssh-add.c
--- openssh/ssh-add.c Tue Oct 17 07:22:28 2000
+++ ossh/ssh-add.c Tue Nov 7 20:37:38 2000
@@ -50,9 +50,9 @@
#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)
@@ -247,6 +247,9 @@
int no_files = 1;
int i;
int deleting = 0;
+#ifndef HAVE___PROGNAME
+ __progname = xstrdup(basename(argv[0]);
+#endif
init_rng();
diff -u openssh/ssh-agent.c ossh/ssh-agent.c
--- openssh/ssh-agent.c Fri Sep 29 07:01:37 2000
+++ ossh/ssh-agent.c Tue Nov 7 20:39:57 2000
@@ -94,9 +94,9 @@
#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)
@@ -667,6 +667,9 @@
pid_t pid;
char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid];
extern int optind;
+#ifndef HAVE___PROGNAME
+ __progname = xstrdup(basename(argv[0]);
+#endif
init_rng();
diff -u openssh/ssh-keygen.c ossh/ssh-keygen.c
--- openssh/ssh-keygen.c Sat Oct 14 00:23:12 2000
+++ ossh/ssh-keygen.c Tue Nov 7 20:40:19 2000
@@ -72,9 +72,9 @@
/* 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];
@@ -602,6 +602,9 @@
Key *public;
extern int optind;
extern char *optarg;
+#ifndef HAVE___PROGNAME
+ __progname = xstrdup(basename(argv[0]);
+#endif
init_rng();
diff -u openssh/ssh.c ossh/ssh.c
--- openssh/ssh.c Fri Oct 27 22:19:58 2000
+++ ossh/ssh.c Tue Nov 7 20:40:46 2000
@@ -61,9 +61,9 @@
#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. */
@@ -234,6 +234,9 @@
struct passwd *pw, pwcopy;
int dummy;
uid_t original_effective_uid;
+#ifndef HAVE___PROGNAME
+ __progname = xstrdup(basename(argv[0]);
+#endif
init_rng();
diff -u openssh/sshconnect.c ossh/sshconnect.c
--- openssh/sshconnect.c Sat Sep 23 01:15:57 2000
+++ ossh/sshconnect.c Tue Nov 7 20:22:25 2000
@@ -35,11 +35,7 @@
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 -u openssh/sshd.c ossh/sshd.c
--- openssh/sshd.c Sat Oct 14 00:23:13 2000
+++ ossh/sshd.c Tue Nov 7 20:41:11 2000
@@ -79,6 +79,12 @@
#define O_NOCTTY 0
#endif
+#ifdef HAVE___PROGNAME
+extern char *__progname;
+#else
+char *__progname;
+#endif
+
/* Server configuration options. */
ServerOptions options;
@@ -491,6 +497,9 @@
int listen_sock, maxfd;
int startup_p[2];
int startups = 0;
+#ifndef HAVE___PROGNAME
+ __progname = xstrdup(basename(argv[0]);
+#endif
init_rng();
More information about the openssh-unix-dev
mailing list