[systemd-commits] 2 commits - src/core src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Dec 24 16:30:00 PST 2013
src/core/service.c | 19 +++++++++++++++++++
src/shared/socket-util.c | 10 +++-------
2 files changed, 22 insertions(+), 7 deletions(-)
New commits:
commit 33649f58afe3e8b09580719fc16eca249d0efffc
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Dec 24 21:24:06 2013 +0100
shared: fix getpeername_pretty() for AF_UNIX sockets
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 4700b3b..6d9c303 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -594,7 +594,7 @@ int getpeername_pretty(int fd, char **ret) {
if (r < 0)
return r;
- if (asprintf(ret, "PID %lu/UID %lu", (unsigned long) ucred.pid, (unsigned long) ucred.pid) < 0)
+ if (asprintf(ret, "PID %lu/UID %lu", (unsigned long) ucred.pid, (unsigned long) ucred.uid) < 0)
return -ENOMEM;
return 0;
commit 79a98c609da042c60260e8e0236464014d480dcb
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Dec 24 21:18:21 2013 +0100
unit: include peer identity in description of per-connection socket-activated services
diff --git a/src/core/service.c b/src/core/service.c
index 4eb3d9e..8097e26 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -3656,6 +3656,8 @@ static void service_bus_name_owner_change(
}
int service_set_socket_fd(Service *s, int fd, Socket *sock) {
+ _cleanup_free_ char *peer = NULL;
+ int r;
assert(s);
assert(fd >= 0);
@@ -3673,6 +3675,23 @@ int service_set_socket_fd(Service *s, int fd, Socket *sock) {
if (s->state != SERVICE_DEAD)
return -EAGAIN;
+ if (getpeername_pretty(fd, &peer) >= 0) {
+
+ if (UNIT(s)->description) {
+ _cleanup_free_ char *a;
+
+ a = strjoin(UNIT(s)->description, " (", peer, ")", NULL);
+ if (!a)
+ return -ENOMEM;
+
+ r = unit_set_description(UNIT(s), a);
+ } else
+ r = unit_set_description(UNIT(s), peer);
+
+ if (r < 0)
+ return r;
+ }
+
s->socket_fd = fd;
unit_ref_set(&s->accept_socket, UNIT(sock));
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 45ada7e..4700b3b 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -422,8 +422,7 @@ const char* socket_address_get_path(const SocketAddress *a) {
}
bool socket_ipv6_is_supported(void) {
- char *l = 0;
- bool enabled;
+ _cleanup_free_ char *l = NULL;
if (access("/sys/module/ipv6", F_OK) != 0)
return 0;
@@ -433,10 +432,7 @@ bool socket_ipv6_is_supported(void) {
return 1;
/* If module was loaded with disable=1 no IPv6 available */
- enabled = l[0] == '0';
- free(l);
-
- return enabled;
+ return l[0] == '0';
}
bool socket_address_matches_fd(const SocketAddress *a, int fd) {
More information about the systemd-commits
mailing list