summaryrefslogtreecommitdiffstats
path: root/misc-utils/uuidd.c
diff options
context:
space:
mode:
authorTheodore Ts'o2009-07-01 04:47:54 +0200
committerTheodore Ts'o2009-07-01 05:26:09 +0200
commitfdb3e93ce907cce3a2133f22bb780ecb317af76a (patch)
treee29e24bc33a24c37b1f56e9106bfb85abdc0a996 /misc-utils/uuidd.c
parentlibuuid: Make sure fd's 0, 1, and 2 are valid before exec'ing uuidd (diff)
downloadkernel-qcow2-util-linux-fdb3e93ce907cce3a2133f22bb780ecb317af76a.tar.gz
kernel-qcow2-util-linux-fdb3e93ce907cce3a2133f22bb780ecb317af76a.tar.xz
kernel-qcow2-util-linux-fdb3e93ce907cce3a2133f22bb780ecb317af76a.zip
uuidd: Avoid closing the server socket when calling create_daemon()
In the event that file descriptors 0-2 are closed when uuidd is started, the server socket could be created as a file descriptor that will get closed when create_daemon() tries detaching the uuidd daemon from its controlling tty. Avoid this case by using dup(2). Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'misc-utils/uuidd.c')
-rw-r--r--misc-utils/uuidd.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index 5e597833e..428445718 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -275,6 +275,18 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
}
/*
+ * Make sure the socket isn't using fd numbers 0-2 to avoid it
+ * getting closed by create_daemon()
+ */
+ while (!debug && s <= 2) {
+ s = dup(s);
+ if (s < 0) {
+ perror("dup");
+ exit(1);
+ }
+ }
+
+ /*
* Create the address we will be binding to.
*/
my_addr.sun_family = AF_UNIX;