]> granicus.if.org Git - sudo/commitdiff
Remove sigaction emulation
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 10 Jun 2010 19:18:23 +0000 (15:18 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 10 Jun 2010 19:18:23 +0000 (15:18 -0400)
Use SA_INTERRUPT in sa_flags

compat/sigaction.c [deleted file]
config.h.in
configure.in
include/compat.h
plugins/sudoers/logging.c
plugins/sudoers/mon_systrace.c
src/exec.c
src/exec_pty.c
src/tgetpass.c

diff --git a/compat/sigaction.c b/compat/sigaction.c
deleted file mode 100644 (file)
index 34c128e..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2001-2005 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Sponsored in part by the Defense Advanced Research Projects
- * Agency (DARPA) and Air Force Research Laboratory, Air Force
- * Materiel Command, USAF, under agreement number F39502-99-1-0512.
- */
-
-#include <signal.h>
-#include <errno.h>
-
-#include <compat.h>
-
-int
-sigaction(int signo, const sigaction_t *sa, sigaction_t *osa)
-{
-    sigaction_t nsa;
-    int error;
-
-    /* We must reverse SV_INTERRUPT since it is the opposite of SA_RESTART */
-    if (sa) {
-       nsa = *sa;
-       nsa.sa_flags ^= SV_INTERRUPT;
-       sa = &nsa;
-    }
-
-    error = sigvec(signo, sa, osa);
-    if (!error && osa)
-       osa->sa_flags ^= SV_INTERRUPT;          /* flip SV_INTERRUPT as above */
-
-    return(error);
-}
-
-int
-sigemptyset(sigset_t *set)
-{
-
-    *set = 0;
-    return(0);
-}
-
-int
-sigfillset(sigset_t *set)
-{
-
-    *set = ~0;;
-    return(0);
-}
-
-int
-sigaddset(sigset_t *set, int signo)
-{
-
-    if (signo <= 0 || signo >= NSIG) {
-       errno = EINVAL;
-       return(-1);
-    }
-
-    SET(*set, sigmask(signo));
-    return(0);
-}
-
-int
-sigdelset(sigset_t *set, int signo)
-{
-
-    if (signo <= 0 || signo >= NSIG) {
-       errno = EINVAL;
-       return(-1);
-    }
-
-    CLR(*set, sigmask(signo));
-    return(0);
-}
-
-int
-sigismember(sigset_t *set, int signo)
-{
-
-    return(ISSET(*set, sigmask(signo)));
-}
-
-int
-sigprocmask(int how, const sigset_t *set, sigset_t *oset)
-{
-    int mask;
-
-    /* If 'set' is NULL the user just wants the current signal mask. */
-    if (set == 0)
-       mask = sigblock(0);
-    else
-       switch (how) {
-           case SIG_BLOCK:
-               mask = sigblock(*set);
-               break;
-           case SIG_UNBLOCK:
-               mask = sigsetmask(~*set);
-               break;
-           case SIG_SETMASK:
-               mask = sigsetmask(*set);
-               break;
-           default:
-               return(-1);
-       }
-
-    if (mask == -1)
-       return(-1);
-    if (oset)
-       *oset = mask;
-    return(0);
-}
index 26f560a5e57b3722820361c6c5e80883edd3e98c..623cd4a2f59201ae2df1bbf9d12b3b768dca3d98 100644 (file)
 /* Define to 1 if you have the `sia_ses_init' function. */
 #undef HAVE_SIA_SES_INIT
 
-/* Define to 1 if you have the `sigaction' function. */
-#undef HAVE_SIGACTION
-
 /* Define to 1 if <signal.h> has the sigaction_t typedef. */
 #undef HAVE_SIGACTION_T
 
index 8f9e379c8c7347442463c553f32ffa7d5b1d2a3f..1beb04955fe08e7e2a384d445e32f4024535ab8a 100644 (file)
@@ -1957,7 +1957,7 @@ AC_CHECK_FUNCS(utimes, [AC_CHECK_FUNCS(futimes futimesat, [break])], [AC_CHECK_F
 AC_CHECK_FUNCS(killpg, [], [AC_LIBOBJ(killpg)])
 SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [AC_LIBOBJ(fnmatch)])
 SUDO_FUNC_ISBLANK
-AC_REPLACE_FUNCS(memrchr strerror strcasecmp sigaction strlcpy strlcat)
+AC_REPLACE_FUNCS(memrchr strerror strcasecmp strlcpy strlcat)
 AC_CHECK_FUNCS(nanosleep, [], [
     # On Solaris, nanosleep is in librt
     AC_CHECK_LIB(rt, nanosleep, [REPLAY_LIBS="${REPLAY_LIBS} -lrt"], [AC_LIBOBJ(nanosleep)])
index 4004845666a9d36b86312a47b41c3859eca5a036..2ce7c3f7ad5143c544b1adf0a7dced2fa23ec6e5 100644 (file)
@@ -181,41 +181,17 @@ int isblank(int);
 #endif /* O_NOCTTY */
 
 /*
- * Emulate POSIX signals via sigvec(2)
+ * Add IRIX-like sigaction_t for those without it.
+ * SA_RESTART is not required by POSIX; SunOS has SA_INTERRUPT instead.
  */
-#ifndef HAVE_SIGACTION
-# define SA_ONSTACK    SV_ONSTACK
-# define SA_RESTART    SV_INTERRUPT            /* opposite effect */
-# define SA_RESETHAND  SV_RESETHAND
-# define SA_NOCLDSTOP  SV_NOCLDSTOP
-# define sa_handler    sv_handler
-# define sa_mask       sv_mask
-# define sa_flags      sv_flags
-typedef struct sigvec sigaction_t;
-typedef int sigset_t;
-int sigaction(int sig, const sigaction_t *act, sigaction_t *oact);
-int sigemptyset(sigset_t *);
-int sigfillset(sigset_t *);
-int sigaddset(sigset_t *, int);
-int sigdelset(sigset_t *, int);
-int sigismember(sigset_t *, int);
-int sigprocmask(int, const sigset_t *, sigset_t *);
-#endif
-
-/*
- * Extra sugar for POSIX signals to deal with the above emulation
- * as well as the fact that SunOS has a SA_INTERRUPT flag.
- */
-#ifdef HAVE_SIGACTION
-# ifndef HAVE_SIGACTION_T
+#ifndef HAVE_SIGACTION_T
 typedef struct sigaction sigaction_t;
-# endif
-# ifndef SA_INTERRUPT
-#  define SA_INTERRUPT 0
-# endif
-# ifndef SA_RESTART
-#  define SA_RESTART   0
-# endif
+#endif
+#ifndef SA_INTERRUPT
+# define SA_INTERRUPT  0
+#endif
+#ifndef SA_RESTART
+# define SA_RESTART    0
 #endif
 
 /*
index 98756e00fcf69bd925f30ea3e1fe233ea61cd3d5..bf9077e621c817ae2ea7a4f36d0bb32b26a3715b 100644 (file)
@@ -478,7 +478,7 @@ send_mail(const char *fmt, ...)
     /* Ignore SIGPIPE in case mailer exits prematurely (or is missing). */
     zero_bytes(&sa, sizeof(sa));
     sigemptyset(&sa.sa_mask);
-    sa.sa_flags = 0;
+    sa.sa_flags = SA_INTERRUPT;
     sa.sa_handler = SIG_IGN;
     (void) sigaction(SIGPIPE, &sa, NULL);
 
index 83eb0e4f54b13699c19e2f48940d34c3653fa29b..5bae00a986f7111382a972ca817864dd70dbca0a 100644 (file)
@@ -113,7 +113,7 @@ systrace_attach(pid)
        error(1, "sigprocmask");
     zero_bytes(&sa, sizeof(sa));
     sigemptyset(&sa.sa_mask);
-    sa.sa_flags = 0;
+    sa.sa_flags = SA_INTERRUPT;
     sa.sa_handler = catchsig;
     if (sigaction(SIGUSR1, &sa, &osa) != 0)
        error(1, "sigaction");
@@ -151,7 +151,7 @@ systrace_attach(pid)
     dodetach = 0;
     zero_bytes(&sa, sizeof(sa));
     sigemptyset(&sa.sa_mask);
-    sa.sa_flags = 0;
+    sa.sa_flags = SA_INTERRUPT;
     sa.sa_handler = catchsig;
     if (sigaction(SIGUSR1, &osa, NULL) != 0 ||
        sigaction(SIGHUP, &sa, NULL) != 0 ||
index 25af3440b3f9e98fcb7e173225ea82f651fdc849..ccc7fb4827579815d9c8253eb4136fdc346b4df9 100644 (file)
@@ -176,7 +176,7 @@ sudo_execve(struct command_details *details, char *argv[], char *envp[],
     sigemptyset(&sa.sa_mask);
 
     /* Note: HP-UX select() will not be interrupted if SA_RESTART set */
-    sa.sa_flags = 0; /* do not restart syscalls */
+    sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
     sa.sa_handler = handler;
     sigaction(SIGALRM, &sa, NULL);
     sigaction(SIGCHLD, &sa, NULL);
index a1e72478b3d1c9d8f4d106d60b29171bcf96e0f1..9e960f55d6a2bb9346129e94fe56f8518316153f 100644 (file)
@@ -532,7 +532,7 @@ fork_pty(struct command_details *details, char *argv[], char *envp[],
     }
 
     /* Job control signals to relay from parent to child. */
-    sa.sa_flags = 0; /* do not restart syscalls */
+    sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
     sa.sa_handler = handler;
     sigaction(SIGTSTP, &sa, NULL);
 #if 0 /* XXX - add these? */
@@ -823,7 +823,7 @@ exec_monitor(struct command_details *details, char *argv[], char *envp[],
     sigaction(SIGTTOU, &sa, NULL);
 
     /* Note: HP-UX select() will not be interrupted if SA_RESTART set */
-    sa.sa_flags = 0;
+    sa.sa_flags = SA_INTERRUPT;
     sa.sa_handler = handler;
     sigaction(SIGCHLD, &sa, NULL);
 
index 7c690de2f6a8da5dc6d574edef7ce8c311c9efe4..8fd965da7f1cfe2044037d1d9ca0291042e9527b 100644 (file)
@@ -241,7 +241,7 @@ sudo_askpass(const char *askpass, const char *prompt)
     /* Ignore SIGPIPE in case child exits prematurely */
     zero_bytes(&sa, sizeof(sa));
     sigemptyset(&sa.sa_mask);
-    sa.sa_flags = 0;
+    sa.sa_flags = SA_INTERRUPT;
     sa.sa_handler = SIG_IGN;
     (void) sigaction(SIGPIPE, &sa, &saved_sa_pipe);