X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fservice.c;h=8097e26b0034bac306813b92d4e26815ad8e7d6d;hp=87eaa29378b369a19c4cf462588e4adf6a90be55;hb=79a98c609da042c60260e8e0236464014d480dcb;hpb=aec8de63b14a93b91b85dc15bf879604352fbbe1 diff --git a/src/core/service.c b/src/core/service.c index 87eaa2937..8097e26b0 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1750,7 +1750,7 @@ static int service_spawn( if (r < 0) goto fail; - our_env = new0(char*, 5); + our_env = new0(char*, 4); if (!our_env) { r = -ENOMEM; goto fail; @@ -1768,12 +1768,6 @@ static int service_spawn( goto fail; } - if (s->watchdog_usec > 0) - if (asprintf(our_env + n_env++, "WATCHDOG_USEC=%llu", (unsigned long long) s->watchdog_usec) < 0) { - r = -ENOMEM; - goto fail; - } - if (UNIT(s)->manager->running_as != SYSTEMD_SYSTEM) if (asprintf(our_env + n_env++, "MANAGERPID=%lu", (unsigned long) getpid()) < 0) { r = -ENOMEM; @@ -1804,6 +1798,7 @@ static int service_spawn( UNIT(s)->manager->cgroup_supported, path, UNIT(s)->id, + s->watchdog_usec, s->type == SERVICE_IDLE ? UNIT(s)->manager->idle_pipe : NULL, s->exec_runtime, &pid); @@ -3661,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); @@ -3678,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));