core: add EXEC_DIRECTORY_TYPE_SHALL_CHOWN() helper

Let's make ConfigurationDirectory= a bit less "special-casey", by hiding
the fact that it's the only per-service dir we do not do chown()ing for
inside of a new EXEC_DIRECTORY_TYPE_SHALL_CHOWN() helper.
This commit is contained in:
Lennart Poettering
2024-10-30 13:33:29 +01:00
parent ba21b29039
commit 2ef87de9d3
3 changed files with 12 additions and 5 deletions
+2 -2
View File
@@ -340,7 +340,7 @@ bool exec_directory_is_private(const ExecContext *context, ExecDirectoryType typ
if (!context->dynamic_user)
return false;
if (type == EXEC_DIRECTORY_CONFIGURATION)
if (!EXEC_DIRECTORY_TYPE_SHALL_CHOWN(type))
return false;
if (type == EXEC_DIRECTORY_RUNTIME && context->runtime_directory_preserve_mode == EXEC_PRESERVE_NO)
@@ -1639,7 +1639,7 @@ int exec_context_get_clean_directories(
return r;
/* Also remove private directories unconditionally. */
if (t != EXEC_DIRECTORY_CONFIGURATION) {
if (EXEC_DIRECTORY_TYPE_SHALL_CHOWN(t)) {
j = path_join(prefix[t], "private", i->path);
if (!j)
return -ENOMEM;