]> granicus.if.org Git - sudo/commitdiff
Call selinux_restore_tty() as part of cleanup() so it gets called
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 14 Jun 2010 19:06:39 +0000 (15:06 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 14 Jun 2010 19:06:39 +0000 (15:06 -0400)
from error()/errorx()

--HG--
branch : 1.7

selinux.c
sudo.c

index a423aa9c79dbf61bdf3b754cf552dfac80d9682d..de3c43eeb096e8a0f2a2bb2c88f5fdf52d2920d0 100644 (file)
--- a/selinux.c
+++ b/selinux.c
@@ -66,7 +66,6 @@ static struct selinux_state {
  *
  * Returns zero on success, non-zero otherwise
  */
-/* XXX - should also be called as part of cleanup() */
 int
 selinux_restore_tty(void)
 {
@@ -91,9 +90,14 @@ selinux_restore_tty(void)
        warning("unable to restore context for %s", se_state.ttyn);
 
 skip_relabel:
-    if (se_state.ttyfd != -1)
+    if (se_state.ttyfd != -1) {
        close(se_state.ttyfd);
-    freecon(chk_tty_context);
+       se_state.ttyfd = -1;
+    }
+    if (chk_tty_context != NULL) {
+       freecon(chk_tty_context);
+       chk_tty_context = NULL;
+    }
     return retval;
 }
 
diff --git a/sudo.c b/sudo.c
index 6cbb198ccd0be29badc369484be1f9bae11404ee..c54f6a22daf0ac4b54bbffba008585322d5c547b 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -1293,6 +1293,9 @@ cleanup(gotsignal)
 #endif
     }
     term_restore(STDIN_FILENO, 0);
+#ifdef HAVE_SELINUX
+    selinux_restore_tty();
+#endif
 }
 
 static void