This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC][BZ #11064] Warn when ldconfig encounters ambiguous SONAME.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Sat, 26 Oct 2013 12:23:57 +0200
- Subject: [RFC][BZ #11064] Warn when ldconfig encounters ambiguous SONAME.
- Authentication-results: sourceware.org; auth=none
Hi,
This adds warning when there are two libraries that conflict in soname.
For simplicity I check that link was created before a ldconfig started
running and report ambiguity otherwise.
Comments?
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 21da007..ea039aa 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -460,6 +460,8 @@ create_links (const char *real_path, const char *path, const char *libname,
struct stat64 stat_lib, stat_so, lstat_so;
int do_link = 1;
int do_remove = 1;
+ static int first = 1;
+ struct stat64 first_stat;
/* XXX: The logics in this function should be simplified. */
/* Get complete path. */
@@ -512,17 +514,37 @@ create_links (const char *real_path, const char *path, const char *libname,
{
/* Remove old link. */
if (do_remove)
- if (unlink (real_full_soname))
- {
- error (0, 0, _("Can't unlink %s"), full_soname);
- do_link = 0;
- }
+ {
+
+ /* Check if we create duplicate symlink. */
+ if (!first && !lstat64 (full_soname, &lstat_so))
+ if (lstat_so.st_mtim.tv_sec > first_stat.st_mtim.tv_sec ||
+ (lstat_so.st_mtim.tv_sec == first_stat.st_mtim.tv_sec &&
+ lstat_so.st_mtim.tv_nsec >= first_stat.st_mtim.tv_nsec))
+ {
+ error (0, 0, _("Ambiguous link from %s to %s"),
+ full_soname, libname);
+ do_link = 0;
+ }
+
+ if (unlink (real_full_soname))
+ {
+ error (0, 0, _("Can't unlink %s"), full_soname);
+ do_link = 0;
+ }
+ }
/* Create symbolic link. */
if (do_link && symlink (libname, real_full_soname))
{
error (0, 0, _("Can't link %s to %s"), full_soname, libname);
do_link = 0;
}
+
+ /* Get timestamp of first change. */
+ if (first)
+ if (!lstat64 (real_full_soname, &first_stat))
+ first = 0;
+
if (opt_verbose)
{
if (do_link)