diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | acconfig.h | 6 | ||||
-rw-r--r-- | configure.ac | 12 | ||||
-rw-r--r-- | openbsd-compat/setproctitle.c | 73 |
4 files changed, 50 insertions, 47 deletions
@@ -1,3 +1,7 @@ | |||
1 | 20030103 | ||
2 | - (djm) Rework openbsd-compat/setproctitle.c a bit: move emulation type | ||
3 | detection to configure.ac. Prompted by stevesk@ | ||
4 | |||
1 | 20030110 | 5 | 20030110 |
2 | - (djm) Enable new setproctitle emulation for Linux, AIX and HP/UX. More | 6 | - (djm) Enable new setproctitle emulation for Linux, AIX and HP/UX. More |
3 | systems may be added later. | 7 | systems may be added later. |
@@ -994,4 +998,4 @@ | |||
994 | save auth method before monitor_reset_key_state(); bugzilla bug #284; | 998 | save auth method before monitor_reset_key_state(); bugzilla bug #284; |
995 | ok provos@ | 999 | ok provos@ |
996 | 1000 | ||
997 | $Id: ChangeLog,v 1.2564 2003/01/10 10:46:02 djm Exp $ | 1001 | $Id: ChangeLog,v 1.2565 2003/01/12 23:04:58 djm Exp $ |
diff --git a/acconfig.h b/acconfig.h index 314cbaaa4..cf5f961f2 100644 --- a/acconfig.h +++ b/acconfig.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: acconfig.h,v 1.146 2003/01/07 04:18:33 djm Exp $ */ | 1 | /* $Id: acconfig.h,v 1.147 2003/01/12 23:04:59 djm Exp $ */ |
2 | 2 | ||
3 | #ifndef _CONFIG_H | 3 | #ifndef _CONFIG_H |
4 | #define _CONFIG_H | 4 | #define _CONFIG_H |
@@ -367,6 +367,10 @@ | |||
367 | /* Silly mkstemp() */ | 367 | /* Silly mkstemp() */ |
368 | #undef HAVE_STRICT_MKSTEMP | 368 | #undef HAVE_STRICT_MKSTEMP |
369 | 369 | ||
370 | /* Setproctitle emulation */ | ||
371 | #undef SETPROCTITLE_STRATEGY | ||
372 | #undef SETPROCTITLE_PS_PADDING | ||
373 | |||
370 | @BOTTOM@ | 374 | @BOTTOM@ |
371 | 375 | ||
372 | /* ******************* Shouldn't need to edit below this line ************** */ | 376 | /* ******************* Shouldn't need to edit below this line ************** */ |
diff --git a/configure.ac b/configure.ac index e64a0dd83..54aad3704 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: configure.ac,v 1.98 2003/01/09 22:53:12 djm Exp $ | 1 | # $Id: configure.ac,v 1.99 2003/01/12 23:04:59 djm Exp $ |
2 | 2 | ||
3 | AC_INIT | 3 | AC_INIT |
4 | AC_CONFIG_SRCDIR([ssh.c]) | 4 | AC_CONFIG_SRCDIR([ssh.c]) |
@@ -82,6 +82,8 @@ case "$host" in | |||
82 | dnl AIX handles lastlog as part of its login message | 82 | dnl AIX handles lastlog as part of its login message |
83 | AC_DEFINE(DISABLE_LASTLOG) | 83 | AC_DEFINE(DISABLE_LASTLOG) |
84 | AC_DEFINE(LOGIN_NEEDS_UTMPX) | 84 | AC_DEFINE(LOGIN_NEEDS_UTMPX) |
85 | AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV) | ||
86 | AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0') | ||
85 | ;; | 87 | ;; |
86 | *-*-cygwin*) | 88 | *-*-cygwin*) |
87 | LIBS="$LIBS /usr/lib/textmode.o" | 89 | LIBS="$LIBS /usr/lib/textmode.o" |
@@ -122,7 +124,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) | |||
122 | AC_DEFINE(LOGIN_NEEDS_UTMPX) | 124 | AC_DEFINE(LOGIN_NEEDS_UTMPX) |
123 | AC_DEFINE(DISABLE_SHADOW) | 125 | AC_DEFINE(DISABLE_SHADOW) |
124 | AC_DEFINE(DISABLE_UTMP) | 126 | AC_DEFINE(DISABLE_UTMP) |
125 | AC_DEFINE(SPT_TYPE,SPT_PSTAT) | 127 | AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT) |
126 | LIBS="$LIBS -lsec -lsecpw" | 128 | LIBS="$LIBS -lsec -lsecpw" |
127 | AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) | 129 | AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) |
128 | disable_ptmx_check=yes | 130 | disable_ptmx_check=yes |
@@ -138,7 +140,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) | |||
138 | AC_DEFINE(LOGIN_NEEDS_UTMPX) | 140 | AC_DEFINE(LOGIN_NEEDS_UTMPX) |
139 | AC_DEFINE(DISABLE_SHADOW) | 141 | AC_DEFINE(DISABLE_SHADOW) |
140 | AC_DEFINE(DISABLE_UTMP) | 142 | AC_DEFINE(DISABLE_UTMP) |
141 | AC_DEFINE(SPT_TYPE,SPT_PSTAT) | 143 | AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT) |
142 | LIBS="$LIBS -lsec" | 144 | LIBS="$LIBS -lsec" |
143 | AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) | 145 | AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) |
144 | ;; | 146 | ;; |
@@ -151,7 +153,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) | |||
151 | AC_DEFINE(LOGIN_NEEDS_UTMPX) | 153 | AC_DEFINE(LOGIN_NEEDS_UTMPX) |
152 | AC_DEFINE(DISABLE_SHADOW) | 154 | AC_DEFINE(DISABLE_SHADOW) |
153 | AC_DEFINE(DISABLE_UTMP) | 155 | AC_DEFINE(DISABLE_UTMP) |
154 | AC_DEFINE(SPT_TYPE,SPT_PSTAT) | 156 | AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT) |
155 | LIBS="$LIBS -lsec" | 157 | LIBS="$LIBS -lsec" |
156 | AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) | 158 | AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) |
157 | ;; | 159 | ;; |
@@ -178,6 +180,8 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) | |||
178 | check_for_libcrypt_later=1 | 180 | check_for_libcrypt_later=1 |
179 | AC_DEFINE(DONT_TRY_OTHER_AF) | 181 | AC_DEFINE(DONT_TRY_OTHER_AF) |
180 | AC_DEFINE(PAM_TTY_KLUDGE) | 182 | AC_DEFINE(PAM_TTY_KLUDGE) |
183 | AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV) | ||
184 | AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0') | ||
181 | inet6_default_4in6=yes | 185 | inet6_default_4in6=yes |
182 | ;; | 186 | ;; |
183 | mips-sony-bsd|mips-sony-newsos4) | 187 | mips-sony-bsd|mips-sony-newsos4) |
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c index 5439bd07e..14d5d2f3c 100644 --- a/openbsd-compat/setproctitle.c +++ b/openbsd-compat/setproctitle.c | |||
@@ -31,7 +31,7 @@ | |||
31 | * to contain some useful information. Mechanism differs wildly across | 31 | * to contain some useful information. Mechanism differs wildly across |
32 | * platforms. | 32 | * platforms. |
33 | * | 33 | * |
34 | * $Header: /var/cvs/openssh/openbsd-compat/setproctitle.c,v 1.3 2003/01/09 22:53:13 djm Exp $ | 34 | * $Header: /var/cvs/openssh/openbsd-compat/setproctitle.c,v 1.4 2003/01/12 23:04:59 djm Exp $ |
35 | * | 35 | * |
36 | * Copyright 2000 by PostgreSQL Global Development Group | 36 | * Copyright 2000 by PostgreSQL Global Development Group |
37 | * various details abducted from various places | 37 | * various details abducted from various places |
@@ -56,51 +56,47 @@ extern char **environ; | |||
56 | /*------ | 56 | /*------ |
57 | * Alternative ways of updating ps display: | 57 | * Alternative ways of updating ps display: |
58 | * | 58 | * |
59 | * PS_USE_PSTAT | 59 | * SETPROCTITLE_STRATEGY == PS_USE_PSTAT |
60 | * use the pstat(PSTAT_SETCMD, ) | 60 | * use the pstat(PSTAT_SETCMD, ) |
61 | * (HPUX) | 61 | * (HPUX) |
62 | * PS_USE_PS_STRINGS | 62 | * SETPROCTITLE_STRATEGY == PS_USE_PS_STRINGS |
63 | * assign PS_STRINGS->ps_argvstr = "string" | 63 | * assign PS_STRINGS->ps_argvstr = "string" |
64 | * (some BSD systems) | 64 | * (some BSD systems) |
65 | * PS_USE_CHANGE_ARGV | 65 | * SETPROCTITLE_STRATEGY == PS_USE_CHANGE_ARGV |
66 | * assign argv[0] = "string" | 66 | * assign argv[0] = "string" |
67 | * (some other BSD systems) | 67 | * (some other BSD systems) |
68 | * PS_USE_CLOBBER_ARGV | 68 | * SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV |
69 | * write over the argv and environment area | 69 | * write over the argv and environment area |
70 | * (most SysV-like systems) | 70 | * (most SysV-like systems) |
71 | * PS_USE_NONE | 71 | * SETPROCTITLE_STRATEGY == PS_USE_NONE |
72 | * don't update ps display | 72 | * don't update ps display |
73 | * (This is the default, as it is safest.) | 73 | * (This is the default, as it is safest.) |
74 | */ | 74 | */ |
75 | #if defined(HAVE_PSTAT) && defined(PSTAT_SETCMD) | 75 | |
76 | #define PS_USE_PSTAT | 76 | #define PS_USE_NONE 0 |
77 | #elif defined(HAVE_PS_STRINGS) | 77 | #define PS_USE_PSTAT 1 |
78 | #define PS_USE_PS_STRINGS | 78 | #define PS_USE_PS_STRINGS 2 |
79 | #elif defined(BSD) || defined(__bsdi__) || defined(__hurd__) | 79 | #define PS_USE_CHANGE_ARGV 3 |
80 | #define PS_USE_CHANGE_ARGV | 80 | #define PS_USE_CLOBBER_ARGV 4 |
81 | #elif defined(__linux__) || defined(_AIX) | 81 | |
82 | #define PS_USE_CLOBBER_ARGV | 82 | #ifndef SETPROCTITLE_STRATEGY |
83 | #else | 83 | # define SETPROCTITLE_STRATEGY PS_USE_NONE |
84 | #define PS_USE_NONE | ||
85 | #endif | 84 | #endif |
86 | 85 | ||
87 | /* Different systems want the buffer padded differently */ | 86 | #ifndef SETPROCTITLE_PS_PADDING |
88 | #if defined(_AIX) || defined(__linux__) || defined(__QNX__) || defined(__svr4__) | 87 | # define SETPROCTITLE_PS_PADDING ' ' |
89 | #define PS_PADDING '\0' | ||
90 | #else | ||
91 | #define PS_PADDING ' ' | ||
92 | #endif | 88 | #endif |
93 | 89 | ||
94 | /* | 90 | /* |
95 | * argv clobbering uses existing argv space, all other methods need a buffer | 91 | * argv clobbering uses existing argv space, all other methods need a buffer |
96 | */ | 92 | */ |
97 | #ifndef PS_USE_CLOBBER_ARGV | 93 | #if SETPROCTITLE_STRATEGY != PS_USE_CLOBBER_ARGV |
98 | static char ps_buffer[256]; | 94 | static char ps_buffer[256]; |
99 | static const size_t ps_buffer_size = sizeof(ps_buffer); | 95 | static const size_t ps_buffer_size = sizeof(ps_buffer); |
100 | #else /* PS_USE_CLOBBER_ARGV */ | 96 | #else |
101 | static char *ps_buffer; /* will point to argv area */ | 97 | static char *ps_buffer; /* will point to argv area */ |
102 | static size_t ps_buffer_size; /* space determined at run time */ | 98 | static size_t ps_buffer_size; /* space determined at run time */ |
103 | #endif /* PS_USE_CLOBBER_ARGV */ | 99 | #endif |
104 | 100 | ||
105 | /* save the original argv[] location here */ | 101 | /* save the original argv[] location here */ |
106 | static int save_argc; | 102 | static int save_argc; |
@@ -115,17 +111,17 @@ extern char *__progname; | |||
115 | void | 111 | void |
116 | setproctitle(const char *fmt, ...) | 112 | setproctitle(const char *fmt, ...) |
117 | { | 113 | { |
118 | #ifdef PS_USE_PSTAT | 114 | #if SETPROCTITLE_STRATEGY == PS_USE_PSTAT |
119 | union pstun pst; | 115 | union pstun pst; |
120 | #endif | 116 | #endif |
121 | #ifndef PS_USE_NONE | 117 | #if SETPROCTITLE_STRATEGY != PS_USE_NONE |
122 | ssize_t used; | 118 | ssize_t used; |
123 | va_list ap; | 119 | va_list ap; |
124 | 120 | ||
125 | /* no ps display if you didn't call save_ps_display_args() */ | 121 | /* no ps display if you didn't call save_ps_display_args() */ |
126 | if (save_argv == NULL) | 122 | if (save_argv == NULL) |
127 | return; | 123 | return; |
128 | #ifdef PS_USE_CLOBBER_ARGV | 124 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV |
129 | /* If ps_buffer is a pointer, it might still be null */ | 125 | /* If ps_buffer is a pointer, it might still be null */ |
130 | if (ps_buffer == NULL) | 126 | if (ps_buffer == NULL) |
131 | return; | 127 | return; |
@@ -134,12 +130,12 @@ setproctitle(const char *fmt, ...) | |||
134 | /* | 130 | /* |
135 | * Overwrite argv[] to point at appropriate space, if needed | 131 | * Overwrite argv[] to point at appropriate space, if needed |
136 | */ | 132 | */ |
137 | #ifdef PS_USE_CHANGE_ARGV | 133 | #if SETPROCTITLE_STRATEGY == PS_USE_CHANGE_ARGV |
138 | save_argv[0] = ps_buffer; | 134 | save_argv[0] = ps_buffer; |
139 | save_argv[1] = NULL; | 135 | save_argv[1] = NULL; |
140 | #endif /* PS_USE_CHANGE_ARGV */ | 136 | #endif /* PS_USE_CHANGE_ARGV */ |
141 | 137 | ||
142 | #ifdef PS_USE_CLOBBER_ARGV | 138 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV |
143 | save_argv[1] = NULL; | 139 | save_argv[1] = NULL; |
144 | #endif /* PS_USE_CLOBBER_ARGV */ | 140 | #endif /* PS_USE_CLOBBER_ARGV */ |
145 | 141 | ||
@@ -158,26 +154,21 @@ setproctitle(const char *fmt, ...) | |||
158 | } | 154 | } |
159 | va_end(ap); | 155 | va_end(ap); |
160 | 156 | ||
161 | #if 0 | 157 | #if SETPROCTITLE_STRATEGY == PS_USE_PSTAT |
162 | error("XXXXXXXXX %s", __progname); | ||
163 | error("XXXXXXXXX %d", ps_buffer_size); | ||
164 | error("XXXXXXXXX %s", ps_buffer); | ||
165 | #endif | ||
166 | |||
167 | #ifdef PS_USE_PSTAT | ||
168 | pst.pst_command = ps_buffer; | 158 | pst.pst_command = ps_buffer; |
169 | pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0); | 159 | pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0); |
170 | #endif /* PS_USE_PSTAT */ | 160 | #endif /* PS_USE_PSTAT */ |
171 | 161 | ||
172 | #ifdef PS_USE_PS_STRINGS | 162 | #if SETPROCTITLE_STRATEGY == PS_USE_PS_STRINGS |
173 | PS_STRINGS->ps_nargvstr = 1; | 163 | PS_STRINGS->ps_nargvstr = 1; |
174 | PS_STRINGS->ps_argvstr = ps_buffer; | 164 | PS_STRINGS->ps_argvstr = ps_buffer; |
175 | #endif /* PS_USE_PS_STRINGS */ | 165 | #endif /* PS_USE_PS_STRINGS */ |
176 | 166 | ||
177 | #ifdef PS_USE_CLOBBER_ARGV | 167 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV |
178 | /* pad unused memory */ | 168 | /* pad unused memory */ |
179 | used = strlen(ps_buffer); | 169 | used = strlen(ps_buffer); |
180 | memset(ps_buffer + used, PS_PADDING, ps_buffer_size - used); | 170 | memset(ps_buffer + used, SETPROCTITLE_PS_PADDING, |
171 | ps_buffer_size - used); | ||
181 | #endif /* PS_USE_CLOBBER_ARGV */ | 172 | #endif /* PS_USE_CLOBBER_ARGV */ |
182 | 173 | ||
183 | #endif /* PS_USE_NONE */ | 174 | #endif /* PS_USE_NONE */ |
@@ -196,7 +187,7 @@ setproctitle(const char *fmt, ...) | |||
196 | void | 187 | void |
197 | compat_init_setproctitle(int argc, char *argv[]) | 188 | compat_init_setproctitle(int argc, char *argv[]) |
198 | { | 189 | { |
199 | #ifdef PS_USE_CLOBBER_ARGV | 190 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV |
200 | char *end_of_area = NULL; | 191 | char *end_of_area = NULL; |
201 | char **new_environ; | 192 | char **new_environ; |
202 | int i; | 193 | int i; |
@@ -205,7 +196,7 @@ compat_init_setproctitle(int argc, char *argv[]) | |||
205 | save_argc = argc; | 196 | save_argc = argc; |
206 | save_argv = argv; | 197 | save_argv = argv; |
207 | 198 | ||
208 | #ifdef PS_USE_CLOBBER_ARGV | 199 | #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV |
209 | /* | 200 | /* |
210 | * If we're going to overwrite the argv area, count the available | 201 | * If we're going to overwrite the argv area, count the available |
211 | * space. Also move the environment to make additional room. | 202 | * space. Also move the environment to make additional room. |