From 20a749bc11d5a5b10a7126cfec5b34d768bb8844 Mon Sep 17 00:00:00 2001 From: Alexey Lebedeff Date: Thu, 10 Mar 2016 17:51:09 +0300 Subject: [PATCH] Add sleep for non-root calls of `systemd-notify` Fixes #2379 Without `CAP_SYS_ADMIN` it's not possible to fake user credentials in `sd_pid_notify` call, and in this case everything depends on timing - whether systemd will be able to get the cgroup of sending process before it exists or not. Adding `sleep(3)` for non-root users will at least make `systemd-notify` useful for them. --- src/notify/notify.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/notify/notify.c b/src/notify/notify.c index 49f97c61d983d..e4c4912320ae0 100644 --- a/src/notify/notify.c +++ b/src/notify/notify.c @@ -199,5 +199,8 @@ int main(int argc, char* argv[]) { } finish: + if (getuid() && r >= 0) { + sleep(10); + } return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }