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
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:49:53 +0200
commitb3c9c3b4ea5bcd877602aa66884809e0ab1a7d76 (patch)
tree7e0beca33ab4f804182937b887bb546a57f78018 /src/shared/bus-util.c
parent1f0774088c4d371a570f7ca2fcb4722c46255e6d (diff)
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 a4e0ec105..eb953b9bb 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -563,8 +563,7 @@ void bus_verify_polkit_async_registry_free(Hashmap *registry) {
#if 0 /// UNNEEDED by elogind
int bus_check_peercred(sd_bus *c) {
struct ucred ucred;
- socklen_t l;
- int fd;
+ int fd, r;
assert(c);
@@ -572,12 +571,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;