]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
execute: sort directory entries when loading credentials recursively
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Apr 2022 21:03:22 +0000 (23:03 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Apr 2022 09:32:47 +0000 (11:32 +0200)
Given that the recusive credential loading allows two ways to load the
same credentials, it's important to define a clear order so that it is
always the same one that wins.

i.e. if you use LoadCredential=foobar:/tmp/xyz and there are two files
/tmp/xyz/abc/cde and /tmp/xyz/abc_cde these would both result in a
credential foobar_abc_cde being set, hence it is important to make clear
which one shall win, and that it is always the same one.

src/core/execute.c

index a0c58ac255e1fa548e58b61ef03f53c2ccd96dd5..c85ca2a3564af170c0139a6692bf4ccb6730203b 100644 (file)
@@ -2819,7 +2819,7 @@ static int acquire_credentials(
                                         /* path= */ lc->id, /* recurse_dir() will suffix the subdir paths from here to the top-level id */
                                         /* statx_mask= */ 0,
                                         /* n_depth_max= */ UINT_MAX,
-                                        RECURSE_DIR_IGNORE_DOT|RECURSE_DIR_ENSURE_TYPE,
+                                        RECURSE_DIR_SORT|RECURSE_DIR_IGNORE_DOT|RECURSE_DIR_ENSURE_TYPE,
                                         load_cred_recurse_dir_cb,
                                         &(struct load_cred_args) {
                                                 .context = context,