diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-06-30 22:36:28 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-06-30 22:36:28 -0400 |
commit | 3381a63c54f2221e3742211df39c5e2ee13d16cc (patch) | |
tree | 0ce4995d2a4422a83fc49a1e842a7a113d17f470 /lib/uuid/gen_uuid.c | |
parent | 6013bbf596fe7fc20e53d5c7fb5cc37e48cc0136 (diff) | |
download | e2fsprogs-3381a63c54f2221e3742211df39c5e2ee13d16cc.tar.gz |
libuuid: Don't run uuidd if it would fail due to permission problems
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>
Diffstat (limited to 'lib/uuid/gen_uuid.c')
-rw-r--r-- | lib/uuid/gen_uuid.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c index 5893aff3..420ca2b2 100644 --- a/lib/uuid/gen_uuid.c +++ b/lib/uuid/gen_uuid.c @@ -481,6 +481,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; @@ -496,6 +497,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(); |