aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorRomain Geissler <romain.geissler@gmail.com>2023-03-26 20:00:15 +0000
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-03-27 16:58:08 -0300
commitcce422a63262dad5e6d7108d36092fc0757b5594 (patch)
tree50de6c87ba543c1b7749426d5b818c4ab8d75909 /elf
parent57ce87a940071a152a27e1e1be1dc9eced55ca6c (diff)
downloadglibc-cce422a63262dad5e6d7108d36092fc0757b5594.zip
glibc-cce422a63262dad5e6d7108d36092fc0757b5594.tar.gz
glibc-cce422a63262dad5e6d7108d36092fc0757b5594.tar.bz2
Fix tst-ldconfig-ld_so_conf-update with custom configure prefix value
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf')
-rw-r--r--elf/tst-ldconfig-ld_so_conf-update.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/elf/tst-ldconfig-ld_so_conf-update.c b/elf/tst-ldconfig-ld_so_conf-update.c
index 503afb3..2c5c486 100644
--- a/elf/tst-ldconfig-ld_so_conf-update.c
+++ b/elf/tst-ldconfig-ld_so_conf-update.c
@@ -33,7 +33,6 @@
#define DSO "libldconfig-ld-mod.so"
#define DSO_DIR "/tmp/tst-ldconfig"
-#define CONF "/etc/ld.so.conf"
static void
@@ -64,6 +63,8 @@ do_test (void)
{
struct support_capture_subprocess result;
+ char *conf_path = xasprintf ("%s/ld.so.conf", support_sysconfdir_prefix);
+
/* Create the needed directories. */
xmkdirp ("/var/cache/ldconfig", 0777);
xmkdirp (DSO_DIR, 0777);
@@ -82,9 +83,9 @@ do_test (void)
is not searched. */
TEST_VERIFY_EXIT (dlopen (DSO, RTLD_NOW | RTLD_GLOBAL) == NULL);
- FILE *fp = xfopen (CONF, "a+");
+ FILE *fp = xfopen (conf_path, "a+");
if (!fp)
- FAIL_EXIT1 ("creating /etc/ld.so.conf failed: %m");
+ FAIL_EXIT1 ("creating %s failed: %m", conf_path);
xfclose (fp);
/* Run ldconfig. */
@@ -95,9 +96,9 @@ do_test (void)
TEST_VERIFY_EXIT (dlopen (DSO, RTLD_NOW | RTLD_GLOBAL) == NULL);
/* Add tst-ldconfig directory to /etc/ld.so.conf. */
- fp = xfopen (CONF, "w");
+ fp = xfopen (conf_path, "w");
if (!(fwrite (DSO_DIR, 1, sizeof (DSO_DIR), fp)))
- FAIL_EXIT1 ("updating /etc/ld.so.conf failed: %m");
+ FAIL_EXIT1 ("updating %s failed: %m", conf_path);
xfclose (fp);
/* Try to dlopen the same DSO again, we expect this to still fail. */
@@ -111,6 +112,8 @@ do_test (void)
/* Finally, we expect dlopen to pass now. */
TEST_VERIFY_EXIT (dlopen (DSO, RTLD_NOW | RTLD_GLOBAL) != NULL);
+ free (conf_path);
+
return 0;
}