public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/11149] New: ldconfig - auxiliary cache does not work properly with -r option
@ 2010-01-08 18:38 vas dot gurevich at gmail dot com
  2010-04-05 18:28 ` [Bug libc/11149] " drepper at redhat dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: vas dot gurevich at gmail dot com @ 2010-01-08 18:38 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 17+ messages in thread
[parent not found: <bug-11149-131@http.sourceware.org/bugzilla/>]

end of thread, other threads:[~2014-06-30 20:25 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-08 18:38 [Bug libc/11149] New: ldconfig - auxiliary cache does not work properly with -r option vas dot gurevich at gmail dot com
2010-04-05 18:28 ` [Bug libc/11149] " drepper at redhat dot com
2010-04-09 16:00 ` vas dot gurevich at gmail dot com
2010-04-09 16:34 ` drepper at redhat dot com
2010-04-09 17:26 ` vas dot gurevich at gmail dot com
2010-04-10 13:43 ` drepper at redhat dot com
2010-04-12 17:28 ` vas dot gurevich at gmail dot com
2010-05-03 21:05 ` drepper at redhat dot com
2010-05-25 19:24 ` vas dot gurevich at gmail dot com
2010-05-25 19:28 ` pasky at suse dot cz
2010-05-25 21:25 ` vas dot gurevich at gmail dot com
2010-05-27 19:29 ` vas dot gurevich at gmail dot com
2010-06-01  0:29 ` pasky at suse dot cz
2010-06-01  0:29 ` pasky at suse dot cz
2010-09-29 20:57 ` anssi dot hannula at iki dot fi
     [not found] <bug-11149-131@http.sourceware.org/bugzilla/>
2011-05-30  1:47 ` drepper.fsp at gmail dot com
2014-06-30 20:25 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).