]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
uuidd: Avoid closing the server socket when calling create_daemon()
authorTheodore Ts'o <tytso@mit.edu>
Mon, 29 Jun 2009 23:32:50 +0000 (19:32 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 29 Jun 2009 23:32:50 +0000 (19:32 -0400)
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>
misc/uuidd.c

index e2d36565f7d885cc480b02be82a987f41811ecaf..6913bf7e2125eeb42030c5ea8bde351e30849f23 100644 (file)
@@ -275,6 +275,18 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
                exit(1);
        }
 
+       /*
+        * 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.
         */