]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libuuid: don't exec uuidd
authorPetr Uzel <petr.uzel@suse.cz>
Thu, 3 May 2012 19:01:59 +0000 (21:01 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 4 May 2012 13:14:18 +0000 (15:14 +0200)
Executing the daemon from the shared library is not quite elegant
solution. Drop this functionality and require uuidd (should it be
needed) to be started from the initscript or by socket-activation.

References: http://www.spinics.net/lists/util-linux-ng/msg05967.html

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
libuuid/src/Makefile.am
libuuid/src/gen_uuid.c

index 1df282ede59cca35c79ef14912f08ae878bf6d1d..8e872100bb489edcbb3f1760dfaece5be8e30295 100644 (file)
@@ -26,7 +26,6 @@ libuuid_la_SOURCES = \
        uuidP.h \
        uuid_time.c \
        $(uuidinc_HEADERS) \
-       $(top_srcdir)/lib/fileutils.c \
        $(top_srcdir)/lib/randutils.c
 
 libuuid_la_DEPENDENCIES = uuid.sym
index 8c102b1e29b06188b7eb5c5059ba62b3ebccadc5..8ff41291c4f0a9dceececd35fcea36f5ca78eac7 100644 (file)
@@ -58,7 +58,6 @@
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
-#include <sys/wait.h>
 #include <sys/stat.h>
 #ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
 #if defined(__linux__) && defined(HAVE_SYS_SYSCALL_H)
 #include <sys/syscall.h>
 #endif
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
 
 #include "uuidP.h"
 #include "uuidd.h"
 #include "randutils.h"
-#include "fileutils.h"
 
 #ifdef HAVE_TLS
 #define THREAD_LOCAL static __thread
@@ -364,20 +359,6 @@ static ssize_t read_all(int fd, char *buf, size_t count)
        return c;
 }
 
-/*
- * Close all file descriptors
- */
-static void close_all_fds(void)
-{
-       int i, max = get_fd_tabsize();
-
-       for (i=0; i < max; i++) {
-               close(i);
-               if (i <= 2)
-                       open("/dev/null", O_RDWR);
-       }
-}
-
 /*
  * Try using the uuidd daemon to generate the UUID
  *
@@ -391,11 +372,6 @@ 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;
-       static int start_attempts = 0;
 
        if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
                return -1;
@@ -404,27 +380,9 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num)
        strcpy(srv_addr.sun_path, UUIDD_SOCKET_PATH);
 
        if (connect(s, (const struct sockaddr *) &srv_addr,
-                   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();
-                               execl(uuidd_path, "uuidd", "-qT", "300",
-                                     (char *) NULL);
-                               exit(EXIT_FAILURE);
-                       }
-                       (void) waitpid(pid, 0, 0);
-                       if (connect(s, (const struct sockaddr *) &srv_addr,
-                                   sizeof(struct sockaddr_un)) < 0)
-                               goto fail;
-               } else
-                       goto fail;
-       }
+                   sizeof(struct sockaddr_un)) < 0)
+               goto fail;
+
        op_buf[0] = op;
        op_len = 1;
        if (op == UUIDD_OP_BULK_TIME_UUID) {