diff options
Diffstat (limited to 'src/bus-proxyd/bus-proxyd.c')
-rw-r--r-- | src/bus-proxyd/bus-proxyd.c | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index b87dffe0e8..60490d5166 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -358,40 +358,6 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hell return 1; } -static int getpeersec(int fd, char **ret) { - socklen_t n = 64; - char *s; - int r; - - assert(fd >= 0); - assert(ret); - - s = new0(char, n); - if (!s) - return -ENOMEM; - - r = getsockopt(fd, SOL_SOCKET, SO_PEERSEC, s, &n); - if (r < 0) { - free(s); - - if (errno != ERANGE) - return r; - - s = new0(char, n); - if (!s) - return -ENOMEM; - - r = getsockopt(fd, SOL_SOCKET, SO_PEERSEC, s, &n); - if (r < 0) { - free(s); - return r; - } - } - - *ret = s; - return 0; -} - int main(int argc, char *argv[]) { _cleanup_bus_unref_ sd_bus *a = NULL, *b = NULL; @@ -427,16 +393,7 @@ int main(int argc, char *argv[]) { sd_is_socket(out_fd, AF_UNIX, 0, 0) > 0; if (is_unix) { - socklen_t l = sizeof(ucred); - - r = getsockopt(in_fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l); - if (r < 0) { - r = -errno; - goto finish; - } - - assert(l == sizeof(ucred)); - + getpeercred(in_fd, &ucred); getpeersec(in_fd, &peersec); } |