dbus: limit the number of env variables to something reasonable, vol. 3

Let's limit the number of environment variables when creating a
transient unit via StartTransientUnit as well, since validating the
environment variable names/assignments is expensive.

Follow-up for 49c1e1bcf2.
This commit is contained in:
Frantisek Sumsal
2026-05-06 16:34:32 +01:00
committed by Luca Boccassi
parent 5c03431107
commit a7e276a82f
+9
View File
@@ -3456,6 +3456,9 @@ int bus_exec_context_set_transient_property(
if (r < 0)
return r;
if (strv_length(l) > ENVIRONMENT_ASSIGNMENTS_MAX)
return sd_bus_error_set(reterr_error, SD_BUS_ERROR_LIMITS_EXCEEDED,
"Too many environment assignments.");
if (!strv_env_is_valid(l))
return sd_bus_error_set(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Invalid environment block.");
@@ -3490,6 +3493,9 @@ int bus_exec_context_set_transient_property(
if (r < 0)
return r;
if (strv_length(l) > ENVIRONMENT_ASSIGNMENTS_MAX)
return sd_bus_error_set(reterr_error, SD_BUS_ERROR_LIMITS_EXCEEDED,
"Too many environment variable names or assignments.");
if (!strv_env_name_or_assignment_is_valid(l))
return sd_bus_error_set(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Invalid UnsetEnvironment= list.");
@@ -3642,6 +3648,9 @@ int bus_exec_context_set_transient_property(
if (r < 0)
return r;
if (strv_length(l) > ENVIRONMENT_ASSIGNMENTS_MAX)
return sd_bus_error_set(reterr_error, SD_BUS_ERROR_LIMITS_EXCEEDED,
"Too many environment variable names.");
if (!strv_env_name_is_valid(l))
return sd_bus_error_set(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Invalid PassEnvironment= block.");