PATCH: Handle symlink to directory in ldconfig.
H. J. Lu
hjl@lucon.org
Wed Jun 23 07:26:00 GMT 2004
On Tue, Jun 22, 2004 at 10:53:33PM +0900, Hideki IWAMOTO wrote:
> This is about the patch which you sent to libc-alpha about three years ago.
> http://sources.redhat.com/ml/libc-alpha/2001-05/msg00084.html
>
> This change causes a problem, when option -r is used.
> Even when option -r is used, stat64 is performed using the original root directory.
> This makes it impossible to use the paths which are not in the original root directory.
>
> This is an example.
>
> > tree tmproot/
> tmproot/
> |-- etc
> | `-- ld.so.conf
> |-- lib
> `-- usr
> |-- bar
> | `-- lib
> |-- foo
> | `-- lib
> |-- lib
> `-- local
> `-- lib
>
> 10 directories, 1 file
> > cat tmproot/etc/ld.so.conf
> /usr/local/lib
> /usr/foo/lib
> > id -u
> 500
> > ls /usr/foo/lib /usr/bar/lib
> ls: /usr/foo/lib: No such file or directory
> ls: /usr/bar/lib: No such file or directory
> > ./build-glibc/elf/ldconfig -v -r tmproot /usr/bar/lib
> ./build-glibc/elf/ldconfig: Can't stat /usr/bar/lib: No such file or directory
> ./build-glibc/elf/ldconfig: Can't stat /usr/foo/lib: No such file or directory
> /usr/local/lib:
> /lib:
> /usr/lib:
>
Here is a patch.
H.J.
-------------- next part --------------
2004-05-06 H.J. Lu <hongjiu.lu@intel.com>
* elf/ldconfig.c (add_dir): Call chroot_canon to get the path
before calling stat64.
--- elf/ldconfig.c.root 2004-06-22 00:18:05.000000000 -0700
+++ elf/ldconfig.c 2004-06-23 00:20:18.088903284 -0700
@@ -322,6 +322,7 @@ add_dir (const char *line)
struct dir_entry *entry;
unsigned int i;
struct stat64 stat_buf;
+ char *path;
entry = xmalloc (sizeof (struct dir_entry));
entry->next = NULL;
@@ -358,7 +359,12 @@ add_dir (const char *line)
while (entry->path[i] == '/' && i > 0)
entry->path[i--] = '\0';
- if (stat64 (entry->path, &stat_buf))
+ if (opt_chroot)
+ path = chroot_canon (opt_chroot, entry->path);
+ else
+ path = entry->path;
+
+ if (stat64 (path, &stat_buf))
{
if (opt_verbose)
error (0, errno, _("Can't stat %s"), entry->path);
More information about the Libc-alpha
mailing list