From: Todd C. Miller Date: Mon, 14 Jun 2010 19:06:39 +0000 (-0400) Subject: Call selinux_restore_tty() as part of cleanup() so it gets called X-Git-Tag: SUDO_1_7_3~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b78de8e0f81d494eed3a617cec6c1fa0cbbd963;p=sudo Call selinux_restore_tty() as part of cleanup() so it gets called from error()/errorx() --HG-- branch : 1.7 --- diff --git a/selinux.c b/selinux.c index a423aa9c7..de3c43eeb 100644 --- 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 6cbb198cc..c54f6a22d 100644 --- 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