diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c index c42a31153dc..7165fa1cf74 100644 --- a/src/systemctl/systemctl-edit.c +++ b/src/systemctl/systemctl-edit.c @@ -349,8 +349,8 @@ int verb_edit(int argc, char *argv[], void *userdata) { STRV_FOREACH(tmp, names) { r = unit_is_masked(bus, *tmp); - if (r < 0) - return r; + if (r < 0 && r != -ENOENT) + return log_error_errno(r, "Failed to check if unit %s is masked: %m", *tmp); if (r > 0) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Cannot edit %s: unit is masked.", *tmp); } diff --git a/test/units/TEST-26-SYSTEMCTL.sh b/test/units/TEST-26-SYSTEMCTL.sh index ed7b9f64bff..8e895aa9ae8 100755 --- a/test/units/TEST-26-SYSTEMCTL.sh +++ b/test/units/TEST-26-SYSTEMCTL.sh @@ -21,6 +21,7 @@ at_exit() { # the 'revert' verb as well export UNIT_NAME="systemctl-test-$RANDOM.service" export UNIT_NAME2="systemctl-test-$RANDOM.service" +export UNIT_NAME_TEMPLATE="systemctl-test-${RANDOM}@.service" cat >"/usr/lib/systemd/system/$UNIT_NAME" <<\EOF [Unit] @@ -65,6 +66,16 @@ EOF printf '%s\n' '[Unit]' 'Description=spectacular' '# this comment should remain' | \ cmp - "/etc/systemd/system/$UNIT_NAME.d/override2.conf" +# Edit nonexistent template unit, see issue #35632. +systemctl edit "$UNIT_NAME_TEMPLATE" --stdin --runtime --force --full <