Replace strsigname() with sig2str(), emulating it as needed.
This commit is contained in:
2
MANIFEST
2
MANIFEST
@@ -51,13 +51,13 @@ compat/regress/fnmatch/fnm_test.in
|
|||||||
compat/regress/glob/files
|
compat/regress/glob/files
|
||||||
compat/regress/glob/globtest.c
|
compat/regress/glob/globtest.c
|
||||||
compat/regress/glob/globtest.in
|
compat/regress/glob/globtest.in
|
||||||
|
compat/sig2str.c
|
||||||
compat/siglist.in
|
compat/siglist.in
|
||||||
compat/snprintf.c
|
compat/snprintf.c
|
||||||
compat/stdbool.h
|
compat/stdbool.h
|
||||||
compat/strlcat.c
|
compat/strlcat.c
|
||||||
compat/strlcpy.c
|
compat/strlcpy.c
|
||||||
compat/strsignal.c
|
compat/strsignal.c
|
||||||
compat/strsigname.c
|
|
||||||
compat/timespec.h
|
compat/timespec.h
|
||||||
compat/utime.h
|
compat/utime.h
|
||||||
compat/utimes.c
|
compat/utimes.c
|
||||||
|
@@ -204,6 +204,9 @@ nanosleep.lo: $(srcdir)/nanosleep.c $(top_builddir)/config.h \
|
|||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/nanosleep.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/nanosleep.c
|
||||||
pw_dup.lo: $(srcdir)/pw_dup.c $(top_builddir)/config.h
|
pw_dup.lo: $(srcdir)/pw_dup.c $(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/pw_dup.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/pw_dup.c
|
||||||
|
sig2str.lo: $(srcdir)/sig2str.c $(top_builddir)/config.h $(incdir)/missing.h \
|
||||||
|
$(incdir)/gettext.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sig2str.c
|
||||||
siglist.lo: siglist.c $(top_builddir)/config.h $(incdir)/missing.h
|
siglist.lo: siglist.c $(top_builddir)/config.h $(incdir)/missing.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) siglist.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) siglist.c
|
||||||
snprintf.lo: $(srcdir)/snprintf.c $(top_builddir)/config.h $(incdir)/missing.h
|
snprintf.lo: $(srcdir)/snprintf.c $(top_builddir)/config.h $(incdir)/missing.h
|
||||||
@@ -215,9 +218,6 @@ strlcpy.lo: $(srcdir)/strlcpy.c $(top_builddir)/config.h $(incdir)/missing.h
|
|||||||
strsignal.lo: $(srcdir)/strsignal.c $(top_builddir)/config.h \
|
strsignal.lo: $(srcdir)/strsignal.c $(top_builddir)/config.h \
|
||||||
$(incdir)/missing.h $(incdir)/gettext.h
|
$(incdir)/missing.h $(incdir)/gettext.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/strsignal.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/strsignal.c
|
||||||
strsigname.lo: $(srcdir)/strsigname.c $(top_builddir)/config.h \
|
|
||||||
$(incdir)/missing.h $(incdir)/gettext.h
|
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/strsigname.c
|
|
||||||
utimes.lo: $(srcdir)/utimes.c $(top_builddir)/config.h \
|
utimes.lo: $(srcdir)/utimes.c $(top_builddir)/config.h \
|
||||||
$(top_srcdir)/compat/utime.h $(incdir)/missing.h
|
$(top_srcdir)/compat/utime.h $(incdir)/missing.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/utimes.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/utimes.c
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2012 Todd C. Miller <Todd.Miller@courtesan.com>
|
* Copyright (c) 2012 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -18,22 +18,34 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <stddef.h>
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
# endif
|
||||||
|
#endif /* STDC_HEADERS */
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif /* HAVE_STRING_H */
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
# include <strings.h>
|
||||||
|
#endif /* HAVE_STRINGS_H */
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "missing.h"
|
#include "missing.h"
|
||||||
|
|
||||||
#define DEFAULT_TEXT_DOMAIN "sudo"
|
|
||||||
#include "gettext.h"
|
|
||||||
|
|
||||||
#if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
|
#if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
|
||||||
# define sudo_sys_signame sys_signame
|
# define sudo_sys_signame sys_signame
|
||||||
#elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
|
#elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
|
||||||
# define sudo_sys_signame _sys_signame
|
# define sudo_sys_signame _sys_signame
|
||||||
#elif defined(HAVE_DECL___SYS_SIGNAME) && HAVE_DECL___SYS_SIGNAME == 1
|
#elif defined(HAVE_DECL___SYS_SIGNAME) && HAVE_DECL___SYS_SIGNAME == 1
|
||||||
# define sudo_sys_signame __sys_signame
|
# define sudo_sys_signame __sys_signame
|
||||||
#elif defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 1
|
#elif defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 1
|
||||||
# define sudo_sys_signame sys_sigabbrev
|
# define sudo_sys_signame sys_sigabbrev
|
||||||
#else
|
#else
|
||||||
# ifdef HAVE_SYS_SIGABBREV
|
# ifdef HAVE_SYS_SIGABBREV
|
||||||
/* sys_sigabbrev is not declared by glibc */
|
/* sys_sigabbrev is not declared by glibc */
|
||||||
@@ -43,13 +55,22 @@ extern const char *const sudo_sys_signame[NSIG];
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return signal name
|
* Translate signal number to name.
|
||||||
*/
|
*/
|
||||||
char *
|
int
|
||||||
strsigname(int signo)
|
sig2str(int signo, char *signame)
|
||||||
{
|
{
|
||||||
if (signo > 0 && signo < NSIG && sudo_sys_signame[signo] != NULL)
|
#if defined(SIGRTMIN) && defined(SIGRTMAX)
|
||||||
return (char *)sudo_sys_signame[signo];
|
/* Realtime signal support as per Solaris. */
|
||||||
/* XXX - should be "Unknown signal: %d" */
|
if (signo >= SIGRTMIN && signo <= SIGRTMAX) {
|
||||||
return _("Unknown signal");
|
snprintf(signame, SIG2STR_MAX, "RTMIN+%d", (signo - SIGRTMIN));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (signo > 0 && signo < NSIG && sudo_sys_signame[signo] != NULL) {
|
||||||
|
strlcpy(signame, sudo_sys_signame[signo], SIG2STR_MAX);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
@@ -491,6 +491,9 @@
|
|||||||
/* Define to 1 if you have the `sia_ses_init' function. */
|
/* Define to 1 if you have the `sia_ses_init' function. */
|
||||||
#undef HAVE_SIA_SES_INIT
|
#undef HAVE_SIA_SES_INIT
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sig2str' function. */
|
||||||
|
#undef HAVE_SIG2STR
|
||||||
|
|
||||||
/* Define to 1 if the system has the type `sigaction_t'. */
|
/* Define to 1 if the system has the type `sigaction_t'. */
|
||||||
#undef HAVE_SIGACTION_T
|
#undef HAVE_SIGACTION_T
|
||||||
|
|
||||||
@@ -539,9 +542,6 @@
|
|||||||
/* Define to 1 if you have the `strsignal' function. */
|
/* Define to 1 if you have the `strsignal' function. */
|
||||||
#undef HAVE_STRSIGNAL
|
#undef HAVE_STRSIGNAL
|
||||||
|
|
||||||
/* Define to 1 if you have the `strsigname' function. */
|
|
||||||
#undef HAVE_STRSIGNAME
|
|
||||||
|
|
||||||
/* Define to 1 if `d_type' is a member of `struct dirent'. */
|
/* Define to 1 if `d_type' is a member of `struct dirent'. */
|
||||||
#undef HAVE_STRUCT_DIRENT_D_TYPE
|
#undef HAVE_STRUCT_DIRENT_D_TYPE
|
||||||
|
|
||||||
|
12
configure
vendored
12
configure
vendored
@@ -18320,19 +18320,19 @@ fi
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
for ac_func in strsigname
|
for ac_func in sig2str
|
||||||
do :
|
do :
|
||||||
ac_fn_c_check_func "$LINENO" "strsigname" "ac_cv_func_strsigname"
|
ac_fn_c_check_func "$LINENO" "sig2str" "ac_cv_func_sig2str"
|
||||||
if test "x$ac_cv_func_strsigname" = xyes; then :
|
if test "x$ac_cv_func_sig2str" = xyes; then :
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
#define HAVE_STRSIGNAME 1
|
#define HAVE_SIG2STR 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
case " $LIBOBJS " in
|
case " $LIBOBJS " in
|
||||||
*" strsigname.$ac_objext "* ) ;;
|
*" sig2str.$ac_objext "* ) ;;
|
||||||
*) LIBOBJS="$LIBOBJS strsigname.$ac_objext"
|
*) LIBOBJS="$LIBOBJS sig2str.$ac_objext"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@@ -2570,10 +2570,10 @@ AC_INCLUDES_DEFAULT
|
|||||||
])
|
])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Check for strsigname() or sys_signame
|
dnl Check for sig2str(), sys_signame or sys_sigabbrev
|
||||||
dnl
|
dnl
|
||||||
AC_CHECK_FUNCS(strsigname, [], [
|
AC_CHECK_FUNCS(sig2str, [], [
|
||||||
AC_LIBOBJ(strsigname)
|
AC_LIBOBJ(sig2str)
|
||||||
HAVE_SIGNAME="false"
|
HAVE_SIGNAME="false"
|
||||||
AC_CHECK_DECLS([sys_signame, _sys_signame, __sys_signame, sys_sigabbrev], [
|
AC_CHECK_DECLS([sys_signame, _sys_signame, __sys_signame, sys_sigabbrev], [
|
||||||
HAVE_SIGNAME="true"
|
HAVE_SIGNAME="true"
|
||||||
|
@@ -284,6 +284,11 @@ extern int errno;
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* For sig2str() */
|
||||||
|
#ifndef SIG2STR_MAX
|
||||||
|
# define SIG2STR_MAX 32
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef WCOREDUMP
|
#ifndef WCOREDUMP
|
||||||
# define WCOREDUMP(x) ((x) & 0x80)
|
# define WCOREDUMP(x) ((x) & 0x80)
|
||||||
#endif
|
#endif
|
||||||
@@ -376,8 +381,8 @@ int unsetenv(const char *);
|
|||||||
#ifndef HAVE_STRSIGNAL
|
#ifndef HAVE_STRSIGNAL
|
||||||
char *strsignal(int);
|
char *strsignal(int);
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAVE_STRSIGNAME
|
#ifndef HAVE_SIG2STR
|
||||||
char *strsigname(int);
|
int sig2str(int, char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _SUDO_MISSING_H */
|
#endif /* _SUDO_MISSING_H */
|
||||||
|
2
mkdep.pl
2
mkdep.pl
@@ -55,7 +55,7 @@ sub mkdep {
|
|||||||
$makefile =~ s:\@SUDOERS_OBJS\@:bsm_audit.lo linux_audit.lo ldap.lo plugin_error.lo sssd.lo:;
|
$makefile =~ s:\@SUDOERS_OBJS\@:bsm_audit.lo linux_audit.lo ldap.lo plugin_error.lo sssd.lo:;
|
||||||
# XXX - fill in AUTH_OBJS from contents of the auth dir instead
|
# XXX - fill in AUTH_OBJS from contents of the auth dir instead
|
||||||
$makefile =~ s:\@AUTH_OBJS\@:afs.lo aix_auth.lo bsdauth.lo dce.lo fwtk.lo getspwuid.lo kerb5.lo pam.lo passwd.lo rfc1938.lo secureware.lo securid5.lo sia.lo:;
|
$makefile =~ s:\@AUTH_OBJS\@:afs.lo aix_auth.lo bsdauth.lo dce.lo fwtk.lo getspwuid.lo kerb5.lo pam.lo passwd.lo rfc1938.lo secureware.lo securid5.lo sia.lo:;
|
||||||
$makefile =~ s:\@LTLIBOBJS\@:closefrom.lo dlopen.lo fnmatch.lo getcwd.lo getgrouplist.lo getline.lo getprogname.lo glob.lo isblank.lo memrchr.lo mksiglist.lo mksigname.lo mktemp.lo nanosleep.lo pw_dup.lo siglist.lo snprintf.lo strlcat.lo strlcpy.lo strsignal.lo strsigname.lo utimes.lo globtest.o fnm_test.o:;
|
$makefile =~ s:\@LTLIBOBJS\@:closefrom.lo dlopen.lo fnmatch.lo getcwd.lo getgrouplist.lo getline.lo getprogname.lo glob.lo isblank.lo memrchr.lo mksiglist.lo mksigname.lo mktemp.lo nanosleep.lo pw_dup.lo sig2str.lo siglist.lo snprintf.lo strlcat.lo strlcpy.lo strsignal.lo utimes.lo globtest.o fnm_test.o:;
|
||||||
|
|
||||||
# Parse OBJS lines
|
# Parse OBJS lines
|
||||||
my %objs;
|
my %objs;
|
||||||
|
25
src/exec.c
25
src/exec.c
@@ -506,6 +506,7 @@ do_tty_io:
|
|||||||
static int
|
static int
|
||||||
handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
||||||
{
|
{
|
||||||
|
char signame[SIG2STR_MAX];
|
||||||
unsigned char signo;
|
unsigned char signo;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
int status;
|
int status;
|
||||||
@@ -531,7 +532,9 @@ handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
|||||||
cstat->val = errno;
|
cstat->val = errno;
|
||||||
debug_return_int(-1);
|
debug_return_int(-1);
|
||||||
}
|
}
|
||||||
sudo_debug_printf(SUDO_DEBUG_DIAG, "received SIG%s", strsigname(signo));
|
if (sig2str(signo, signame) == -1)
|
||||||
|
snprintf(signame, sizeof(signame), "%d", signo);
|
||||||
|
sudo_debug_printf(SUDO_DEBUG_DIAG, "received SIG%s", signame);
|
||||||
if (signo == SIGCHLD) {
|
if (signo == SIGCHLD) {
|
||||||
/*
|
/*
|
||||||
* If logging I/O, child is the intermediate process,
|
* If logging I/O, child is the intermediate process,
|
||||||
@@ -575,10 +578,8 @@ handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
|||||||
sa.sa_handler = SIG_DFL;
|
sa.sa_handler = SIG_DFL;
|
||||||
sigaction(SIGTSTP, &sa, NULL);
|
sigaction(SIGTSTP, &sa, NULL);
|
||||||
}
|
}
|
||||||
if (kill(getpid(), signo) != 0) {
|
if (kill(getpid(), signo) != 0)
|
||||||
warning("kill(%d, SIG%s)", (int)getpid(),
|
warning("kill(%d, SIG%s)", (int)getpid(), signame);
|
||||||
strsigname(signo));
|
|
||||||
}
|
|
||||||
if (signo == SIGTSTP)
|
if (signo == SIGTSTP)
|
||||||
sigaction(SIGTSTP, &osa, NULL);
|
sigaction(SIGTSTP, &osa, NULL);
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
@@ -607,7 +608,7 @@ handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
|||||||
if (signo == SIGALRM)
|
if (signo == SIGALRM)
|
||||||
terminate_command(child, false);
|
terminate_command(child, false);
|
||||||
else if (kill(child, signo) != 0)
|
else if (kill(child, signo) != 0)
|
||||||
warning("kill(%d, SIG%s)", (int)child, strsigname(signo));
|
warning("kill(%d, SIG%s)", (int)child, signame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,6 +621,7 @@ handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
|||||||
static void
|
static void
|
||||||
forward_signals(int sock)
|
forward_signals(int sock)
|
||||||
{
|
{
|
||||||
|
char signame[SIG2STR_MAX];
|
||||||
struct sigforward *sigfwd;
|
struct sigforward *sigfwd;
|
||||||
struct command_status cstat;
|
struct command_status cstat;
|
||||||
ssize_t nsent;
|
ssize_t nsent;
|
||||||
@@ -627,9 +629,10 @@ forward_signals(int sock)
|
|||||||
|
|
||||||
while (!tq_empty(&sigfwd_list)) {
|
while (!tq_empty(&sigfwd_list)) {
|
||||||
sigfwd = tq_first(&sigfwd_list);
|
sigfwd = tq_first(&sigfwd_list);
|
||||||
|
if (sig2str(sigfwd->signo, signame) == -1)
|
||||||
|
snprintf(signame, sizeof(signame), "%d", sigfwd->signo);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"sending SIG%s to child over backchannel",
|
"sending SIG%s to child over backchannel", signame);
|
||||||
strsigname(sigfwd->signo));
|
|
||||||
cstat.type = CMD_SIGNO;
|
cstat.type = CMD_SIGNO;
|
||||||
cstat.val = sigfwd->signo;
|
cstat.val = sigfwd->signo;
|
||||||
do {
|
do {
|
||||||
@@ -662,10 +665,12 @@ static void
|
|||||||
schedule_signal(int signo)
|
schedule_signal(int signo)
|
||||||
{
|
{
|
||||||
struct sigforward *sigfwd;
|
struct sigforward *sigfwd;
|
||||||
|
char signame[SIG2STR_MAX];
|
||||||
debug_decl(schedule_signal, SUDO_DEBUG_EXEC)
|
debug_decl(schedule_signal, SUDO_DEBUG_EXEC)
|
||||||
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_DIAG, "forwarding SIG%s to child",
|
if (sig2str(signo, signame) == -1)
|
||||||
strsigname(signo));
|
snprintf(signame, sizeof(signame), "%d", signo);
|
||||||
|
sudo_debug_printf(SUDO_DEBUG_DIAG, "forwarding SIG%s to child", signame);
|
||||||
|
|
||||||
sigfwd = ecalloc(1, sizeof(*sigfwd));
|
sigfwd = ecalloc(1, sizeof(*sigfwd));
|
||||||
sigfwd->prev = sigfwd;
|
sigfwd->prev = sigfwd;
|
||||||
|
@@ -335,6 +335,7 @@ check_foreground(void)
|
|||||||
int
|
int
|
||||||
suspend_parent(int signo)
|
suspend_parent(int signo)
|
||||||
{
|
{
|
||||||
|
char signame[SIG2STR_MAX];
|
||||||
sigaction_t sa, osa;
|
sigaction_t sa, osa;
|
||||||
int n, oldmode = ttymode, rval = 0;
|
int n, oldmode = ttymode, rval = 0;
|
||||||
debug_decl(suspend_parent, SUDO_DEBUG_EXEC);
|
debug_decl(suspend_parent, SUDO_DEBUG_EXEC);
|
||||||
@@ -372,16 +373,18 @@ suspend_parent(int signo)
|
|||||||
} while (!n && errno == EINTR);
|
} while (!n && errno == EINTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sig2str(signo, signame) == -1)
|
||||||
|
snprintf(signame, sizeof(signame), "%d", signo);
|
||||||
|
|
||||||
/* Suspend self and continue command when we resume. */
|
/* Suspend self and continue command when we resume. */
|
||||||
zero_bytes(&sa, sizeof(sa));
|
zero_bytes(&sa, sizeof(sa));
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
|
sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
|
||||||
sa.sa_handler = SIG_DFL;
|
sa.sa_handler = SIG_DFL;
|
||||||
sigaction(signo, &sa, &osa);
|
sigaction(signo, &sa, &osa);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "kill parent SIG%s",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "kill parent SIG%s", signame);
|
||||||
strsigname(signo));
|
|
||||||
if (killpg(ppgrp, signo) != 0)
|
if (killpg(ppgrp, signo) != 0)
|
||||||
warning("killpg(%d, SIG%s)", (int)ppgrp, strsigname(signo));
|
warning("killpg(%d, SIG%s)", (int)ppgrp, signame);
|
||||||
|
|
||||||
/* Check foreground/background status on resume. */
|
/* Check foreground/background status on resume. */
|
||||||
check_foreground();
|
check_foreground();
|
||||||
@@ -823,12 +826,16 @@ fd_set_iobs(fd_set *fdsr, fd_set *fdsw)
|
|||||||
static void
|
static void
|
||||||
deliver_signal(pid_t pid, int signo, bool from_parent)
|
deliver_signal(pid_t pid, int signo, bool from_parent)
|
||||||
{
|
{
|
||||||
|
char signame[SIG2STR_MAX];
|
||||||
int status;
|
int status;
|
||||||
debug_decl(deliver_signal, SUDO_DEBUG_EXEC);
|
debug_decl(deliver_signal, SUDO_DEBUG_EXEC);
|
||||||
|
|
||||||
|
if (sig2str(signo, signame) == -1)
|
||||||
|
snprintf(signame, sizeof(signame), "%d", signo);
|
||||||
|
|
||||||
/* Handle signal from parent. */
|
/* Handle signal from parent. */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "received SIG%s%s",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "received SIG%s%s",
|
||||||
strsigname(signo), from_parent ? " from parent" : "");
|
signame, from_parent ? " from parent" : "");
|
||||||
switch (signo) {
|
switch (signo) {
|
||||||
case SIGALRM:
|
case SIGALRM:
|
||||||
terminate_command(pid, true);
|
terminate_command(pid, true);
|
||||||
@@ -904,19 +911,25 @@ handle_sigchld(int backchannel, struct command_status *cstat)
|
|||||||
} while (pid == -1 && errno == EINTR);
|
} while (pid == -1 && errno == EINTR);
|
||||||
if (pid == cmnd_pid) {
|
if (pid == cmnd_pid) {
|
||||||
if (cstat->type != CMD_ERRNO) {
|
if (cstat->type != CMD_ERRNO) {
|
||||||
|
char signame[SIG2STR_MAX];
|
||||||
|
|
||||||
cstat->type = CMD_WSTATUS;
|
cstat->type = CMD_WSTATUS;
|
||||||
cstat->val = status;
|
cstat->val = status;
|
||||||
if (WIFSTOPPED(status)) {
|
if (WIFSTOPPED(status)) {
|
||||||
|
if (sig2str(WSTOPSIG(status), signame) == -1)
|
||||||
|
snprintf(signame, sizeof(signame), "%d", WSTOPSIG(status));
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"command stopped, SIG%s", strsigname(WSTOPSIG(status)));
|
"command stopped, SIG%s", signame);
|
||||||
do {
|
do {
|
||||||
cmnd_pgrp = tcgetpgrp(io_fds[SFD_SLAVE]);
|
cmnd_pgrp = tcgetpgrp(io_fds[SFD_SLAVE]);
|
||||||
} while (cmnd_pgrp == -1 && errno == EINTR);
|
} while (cmnd_pgrp == -1 && errno == EINTR);
|
||||||
if (send_status(backchannel, cstat) == -1)
|
if (send_status(backchannel, cstat) == -1)
|
||||||
return alive; /* XXX */
|
return alive; /* XXX */
|
||||||
} else if (WIFSIGNALED(status)) {
|
} else if (WIFSIGNALED(status)) {
|
||||||
|
if (sig2str(WTERMSIG(status), signame) == -1)
|
||||||
|
snprintf(signame, sizeof(signame), "%d", WTERMSIG(status));
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"command killed, SIG%s", strsigname(WTERMSIG(status)));
|
"command killed, SIG%s", signame);
|
||||||
} else {
|
} else {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "command exited: %d",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "command exited: %d",
|
||||||
WEXITSTATUS(status));
|
WEXITSTATUS(status));
|
||||||
|
Reference in New Issue
Block a user