This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
ldconfig issues (was Re: PATCH: Treat symlink as regular file in ldconfig)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ulrich Drepper <drepper at redhat dot com>, Roland McGrath <roland at redhat dot com>, "H. J. Lu" <hjl at lucon dot org>
- Cc: GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Sun, 24 Aug 2003 12:48:38 +0200
- Subject: ldconfig issues (was Re: PATCH: Treat symlink as regular file in ldconfig)
- References: <20030721174531.GA17637@lucon.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Jul 21, 2003 at 10:45:31AM -0700, H. J. Lu wrote:
> In a directory, there are
>
> [hjl@gnu ldconfig]$ ls -l
> total 20
> drwxr-xr-x 2 hjl hjl 4096 Jul 21 10:07 lib
> -rwxr-xr-x 1 hjl hjl 6192 Jul 21 10:21 libbar-2.2.4.so
> lrwxrwxrwx 1 hjl hjl 19 Jul 21 10:07 libbar-2.3.2.so ->
> lib/libbar-2.3.2.so
> -rwxr-xr-x 1 hjl hjl 6208 Jul 21 10:36 libfoo-2.2.4.so
> lrwxrwxrwx 1 hjl hjl 19 Jul 21 09:57 libfoo-2.3.2.so ->
> lib/libfoo-2.3.2.so
> [hjl@gnu ldconfig]$ ldconfig -nv .
> .:
> libfoo.so -> libfoo-2.2.4.so (changed)
> libbar-2.2.4.so -> libbar-2.2.4.so
>
> I think libfoo.so should point to libfoo-2.3.2.so.
>
> [hjl@gnu ldconfig]$ /export/build/gnu/glibc/build-i686-linux/elf/ldconfig -nv .
> .:
> libbar-2.2.4.so -> libbar-2.2.4.so
> libfoo.so -> libfoo-2.3.2.so (changed)
>
> I am enclosing a patch here.
>
>
> H.J.
> 2003-07-21 <hongjiu.lu@intel.com>
>
> * elf/ldconfig.c (search_dir): Treat symlink as regular file
> if it won't point to itself.
Unfortunately, this patch creates unwanted symlinks in /usr/lib.
On typical glibc installation, one has
/lib/librt-2.3.2.so
/lib/librt.so.6 -> librt-2.3.2.so
/usr/lib/librt.so -> ../../lib/librt.so.6
With this patch, another symlink is created:
/usr/lib/librt.so.6 -> librt.so
This means there is one more (unneeded) entry in ld.so.cache, and if
arch subdirs below /lib are used, it means things break if LD_LIBRARY_PATH
is used.
Consider /lib/librt-2.3.2.so and /lib/tls/librt-2.3.2.so,
/usr/lib/librt.so -> ../../lib/librt.so.6 (both libraries export the same
set of symbols, so it doesn't matter against which one you link).
ldconfig with this change will create /usr/lib/librt.so.6 (pointing
indirectly to /lib/librt-2.3.2.so) but not /usr/lib/tls/librt.so.6,
which means if LD_LIBRARY_PATH=/usr is used, one might use librt.so
not corresponding to libc.so (libc.so is a linker script, so
/usr/lib/libc.so.6 is not created).
Either this patch should be backed out, or symlinks intended for
the linker shouldn't be considered in that place of search_dir.
Given the GNU style of versioning shared libraries, this cannot be
*.so, but e.g.
char *real_base_name = basename (real_name);
if (strcmp (base_real_name, soname) != 0)
{
len = strlen (real_name);
if (len < 3
|| strcmp (real_name + len - 3, ".so") != 0
|| strncmp (base_real_name, soname, strlen (base_real_name)) != 0)
is_link = 0;
}
might do it.
Also, there is a bug in current ldconfig.c,
if (real_name != real_file_name)
free (real_name);
cannot be before this check which uses real_name.
Jakub