From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23265 invoked by alias); 8 Jan 2010 18:38:39 -0000 Received: (qmail 23236 invoked by uid 48); 8 Jan 2010 18:38:23 -0000 Date: Fri, 08 Jan 2010 18:38:00 -0000 From: "vas dot gurevich at gmail dot com" To: glibc-bugs@sources.redhat.com Message-ID: <20100108183822.11149.vas.gurevich@gmail.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/11149] New: ldconfig - auxiliary cache does not work properly with -r option X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00019.txt.bz2 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.