This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] [BZ #14462] Fix paths shown by ldconfig -r
- From: Allan McRae <allan at archlinux dot org>
- To: libc-alpha <libc-alpha at sourceware dot org>
- Date: Fri, 14 Sep 2012 13:42:19 +1000
- Subject: [PATCH] [BZ #14462] Fix paths shown by ldconfig -r
This fixes the potentially confusing paths shown by ldconfig when used
with the -r option.
Before:
$ ldconfig -r /tmp/ /foo
ldconfig: Warning: ignoring configuration file that cannot be opened:
/etc/ld.so.conf: No such file or directory
ldconfig: Can't create temporary cache file /tmp/etc/ld.so.cache~: No
such file
or directory
$ sudo ldconfig -r /tmp/ /foo
ldconfig: Warning: ignoring configuration file that cannot be opened:
/etc/ld.so.conf: No such file or directory
ldconfig: Can't create temporary cache file /etc/ld.so.cache~: No such
file or
directory
After:
$ ldconfig -r /tmp/ /foo
ldconfig: Warning: ignoring configuration file that cannot be opened:
/tmp/etc/ld.so.conf: No such file or directory
ldconfig: Can't create temporary cache file /tmp/etc/ld.so.cache~: No
such file or directory
$ sudo ldconfig -r /tmp/ /foo
ldconfig: Warning: ignoring configuration file that cannot be opened:
/tmp/etc/ld.so.conf: No such file or directory
ldconfig: Can't create temporary cache file /tmp/etc/ld.so.cache~: No
such file or directory
2012-09-14 Allan McRae <allan@archlinux.org>
[BZ #14462]
* elf/ldconfig.c (main): Save path to chroot dir for use in
error messages.
(parse_conf): Print full path to missing conf file.
* elf/config.c (save_cache): Print full path to failed
temporary cache file.
diff --git a/elf/cache.c b/elf/cache.c
index db8b9fa..d78b7c8 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -50,6 +50,9 @@ static struct cache_entry *entries;
static const char *flag_descr[] =
{ "libc4", "ELF", "libc5", "libc6"};
+extern char *opt_chroot;
+extern char *chroot_dir;
+
/* Print a single entry. */
static void
print_entry (const char *lib, int flag, unsigned int osversion,
@@ -403,8 +406,8 @@ save_cache (const char *cache_name)
int fd = open (temp_name, O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW,
S_IRUSR|S_IWUSR);
if (fd < 0)
- error (EXIT_FAILURE, errno, _("Can't create temporary cache file %s"),
- temp_name);
+ error (EXIT_FAILURE, errno, _("Can't create temporary cache file
%s%s"),
+ opt_chroot ? "" : chroot_dir, temp_name);
/* Write contents. */
if (opt_format != 2)
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 8d6e77f..b4821e7 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -105,8 +105,11 @@ static int opt_link = 1;
/* Only process directories specified on the command line. */
static int opt_only_cline;
-/* Path to root for chroot. */
-static char *opt_chroot;
+/* Directory argument for chroot. */
+char *opt_chroot;
+
+/* Path to root. */
+char *chroot_dir;
/* Manually link given shared libraries. */
static int opt_manual_link;
@@ -1062,8 +1065,8 @@ parse_conf (const char *filename, bool do_chroot)
if (file == NULL)
{
error (0, errno, _("\
-Warning: ignoring configuration file that cannot be opened: %s"),
- canon);
+Warning: ignoring configuration file that cannot be opened: %s%s"),
+ chroot_dir, filename);
if (canon != filename)
free ((char *) canon);
return;
@@ -1276,6 +1279,8 @@ main (int argc, char **argv)
if (endp == opt_chroot)
opt_chroot = NULL;
+ chroot_dir = opt_chroot;
+
if (opt_chroot)
{
/* It is faster to use chroot if we can. */