PATCH: Treat symlink as regular file in ldconfig

H. J. Lu hjl@lucon.org
Mon Jul 21 19:43:00 GMT 2003


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.
-------------- next part --------------
2003-07-21  <hongjiu.lu@intel.com>

	* elf/ldconfig.c (search_dir): Treat symlink as regular file
	if it won't point to itself.

--- elf/ldconfig.c.symlink	2003-06-28 16:10:27.000000000 -0700
+++ elf/ldconfig.c	2003-07-21 10:37:41.000000000 -0700
@@ -787,11 +787,18 @@ search_dir (const struct dir_entry *entr
       if (real_name != real_file_name)
 	free (real_name);
 
-      /* 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, we treat
+	     it as a normal file.  */
+	  if (strcmp (basename (real_name), soname) != 0)
+	    is_link = 0;
+	  else
+	    {
+	      free (soname);
+	      soname = xstrdup (direntry->d_name);
+	    }
 	}
 
       if (flag == FLAG_ELF


More information about the Libc-alpha mailing list