]> err.no Git - util-linux/commitdiff
libuuid: Don't run uuidd if it would fail due to permission problems
authorTheodore Ts'o <tytso@mit.edu>
Wed, 1 Jul 2009 03:06:44 +0000 (23:06 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 1 Jul 2009 03:26:09 +0000 (23:26 -0400)
Some distributions don't like installing uuidd setuid or setgid.  So
if the setuid or setigid bit is not set with uuidd, and the current
process does not have write access to the UUIDD work directory, don't
try running uuidd, since it won't work properly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
shlibs/uuid/src/gen_uuid.c
shlibs/uuid/src/uuidd.h

index 13096c0d29644fbf2bb1bd7b49f6791e4d9d2a34..8bb29f38dbe1b4adaa792c9a591fedeb0847aa43 100644 (file)
@@ -485,6 +485,7 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num)
        ssize_t ret;
        int32_t reply_len = 0, expected = 16;
        struct sockaddr_un srv_addr;
+       struct stat st;
        pid_t pid;
        static const char *uuidd_path = UUIDD_PATH;
        static int access_ret = -2;
@@ -500,6 +501,10 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num)
                    sizeof(struct sockaddr_un)) < 0) {
                if (access_ret == -2)
                        access_ret = access(uuidd_path, X_OK);
+               if (access_ret == 0)
+                       access_ret = stat(uuidd_path, &st);
+               if (access_ret == 0 && (st.st_mode & (S_ISUID | S_ISGID)) == 0)
+                       access_ret = access(UUIDD_DIR, W_OK);
                if (access_ret == 0 && start_attempts++ < 5) {
                        if ((pid = fork()) == 0) {
                                close_all_fds();
index c80723613fcc8df22912bfb9690a319b78aee1b5..68ee0e5c6449c2893dd0b1ddd0a376744f354bb0 100644 (file)
@@ -35,8 +35,9 @@
 #ifndef _UUID_UUIDD_H
 #define _UUID_UUIDD_H
 
-#define UUIDD_SOCKET_PATH      "/var/run/uuidd/request"
-#define UUIDD_PIDFILE_PATH     "/var/run/uuidd/uuidd.pid"
+#define UUIDD_DIR              "/var/run/uuidd"
+#define UUIDD_SOCKET_PATH      UUIDD_DIR "/request"
+#define UUIDD_PIDFILE_PATH     UUIDD_DIR "/uuidd.pid"
 #define UUIDD_PATH             "/usr/sbin/uuidd"
 
 #define UUIDD_OP_GETPID                        0