From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by sourceware.org (Postfix) with ESMTPS id 5E1183857361 for ; Tue, 11 Oct 2022 20:59:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5E1183857361 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aurel32.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Content-Transfer-Encoding:From:Reply-To: Subject:Content-ID:Content-Description:X-Debbugs-Cc; bh=ZTdQxnaNC0e/BTHLD7JzCj3gsFwWpFQy22K/9lCDIgw=; b=S3VKZcpZSch8BAgAdbFO3HvmbS J59s2MhP6R62DPRH8+Oo9W8Wr/ItFvnLrwJviAlR9lhR7O1/jiU6ADD/rzab/0Vw63HpqNZGWP9Pa sVS77oJKmYK+L+g/8EduZj5U2g2xKvf2kjG7v0fVhblSWfqTXhja2KylljZEg+Bq1T4fNFOrDtKj8 OVolCDazHMOsZLYYaJyW8hCja7N1jMq/YzKtQxSFG8cdVoLkN0rAjpxuoezCT/4jCdmt9dh7HLjRd 0YqK66fOH1GPF+367w5OxUtbaLo00OAaoCDuHLJ9Ex0caBfrulueMwkbsMJ8g6makhVubGUq65Ack AxeYsTSw==; Received: from [2a01:e34:ec5d:a741:8a4c:7c4e:dc4c:1787] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oiMLe-004MkY-5x; Tue, 11 Oct 2022 22:59:34 +0200 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.96) (envelope-from ) id 1oiMLd-00GnAj-2X; Tue, 11 Oct 2022 22:59:33 +0200 Date: Tue, 11 Oct 2022 22:59:33 +0200 From: Aurelien Jarno To: Johannes Schauer Marin Rodrigues Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] ldconfig: create /var/cache/ldconfig also with -r Message-ID: Mail-Followup-To: Johannes Schauer Marin Rodrigues , libc-alpha@sourceware.org References: <20221011122053.1005166-1-josch@mister-muffin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221011122053.1005166-1-josch@mister-muffin.de> User-Agent: Mutt/2.2.7 (2022-08-07) X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_NONE,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 List-Id: On 2022-10-11 14:20, Johannes Schauer Marin Rodrigues wrote: > 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); > + } This drops the use chroot_canon() call. I am afraid it might allows one to "escape" the "chroot". Imagine that /var/cache/ldconfig is a symlink pointing outside of the opt_chroot. To avoid changing the code too much, one way could be to call chroot_canon(opt_chroot, "/var/cache/ldconfig") and concatenate the result with "aux-cache". -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://www.aurel32.net