aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2020-10-03 20:53:40 +0100
committerSergei Trofimovich <slyfox@gentoo.org>2020-10-03 20:53:40 +0100
commit61f27d670b1d0c07e50ead2d317abe05d0196ab0 (patch)
tree569b64e9e5447a49e9f81c617b42502b54587de3
parentlddtree.sh: drop /lib extraction heuristics (diff)
downloadpax-utils-61f27d67.tar.gz
pax-utils-61f27d67.tar.bz2
pax-utils-61f27d67.zip
scanelg: add --ldcache=<arg> option to ease testing
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rw-r--r--man/scanelf.docbook7
-rw-r--r--paxldso.c4
-rw-r--r--paxldso.h3
-rw-r--r--scanelf.c3
4 files changed, 16 insertions, 1 deletions
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 '?':