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