summaryrefslogtreecommitdiffstats
path: root/src/core/exec-credential.c
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-02-06 15:20:49 +0100
committerMike Yuan <me@yhndnzj.com>2024-02-06 17:43:32 +0100
commit0f781376c033c8c8d38157a810e45cf226bc8d72 (patch)
tree1a26fe2ad39de667bf1d2cf2a724f9be66f4ccb7 /src/core/exec-credential.c
parentcore/exec-credential: add missing assertions (diff)
downloadsystemd-0f781376c033c8c8d38157a810e45cf226bc8d72.tar.xz
systemd-0f781376c033c8c8d38157a810e45cf226bc8d72.zip
core/exec-credential: use FOREACH_ARRAY at one more place
Diffstat (limited to 'src/core/exec-credential.c')
-rw-r--r--src/core/exec-credential.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/core/exec-credential.c b/src/core/exec-credential.c
index 3b017972a7..7248ad0348 100644
--- a/src/core/exec-credential.c
+++ b/src/core/exec-credential.c
@@ -342,38 +342,36 @@ static int load_credential_glob(
if (r < 0)
return r;
- for (size_t n = 0; n < pglob.gl_pathc; n++) {
+ FOREACH_ARRAY(p, pglob.gl_pathv, pglob.gl_pathc) {
_cleanup_free_ char *fn = NULL;
_cleanup_(erase_and_freep) char *data = NULL;
size_t size;
/* path is absolute, hence pass AT_FDCWD as nop dir fd here */
r = read_full_file_full(
- AT_FDCWD,
- pglob.gl_pathv[n],
- UINT64_MAX,
- encrypted ? CREDENTIAL_ENCRYPTED_SIZE_MAX : CREDENTIAL_SIZE_MAX,
- flags,
- NULL,
- &data, &size);
+ AT_FDCWD,
+ *p,
+ UINT64_MAX,
+ encrypted ? CREDENTIAL_ENCRYPTED_SIZE_MAX : CREDENTIAL_SIZE_MAX,
+ flags,
+ NULL,
+ &data, &size);
if (r < 0)
- return log_debug_errno(r, "Failed to read credential '%s': %m",
- pglob.gl_pathv[n]);
+ return log_debug_errno(r, "Failed to read credential '%s': %m", *p);
- r = path_extract_filename(pglob.gl_pathv[n], &fn);
+ r = path_extract_filename(*p, &fn);
if (r < 0)
- return log_debug_errno(r, "Failed to extract filename from '%s': %m",
- pglob.gl_pathv[n]);
+ return log_debug_errno(r, "Failed to extract filename from '%s': %m", *p);
r = maybe_decrypt_and_write_credential(
- write_dfd,
- fn,
- encrypted,
- uid,
- gid,
- ownership_ok,
- data, size,
- left);
+ write_dfd,
+ fn,
+ encrypted,
+ uid,
+ gid,
+ ownership_ok,
+ data, size,
+ left);
if (r == -EEXIST)
continue;
if (r < 0)