[prev in list] [next in list] [prev in thread] [next in thread] 

List:       selinux
Subject:    [PATCH 49/63] policycoreutils: restorecond: make restorecond -u exit
From:       Daniel J Walsh <dwalsh () redhat ! com>
Date:       2011-11-01 19:57:18
Message-ID: 4EB04F1E.8030306 () redhat ! com
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


   This patch looks good to me. acked.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6wTx4ACgkQrlYvE4MpobPA6ACfZeAur5Hn/gSkFUJMOdtbCoGn
S1MAnjcUzDWIsSM+9POsRmRI4JxlxEVw
=273V
-----END PGP SIGNATURE-----

["0049-policycoreutils-restorecond-make-restorecond-u-exit-.patch" (text/plain)]

From 34999f94347fbececde40e562a6ac0656e464b66 Mon Sep 17 00:00:00 2001
From: Dan Walsh <dwalsh@redhat.com>
Date: Thu, 6 Oct 2011 16:05:03 -0400
Subject: [PATCH 49/63] policycoreutils: restorecond: make restorecond -u exit
 when terminal closes

Make restorecond -u watch the terminal io channel for and exit indicator
and then exit itself if it is not being run from dbus.  If being run
from dbus, dbus takes care of the session cleanup.

Signed-off-by: Eric Paris <eparis@redhat.com>
---
 policycoreutils/restorecond/user.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/policycoreutils/restorecond/user.c b/policycoreutils/restorecond/user.c
index ade3fb8..4257058 100644
--- a/policycoreutils/restorecond/user.c
+++ b/policycoreutils/restorecond/user.c
@@ -123,6 +123,11 @@ io_channel_callback
        sizeof (buffer),
        &bytes_read);
 
+    if (! bytes_read) {
+	    /* Sesssion/Terminal Ended */
+	    exit(0);
+    }
+
     while (i < bytes_read) {
 	    struct inotify_event *event;
 	    event = (struct inotify_event *)&buffer[i];
@@ -148,6 +153,7 @@ io_channel_callback
 
   if (condition & G_IO_HUP) {
     g_io_channel_close (source);
+    exit(0);
     return FALSE;
   }
 
@@ -210,6 +216,13 @@ static int local_server() {
 			perror("flock");
 		return -1;
 	}
+	/* watch for stdin/terminal going away */
+	GIOChannel *in = g_io_channel_unix_new(0);
+	g_io_add_watch_full( in,
+			     G_PRIORITY_HIGH,
+			     G_IO_IN|G_IO_ERR|G_IO_HUP,
+			     io_channel_callback, NULL, NULL);
+
 	return 0;
 }
 
@@ -221,7 +234,7 @@ int server(int master_fd, const char *watch_file) {
 #ifdef HAVE_DBUS
     if (dbus_server(loop) != 0)
 #endif /* HAVE_DBUS */
-	    if (local_server(loop))
+	    if (local_server())
 		    goto end;
 
     read_config(master_fd, watch_file);
-- 
1.7.7


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic