]> granicus.if.org Git - sudo/commitdiff
Attempt to handle systems with SA_SIGINFO but that lack SI_USER.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 29 Jul 2014 02:25:46 +0000 (20:25 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 29 Jul 2014 02:25:46 +0000 (20:25 -0600)
src/exec.c
src/exec_pty.c
src/sudo_exec.h

index 0c5163db22671b691bbb8f03ae5b6d6d17009f6b..275ee75852e6d958b25d0e23b98a6bd76ab634ad 100644 (file)
@@ -870,7 +870,7 @@ handler(int s, siginfo_t *info, void *context)
      * kill itself.  For example, this can happen with some versions of
      * reboot that call kill(-1, SIGTERM) to kill all other processes.
      */
-    if (info != NULL && info->si_code == SI_USER) {
+    if (USER_SIGNALED(info)) {
        pid_t si_pgrp = getpgid(info->si_pid);
        if (si_pgrp != (pid_t)-1) {
            if (si_pgrp == ppgrp || si_pgrp == cmnd_pid)
@@ -926,7 +926,7 @@ handler_user_only(int s, siginfo_t *info, void *context)
      * often trap ^Z and send SIGTSTP to their own pgrp, so we don't
      * want to send an extra SIGTSTP.
      */
-    if (info == NULL || info->si_code != SI_USER)
+    if (!USER_SIGNALED(info))
        return;
     if ((si_pgrp = getpgid(info->si_pid)) != (pid_t)-1) {
        if (si_pgrp == ppgrp || si_pgrp == cmnd_pid)
index 9facbfb683d04c7ff8130d3e4474404a44912584..e6c97525de2a5a4d8f6e3fe21a7947ce3322bd45 100644 (file)
@@ -141,7 +141,7 @@ mon_handler(int s, siginfo_t *info, void *context)
      * itself.  This can happen with, e.g., BSD-derived versions of
      * reboot that call kill(-1, SIGTERM) to kill all other processes.
      */
-    if (info != NULL && info->si_code == SI_USER) {
+    if (USER_SIGNALED(info)) {
        pid_t si_pgrp = getpgid(info->si_pid);
        if (si_pgrp != (pid_t)-1) {
            if (si_pgrp == cmnd_pgrp)
index 9be208e36d5f60a90fcc806585ef077ac17580e9..4c09e46492b811decfc95df69ffa2e0e8a86f435 100644 (file)
 # define MSG_WAITALL 0
 #endif
 
+/*
+ * Some older systems support siginfo but predate SI_USER.
+ */
+#ifdef SA_SIGINFO
+# ifdef SI_USER
+#  define USER_SIGNALED(_info) ((_info) != NULL && (_info)->si_code == SI_USER)
+# else
+#  define USER_SIGNALED(_info) ((_info) != NULL && (_info)->si_code <= 0)
+# endif
+#endif
+
 /*
  * Special values to indicate whether continuing in foreground or background.
  */