[systemd-devel] [PATCH] Set $NOTIFY_SOCKET for control procs if NotifyAccess=all

Brandon L Black blblack at gmail.com
Sat Oct 11 15:13:40 PDT 2014


---
 TODO               |  2 --
 src/core/service.c | 13 ++++---------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/TODO b/TODO
index 69ed60e..05a61a3 100644
--- a/TODO
+++ b/TODO
@@ -167,8 +167,6 @@ Features:
 
 * journalctl: add the ability to look for the most recent process of a binary. journalctl /usr/bin/X11 --pid=-1 or so...
 
-* set NOTIFY_SOCKET also for control processes
-
 * mount_cgroup_controllers(): symlinks need to get the label applied
 
 * For timer units: add some mechanisms so that timer units that trigger immediately on boot do not have the services
diff --git a/src/core/service.c b/src/core/service.c
index f551061..cb8b76d 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -883,7 +883,6 @@ static int service_spawn(
                 bool apply_permissions,
                 bool apply_chroot,
                 bool apply_tty_stdin,
-                bool set_notify_socket,
                 bool is_control,
                 pid_t *_pid) {
 
@@ -948,6 +947,10 @@ static int service_spawn(
                 goto fail;
         }
 
+        const bool set_notify_socket = is_control
+                ? s->notify_access == NOTIFY_ALL
+                : s->notify_access != NOTIFY_NONE;
+
         if (set_notify_socket)
                 if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=%s", UNIT(s)->manager->notify_socket) < 0) {
                         r = -ENOMEM;
@@ -1153,7 +1156,6 @@ static void service_enter_stop_post(Service *s, ServiceResult f) {
                                   !s->permissions_start_only,
                                   !s->root_directory_start_only,
                                   true,
-                                  false,
                                   true,
                                   &s->control_pid);
                 if (r < 0)
@@ -1253,7 +1255,6 @@ static void service_enter_stop(Service *s, ServiceResult f) {
                                   !s->permissions_start_only,
                                   !s->root_directory_start_only,
                                   false,
-                                  false,
                                   true,
                                   &s->control_pid);
                 if (r < 0)
@@ -1316,7 +1317,6 @@ static void service_enter_start_post(Service *s) {
                                   !s->permissions_start_only,
                                   !s->root_directory_start_only,
                                   false,
-                                  false,
                                   true,
                                   &s->control_pid);
                 if (r < 0)
@@ -1383,7 +1383,6 @@ static void service_enter_start(Service *s) {
                           true,
                           true,
                           true,
-                          s->notify_access != NOTIFY_NONE,
                           false,
                           &pid);
         if (r < 0)
@@ -1449,7 +1448,6 @@ static void service_enter_start_pre(Service *s) {
                                   !s->permissions_start_only,
                                   !s->root_directory_start_only,
                                   true,
-                                  false,
                                   true,
                                   &s->control_pid);
                 if (r < 0)
@@ -1530,7 +1528,6 @@ static void service_enter_reload(Service *s) {
                                   !s->permissions_start_only,
                                   !s->root_directory_start_only,
                                   false,
-                                  false,
                                   true,
                                   &s->control_pid);
                 if (r < 0)
@@ -1568,7 +1565,6 @@ static void service_run_next_control(Service *s) {
                           !s->root_directory_start_only,
                           s->control_command_id == SERVICE_EXEC_START_PRE ||
                           s->control_command_id == SERVICE_EXEC_STOP_POST,
-                          false,
                           true,
                           &s->control_pid);
         if (r < 0)
@@ -1611,7 +1607,6 @@ static void service_run_next_main(Service *s) {
                           true,
                           true,
                           true,
-                          s->notify_access != NOTIFY_NONE,
                           false,
                           &pid);
         if (r < 0)
-- 
1.9.3



More information about the systemd-devel mailing list