summaryrefslogtreecommitdiff
path: root/src/shared/bus-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-30 15:20:38 +0100
committerLennart Poettering <lennart@poettering.net>2018-01-04 13:28:24 +0100
commit3e641e361d8b62923bea3cd9786dbd5cfba26b89 (patch)
treea226df046b102d773faeb3948601340ac049109c /src/shared/bus-util.c
parent86ed6d1b1f68db45afc87a29c17ca0065e84cdab (diff)
downloadsystemd-3e641e361d8b62923bea3cd9786dbd5cfba26b89.tar.gz
sd-bus: port one use of SO_PEERCRED by getpeercred()
Diffstat (limited to 'src/shared/bus-util.c')
-rw-r--r--src/shared/bus-util.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 7a185461a3..50731fa5ff 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -560,8 +560,7 @@ void bus_verify_polkit_async_registry_free(Hashmap *registry) {
int bus_check_peercred(sd_bus *c) {
struct ucred ucred;
- socklen_t l;
- int fd;
+ int fd, r;
assert(c);
@@ -569,12 +568,9 @@ int bus_check_peercred(sd_bus *c) {
if (fd < 0)
return fd;
- l = sizeof(struct ucred);
- if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l) < 0)
- return -errno;
-
- if (l != sizeof(struct ucred))
- return -E2BIG;
+ r = getpeercred(fd, &ucred);
+ if (r < 0)
+ return r;
if (ucred.uid != 0 && ucred.uid != geteuid())
return -EPERM;