When mangling names, optionally emit a warning (#8400)
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 21 Mar 2018 14:26:47 +0000 (15:26 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Mar 2018 14:26:47 +0000 (15:26 +0100)
commit37cbc1d57992f49b3607bd66973dd30e0a8d1073
tree495e940367f2cf5534c43b14af602c344969accf
parentb85aca4f9218adf52f6c09d490f189d59b4dacd5
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.
12 files changed:
src/basic/unit-name.c
src/basic/unit-name.h
src/core/device.c
src/debug-generator/debug-generator.c
src/escape/escape.c
src/fstab-generator/fstab-generator.c
src/journal/journalctl.c
src/nspawn/nspawn-register.c
src/run/run.c
src/systemctl/systemctl.c
src/sysv-generator/sysv-generator.c
src/test/test-unit-name.c