]> 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:09:15 +0000 (15:09 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 14 Jun 2010 19:09:15 +0000 (15:09 -0400)
from error()/errorx()

src/exec_pty.c
src/selinux.c

index 9e960f55d6a2bb9346129e94fe56f8518316153f..232da0654f2f2ef1b216293ae82a5f5d9f66b12b 100644 (file)
@@ -121,6 +121,9 @@ cleanup(int gotsignal)
 {
     if (!tq_empty(&io_plugins))
        term_restore(io_fds[SFD_USERTTY], 0);
+#ifdef HAVE_SELINUX
+    selinux_restore_tty();
+#endif
 }
 
 /*
index 0c70710eab1efaf32470274fdadfb7b2c2f0dc09..3a40d5a3baf259d9c098aad69d1f8c17c04aeaf8 100644 (file)
@@ -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;
 }