[systemd-devel] [PATCH v3] systemctl: add add-wants and add-requires verbs
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Thu Sep 25 19:02:19 PDT 2014
On Thu, Sep 25, 2014 at 03:26:45PM +0200, Lukas Nykryn wrote:
> +static int add_install_dependency(sd_bus *bus, char **args) {
> + _cleanup_strv_free_ char **names = NULL;
> + _cleanup_free_ char *target = NULL;
> + const char *verb = args[0];
> + UnitFileInstallDependency dep;
> + int r = 0;
> +
> + if (!args[1])
> + return 0;
> +
> + target = unit_name_mangle_with_suffix(args[1], MANGLE_NOGLOB, ".target");
> + if (!target)
> + return log_oom();
> +
> + r = mangle_names(args+2, &names);
> + if (r < 0)
> + return r;
> +
> + if (streq(verb, "add-wants"))
> + dep = UNIT_FILE_INSTALL_DEPENDENCY_WANTS;
> + else if (streq(verb, "add-requires"))
> + dep = UNIT_FILE_INSTALL_DEPENDENCY_REQUIRES;
> + else
> + assert_not_reached("Unknown verb");
> +
> + if (!bus || avoid_bus()) {
> + UnitFileChange *changes = NULL;
> + unsigned n_changes = 0;
> +
> + r = unit_file_add_install_dependency(arg_scope, arg_runtime, arg_root, names, target, dep, arg_force, &changes, &n_changes);
I think this is missing some error reporting. When I run 'systmectl add-wants --root=/ ...'
it obviously fails with permission denied. But no indication is given, apart from a non-zero
return code. If I run it as root for a non-existent unit file, it doesn't say anything either.
When I run it over dbus, the error message for a non-existent unit is
"Failed to execute operation: No such file or directory". It would be nice to at least
include the unit name in the message.
Zbyszek
More information about the systemd-devel
mailing list