summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-31 20:19:44 +0200
committerLennart Poettering <lennart@poettering.net>2013-04-01 03:29:29 +0200
commit9ab32f9daa9601250f183a694586712654be2ffe (patch)
treedc9a02775d360a39ac3d8c83b0469fa1f04d24b1
parent15d5af8145a36194385b4558eeeef91512f2151e (diff)
bus: reuse sd_is_socket() call
-rw-r--r--Makefile.am3
-rw-r--r--src/libsystemd-bus/bus-socket.c15
2 files changed, 6 insertions, 12 deletions
diff --git a/Makefile.am b/Makefile.am
index ef13ad20ba..2a2a9fe2ed 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1689,7 +1689,8 @@ libsystemd_bus_la_SOURCES = \
libsystemd_bus_la_LIBADD = \
libsystemd-id128-internal.la \
- libsystemd-shared.la
+ libsystemd-shared.la \
+ libsystemd-daemon.la
noinst_LTLIBRARIES += \
libsystemd-bus.la
diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c
index ce6af49b26..b9ef7c0372 100644
--- a/src/libsystemd-bus/bus-socket.c
+++ b/src/libsystemd-bus/bus-socket.c
@@ -31,6 +31,7 @@
#include "missing.h"
#include "strv.h"
#include "utf8.h"
+#include "sd-daemon.h"
#include "sd-bus.h"
#include "bus-socket.h"
@@ -589,25 +590,17 @@ static int bus_socket_start_auth_client(sd_bus *b) {
}
static int bus_socket_start_auth(sd_bus *b) {
- int domain = 0, r;
- socklen_t sl;
-
assert(b);
b->state = BUS_AUTHENTICATING;
b->auth_timeout = now(CLOCK_MONOTONIC) + BUS_DEFAULT_TIMEOUT;
- sl = sizeof(domain);
- r = getsockopt(b->input_fd, SOL_SOCKET, SO_DOMAIN, &domain, &sl);
- if (r < 0 || domain != AF_UNIX)
+ if (sd_is_socket(b->input_fd, AF_UNIX, 0, 0) <= 0)
b->negotiate_fds = false;
- if (b->output_fd != b->input_fd) {
- r = getsockopt(b->output_fd, SOL_SOCKET, SO_DOMAIN, &domain, &sl);
- if (r < 0 || domain != AF_UNIX)
+ if (b->output_fd != b->input_fd)
+ if (sd_is_socket(b->output_fd, AF_UNIX, 0, 0) <= 0)
b->negotiate_fds = false;
- }
-
if (b->is_server)
return bus_socket_read_auth(b);