Final Suggestion (Re: suggested bsd-setproctitle.c)
Kevin Steves
stevesk at sweden.hp.com
Sun Nov 12 03:28:33 EST 2000
On Thu, 9 Nov 2000, Ben Lindstrom wrote:
: On Thu, 9 Nov 2000, Kevin Steves wrote:
: > Where should the set_progname() function go? Should I create a
: > util-portable.c or is there a better place?
: >
: I see no problems putting it in bsd-misc.c myself. We have around 95
: files.. And I don't think that set_progname() needs it's own file.=)
How does the attached patch look?
: I'd love to take all the bsd-*.c files and push them into a compat/
: directory and tweak the configure/make files just to clean things
: up. =) But that distrupts the CVS a great deal.
I was thinking about that too.
-------------- next part --------------
Index: bsd-misc.h
===================================================================
RCS file: /var/cvs/openssh/bsd-misc.h,v
retrieving revision 1.9
diff -u -r1.9 bsd-misc.h
--- bsd-misc.h 2000/11/05 09:08:45 1.9
+++ bsd-misc.h 2000/11/11 15:56:36
@@ -27,10 +27,11 @@
#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);
Index: bsd-misc.c
===================================================================
RCS file: /var/cvs/openssh/bsd-misc.c,v
retrieving revision 1.16
diff -u -r1.16 bsd-misc.c
--- bsd-misc.c 2000/10/18 13:11:44 1.16
+++ bsd-misc.c 2000/11/11 15:56:36
@@ -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)
{
Index: bsd-setproctitle.c
===================================================================
RCS file: /var/cvs/openssh/bsd-setproctitle.c,v
retrieving revision 1.1
diff -u -r1.1 bsd-setproctitle.c
--- bsd-setproctitle.c 2000/10/18 13:11:44 1.1
+++ bsd-setproctitle.c 2000/11/11 15:56:36
@@ -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
Index: log-server.c
===================================================================
RCS file: /var/cvs/openssh/log-server.c,v
retrieving revision 1.12
diff -u -r1.12 log-server.c
--- log-server.c 2000/09/16 02:29:09 1.12
+++ log-server.c 2000/11/11 15:56:36
@@ -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;
Index: sshconnect.c
===================================================================
RCS file: /var/cvs/openssh/sshconnect.c,v
retrieving revision 1.44
diff -u -r1.44 sshconnect.c
--- sshconnect.c 2000/09/23 06:15:57 1.44
+++ sshconnect.c 2000/11/11 15:56:38
@@ -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.
Index: session.c
===================================================================
RCS file: /var/cvs/openssh/session.c,v
retrieving revision 1.52
diff -u -r1.52 session.c
--- session.c 2000/10/28 03:19:58 1.52
+++ session.c 2000/11/11 15:56:42
@@ -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;
Index: ssh-add.c
===================================================================
RCS file: /var/cvs/openssh/ssh-add.c,v
retrieving revision 1.26
diff -u -r1.26 ssh-add.c
--- ssh-add.c 2000/10/17 12:22:28 1.26
+++ ssh-add.c 2000/11/11 15:56:42
@@ -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)
@@ -248,6 +248,7 @@
int i;
int deleting = 0;
+ __progname = get_progname(argv[0]);
init_rng();
/* check if RSA support exists */
Index: ssh-agent.c
===================================================================
RCS file: /var/cvs/openssh/ssh-agent.c,v
retrieving revision 1.33
diff -u -r1.33 ssh-agent.c
--- ssh-agent.c 2000/09/29 12:01:37 1.33
+++ ssh-agent.c 2000/11/11 15:56:44
@@ -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)
@@ -668,6 +668,7 @@
char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid];
extern int optind;
+ __progname = get_progname(av[0]);
init_rng();
/* check if RSA support exists */
Index: ssh-keygen.c
===================================================================
RCS file: /var/cvs/openssh/ssh-keygen.c,v
retrieving revision 1.26
diff -u -r1.26 ssh-keygen.c
--- ssh-keygen.c 2000/10/14 05:23:12 1.26
+++ ssh-keygen.c 2000/11/11 15:56:44
@@ -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];
@@ -603,6 +603,7 @@
extern int optind;
extern char *optarg;
+ __progname = get_progname(av[0]);
init_rng();
SSLeay_add_all_algorithms();
Index: ssh.c
===================================================================
RCS file: /var/cvs/openssh/ssh.c,v
retrieving revision 1.47
diff -u -r1.47 ssh.c
--- ssh.c 2000/10/28 03:19:58 1.47
+++ ssh.c 2000/11/11 15:56:48
@@ -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. */
@@ -235,6 +235,7 @@
int dummy;
uid_t original_effective_uid;
+ __progname = get_progname(av[0]);
init_rng();
/*
Index: sftp-server.c
===================================================================
RCS file: /var/cvs/openssh/sftp-server.c,v
retrieving revision 1.3
diff -u -r1.3 sftp-server.c
--- sftp-server.c 2000/09/23 03:58:32 1.3
+++ sftp-server.c 2000/11/11 15:56:48
@@ -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;
@@ -1015,6 +1021,7 @@
int in, out, max;
ssize_t len, olen;
+ __progname = get_progname(av[0]);
handle_init();
in = dup(STDIN_FILENO);
Index: sshd.c
===================================================================
RCS file: /var/cvs/openssh/sshd.c,v
retrieving revision 1.94
diff -u -r1.94 sshd.c
--- sshd.c 2000/10/14 05:23:13 1.94
+++ sshd.c 2000/11/11 15:56:52
@@ -79,6 +79,12 @@
#define O_NOCTTY 0
#endif
+#ifdef HAVE___PROGNAME
+extern char *__progname;
+#else
+char *__progname;
+#endif
+
/* Server configuration options. */
ServerOptions options;
@@ -492,6 +498,7 @@
int startup_p[2];
int startups = 0;
+ __progname = get_progname(av[0]);
init_rng();
/* Save argv[0]. */
Index: scp.c
===================================================================
RCS file: /var/cvs/openssh/scp.c,v
retrieving revision 1.39
diff -u -r1.39 scp.c
--- scp.c 2000/10/28 03:19:58 1.39
+++ scp.c 2000/11/11 15:56:54
@@ -84,6 +84,12 @@
#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
@@ -248,6 +254,8 @@
char *targ;
extern char *optarg;
extern int optind;
+
+ __progname = get_progname(argv[0]);
args.list = NULL;
addargs("ssh"); /* overwritten with ssh_program */
More information about the openssh-unix-dev
mailing list