diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2010-06-11 12:47:00 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-14 16:54:30 -0400 |
commit | 946aba311fd280fbd673944c0181063d2600c878 (patch) | |
tree | 163e58696f87a6dcf44db8d8d4a48cb590834d1f | |
parent | aacb25fadb202845d2ca109487bca7a639a0271d (diff) | |
download | sssd-946aba311fd280fbd673944c0181063d2600c878.tar.gz sssd-946aba311fd280fbd673944c0181063d2600c878.tar.bz2 sssd-946aba311fd280fbd673944c0181063d2600c878.zip |
get_uid_from_pid should use fstat rather than lstat
Fixes: #541
-rw-r--r-- | src/util/find_uid.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/util/find_uid.c b/src/util/find_uid.c index 06c65dbc..6f43ac38 100644 --- a/src/util/find_uid.c +++ b/src/util/find_uid.c @@ -75,35 +75,35 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid) return EINVAL; } - ret = lstat(path, &stat_buf); - if (ret == -1) { + fd = open(path, O_RDONLY); + if (fd == -1) { error = errno; if (error == ENOENT) { DEBUG(7, ("Proc file [%s] is not available anymore, continuing.\n", path)); return EOK; } - DEBUG(1, ("lstat failed [%d][%s].\n", error, strerror(error))); + DEBUG(1, ("open failed [%d][%s].\n", error, strerror(error))); return error; } - if (!S_ISREG(stat_buf.st_mode)) { - DEBUG(1, ("not a regular file\n")); - return EINVAL; - } - - fd = open(path, O_RDONLY); - if (fd == -1) { + ret = fstat(fd, &stat_buf); + if (ret == -1) { error = errno; if (error == ENOENT) { DEBUG(7, ("Proc file [%s] is not available anymore, continuing.\n", path)); return EOK; } - DEBUG(1, ("open failed [%d][%s].\n", error, strerror(error))); + DEBUG(1, ("fstat failed [%d][%s].\n", error, strerror(error))); return error; } + if (!S_ISREG(stat_buf.st_mode)) { + DEBUG(1, ("not a regular file\n")); + return EINVAL; + } + while ((ret = read(fd, buf, BUFSIZE)) != 0) { if (ret == -1) { error = errno; |