service: FileDescriptorStoreMax should also imply NotifyAccess
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Mon, 14 May 2018 14:45:09 +0000 (15:45 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 15 May 2018 10:33:56 +0000 (12:33 +0200)
Commenting out "WatchdogTimeout=3min" in systemd-logind.service causes
NotifyAccess to go from "main" to "none", breaking support for logind
restart.  Let's fix that.

man/systemd.service.xml
src/core/service.c

index 03c7b01..e200bef 100644 (file)
         passed to the service manager from a specific service are passed back to the service's main process on the next
         service restart. Any file descriptors passed to the service manager are automatically closed when
         <constant>POLLHUP</constant> or <constant>POLLERR</constant> is seen on them, or when the service is fully
-        stopped and no job is queued or being executed for it.</para></listitem>
+        stopped and no job is queued or being executed for it. If this option is used, <varname>NotifyAccess=</varname>
+        (see above) should be set to open access to the notification socket provided by systemd. If
+        <varname>NotifyAccess=</varname> is not set, it will be implicitly set to
+        <option>main</option>.</para></listitem>
       </varlistentry>
 
       <varlistentry>
index bf4f278..1af3032 100644 (file)
@@ -715,10 +715,9 @@ static int service_add_extras(Service *s) {
         if (r < 0)
                 return r;
 
-        if (s->type == SERVICE_NOTIFY && s->notify_access == NOTIFY_NONE)
-                s->notify_access = NOTIFY_MAIN;
-
-        if (s->watchdog_usec > 0 && s->notify_access == NOTIFY_NONE)
+        /* If the service needs the notify socket, let's enable it automatically. */
+        if (s->notify_access == NOTIFY_NONE &&
+            (s->type == SERVICE_NOTIFY || s->watchdog_usec > 0 || s->n_fd_store_max > 0))
                 s->notify_access = NOTIFY_MAIN;
 
         r = service_add_default_dependencies(s);