]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: reload configuration when enabling sysv units too (#3297)
authorFranck Bui <fbui@suse.com>
Thu, 19 May 2016 14:37:04 +0000 (16:37 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 19 May 2016 14:37:04 +0000 (10:37 -0400)
After enabling/disabling a unit, the daemon configuration is expected
to be unless '--no-reload' option is passed.

However this is not done when enabling a sysv units. This can lead to
the following scenario:

   $ cp /etc/init.d/named /etc/init.d/foo
   $ systemctl enable foo
   foo.service is not a native service, redirecting to systemd-sysv-install
   Executing /usr/lib/systemd/systemd-sysv-install enable foo
   $ systemctl start foo
   Failed to start foo.service: Unit foo.service failed to load: No such file or directory.

This can also be seen after installing a package providing a sysv
service: the service can't be started unless 'daemon-reload' is called
manually. This shouldn't be needed and this patch will fix this case
too since during package installation, the service is expected to be
enabled/disabled.

src/systemctl/systemctl.c

index 3b4678c1190fbb5b8bbbc483ac017d8b742bea1a..fe24b936ec2abd14df448d340d35ac79ba78a4d2 100644 (file)
@@ -5478,8 +5478,11 @@ static int enable_unit(int argc, char *argv[], void *userdata) {
                 return r;
 
         /* If the operation was fully executed by the SysV compat, let's finish early */
-        if (strv_isempty(names))
-                return 0;
+        if (strv_isempty(names)) {
+                if (arg_no_reload || install_client_side())
+                        return 0;
+                return daemon_reload(argc, argv, userdata);
+        }
 
         if (install_client_side()) {
                 if (streq(verb, "enable")) {