core/execute: don't assert on an unpatched exec context

Issue: https://github.com/systemd/systemd/issues/43442
This commit is contained in:
Ivan Kruglov
2026-08-25 06:05:37 -07:00
parent d3c93d1678
commit 262b155a32
+7 -2
View File
@@ -1724,8 +1724,13 @@ static int exec_context_serialize(const ExecContext *c, FILE *f) {
if (r < 0)
return r;
/* This must be set in unit_patch_contexts() before executing a command. */
assert(c->private_var_tmp >= 0 && c->private_var_tmp < _PRIVATE_TMP_MAX);
/* This must be set in unit_patch_contexts() before executing a command. A unit whose load failed
* never goes through that, yet can still be stopped, hence this is reachable. Refuse instead of
* asserting, this runs in PID 1. */
if (c->private_var_tmp < 0 || c->private_var_tmp >= _PRIVATE_TMP_MAX)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"PrivateVarTmp= is not set up, unit was not fully loaded, refusing.");
r = serialize_item(f, "exec-context-private-var-tmp", private_tmp_to_string(c->private_var_tmp));
if (r < 0)
return r;