diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/socket.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/core/socket.c b/src/core/socket.c index d57e7701ca..7c18a2b75c 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -663,21 +663,17 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) { int k; k = getpeercred(fd, &ucred); - if (k >= 0) { - if (asprintf(&r, - "%u-"PID_FMT"-"UID_FMT, - nr, ucred.pid, ucred.uid) < 0) - return -ENOMEM; - } else if (k == -ENODATA) { - /* This handles the case where somebody is - * connecting from another pid/uid namespace - * (e.g. from outside of our container). */ - if (asprintf(&r, - "%u-unknown", - nr) < 0) - return -ENOMEM; - } else + if (k < 0) return k; + + if (asprintf(&r, + "%u-%lu-%lu", + nr, + (unsigned long) ucred.pid, + (unsigned long) ucred.uid) < 0) + return -ENOMEM; + + break; } default: |