Kill POSIX_SIGNALS define and old signal support now that we emulate POSIX ones
Also be sure to correctly initialize struct sigaction.
This commit is contained in:
@@ -125,12 +125,6 @@
|
||||
/* Define if you want to use execv() instead of execvp(). */
|
||||
#undef USE_EXECV
|
||||
|
||||
/* Define if you have POSIX signals. */
|
||||
#undef HAVE_SIGACTION
|
||||
#ifdef HAVE_SIGACTION
|
||||
# define POSIX_SIGNALS
|
||||
#endif /* HAVE_SIGACTION */
|
||||
|
||||
/* Define if you have tzset(3). */
|
||||
#undef HAVE_TZSET
|
||||
|
||||
|
@@ -1550,7 +1550,7 @@ esac
|
||||
dnl
|
||||
dnl Function checks
|
||||
dnl
|
||||
AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf sigaction tzset \
|
||||
AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \
|
||||
seteuid setegid strftime setrlimit initgroups fstat)
|
||||
if test -z "$BROKEN_SETREUID"; then
|
||||
AC_CHECK_FUNCS(setreuid)
|
||||
@@ -1570,7 +1570,7 @@ AC_CHECK_FUNCS(innetgr _innetgr, AC_CHECK_FUNCS(getdomainname) [break])
|
||||
AC_CHECK_FUNCS(lsearch, , [AC_CHECK_LIB(compat, lsearch, AC_CHECK_HEADER(search.h, AC_DEFINE(HAVE_LSEARCH) [LIBS="${LIBS} -lcompat"], AC_LIBOBJ(lsearch)), AC_LIBOBJ(lsearch))])
|
||||
AC_CHECK_FUNCS(utime, SUDO_FUNC_UTIME_POSIX, AC_LIBOBJ(utime))
|
||||
SUDO_FUNC_FNMATCH(AC_DEFINE(HAVE_FNMATCH), AC_LIBOBJ(fnmatch))
|
||||
AC_REPLACE_FUNCS(strerror strcasecmp)
|
||||
AC_REPLACE_FUNCS(strerror strcasecmp sigaction)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf, , [NEED_SNPRINTF=1])
|
||||
dnl
|
||||
dnl If NEED_SNPRINTF is set, add snprintf.c to LIBOBJS
|
||||
|
15
logging.c
15
logging.c
@@ -432,23 +432,15 @@ send_mail(line)
|
||||
FILE *mail;
|
||||
char *p;
|
||||
int pfd[2], pid, status;
|
||||
#ifdef POSIX_SIGNALS
|
||||
sigset_t set, oset;
|
||||
#else
|
||||
int omask;
|
||||
#endif /* POSIX_SIGNALS */
|
||||
|
||||
/* Just return if mailer is disabled. */
|
||||
if (!def_str(I_MAILERPATH) || !def_str(I_MAILTO))
|
||||
return;
|
||||
|
||||
#ifdef POSIX_SIGNALS
|
||||
(void) sigemptyset(&set);
|
||||
(void) sigaddset(&set, SIGCHLD);
|
||||
(void) sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
#else
|
||||
omask = sigblock(sigmask(SIGCHLD));
|
||||
#endif /* POSIX_SIGNALS */
|
||||
|
||||
if (pipe(pfd) == -1) {
|
||||
(void) fprintf(stderr, "%s: cannot open pipe: %s\n",
|
||||
@@ -534,11 +526,7 @@ send_mail(line)
|
||||
#ifdef sudo_waitpid
|
||||
(void) sudo_waitpid(pid, &status, WNOHANG);
|
||||
#endif
|
||||
#ifdef POSIX_SIGNALS
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
#else
|
||||
(void) sigsetmask(omask);
|
||||
#endif /* POSIX_SIGNALS */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -584,9 +572,6 @@ reapchild(sig)
|
||||
#else
|
||||
(void) wait(&status);
|
||||
#endif
|
||||
#ifndef POSIX_SIGNALS
|
||||
(void) signal(SIGCHLD, reapchild);
|
||||
#endif /* POSIX_SIGNALS */
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
|
23
sudo.c
23
sudo.c
@@ -146,11 +146,7 @@ main(argc, argv, envp)
|
||||
int cmnd_status;
|
||||
int sudo_mode;
|
||||
int pwflag;
|
||||
#ifdef POSIX_SIGNALS
|
||||
sigset_t set, oset;
|
||||
#else
|
||||
int omask;
|
||||
#endif /* POSIX_SIGNALS */
|
||||
extern int printmatches;
|
||||
extern char **environ;
|
||||
|
||||
@@ -177,15 +173,11 @@ main(argc, argv, envp)
|
||||
* Block signals so the user cannot interrupt us at some point and
|
||||
* avoid the logging.
|
||||
*/
|
||||
#ifdef POSIX_SIGNALS
|
||||
(void) sigemptyset(&set);
|
||||
(void) sigaddset(&set, SIGINT);
|
||||
(void) sigaddset(&set, SIGQUIT);
|
||||
(void) sigaddset(&set, SIGTSTP);
|
||||
(void) sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
#else
|
||||
omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGTSTP));
|
||||
#endif /* POSIX_SIGNALS */
|
||||
|
||||
/*
|
||||
* Setup signal handlers, turn off core dumps, and close open files.
|
||||
@@ -344,11 +336,7 @@ main(argc, argv, envp)
|
||||
endpwent();
|
||||
|
||||
/* Reset signal mask before we exec. */
|
||||
#ifdef POSIX_SIGNALS
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
#else
|
||||
(void) sigsetmask(omask);
|
||||
#endif /* POSIX_SIGNALS */
|
||||
|
||||
/* Override user's umask if configured to do so. */
|
||||
if (def_ival(I_UMASK) != 0777)
|
||||
@@ -809,9 +797,7 @@ initial_setup()
|
||||
#ifdef HAVE_SETRLIMIT
|
||||
struct rlimit rl;
|
||||
#endif
|
||||
#ifdef POSIX_SIGNALS
|
||||
struct sigaction sa;
|
||||
#endif
|
||||
sigaction_t sa;
|
||||
|
||||
#if defined(RLIMIT_CORE) && !defined(SUDO_DEVEL)
|
||||
/*
|
||||
@@ -841,13 +827,10 @@ initial_setup()
|
||||
(void) close(fd);
|
||||
|
||||
/* Catch children as they die... */
|
||||
#ifdef POSIX_SIGNALS
|
||||
(void) memset((VOID *)&sa, 0, sizeof(sa));
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sa.sa_handler = reapchild;
|
||||
(void) sigaction(SIGCHLD, &sa, NULL);
|
||||
#else
|
||||
(void) signal(SIGCHLD, reapchild);
|
||||
#endif /* POSIX_SIGNALS */
|
||||
|
||||
/* Set set_perms pointer to the correct function */
|
||||
#if defined(_SC_SAVED_IDS) && defined(_SC_VERSION)
|
||||
|
38
visudo.c
38
visudo.c
@@ -568,28 +568,18 @@ whatnow()
|
||||
static void
|
||||
setup_signals()
|
||||
{
|
||||
#ifdef POSIX_SIGNALS
|
||||
struct sigaction action; /* POSIX signal structure */
|
||||
#endif /* POSIX_SIGNALS */
|
||||
sigaction_t sa;
|
||||
|
||||
/*
|
||||
* Setup signal handlers to cleanup nicely.
|
||||
*/
|
||||
#ifdef POSIX_SIGNALS
|
||||
(void) memset((VOID *)&action, 0, sizeof(action));
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_flags = 0;
|
||||
action.sa_handler = Exit;
|
||||
(void) sigaction(SIGTERM, &action, NULL);
|
||||
(void) sigaction(SIGHUP, &action, NULL);
|
||||
(void) sigaction(SIGINT, &action, NULL);
|
||||
(void) sigaction(SIGQUIT, &action, NULL);
|
||||
#else
|
||||
(void) signal(SIGTERM, Exit);
|
||||
(void) signal(SIGHUP, Exit);
|
||||
(void) signal(SIGINT, Exit);
|
||||
(void) signal(SIGQUIT, Exit);
|
||||
#endif /* POSIX_SIGNALS */
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sa.sa_handler = Exit;
|
||||
(void) sigaction(SIGTERM, &sa, NULL);
|
||||
(void) sigaction(SIGHUP, &sa, NULL);
|
||||
(void) sigaction(SIGINT, &sa, NULL);
|
||||
(void) sigaction(SIGQUIT, &sa, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -599,15 +589,11 @@ run_command(path, argv)
|
||||
{
|
||||
int status;
|
||||
pid_t pid;
|
||||
#ifndef POSIX_SIGNALS
|
||||
int omask = sigblock(sigmask(SIGCHLD));
|
||||
#else
|
||||
sigset_t set, oset;
|
||||
|
||||
(void) sigemptyset(&set);
|
||||
(void) sigaddset(&set, SIGCHLD);
|
||||
(void) sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
#endif /* POSIX_SIGNALS */
|
||||
|
||||
switch (pid = fork()) {
|
||||
case -1:
|
||||
@@ -616,11 +602,7 @@ run_command(path, argv)
|
||||
Exit(-1);
|
||||
break; /* NOTREACHED */
|
||||
case 0:
|
||||
#ifdef POSIX_SIGNALS
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
#else
|
||||
(void) sigsetmask(omask);
|
||||
#endif /* POSIX_SIGNALS */
|
||||
execv(path, argv);
|
||||
(void) fprintf(stderr,
|
||||
"%s: unable to run %s: %s\n", Argv[0], path, strerror(errno));
|
||||
@@ -634,11 +616,7 @@ run_command(path, argv)
|
||||
pid = wait(&status);
|
||||
#endif
|
||||
|
||||
#ifdef POSIX_SIGNALS
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
#else
|
||||
(void) sigsetmask(omask);
|
||||
#endif /* POSIX_SIGNALS */
|
||||
|
||||
/* XXX - should use WEXITSTATUS() */
|
||||
return(pid == -1 ? -1 : (status >> 8));
|
||||
|
Reference in New Issue
Block a user