- (djm) Rework openbsd-compat/setproctitle.c a bit: move emulation type

detection to configure.ac. Prompted by stevesk@
This commit is contained in:
Damien Miller 2003-01-13 10:04:58 +11:00
parent 4790772cda
commit ec201964e4
4 changed files with 50 additions and 47 deletions

View File

@ -1,3 +1,7 @@
20030103
- (djm) Rework openbsd-compat/setproctitle.c a bit: move emulation type
detection to configure.ac. Prompted by stevesk@
20030110 20030110
- (djm) Enable new setproctitle emulation for Linux, AIX and HP/UX. More - (djm) Enable new setproctitle emulation for Linux, AIX and HP/UX. More
systems may be added later. systems may be added later.
@ -994,4 +998,4 @@
save auth method before monitor_reset_key_state(); bugzilla bug #284; save auth method before monitor_reset_key_state(); bugzilla bug #284;
ok provos@ ok provos@
$Id: ChangeLog,v 1.2564 2003/01/10 10:46:02 djm Exp $ $Id: ChangeLog,v 1.2565 2003/01/12 23:04:58 djm Exp $

View File

@ -1,4 +1,4 @@
/* $Id: acconfig.h,v 1.146 2003/01/07 04:18:33 djm Exp $ */ /* $Id: acconfig.h,v 1.147 2003/01/12 23:04:59 djm Exp $ */
#ifndef _CONFIG_H #ifndef _CONFIG_H
#define _CONFIG_H #define _CONFIG_H
@ -367,6 +367,10 @@
/* Silly mkstemp() */ /* Silly mkstemp() */
#undef HAVE_STRICT_MKSTEMP #undef HAVE_STRICT_MKSTEMP
/* Setproctitle emulation */
#undef SETPROCTITLE_STRATEGY
#undef SETPROCTITLE_PS_PADDING
@BOTTOM@ @BOTTOM@
/* ******************* Shouldn't need to edit below this line ************** */ /* ******************* Shouldn't need to edit below this line ************** */

View File

@ -1,4 +1,4 @@
# $Id: configure.ac,v 1.98 2003/01/09 22:53:12 djm Exp $ # $Id: configure.ac,v 1.99 2003/01/12 23:04:59 djm Exp $
AC_INIT AC_INIT
AC_CONFIG_SRCDIR([ssh.c]) AC_CONFIG_SRCDIR([ssh.c])
@ -82,6 +82,8 @@ case "$host" in
dnl AIX handles lastlog as part of its login message dnl AIX handles lastlog as part of its login message
AC_DEFINE(DISABLE_LASTLOG) AC_DEFINE(DISABLE_LASTLOG)
AC_DEFINE(LOGIN_NEEDS_UTMPX) AC_DEFINE(LOGIN_NEEDS_UTMPX)
AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
;; ;;
*-*-cygwin*) *-*-cygwin*)
LIBS="$LIBS /usr/lib/textmode.o" LIBS="$LIBS /usr/lib/textmode.o"
@ -122,7 +124,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
AC_DEFINE(LOGIN_NEEDS_UTMPX) AC_DEFINE(LOGIN_NEEDS_UTMPX)
AC_DEFINE(DISABLE_SHADOW) AC_DEFINE(DISABLE_SHADOW)
AC_DEFINE(DISABLE_UTMP) AC_DEFINE(DISABLE_UTMP)
AC_DEFINE(SPT_TYPE,SPT_PSTAT) AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
LIBS="$LIBS -lsec -lsecpw" LIBS="$LIBS -lsec -lsecpw"
AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
disable_ptmx_check=yes disable_ptmx_check=yes
@ -138,7 +140,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
AC_DEFINE(LOGIN_NEEDS_UTMPX) AC_DEFINE(LOGIN_NEEDS_UTMPX)
AC_DEFINE(DISABLE_SHADOW) AC_DEFINE(DISABLE_SHADOW)
AC_DEFINE(DISABLE_UTMP) AC_DEFINE(DISABLE_UTMP)
AC_DEFINE(SPT_TYPE,SPT_PSTAT) AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
LIBS="$LIBS -lsec" LIBS="$LIBS -lsec"
AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
;; ;;
@ -151,7 +153,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
AC_DEFINE(LOGIN_NEEDS_UTMPX) AC_DEFINE(LOGIN_NEEDS_UTMPX)
AC_DEFINE(DISABLE_SHADOW) AC_DEFINE(DISABLE_SHADOW)
AC_DEFINE(DISABLE_UTMP) AC_DEFINE(DISABLE_UTMP)
AC_DEFINE(SPT_TYPE,SPT_PSTAT) AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
LIBS="$LIBS -lsec" LIBS="$LIBS -lsec"
AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])) AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
;; ;;
@ -178,6 +180,8 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
check_for_libcrypt_later=1 check_for_libcrypt_later=1
AC_DEFINE(DONT_TRY_OTHER_AF) AC_DEFINE(DONT_TRY_OTHER_AF)
AC_DEFINE(PAM_TTY_KLUDGE) AC_DEFINE(PAM_TTY_KLUDGE)
AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
inet6_default_4in6=yes inet6_default_4in6=yes
;; ;;
mips-sony-bsd|mips-sony-newsos4) mips-sony-bsd|mips-sony-newsos4)

