diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-24 15:53:04 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-24 15:53:04 +0100 |
commit | eff05270986a13e7de93ae16311f654d3f7c166f (patch) | |
tree | c5c7d7c456f8a8b9d3e75cb9e36b5974215003ed /src/libsystemd-bus/bus-socket.c | |
parent | 96415cad2fdd8d280ae94b02651b5f826a2f7f3d (diff) |
util: unify SO_PEERCRED/SO_PEERSEC invocations
Introduce new call getpeercred() which internally just uses SO_PEERCRED
but checks if the returned data is actually useful due to namespace
quirks.
Diffstat (limited to 'src/libsystemd-bus/bus-socket.c')
-rw-r--r-- | src/libsystemd-bus/bus-socket.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c index 66924b29fa..0c4b6af447 100644 --- a/src/libsystemd-bus/bus-socket.c +++ b/src/libsystemd-bus/bus-socket.c @@ -625,14 +625,10 @@ void bus_socket_setup(sd_bus *b) { } static void bus_get_peercred(sd_bus *b) { - socklen_t l; - 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) { |