summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-06-11 12:47:00 +0200
committerStephen Gallagher <sgallagh@redhat.com>2010-06-14 16:54:42 -0400
commitc4dcc8413f6de1714227f8dc2f3e1558f8ab75fa (patch)
tree4218a656060731a1348a066790c4eef73c0bc3eb
parent75392c5a8a896f0c300b3bc837859616b27daeb6 (diff)
downloadsssd-c4dcc8413f6de1714227f8dc2f3e1558f8ab75fa.tar.gz
sssd-c4dcc8413f6de1714227f8dc2f3e1558f8ab75fa.tar.xz
sssd-c4dcc8413f6de1714227f8dc2f3e1558f8ab75fa.zip
get_uid_from_pid should use fstat rather than lstat
Fixes: #541
-rw-r--r--src/util/find_uid.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/util/find_uid.c b/src/util/find_uid.c
index 06c65dbc0..6f43ac388 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;