commit: 61f27d670b1d0c07e50ead2d317abe05d0196ab0
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 3 19:53:40 2020 +0000
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat Oct 3 19:53:40 2020 +0000
URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=61f27d67
scanelg: add --ldcache=<arg> option to ease testing
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
man/scanelf.docbook | 7 +++++++
paxldso.c | 4 +++-
paxldso.h | 3 +++
scanelf.c | 3 +++
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/man/scanelf.docbook b/man/scanelf.docbook
index d9032a9..22503b2 100644
--- a/man/scanelf.docbook
+++ b/man/scanelf.docbook
@@ -214,6 +214,13 @@
listing ELFs.
</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--ldcache</option> <replaceable>PATH</replaceable></term>
+ <listitem><para>
+ Use specified path instead of /etc/ld.so.cache. Generally paired with
+ options like -L or -n.
+ </para></listitem>
+ </varlistentry>
</variablelist>
</refsect1>
diff --git a/paxldso.c b/paxldso.c
index 0cb7b01..2d8ddea 100644
--- a/paxldso.c
+++ b/paxldso.c
@@ -156,7 +156,7 @@ char *ldso_cache_lookup_lib(elfobj *elf, const char *fname)
if (ldcache == NULL) {
int fd;
- const char *cachefile = root_rel_path("/etc/ld.so.cache");
+ const char *cachefile = root_rel_path(ldcache_path);
struct stat st;
if (fstatat(root_fd, cachefile, &st, 0))
@@ -369,3 +369,5 @@ void paxldso_cleanup(void)
ldso_config_cleanup();
}
#endif
+
+const char * ldcache_path = "/etc/ld.so.cache";
diff --git a/paxldso.h b/paxldso.h
index 16cbbac..fb7d938 100644
--- a/paxldso.h
+++ b/paxldso.h
@@ -66,4 +66,7 @@ extern void paxldso_cleanup(void);
# define paxldso_cleanup()
#endif
+/* Path to ld.so.cache. Usually overridden for tests. */
+extern const char * ldcache_path;
+
#endif
diff --git a/scanelf.c b/scanelf.c
index c2bda35..50497b2 100644
--- a/scanelf.c
+++ b/scanelf.c
@@ -1832,6 +1832,7 @@ static void scanelf_envpath(void)
static struct option const long_opts[] = {
{"path", no_argument, NULL, 'p'},
{"ldpath", no_argument, NULL, 'l'},
+ {"ldcache", a_argument, NULL, 130},
{"use-ldpath",no_argument, NULL, 129},
{"root", a_argument, NULL, 128},
{"recursive", no_argument, NULL, 'R'},
@@ -1877,6 +1878,7 @@ static struct option const long_opts[] = {
static const char * const opts_help[] = {
"Scan all directories in PATH environment",
"Scan all directories in /etc/ld.so.conf",
+ "Use alternate ld.so.cache specified in <arg>",
"Use ld.so.conf to show full path (use with -r/-n)",
"Root directory (use with -l or -p)",
"Scan directories recursively",
@@ -2120,6 +2122,7 @@ static int parseargs(int argc, char *argv[])
err("Could not open root: %s", optarg);
break;
case 129: load_cache_config = use_ldpath = 1; break;
+ case 130: ldcache_path = optarg; break;
case ':':
err("Option '%c' is missing parameter", optopt);
case '?':