From a67bacff34b3e4f3a6387742177536d6ea8773f7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 21 Dec 2022 16:52:07 +0100 Subject: [PATCH] =?UTF-8?q?tmpfiles:=20port=20basename()=20=E2=86=92=20pat?= =?UTF-8?q?h=5Fextract=5Ffilename()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tmpfiles/offline-passwd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tmpfiles/offline-passwd.c b/src/tmpfiles/offline-passwd.c index f7d3978c93..f712099b0b 100644 --- a/src/tmpfiles/offline-passwd.c +++ b/src/tmpfiles/offline-passwd.c @@ -9,8 +9,9 @@ DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(uid_gid_hash_ops, char, string_hash_func, string_compare_func, free); static int open_passwd_file(const char *root, const char *fname, FILE **ret_file) { - _cleanup_free_ char *p = NULL; + _cleanup_free_ char *p = NULL, *bn = NULL; _cleanup_close_ int fd = -EBADF; + int r; fd = chase_symlinks_and_open(fname, root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC, &p); if (fd < 0) @@ -22,7 +23,11 @@ static int open_passwd_file(const char *root, const char *fname, FILE **ret_file TAKE_FD(fd); - log_debug("Reading %s entries from %s...", basename(fname), p); + r = path_extract_filename(fname, &bn); + if (r < 0) + return r; + + log_debug("Reading %s entries from %s...", bn, p); *ret_file = f; return 0;