diff options
Diffstat (limited to 'libselinux/src/procattr.c')
-rw-r--r-- | libselinux/src/procattr.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c index f9903505..e444571c 100644 --- a/libselinux/src/procattr.c +++ b/libselinux/src/procattr.c @@ -95,6 +95,12 @@ static int openattr(pid_t pid, const char *attr, int flags) if (pid > 0) rc = asprintf(&path, "/proc/%d/attr/%s", pid, attr); else { + rc = asprintf(&path, "/proc/thread-self/attr/%s", attr); + if (rc < 0) + return -1; + fd = open(path, flags | O_CLOEXEC); + if (fd >= 0 || errno != ENOENT) + goto out; if (!tid) tid = gettid(); rc = asprintf(&path, "/proc/self/task/%d/attr/%s", tid, attr); @@ -103,6 +109,7 @@ static int openattr(pid_t pid, const char *attr, int flags) return -1; fd = open(path, flags | O_CLOEXEC); +out: free(path); return fd; } |