chiark / gitweb /
util: unify SO_PEERCRED/SO_PEERSEC invocations
[elogind.git] / src / libsystemd-bus / bus-socket.c
index 66924b29fac639bd523378b58c6ca9ae57d7b598..0c4b6af447297fbe8f1e348f096df36d879f37d9 100644 (file)
@@ -625,14 +625,10 @@ void bus_socket_setup(sd_bus *b) {
 }
 
 static void bus_get_peercred(sd_bus *b) {
 }
 
 static void bus_get_peercred(sd_bus *b) {
-        socklen_t l;
-
         assert(b);
 
         /* Get the peer for socketpair() sockets */
         assert(b);
 
         /* Get the peer for socketpair() sockets */
-        l = sizeof(b->ucred);
-        if (getsockopt(b->input_fd, SOL_SOCKET, SO_PEERCRED, &b->ucred, &l) >= 0 && l >= sizeof(b->ucred))
-                b->ucred_valid = b->ucred.pid > 0;
+        b->ucred_valid = getpeercred(b->input_fd, &b->ucred) >= 0;
 }
 
 static int bus_socket_start_auth_client(sd_bus *b) {
 }
 
 static int bus_socket_start_auth_client(sd_bus *b) {