diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-03-04 16:23:46 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2021-03-04 20:50:41 +0000 |
commit | e6283cbf48a3821d03ec73252620fc1b04bd4588 (patch) | |
tree | ed8e451aecfab3b09763dc53598300c663607f69 /src/run/run.c | |
parent | 4d930e87ee30e74a585c840b4642157dd6321707 (diff) | |
download | systemd-e6283cbf48a3821d03ec73252620fc1b04bd4588.tar.gz |
run: tweak algorithm for generating unit name from dbus unique name
This reverts behaviour of systemd-run's unit name generation to the
status quo ante of #18871: we chop off the ":1." prefix if we can.
However, to address the issue that the unique name can overrun we then
do what #18871 did as fallback: only chop off the ":" prefix.
This way we should have pretty names that look like they always looked
in the common case, but in the case of a unique name overrun we still
will have names that work.
Follow-up for #18871
Diffstat (limited to 'src/run/run.c')
-rw-r--r-- | src/run/run.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/run/run.c b/src/run/run.c index 8c036857cf..ac405d39d7 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -956,10 +956,12 @@ static int make_unit_name(sd_bus *bus, UnitType t, char **ret) { return 0; } - /* We managed to get the unique name, then let's use that to - * name our transient units. */ + /* We managed to get the unique name, then let's use that to name our transient units. */ - id = startswith(unique, ":"); + id = startswith(unique, ":1."); /* let' strip the usual prefix */ + if (!id) + id = startswith(unique, ":"); /* the spec only requires things to start with a colon, hence + * let's add a generic fallback for that. */ if (!id) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unique name %s has unexpected format.", |