From patchwork Mon Jun 22 15:13:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39738 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 AC577389365E; Mon, 22 Jun 2020 15:14:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC577389365E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1592838855; bh=6EWzN2Mg8EIqnNC8ljX+Q7yD/tck7b0o6s9SUDPp2H8=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=G+LL2yUfoprMpCHkq5TZECPz25EQMopzbJ+bYwoEnyzLGxTN6GrOvgvyzpchf0+0j Cfv+rnaXq6rC78gSqc0wur6GTk1V9jkmj9gu65yr9suMzbmqHu8DqnzobTOeydVxt2 yzPV6NYJypkp74Ww4axqOU/mOXzRpd+Ggz1Fwf0I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 2EDA9388F065 for ; Mon, 22 Jun 2020 15:14:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2EDA9388F065 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-G11gHNSVNP-N0YsMHc4F8g-1; Mon, 22 Jun 2020 11:14:11 -0400 X-MC-Unique: G11gHNSVNP-N0YsMHc4F8g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79D2F108A7F4 for ; Mon, 22 Jun 2020 15:13:47 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-185.ams2.redhat.com [10.36.112.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF83A10013D7 for ; Mon, 22 Jun 2020 15:13:46 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 08/30] elf: Record whether paths come from LD_LIBRARY_PATH or --library-path In-Reply-To: References: Message-Id: <430c94a366325a79ed83392e14b1f23df648bf8c.1592836143.git.fweimer@redhat.com> Date: Mon, 22 Jun 2020 17:13:45 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This allows more precise diagnostics. --- elf/dl-load.c | 4 ++-- elf/dl-main.h | 5 ++++- elf/dl-support.c | 2 +- elf/rtld.c | 3 +++ sysdeps/generic/ldsodefs.h | 6 ++++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 34d3b02a95..2339ada485 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -682,7 +682,7 @@ cache_rpath (struct link_map *l, void -_dl_init_paths (const char *llp) +_dl_init_paths (const char *llp, const char *source) { size_t idx; const char *strp; @@ -820,7 +820,7 @@ _dl_init_paths (const char *llp) } (void) fillin_rpath (llp_tmp, env_path_list.dirs, ":;", - "LD_LIBRARY_PATH", NULL, l); + source, NULL, l); if (env_path_list.dirs[0] == NULL) { diff --git a/elf/dl-main.h b/elf/dl-main.h index 681f366871..68dd27d0d7 100644 --- a/elf/dl-main.h +++ b/elf/dl-main.h @@ -71,6 +71,9 @@ struct dl_main_state /* The library search path. */ const char *library_path; + /* Where library_path comes from. LD_LIBRARY_PATH or --library. */ + const char *library_path_source; + /* The list preloaded objects from LD_PRELOAD. */ const char *preloadlist; @@ -91,7 +94,7 @@ struct dl_main_state static inline void call_init_paths (const struct dl_main_state *state) { - _dl_init_paths (state->library_path); + _dl_init_paths (state->library_path, state->library_path_source); } /* Print ld.so usage information and exit. */ diff --git a/elf/dl-support.c b/elf/dl-support.c index 7704c101c5..afbc94df54 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -323,7 +323,7 @@ _dl_non_dynamic_init (void) /* Initialize the data structures for the search paths for shared objects. */ - _dl_init_paths (getenv ("LD_LIBRARY_PATH")); + _dl_init_paths (getenv ("LD_LIBRARY_PATH"), "LD_LIBRARY_PATH"); /* Remember the last search directory added at startup. */ _dl_init_all_dirs = GL(dl_all_dirs); diff --git a/elf/rtld.c b/elf/rtld.c index 5fe6ca969a..eac9a1e743 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -269,6 +269,7 @@ dl_main_state_init (struct dl_main_state *state) { audit_list_init (&state->audit_list); state->library_path = NULL; + state->library_path_source = NULL; state->preloadlist = NULL; state->preloadarg = NULL; state->mode = normal; @@ -1181,6 +1182,7 @@ dl_main (const ElfW(Phdr) *phdr, && _dl_argc > 2) { state.library_path = _dl_argv[2]; + state.library_path_source = "--library_path"; _dl_skip_args += 2; _dl_argc -= 2; @@ -2609,6 +2611,7 @@ process_envvars (struct dl_main_state *state) && memcmp (envline, "LIBRARY_PATH", 12) == 0) { state->library_path = &envline[13]; + state->library_path_source = "LD_LIBRARY_PATH"; break; } diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 42fe912f47..0f23352302 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1034,8 +1034,10 @@ rtld_hidden_proto (_dl_debug_state) extern struct r_debug *_dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) attribute_hidden; -/* Initialize the basic data structure for the search paths. */ -extern void _dl_init_paths (const char *library_path) attribute_hidden; +/* Initialize the basic data structure for the search paths. SOURCE + is either "LD_LIBRARY_PATH" or "--library-path". */ +extern void _dl_init_paths (const char *library_path, const char *source) + attribute_hidden; /* Gather the information needed to install the profiling tables and start the timers. */