Patchwork scripts/test-installation.pl: Handle NSS crypto libraries [BZ #21940]

login
register
mail settings
Submitter Florian Weimer
Date Aug. 10, 2017, 12:30 p.m.
Message ID <20170810123022.6DB7B439942E1@oldenburg.str.redhat.com>
Download mbox | patch
Permalink /patch/22060/
State Superseded
Headers show

Comments

Florian Weimer - Aug. 10, 2017, 12:30 p.m.
The warning looked like this:

Use of uninitialized value in string ne at
  …/scripts/test-installation.pl line 184, <LDD> line 24.

It is triggered by this line of ldd output:

 libfreebl3.so => /lib64/libfreebl3.so (0x00007f055003c000)

The other lines have a version in the soname:

 libanl.so.1 => /lib64/libanl.so.1 (0x00007f055023f000)

2017-08-10  Florian Weimer  <fweimer@redhat.com>

	[BZ #21940]
	* scripts/test-installation.pl: Handle NSS crypto libaries in ldd
	output.
Florian Weimer - Oct. 5, 2017, 10:53 a.m.
On 08/10/2017 02:30 PM, Florian Weimer wrote:
> The warning looked like this:
> 
> Use of uninitialized value in string ne at
>    …/scripts/test-installation.pl line 184, <LDD> line 24.
> 
> It is triggered by this line of ldd output:
> 
>   libfreebl3.so => /lib64/libfreebl3.so (0x00007f055003c000)
> 
> The other lines have a version in the soname:
> 
>   libanl.so.1 => /lib64/libanl.so.1 (0x00007f055023f000)
> 
> 2017-08-10  Florian Weimer<fweimer@redhat.com>
> 
> 	[BZ #21940]
> 	* scripts/test-installation.pl: Handle NSS crypto libaries in ldd
> 	output.

Ping?

<https://sourceware.org/ml/libc-alpha/2017-08/msg00391.html>

Thanks,
Florian
Rical Jasan - Oct. 7, 2017, 10:50 a.m.
On 08/10/2017 05:30 AM, Florian Weimer wrote:
> The warning looked like this:
> 
> Use of uninitialized value in string ne at
>   …/scripts/test-installation.pl line 184, <LDD> line 24.
> 
> It is triggered by this line of ldd output:
> 
>  libfreebl3.so => /lib64/libfreebl3.so (0x00007f055003c000)
> 
> The other lines have a version in the soname:
> 
>  libanl.so.1 => /lib64/libanl.so.1 (0x00007f055023f000)
> 
> 2017-08-10  Florian Weimer  <fweimer@redhat.com>
> 
> 	[BZ #21940]
> 	* scripts/test-installation.pl: Handle NSS crypto libaries in ldd
> 	output.
> 
> diff --git a/scripts/test-installation.pl b/scripts/test-installation.pl
> index 4b0e9f3c4a..466c526cc9 100755
> --- a/scripts/test-installation.pl
> +++ b/scripts/test-installation.pl
> @@ -177,10 +177,15 @@ open LDD, "ldd /tmp/test-prg$$ |"
>    or die ("Couldn't execute ldd");
>  while (<LDD>) {
>    if (/^\s*lib/) {
> +    # When libcrypt is linked against NSS, some of the referenced
> +    # libraries do not have a trailing version in their soname.
>      ($name, $version1, $version2) =
> -      /^\s*lib(\w*)\.so\.([0-9\.]*)\s*=>.*\.so\.([0-9\.]*)/;
> +      /^\s*lib(\w*)\.so(?:\.([0-9\.]*))?\s*=>.*\.so(?:\.([0-9\.]*))?/;

I would use:

/^\s*lib(\w+)\.so(?:\.([0-9\.]+))?\s*=>.*\.so(?:\.([0-9\.]+))?/
           ^                  ^                           ^
to avoid matching "lib.so.".

>      $found{$name} = 1;
> -    if ($versions{$name} ne $version1 || $version1 ne $version2) {
> +    if (defined($version1) != defined($version2)
> +	|| defined($version1) != defined($versions{$name})
> +	|| (defined($versions{$name})
> +	    && ($versions{$name} ne $version1 || $version1 ne $version2))) {
>        print "Library lib$name is not correctly installed.\n";
>        print "Please check your installation!\n";
>        print "Offending line of ldd output: $_\n";

It might help readability to follow up the match with something like:

 next if ! (defined($name) && defined($version1) && defined($version2));
 next if ! (exists $versions{$name}) && defined($versions{$name}));

(I seem to recall tests on hash entries creating them when they didn't
previously exist, but that may not matter here.  Something other than
`next' may also be desirable, and the opportunity for more fine-grained
error messages is introduced, if useful.)

Then you could retain the simpler conditional:

 if ($versions{$name} ne $version1 || $version1 ne $version2) {

That also continues using string comparisons, which would be better in
case there are multiple "."'s.  NSS installs *.so files on my system,
but I do have programs that link against libraries with multiple version
points; e.g.:

$ ldd /usr/bin/avprobe | grep bz2
	libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x00007f869fab8000)

Rical

Patch

diff --git a/scripts/test-installation.pl b/scripts/test-installation.pl
index 4b0e9f3c4a..466c526cc9 100755
--- a/scripts/test-installation.pl
+++ b/scripts/test-installation.pl
@@ -177,10 +177,15 @@  open LDD, "ldd /tmp/test-prg$$ |"
   or die ("Couldn't execute ldd");
 while (<LDD>) {
   if (/^\s*lib/) {
+    # When libcrypt is linked against NSS, some of the referenced
+    # libraries do not have a trailing version in their soname.
     ($name, $version1, $version2) =
-      /^\s*lib(\w*)\.so\.([0-9\.]*)\s*=>.*\.so\.([0-9\.]*)/;
+      /^\s*lib(\w*)\.so(?:\.([0-9\.]*))?\s*=>.*\.so(?:\.([0-9\.]*))?/;
     $found{$name} = 1;
-    if ($versions{$name} ne $version1 || $version1 ne $version2) {
+    if (defined($version1) != defined($version2)
+	|| defined($version1) != defined($versions{$name})
+	|| (defined($versions{$name})
+	    && ($versions{$name} ne $version1 || $version1 ne $version2))) {
       print "Library lib$name is not correctly installed.\n";
       print "Please check your installation!\n";
       print "Offending line of ldd output: $_\n";