]> git.proxmox.com Git - systemd.git/commitdiff
systemctl: mangle names when avoiding dbus
authorVáclav Pavlín <vpavlin@redhat.com>
Fri, 17 May 2013 14:03:36 +0000 (14:03 +0000)
committerMichael Stapelberg <michael@stapelberg.de>
Wed, 27 Nov 2013 18:40:13 +0000 (19:40 +0100)
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

index 0c39c94a371ce2ee6e98c2a4e2e94b9513cef828..d935249ddb406941e589aefb85c70e8f94f0ab0f 100644 (file)
@@ -4244,33 +4244,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");
 
@@ -4329,10 +4333,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.");