[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [sandbox PATCH 1/2] builder: Use prefix '=> /' to identify lib path



On Tue, Nov 20, 2018 at 07:10:19PM +0000, Radostin Stoyanov wrote:
> The output of ldd might contain a fully qualified path on the left
> hand side of the '=>'. For example:
> 
> (glibc 2.28)
> $ ldd /usr/libexec/libvirt-sandbox-init-common  | grep ld
>     /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fcdceb96000)
> 
> (glibc 2.27)
> $ ldd /usr/libexec/libvirt-sandbox-init-common | grep ld
>     /lib64/ld-linux-x86-64.so.2 (0x00007f18135eb000)
> 
> Signed-off-by: Radostin Stoyanov <rstoyanov1 gmail com>
> ---
>  libvirt-sandbox/libvirt-sandbox-builder.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/libvirt-sandbox/libvirt-sandbox-builder.c b/libvirt-sandbox/libvirt-sandbox-builder.c
> index 8cfc2f4..7058112 100644
> --- a/libvirt-sandbox/libvirt-sandbox-builder.c
> +++ b/libvirt-sandbox/libvirt-sandbox-builder.c
> @@ -297,7 +297,7 @@ static gboolean gvir_sandbox_builder_copy_program(const char *program,
>      /* Loop over the output lines to get the path to the libraries to copy */
>      line = out;
>      while ((tmp = strchr(line, '\n'))) {
> -        gchar *start, *end;
> +        gchar *start, *end, *tmp2;
>          *tmp = '\0';
>  
>          /* Search the line for the library path */
> @@ -308,22 +308,20 @@ static gboolean gvir_sandbox_builder_copy_program(const char *program,
>              const gchar *newname = NULL;
>              *end = '\0';
>  
> +            if ((tmp2 = strstr(start, "=> ")))
> +                start = tmp2 + 3;
> +
>              /* There are countless different naming schemes for
>               * the ld-linux.so library across architectures. Pretty
>               * much the only thing in common is they start with
> -             * the two letters 'ld'. The LDD program prints it
> -             * out differently too - it doesn't include " => "
> -             * as this library is special - its actually a static
> -             * linked executable not a library.
> +             * the two letters 'ld'.
>               *
>               * To make life easier for libvirt-sandbox-init-{qemu,lxc}
>               * we just call the file 'ld.so' when we copy it into our
>               * scratch dir, no matter what it was called on the host.
>               */
> -            if (!strstr(line, " => ") &&
> -                strstr(start, "/ld")) {
> +            if (strstr(start, "/ld"))
>                  newname = "ld.so";
> -            }
>  
>              if (!gvir_sandbox_builder_copy_file(start, dest, newname, error))
>                  goto cleanup;

Reviewed-by: Daniel P. Berrangé <berrange redhat com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]