This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: 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>
- Cc: Roland McGrath <roland at redhat dot com>, "H. J. Lu" <hjl at lucon dot org>, GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Mon, 25 Aug 2003 09:57:48 +0200
- Subject: Re: ldconfig issues (was Re: PATCH: Treat symlink as regular file in ldconfig)
- References: <20030721174531.GA17637@lucon.org> <20030824104838.GX12344@sunsite.ms.mff.cuni.cz> <3F49D18E.3040405@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Aug 25, 2003 at 02:06:22AM -0700, Ulrich Drepper wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jakub Jelinek wrote:
>
> >>2003-07-21 <hongjiu.lu@intel.com>
> >>
> >> * elf/ldconfig.c (search_dir): Treat symlink as regular file
> >> if it won't point to itself.
>
> I've reverted the patch. HJ, please provide some more background on
> what this patch was meant to fix.
I think HJ showed why he wanted that.
Say there is:
/usr/lib/subdir with
libfoo-2.3.2.so
libbar.so.7.1
(as normal files) and /usr/lib has:
libfoo-2.3.2.so -> subdir/libfoo-2.3.2.so
libbar.so.7.1 -> subdir/libbar.so.7.1
symlinks (names chosen to match both the GNU versioning style and the most
common one for other packages). This can e.g. happen if you
install some package in some non-standard library and add symlinks to
/usr/lib or other common library directory to point to the real libraries.
Without his patch, ldconfig would not create libfoo.so.1 nor libbar.so.7
symlinks in /usr/lib nor enter it into ld.so.cache.
The following patch keeps the above 2 cases working like
ldconfig newer than 2003-07-21 did, but will not consider
libfoo.so or libbar.so symlinks (assuming the SONAMEs are libfoo.so.1 and
libbar.so.7).
2003-08-25 Jakub Jelinek <jakub@redhat.com>
* elf/ldconfig.c (search_dir): Treat symlink as regular file
if it won't point to itself unless it is .so symlink for the
linker.
--- libc/elf/ldconfig.c.jj 2003-08-25 05:32:15.000000000 -0400
+++ libc/elf/ldconfig.c 2003-08-25 05:17:42.000000000 -0400
@@ -787,16 +787,33 @@ search_dir (const struct dir_entry *entr
continue;
}
- /* Links will just point to itself. */
+
+ /* A link may just point to itself. */
if (is_link)
{
- free (soname);
- soname = xstrdup (direntry->d_name);
- }
+ /* If the path the link points to isn't its soname and it is not
+ .so symlink for ld(1) only, we treat it as a normal file. */
+ char *real_base_name = basename (real_name);
+
+ if (strcmp (real_base_name, soname) != 0)
+ {
+ len = strlen (real_base_name);
+ if (len < strlen (".so")
+ || strcmp (real_base_name + len - strlen (".so"), ".so") != 0
+ || strncmp (real_base_name, soname, len) != 0)
+ is_link = 0;
+ }
+ }
if (real_name != real_file_name)
free (real_name);
+ if (is_link)
+ {
+ free (soname);
+ soname = xstrdup (direntry->d_name);
+ }
+
if (flag == FLAG_ELF
&& (entry->flag == FLAG_ELF_LIBC5
|| entry->flag == FLAG_ELF_LIBC6))
Jakub