summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-04-13 22:48:30 +0200
committerLennart Poettering <lennart@poettering.net>2022-04-22 11:32:46 +0200
commit11348386158ae51af7d3866f814b5468877fa60b (patch)
tree2da93f53f54eba20d367bbc0ecbecb4c32859580
parent3691083ce5e12e0290f0c8a83983cb0eefb6c126 (diff)
downloadsystemd-11348386158ae51af7d3866f814b5468877fa60b.tar.gz
execute: let recurse_dir() concate the cred name for us
recurse_dir() allows specifiying a freely choosable initial path to which to append the subdirs as it descends into the tree. If we pass the configured id there, recurse_dir() will suffix the subdir to that for us, so that we don't have to do that manually anymore in the callback, simplifying things a bit.
-rw-r--r--src/core/execute.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 580589eab8..eb06215266 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -2718,8 +2718,8 @@ static int load_cred_recurse_dir_cb(
const struct statx *sx,
void *userdata) {
- _cleanup_free_ char *credname = NULL, *sub_id = NULL;
struct load_cred_args *args = ASSERT_PTR(userdata);
+ _cleanup_free_ char *sub_id = NULL;
int r;
if (event != RECURSE_DIR_ENTRY)
@@ -2728,11 +2728,7 @@ static int load_cred_recurse_dir_cb(
if (!IN_SET(de->d_type, DT_REG, DT_SOCK))
return RECURSE_DIR_CONTINUE;
- credname = strreplace(path, "/", "_");
- if (!credname)
- return -ENOMEM;
-
- sub_id = strjoin(args->parent_load_credential->id, "_", credname);
+ sub_id = strreplace(path, "/", "_");
if (!sub_id)
return -ENOMEM;
@@ -2832,7 +2828,7 @@ static int acquire_credentials(
r = recurse_dir(
sub_fd,
- /* path= */ NULL,
+ /* 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,