summaryrefslogtreecommitdiff
path: root/src/core/socket.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-24 15:53:04 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-24 15:53:04 +0100
commiteff05270986a13e7de93ae16311f654d3f7c166f (patch)
treec5c7d7c456f8a8b9d3e75cb9e36b5974215003ed /src/core/socket.c
parent96415cad2fdd8d280ae94b02651b5f826a2f7f3d (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/core/socket.c')
-rw-r--r--src/core/socket.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 31fc2a2526..88599ca9c1 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -671,10 +671,11 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) {
case AF_UNIX: {
struct ucred ucred;
+ int k;
- l = sizeof(ucred);
- if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l) < 0)
- return -errno;
+ k = getpeercred(fd, &ucred);
+ if (k < 0)
+ return k;
if (asprintf(&r,
"%u-%lu-%lu",