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);
}
# 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]
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 <<EOF
+[Unit]
+Description=template unit test
+# this comment should remain
+
+EOF
+printf '%s\n' '[Unit]' 'Description=template unit test' '# this comment should remain' | \
+ cmp - "/run/systemd/system/$UNIT_NAME_TEMPLATE"
+
# Test simultaneous editing of two units and creation of drop-in for a nonexistent unit
systemctl edit "$UNIT_NAME" "$UNIT_NAME2" --stdin --force --drop-in=override2.conf <<<'[X-Section]'
printf '%s\n' '[X-Section]' | cmp - "/etc/systemd/system/$UNIT_NAME.d/override2.conf"