From patchwork Tue Oct 11 12:20:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schauer Marin Rodrigues X-Patchwork-Id: 58650 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B53F53857012 for ; Tue, 11 Oct 2022 12:21:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from fulda116.server4you.de (mister-muffin.de [144.76.155.182]) by sourceware.org (Postfix) with ESMTP id 1C22B3858C2D for ; Tue, 11 Oct 2022 12:20:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C22B3858C2D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mister-muffin.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mister-muffin.de Received: from localhost (win7217.informatik.uni-wuerzburg.de [132.187.9.217]) by mister-muffin.de (Postfix) with ESMTPSA id BC91A5D; Tue, 11 Oct 2022 14:20:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mister-muffin.de; s=mail; t=1665490854; bh=QWm2W6H2vFCteXgN2C9cr5PVgHKnleeLUvbEJdnSkGY=; h=From:To:Cc:Subject:Date:From; b=i7n4UVxnVb5ZlO8W81ah7u7XH87O+sGORU8p9aw4q7PpxYEGuhqT5kBfF8o/e8lte a1IdwBby3NXHbXaMJXR1TUJJO7MLzRWkJXAS0/VSKlDzMZQr1VJJroLfkbbEQIezq5 AM7EuFy3gDOs/IntsibV91vyaLs3f7FE7QwlqwRw= From: Johannes Schauer Marin Rodrigues To: libc-alpha@sourceware.org Subject: [PATCH] ldconfig: create /var/cache/ldconfig also with -r Date: Tue, 11 Oct 2022 14:20:53 +0200 Message-Id: <20221011122053.1005166-1-josch@mister-muffin.de> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Schauer Marin Rodrigues Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Without the -r option, ldconfig creates /var/cache/ldconfig if it didn't exist yet. With the -r option, a non-existing /var/cache/ldconfig inside the chroot directory will *not* get created because chroot_canon() will return NULL if the path doesn't exist. This means that aux_cache_file will be set to NULL and save_aux_cache() doesn't get executed at the end. So instead of using chroot_canon() to prepending the chroot path, combine the paths manually. --- elf/ldconfig.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/elf/ldconfig.c b/elf/ldconfig.c index e6c24e71a4..da76dc31b8 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -1293,9 +1293,11 @@ main (int argc, char **argv) add_system_dir (LIBDIR); } - const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE; - if (opt_chroot != NULL) - aux_cache_file = chroot_canon (opt_chroot, aux_cache_file); + char *aux_cache_file = (char *)(_PATH_LDCONFIG_AUX_CACHE); + if (opt_chroot != NULL) { + aux_cache_file = alloca (strlen (opt_chroot) + strlen (_PATH_LDCONFIG_AUX_CACHE) + 2); + sprintf (aux_cache_file, "%s/%s", opt_chroot, _PATH_LDCONFIG_AUX_CACHE); + } if (! opt_ignore_aux_cache && aux_cache_file) load_aux_cache (aux_cache_file);