This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11149] New: ldconfig - auxiliary cache does not work properly with -r option
- From: "vas dot gurevich at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 8 Jan 2010 18:38:22 -0000
- Subject: [Bug libc/11149] New: ldconfig - auxiliary cache does not work properly with -r option
- Reply-to: sourceware-bugzilla at sourceware dot org
There are 2 bugs here:
When we use ldconfig with -r option like usual user we use absolute path to
aux-cache file without any changes according to the new root.
When we use ldconfig with -r option like usual user we do not check if the
symbolic link in our new root points outside of our root and we need "normalize"
the name according to -r option.
(We have a link to /lib/ourlib and stat this link instead of
/our_new_root/lib/ourlib)
I am proposing the patch against 2.11.1 here:
--- orig/glibc-2.11.1/elf/ldconfig.c 2009-12-08 22:10:20.000000000 +0200
+++ patch/glibc-2.11.1/elf/ldconfig.c 2010-01-08 18:10:32.000000000 +0200
@@ -118,6 +118,9 @@
/* Cache file to use. */
static char *cache_file;
+/* Aux cache file to use. */
+static char *aux_cache_file;
+
/* Configuration file. */
static const char *config_file;
@@ -790,6 +793,34 @@
lstat_buf.st_ino = stat_buf.st_ino;
lstat_buf.st_size = stat_buf.st_size;
lstat_buf.st_ctime = stat_buf.st_ctime;
+
+ /* We need to check if it is link outside of new root
+ and stat returns to us different info than real chroot. */
+ if (opt_chroot)
+ {
+ char *real_name = chroot_canon (opt_chroot, file_name);
+ if (real_name == NULL)
+ {
+ if (strstr (file_name, ".so") == NULL)
+ error (0, 0, _("Input file %s not found.\n"), file_name);
+ continue;
+ }
+ if (__builtin_expect (stat64 (real_name, &stat_buf), 0))
+ {
+ error (0, errno, _("Cannot stat %s"), real_name);
+ continue;
+ }
+ if (lstat_buf.st_dev != stat_buf.st_dev
+ || lstat_buf.st_ino != stat_buf.st_ino
+ || lstat_buf.st_size != stat_buf.st_size
+ || lstat_buf.st_ctime != stat_buf.st_ctime)
+ {
+ lstat_buf.st_dev = stat_buf.st_dev;
+ lstat_buf.st_ino = stat_buf.st_ino;
+ lstat_buf.st_size = stat_buf.st_size;
+ lstat_buf.st_ctime = stat_buf.st_ctime;
+ }
+ }
}
else
is_dir = S_ISDIR (lstat_buf.st_mode);
@@ -1346,8 +1377,39 @@
add_system_dir (LIBDIR);
}
+ if (aux_cache_file == NULL)
+ {
+ aux_cache_file = alloca (strlen (_PATH_LDCONFIG_AUX_CACHE) + 1);
+ strcpy (aux_cache_file, _PATH_LDCONFIG_AUX_CACHE);
+ }
+
+ if (opt_chroot)
+ {
+ /* Canonicalize the directory name of aux_cache_file, not aux_cache_file,
+ because we'll rename a temporary aux cache file to it. */
+ char *p = strrchr (aux_cache_file, '/');
+ char *canon = chroot_canon (opt_chroot,
+ p ? (*p = '\0', aux_cache_file) : "/");
+
+ if (canon == NULL)
+ {
+ error (EXIT_FAILURE, errno,
+ _("Can't open aux cache file directory %s\n"),
+ p ? aux_cache_file : "/");
+ }
+
+ if (p)
+ ++p;
+ else
+ p = aux_cache_file;
+
+ aux_cache_file = alloca (strlen (canon) + strlen (p) + 2);
+ sprintf (aux_cache_file, "%s/%s", canon, p);
+ free (canon);
+ }
+
if (! opt_ignore_aux_cache)
- load_aux_cache (_PATH_LDCONFIG_AUX_CACHE);
+ load_aux_cache (aux_cache_file);
else
init_aux_cache ();
@@ -1356,7 +1418,7 @@
if (opt_build_cache)
{
save_cache (cache_file);
- save_aux_cache (_PATH_LDCONFIG_AUX_CACHE);
+ save_aux_cache (aux_cache_file);
}
return 0;
I checked the newest 2.12, we still have it.
--
Summary: ldconfig - auxiliary cache does not work properly with -
r option
Product: glibc
Version: 2.11
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: vas dot gurevich at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11149
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.