1 |
commit: 61f27d670b1d0c07e50ead2d317abe05d0196ab0 |
2 |
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 3 19:53:40 2020 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 3 19:53:40 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=61f27d67 |
7 |
|
8 |
scanelg: add --ldcache=<arg> option to ease testing |
9 |
|
10 |
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org> |
11 |
|
12 |
man/scanelf.docbook | 7 +++++++ |
13 |
paxldso.c | 4 +++- |
14 |
paxldso.h | 3 +++ |
15 |
scanelf.c | 3 +++ |
16 |
4 files changed, 16 insertions(+), 1 deletion(-) |
17 |
|
18 |
diff --git a/man/scanelf.docbook b/man/scanelf.docbook |
19 |
index d9032a9..22503b2 100644 |
20 |
--- a/man/scanelf.docbook |
21 |
+++ b/man/scanelf.docbook |
22 |
@@ -214,6 +214,13 @@ |
23 |
listing ELFs. |
24 |
</para></listitem> |
25 |
</varlistentry> |
26 |
+ <varlistentry> |
27 |
+ <term><option>--ldcache</option> <replaceable>PATH</replaceable></term> |
28 |
+ <listitem><para> |
29 |
+ Use specified path instead of /etc/ld.so.cache. Generally paired with |
30 |
+ options like -L or -n. |
31 |
+ </para></listitem> |
32 |
+ </varlistentry> |
33 |
</variablelist> |
34 |
</refsect1> |
35 |
|
36 |
|
37 |
diff --git a/paxldso.c b/paxldso.c |
38 |
index 0cb7b01..2d8ddea 100644 |
39 |
--- a/paxldso.c |
40 |
+++ b/paxldso.c |
41 |
@@ -156,7 +156,7 @@ char *ldso_cache_lookup_lib(elfobj *elf, const char *fname) |
42 |
|
43 |
if (ldcache == NULL) { |
44 |
int fd; |
45 |
- const char *cachefile = root_rel_path("/etc/ld.so.cache"); |
46 |
+ const char *cachefile = root_rel_path(ldcache_path); |
47 |
struct stat st; |
48 |
|
49 |
if (fstatat(root_fd, cachefile, &st, 0)) |
50 |
@@ -369,3 +369,5 @@ void paxldso_cleanup(void) |
51 |
ldso_config_cleanup(); |
52 |
} |
53 |
#endif |
54 |
+ |
55 |
+const char * ldcache_path = "/etc/ld.so.cache"; |
56 |
|
57 |
diff --git a/paxldso.h b/paxldso.h |
58 |
index 16cbbac..fb7d938 100644 |
59 |
--- a/paxldso.h |
60 |
+++ b/paxldso.h |
61 |
@@ -66,4 +66,7 @@ extern void paxldso_cleanup(void); |
62 |
# define paxldso_cleanup() |
63 |
#endif |
64 |
|
65 |
+/* Path to ld.so.cache. Usually overridden for tests. */ |
66 |
+extern const char * ldcache_path; |
67 |
+ |
68 |
#endif |
69 |
|
70 |
diff --git a/scanelf.c b/scanelf.c |
71 |
index c2bda35..50497b2 100644 |
72 |
--- a/scanelf.c |
73 |
+++ b/scanelf.c |
74 |
@@ -1832,6 +1832,7 @@ static void scanelf_envpath(void) |
75 |
static struct option const long_opts[] = { |
76 |
{"path", no_argument, NULL, 'p'}, |
77 |
{"ldpath", no_argument, NULL, 'l'}, |
78 |
+ {"ldcache", a_argument, NULL, 130}, |
79 |
{"use-ldpath",no_argument, NULL, 129}, |
80 |
{"root", a_argument, NULL, 128}, |
81 |
{"recursive", no_argument, NULL, 'R'}, |
82 |
@@ -1877,6 +1878,7 @@ static struct option const long_opts[] = { |
83 |
static const char * const opts_help[] = { |
84 |
"Scan all directories in PATH environment", |
85 |
"Scan all directories in /etc/ld.so.conf", |
86 |
+ "Use alternate ld.so.cache specified in <arg>", |
87 |
"Use ld.so.conf to show full path (use with -r/-n)", |
88 |
"Root directory (use with -l or -p)", |
89 |
"Scan directories recursively", |
90 |
@@ -2120,6 +2122,7 @@ static int parseargs(int argc, char *argv[]) |
91 |
err("Could not open root: %s", optarg); |
92 |
break; |
93 |
case 129: load_cache_config = use_ldpath = 1; break; |
94 |
+ case 130: ldcache_path = optarg; break; |
95 |
case ':': |
96 |
err("Option '%c' is missing parameter", optopt); |
97 |
case '?': |