mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-11-24 19:53:24 +08:00
- (djm) Rework openbsd-compat/setproctitle.c a bit: move emulation type
detection to configure.ac. Prompted by stevesk@
This commit is contained in:
parent
4790772cda
commit
ec201964e4
@ -1,3 +1,7 @@
|
||||
20030103
|
||||
- (djm) Rework openbsd-compat/setproctitle.c a bit: move emulation type
|
||||
detection to configure.ac. Prompted by stevesk@
|
||||
|
||||
20030110
|
||||
- (djm) Enable new setproctitle emulation for Linux, AIX and HP/UX. More
|
||||
systems may be added later.
|
||||
@ -994,4 +998,4 @@
|
||||
save auth method before monitor_reset_key_state(); bugzilla bug #284;
|
||||
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 $
|
||||
|
@ -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
|
||||
#define _CONFIG_H
|
||||
@ -367,6 +367,10 @@
|
||||
/* Silly mkstemp() */
|
||||
#undef HAVE_STRICT_MKSTEMP
|
||||
|
||||
/* Setproctitle emulation */
|
||||
#undef SETPROCTITLE_STRATEGY
|
||||
#undef SETPROCTITLE_PS_PADDING
|
||||
|
||||
@BOTTOM@
|
||||
|
||||
/* ******************* Shouldn't need to edit below this line ************** */
|
||||
|
12
configure.ac
12
configure.ac
@ -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_CONFIG_SRCDIR([ssh.c])
|
||||
@ -82,6 +82,8 @@ case "$host" in
|
||||
dnl AIX handles lastlog as part of its login message
|
||||
AC_DEFINE(DISABLE_LASTLOG)
|
||||
AC_DEFINE(LOGIN_NEEDS_UTMPX)
|
||||
AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
|
||||
AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
|
||||
;;
|
||||
*-*-cygwin*)
|
||||
LIBS="$LIBS /usr/lib/textmode.o"
|
||||
@ -122,7 +124,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
|
||||
AC_DEFINE(LOGIN_NEEDS_UTMPX)
|
||||
AC_DEFINE(DISABLE_SHADOW)
|
||||
AC_DEFINE(DISABLE_UTMP)
|
||||
AC_DEFINE(SPT_TYPE,SPT_PSTAT)
|
||||
AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
|
||||
LIBS="$LIBS -lsec -lsecpw"
|
||||
AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
|
||||
disable_ptmx_check=yes
|
||||
@ -138,7 +140,7 @@ main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
|
||||
AC_DEFINE(LOGIN_NEEDS_UTMPX)
|
||||
AC_DEFINE(DISABLE_SHADOW)
|
||||
AC_DEFINE(DISABLE_UTMP)
|
||||
AC_DEFINE(SPT_TYPE,SPT_PSTAT)
|
||||
AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
|
||||
LIBS="$LIBS -lsec"
|
||||
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(DISABLE_SHADOW)
|
||||
AC_DEFINE(DISABLE_UTMP)
|
||||
AC_DEFINE(SPT_TYPE,SPT_PSTAT)
|
||||
AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
|
||||
LIBS="$LIBS -lsec"
|
||||
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
|
||||
AC_DEFINE(DONT_TRY_OTHER_AF)
|
||||
AC_DEFINE(PAM_TTY_KLUDGE)
|
||||
AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
|
||||
AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
|
||||
inet6_default_4in6=yes
|
||||
;;
|
||||
mips-sony-bsd|mips-sony-newsos4)
|
||||
|
@ -31,7 +31,7 @@
|
||||
* to contain some useful information. Mechanism differs wildly across
|
||||
* 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
|
||||
* various details abducted from various places
|
||||
@ -56,51 +56,47 @@ extern char **environ;
|
||||
/*------
|
||||
* Alternative ways of updating ps display:
|
||||
*
|
||||
* PS_USE_PSTAT
|
||||
* SETPROCTITLE_STRATEGY == PS_USE_PSTAT
|
||||
* use the pstat(PSTAT_SETCMD, )
|
||||
* (HPUX)
|
||||
* PS_USE_PS_STRINGS
|
||||
* SETPROCTITLE_STRATEGY == PS_USE_PS_STRINGS
|
||||
* assign PS_STRINGS->ps_argvstr = "string"
|
||||
* (some BSD systems)
|
||||
* PS_USE_CHANGE_ARGV
|
||||
* SETPROCTITLE_STRATEGY == PS_USE_CHANGE_ARGV
|
||||
* assign argv[0] = "string"
|
||||
* (some other BSD systems)
|
||||
* PS_USE_CLOBBER_ARGV
|
||||
* SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
|
||||
* write over the argv and environment area
|
||||
* (most SysV-like systems)
|
||||
* PS_USE_NONE
|
||||
* SETPROCTITLE_STRATEGY == PS_USE_NONE
|
||||
* don't update ps display
|
||||
* (This is the default, as it is safest.)
|
||||
*/
|
||||
#if defined(HAVE_PSTAT) && defined(PSTAT_SETCMD)
|
||||
#define PS_USE_PSTAT
|
||||
#elif defined(HAVE_PS_STRINGS)
|
||||
#define PS_USE_PS_STRINGS
|
||||
#elif defined(BSD) || defined(__bsdi__) || defined(__hurd__)
|
||||
#define PS_USE_CHANGE_ARGV
|
||||
#elif defined(__linux__) || defined(_AIX)
|
||||
#define PS_USE_CLOBBER_ARGV
|
||||
#else
|
||||
#define PS_USE_NONE
|
||||
|
||||
#define PS_USE_NONE 0
|
||||
#define PS_USE_PSTAT 1
|
||||
#define PS_USE_PS_STRINGS 2
|
||||
#define PS_USE_CHANGE_ARGV 3
|
||||
#define PS_USE_CLOBBER_ARGV 4
|
||||
|
||||
#ifndef SETPROCTITLE_STRATEGY
|
||||
# define SETPROCTITLE_STRATEGY PS_USE_NONE
|
||||
#endif
|
||||
|
||||
/* Different systems want the buffer padded differently */
|
||||
#if defined(_AIX) || defined(__linux__) || defined(__QNX__) || defined(__svr4__)
|
||||
#define PS_PADDING '\0'
|
||||
#else
|
||||
#define PS_PADDING ' '
|
||||
#ifndef SETPROCTITLE_PS_PADDING
|
||||
# define SETPROCTITLE_PS_PADDING ' '
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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 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 size_t ps_buffer_size; /* space determined at run time */
|
||||
#endif /* PS_USE_CLOBBER_ARGV */
|
||||
#endif
|
||||
|
||||
/* save the original argv[] location here */
|
||||
static int save_argc;
|
||||
@ -115,17 +111,17 @@ extern char *__progname;
|
||||
void
|
||||
setproctitle(const char *fmt, ...)
|
||||
{
|
||||
#ifdef PS_USE_PSTAT
|
||||
#if SETPROCTITLE_STRATEGY == PS_USE_PSTAT
|
||||
union pstun pst;
|
||||
#endif
|
||||
#ifndef PS_USE_NONE
|
||||
#if SETPROCTITLE_STRATEGY != PS_USE_NONE
|
||||
ssize_t used;
|
||||
va_list ap;
|
||||
|
||||
/* no ps display if you didn't call save_ps_display_args() */
|
||||
if (save_argv == NULL)
|
||||
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 == NULL)
|
||||
return;
|
||||
@ -134,12 +130,12 @@ setproctitle(const char *fmt, ...)
|
||||
/*
|
||||
* 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[1] = NULL;
|
||||
#endif /* PS_USE_CHANGE_ARGV */
|
||||
|
||||
#ifdef PS_USE_CLOBBER_ARGV
|
||||
#if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
|
||||
save_argv[1] = NULL;
|
||||
#endif /* PS_USE_CLOBBER_ARGV */
|
||||
|
||||
@ -158,26 +154,21 @@ setproctitle(const char *fmt, ...)
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
#if 0
|
||||
error("XXXXXXXXX %s", __progname);
|
||||
error("XXXXXXXXX %d", ps_buffer_size);
|
||||
error("XXXXXXXXX %s", ps_buffer);
|
||||
#endif
|
||||
|
||||
#ifdef PS_USE_PSTAT
|
||||
#if SETPROCTITLE_STRATEGY == PS_USE_PSTAT
|
||||
pst.pst_command = ps_buffer;
|
||||
pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0);
|
||||
#endif /* PS_USE_PSTAT */
|
||||
|
||||
#ifdef PS_USE_PS_STRINGS
|
||||
#if SETPROCTITLE_STRATEGY == PS_USE_PS_STRINGS
|
||||
PS_STRINGS->ps_nargvstr = 1;
|
||||
PS_STRINGS->ps_argvstr = ps_buffer;
|
||||
#endif /* PS_USE_PS_STRINGS */
|
||||
|
||||
#ifdef PS_USE_CLOBBER_ARGV
|
||||
#if SETPROCTITLE_STRATEGY == PS_USE_CLOBBER_ARGV
|
||||
/* pad unused memory */
|
||||
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_NONE */
|
||||
@ -196,7 +187,7 @@ setproctitle(const char *fmt, ...)
|
||||
void
|
||||
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 **new_environ;
|
||||
int i;
|
||||
@ -205,7 +196,7 @@ compat_init_setproctitle(int argc, char *argv[])
|
||||
save_argc = argc;
|
||||
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
|
||||
* space. Also move the environment to make additional room.
|
||||
|
Loading…
Reference in New Issue
Block a user