diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-03-21 15:26:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-03-21 15:26:47 +0100 |
commit | 37cbc1d57992f49b3607bd66973dd30e0a8d1073 (patch) | |
tree | 495e940367f2cf5534c43b14af602c344969accf /src/run | |
parent | b85aca4f9218adf52f6c09d490f189d59b4dacd5 (diff) | |
download | systemd-37cbc1d57992f49b3607bd66973dd30e0a8d1073.tar.gz |
When mangling names, optionally emit a warning (#8400)
The warning is not emitted for absolute paths like /dev/sda or /home, which are
converted to .device and .mount unit names without any fuss.
Most of the time it's unlikely that users use invalid unit names on purpose,
so let's warn them. Warnings are silenced when --quiet is used.
$ build/systemctl show -p Id hello@foo-bar/baz
Invalid unit name "hello@foo-bar/baz" was escaped as "hello@foo-bar-baz" (maybe you should use systemd-escape?)
Id=hello@foo-bar-baz.service
$ build/systemd-run --user --slice foo-bar/baz --unit foo-bar/foo true
Invalid unit name "foo-bar/foo" was escaped as "foo-bar-foo" (maybe you should use systemd-escape?)
Invalid unit name "foo-bar/baz" was escaped as "foo-bar-baz" (maybe you should use systemd-escape?)
Running as unit: foo-bar-foo.service
Fixes #8302.
Diffstat (limited to 'src/run')
-rw-r--r-- | src/run/run.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/run/run.c b/src/run/run.c index cfab3d6f97..1da185dde9 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -520,7 +520,7 @@ static int transient_cgroup_set_properties(sd_bus_message *m) { if (!isempty(arg_slice)) { _cleanup_free_ char *slice = NULL; - r = unit_name_mangle_with_suffix(arg_slice, UNIT_NAME_NOGLOB, ".slice", &slice); + r = unit_name_mangle_with_suffix(arg_slice, arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN, ".slice", &slice); if (r < 0) return log_error_errno(r, "Failed to mangle name '%s': %m", arg_slice); @@ -984,7 +984,7 @@ static int start_transient_service( } if (arg_unit) { - r = unit_name_mangle_with_suffix(arg_unit, UNIT_NAME_NOGLOB, ".service", &service); + r = unit_name_mangle_with_suffix(arg_unit, arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN, ".service", &service); if (r < 0) return log_error_errno(r, "Failed to mangle unit name: %m"); } else { @@ -1187,7 +1187,7 @@ static int start_transient_scope( return log_oom(); if (arg_unit) { - r = unit_name_mangle_with_suffix(arg_unit, UNIT_NAME_NOGLOB, ".scope", &scope); + r = unit_name_mangle_with_suffix(arg_unit, arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN, ".scope", &scope); if (r < 0) return log_error_errno(r, "Failed to mangle scope name: %m"); } else { @@ -1358,11 +1358,11 @@ static int start_transient_trigger( break; default: - r = unit_name_mangle_with_suffix(arg_unit, UNIT_NAME_NOGLOB, ".service", &service); + r = unit_name_mangle_with_suffix(arg_unit, arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN, ".service", &service); if (r < 0) return log_error_errno(r, "Failed to mangle unit name: %m"); - r = unit_name_mangle_with_suffix(arg_unit, UNIT_NAME_NOGLOB, suffix, &trigger); + r = unit_name_mangle_with_suffix(arg_unit, arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN, suffix, &trigger); if (r < 0) return log_error_errno(r, "Failed to mangle unit name: %m"); |