summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-24 21:18:21 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-25 01:29:55 +0100
commit79a98c609da042c60260e8e0236464014d480dcb (patch)
tree41b2a3453324695917a55294743273711e51b80a /src/core
parentdb69869f264af2d1afcdd3e573e0e9fdd5bef065 (diff)
unit: include peer identity in description of per-connection socket-activated services
Diffstat (limited to 'src/core')
-rw-r--r--src/core/service.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/service.c b/src/core/service.c
index 4eb3d9e668..8097e26b00 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));