View File

@ -31,7 +31,7 @@
* to contain some useful information. Mechanism differs wildly across * to contain some useful information. Mechanism differs wildly across
* platforms. * platforms.
* *
* $Header: /var/cvs/openssh/openbsd-compat/setproctitle.c,v 1.3 2003/01/09 22:53:13 djm Exp $ * $Header: /var/cvs/openssh/openbsd-compat/setproctitle.c,v 1.4 2003/01/12 23:04:59 djm Exp $
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* various details abducted from various places * various details abducted from various places
@ -56,51 +56,47 @@ extern char **environ;
/*------ /*------
* Alternative ways of updating ps display: * Alternative ways of updating ps display:
* *
* PS_USE_PSTAT * SETPROCTITLE_STRATEGY == PS_USE_PSTAT
* use the pstat(PSTAT_SETCMD, ) * use the pstat(PSTAT_SETCMD, )
* (HPUX) * (HPUX)
* PS_USE_PS_STRINGS * SETPROCTITLE_STRATEGY == PS_USE_PS_STRINGS
* assign PS_STRINGS->ps_argvstr = "string" * assign PS_STRINGS->ps_argvstr = "string"
* (some BSD systems) * (some BSD systems)
* PS_USE_CHANGE_ARGV * SETPROCTITLE_STRATEGY == PS_USE_CHANGE_ARGV
* assign argv[0] = "string" * assign argv[0] = "string"
* (some other BSD systems) * (some other BSD systems)
* PS_USE_CLOBBER_ARGV * SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
* write over the argv and environment area * write over the argv and environment area
* (most SysV-like systems) * (most SysV-like systems)
* PS_USE_NONE * SETPROCTITLE_STRATEGY == PS_USE_NONE
* don't update ps display * don't update ps display
* (This is the default, as it is safest.) * (This is the default, as it is safest.)
*/ */
#if defined(HAVE_PSTAT) && defined(PSTAT_SETCMD)
#define PS_USE_PSTAT #define PS_USE_NONE 0
#elif defined(HAVE_PS_STRINGS) #define PS_USE_PSTAT 1
#define PS_USE_PS_STRINGS #define PS_USE_PS_STRINGS 2
#elif defined(BSD) || defined(__bsdi__) || defined(__hurd__) #define PS_USE_CHANGE_ARGV 3
#define PS_USE_CHANGE_ARGV #define PS_USE_CLOBBER_ARGV 4
#elif defined(__linux__) || defined(_AIX)
#define PS_USE_CLOBBER_ARGV #ifndef SETPROCTITLE_STRATEGY
#else # define SETPROCTITLE_STRATEGY PS_USE_NONE
#define PS_USE_NONE
#endif #endif
/* Different systems want the buffer padded differently */ #ifndef SETPROCTITLE_PS_PADDING
#if defined(_AIX) || defined(__linux__) || defined(__QNX__) || defined(__svr4__) # define SETPROCTITLE_PS_PADDING ' '
#define PS_PADDING '\0'
#else
#define PS_PADDING ' '
#endif #endif
/* /*
* argv clobbering uses existing argv space, all other methods need a buffer * argv clobbering uses existing argv space, all other methods need a buffer
*/ */
#ifndef PS_USE_CLOBBER_ARGV #if SETPROCTITLE_STRATEGY != PS_USE_CLOBBER_ARGV
static char ps_buffer[256]; static char ps_buffer[256];
static const size_t ps_buffer_size = sizeof(ps_buffer); static const size_t ps_buffer_size = sizeof(ps_buffer);
#else /* PS_USE_CLOBBER_ARGV */ #else
static char *ps_buffer; /* will point to argv area */ static char *ps_buffer; /* will point to argv area */
static size_t ps_buffer_size; /* space determined at run time */ static size_t ps_buffer_size; /* space determined at run time */
#endif /* PS_USE_CLOBBER_ARGV */ #endif
/* save the original argv[] location here */ /* save the original argv[] location here */
static int save_argc; static int save_argc;
@ -115,17 +111,17 @@ extern char *__progname;
void void
setproctitle(const char *fmt, ...) setproctitle(const char *fmt, ...)
{ {
#ifdef PS_USE_PSTAT #if SETPROCTITLE_STRATEGY == PS_USE_PSTAT
union pstun pst; union pstun pst;
#endif #endif
#ifndef PS_USE_NONE #if SETPROCTITLE_STRATEGY != PS_USE_NONE
ssize_t used; ssize_t used;
va_list ap; va_list ap;
/* no ps display if you didn't call save_ps_display_args() */ /* no ps display if you didn't call save_ps_display_args() */
if (save_argv == NULL) if (save_argv == NULL)
return; return;
#ifdef PS_USE_CLOBBER_ARGV #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
/* If ps_buffer is a pointer, it might still be null */ /* If ps_buffer is a pointer, it might still be null */
if (ps_buffer == NULL) if (ps_buffer == NULL)
return; return;
@ -134,12 +130,12 @@ setproctitle(const char *fmt, ...)
/* /*
* Overwrite argv[] to point at appropriate space, if needed * Overwrite argv[] to point at appropriate space, if needed
*/ */
#ifdef PS_USE_CHANGE_ARGV #if SETPROCTITLE_STRATEGY == PS_USE_CHANGE_ARGV
save_argv[0] = ps_buffer; save_argv[0] = ps_buffer;
save_argv[1] = NULL; save_argv[1] = NULL;
#endif /* PS_USE_CHANGE_ARGV */ #endif /* PS_USE_CHANGE_ARGV */
#ifdef PS_USE_CLOBBER_ARGV #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
save_argv[1] = NULL; save_argv[1] = NULL;
#endif /* PS_USE_CLOBBER_ARGV */ #endif /* PS_USE_CLOBBER_ARGV */
@ -158,26 +154,21 @@ setproctitle(const char *fmt, ...)
} }
va_end(ap); va_end(ap);
#if 0 #if SETPROCTITLE_STRATEGY == PS_USE_PSTAT
error("XXXXXXXXX %s", __progname);
error("XXXXXXXXX %d", ps_buffer_size);
error("XXXXXXXXX %s", ps_buffer);
#endif
#ifdef PS_USE_PSTAT
pst.pst_command = ps_buffer; pst.pst_command = ps_buffer;
pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0); pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0);
#endif /* PS_USE_PSTAT */ #endif /* PS_USE_PSTAT */
#ifdef PS_USE_PS_STRINGS #if SETPROCTITLE_STRATEGY == PS_USE_PS_STRINGS
PS_STRINGS->ps_nargvstr = 1; PS_STRINGS->ps_nargvstr = 1;
PS_STRINGS->ps_argvstr = ps_buffer; PS_STRINGS->ps_argvstr = ps_buffer;
#endif /* PS_USE_PS_STRINGS */ #endif /* PS_USE_PS_STRINGS */
#ifdef PS_USE_CLOBBER_ARGV #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
/* pad unused memory */ /* pad unused memory */
used = strlen(ps_buffer); used = strlen(ps_buffer);
memset(ps_buffer + used, PS_PADDING, ps_buffer_size - used); memset(ps_buffer + used, SETPROCTITLE_PS_PADDING,
ps_buffer_size - used);
#endif /* PS_USE_CLOBBER_ARGV */ #endif /* PS_USE_CLOBBER_ARGV */
#endif /* PS_USE_NONE */ #endif /* PS_USE_NONE */
@ -196,7 +187,7 @@ setproctitle(const char *fmt, ...)
void void
compat_init_setproctitle(int argc, char *argv[]) compat_init_setproctitle(int argc, char *argv[])
{ {
#ifdef PS_USE_CLOBBER_ARGV #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
char *end_of_area = NULL; char *end_of_area = NULL;
char **new_environ; char **new_environ;
int i; int i;
@ -205,7 +196,7 @@ compat_init_setproctitle(int argc, char *argv[])
save_argc = argc; save_argc = argc;
save_argv = argv; save_argv = argv;
#ifdef PS_USE_CLOBBER_ARGV #if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
/* /*
* If we're going to overwrite the argv area, count the available * If we're going to overwrite the argv area, count the available
* space. Also move the environment to make additional room. * space. Also move the environment to make additional room.