Control: tags -1 patch fixed-upstream

On ven, set 20, 2013 at 05:03:03 +0200, Michael Biebl wrote:
> Package: systemd
> Version: 204-4
> Severity: normal
> 
> root@pluto:~# find /etc/systemd/ -name "*syslog*"
> /etc/systemd/system/multi-user.target.wants/rsyslog.service
> /etc/systemd/system/syslog.service
> root@pluto:~# systemctl disable rsyslog
> Synchronizing state for rsyslog with sysvinit using update-rc.d...
> Executing /usr/sbin/update-rc.d rsyslog disable
> insserv: warning: current start runlevel(s) (empty) of script `rsyslog' 
> overrides LSB defaults (2 3 4 5).
> insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script 
> `rsyslog' overrides LSB defaults (0 1 6).
> root@pluto:~# find /etc/systemd/ -name "*syslog*"
> /etc/systemd/system/syslog.service
> 
> 
> Interestingly, using "systemctl disable rsyslog.service", the
> syslog.service is correctly removed on disable.
> Not quite sure if this is a bug in our SysV synchronization code or an
> upstream issue.

The problem seems to be that "rsyslog" is not recognized as a systemd unit
because it lacks the ".service" suffix, so systemctl only disables the sysv
unit.

I dug through the upstream repository and I found this commit [0] which, at
first glance, seems to be what's needed here (basically that "mangle_names()"
function is what adds the ".service" suffix if it's not present).

The upstream patch doesn't work as-is though, because there have been other
changes before that, so I modified it a little bit (see attachment) and
verified that it works with systemd v204. I don't know if it has any bad side
effect though, so more testing is advised.

Cheers

[0] http://cgit.freedesktop.org/systemd/systemd/commit/?id=3a05c0f9

-- 
perl -E '$_=q;$/= @{[@_]};and s;\S+;<inidehG ordnasselA>;eg;say~~reverse'
From 8021d755f29e56d58248f274d027434a90ae4889 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=A1clav=20Pavl=C3=ADn?= <[email protected]>
Date: Fri, 17 May 2013 14:03:36 +0000
Subject: [PATCH] systemctl: mangle names when avoiding dbus

Unit names were mangled in function enable_unit only when dbus was
used. This patch adds mangling also when the dbus is not in use.

This makes it possible to say e.g.:
   systemctl --root=/path enable cups
without spelling cups.service out in full.
---
 src/systemctl/systemctl.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 3cca861..18df5c5 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4208,33 +4208,37 @@ static int enable_unit(DBusConnection *bus, char **args) {
         _cleanup_dbus_error_free_ DBusError error;
         _cleanup_strv_free_ char **mangled_names = NULL;
 
-        dbus_error_init(&error);
+        if (!args[1])
+                return 0;
+
+        r = mangle_names(args+1, &mangled_names);
+        if (r < 0)
+                goto finish;
 
         r = enable_sysv_units(args);
         if (r < 0)
                 return r;
 
-        if (!args[1])
-                return 0;
+        dbus_error_init(&error);
 
         if (!bus || avoid_bus()) {
                 if (streq(verb, "enable")) {
-                        r = unit_file_enable(arg_scope, arg_runtime, arg_root, args+1, arg_force, &changes, &n_changes);
+                        r = unit_file_enable(arg_scope, arg_runtime, arg_root, mangled_names, arg_force, &changes, &n_changes);
                         carries_install_info = r;
                 } else if (streq(verb, "disable"))
-                        r = unit_file_disable(arg_scope, arg_runtime, arg_root, args+1, &changes, &n_changes);
+                        r = unit_file_disable(arg_scope, arg_runtime, arg_root, mangled_names, &changes, &n_changes);
                 else if (streq(verb, "reenable")) {
-                        r = unit_file_reenable(arg_scope, arg_runtime, arg_root, args+1, arg_force, &changes, &n_changes);
+                        r = unit_file_reenable(arg_scope, arg_runtime, arg_root, mangled_names, arg_force, &changes, &n_changes);
                         carries_install_info = r;
                 } else if (streq(verb, "link"))
-                        r = unit_file_link(arg_scope, arg_runtime, arg_root, args+1, arg_force, &changes, &n_changes);
+                        r = unit_file_link(arg_scope, arg_runtime, arg_root, mangled_names, arg_force, &changes, &n_changes);
                 else if (streq(verb, "preset")) {
-                        r = unit_file_preset(arg_scope, arg_runtime, arg_root, args+1, arg_force, &changes, &n_changes);
+                        r = unit_file_preset(arg_scope, arg_runtime, arg_root, mangled_names, arg_force, &changes, &n_changes);
                         carries_install_info = r;
                 } else if (streq(verb, "mask"))
-                        r = unit_file_mask(arg_scope, arg_runtime, arg_root, args+1, arg_force, &changes, &n_changes);
+                        r = unit_file_mask(arg_scope, arg_runtime, arg_root, mangled_names, arg_force, &changes, &n_changes);
                 else if (streq(verb, "unmask"))
-                        r = unit_file_unmask(arg_scope, arg_runtime, arg_root, args+1, &changes, &n_changes);
+                        r = unit_file_unmask(arg_scope, arg_runtime, arg_root, mangled_names, &changes, &n_changes);
                 else
                         assert_not_reached("Unknown verb");
 
@@ -4293,10 +4297,6 @@ static int enable_unit(DBusConnection *bus, char **args) {
 
                 dbus_message_iter_init_append(m, &iter);
 
-                r = mangle_names(args+1, &mangled_names);
-                if(r < 0)
-                        goto finish;
-
                 r = bus_append_strv_iter(&iter, mangled_names);
                 if (r < 0) {
                         log_error("Failed to append unit files.");
-- 
1.8.4.4

Attachment: signature.asc
Description: Digital signature

Reply via email to