This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [BZ #14462] Fix paths shown by ldconfig -r


On Friday, September 14, 2012 13:42:19 Allan McRae wrote:
> This fixes the potentially confusing paths shown by ldconfig when used
> with the -r option.
> 
> Before:
> 
> $ ldconfig -r /tmp/ /foo
> ldconfig: Warning: ignoring configuration file that cannot be opened:
> /etc/ld.so.conf: No such file or directory
> ldconfig: Can't create temporary cache file /tmp/etc/ld.so.cache~: No
> such file
> or directory
> 
> $ sudo ldconfig -r /tmp/ /foo
> ldconfig: Warning: ignoring configuration file that cannot be opened:
> /etc/ld.so.conf: No such file or directory
> ldconfig: Can't create temporary cache file /etc/ld.so.cache~: No such
> file or
> directory
> 
> 
> After:
> 
> $ ldconfig -r /tmp/ /foo
> ldconfig: Warning: ignoring configuration file that cannot be opened:
> /tmp/etc/ld.so.conf: No such file or directory
> ldconfig: Can't create temporary cache file /tmp/etc/ld.so.cache~: No
> such file or directory
> 
> $ sudo ldconfig -r /tmp/ /foo
> ldconfig: Warning: ignoring configuration file that cannot be opened:
> /tmp/etc/ld.so.conf: No such file or directory
> ldconfig: Can't create temporary cache file /tmp/etc/ld.so.cache~: No
> such file or directory
> 

What happens if I call ldconfig with ldconfig -r /tmp /foo without - so 
without a trailing slash? Would that display a path with one / missing?

Andreas

> 
> 2012-09-14  Allan McRae  <allan@archlinux.org>
> 
> 	[BZ #14462]
> 	* elf/ldconfig.c (main): Save path to chroot dir for use in
> 	error messages.
> 	(parse_conf): Print full path to missing conf file.
> 	* elf/config.c (save_cache): Print full path to failed
> 	temporary cache file.
> 
> 
> 
> diff --git a/elf/cache.c b/elf/cache.c
> index db8b9fa..d78b7c8 100644
> --- a/elf/cache.c
> +++ b/elf/cache.c
> @@ -50,6 +50,9 @@ static struct cache_entry *entries;
>  static const char *flag_descr[] =
>  { "libc4", "ELF", "libc5", "libc6"};
> 
> +extern char *opt_chroot;
> +extern char *chroot_dir;
> +
>  /* Print a single entry.  */
>  static void
>  print_entry (const char *lib, int flag, unsigned int osversion,
> @@ -403,8 +406,8 @@ save_cache (const char *cache_name)
>    int fd = open (temp_name, O_CREAT|O_WRONLY|O_TRUNC|O_NOFOLLOW,
>  		 S_IRUSR|S_IWUSR);
>    if (fd < 0)
> -    error (EXIT_FAILURE, errno, _("Can't create temporary cache file
> %s"), -	   temp_name);
> +    error (EXIT_FAILURE, errno, _("Can't create temporary cache file
> %s%s"),
> +	   opt_chroot ? "" : chroot_dir, temp_name);
> 
>    /* Write contents.  */
>    if (opt_format != 2)
> diff --git a/elf/ldconfig.c b/elf/ldconfig.c
> index 8d6e77f..b4821e7 100644
> --- a/elf/ldconfig.c
> +++ b/elf/ldconfig.c
> @@ -105,8 +105,11 @@ static int opt_link = 1;
>  /* Only process directories specified on the command line.  */
>  static int opt_only_cline;
> 
> -/* Path to root for chroot.  */
> -static char *opt_chroot;
> +/* Directory argument for chroot.  */
> +char *opt_chroot;
> +
> +/* Path to root.  */
> +char *chroot_dir;
> 
>  /* Manually link given shared libraries.  */
>  static int opt_manual_link;
> @@ -1062,8 +1065,8 @@ parse_conf (const char *filename, bool
> do_chroot) if (file == NULL)
>      {
>        error (0, errno, _("\
> -Warning: ignoring configuration file that cannot be opened: %s"),
> -	     canon);
> +Warning: ignoring configuration file that cannot be opened: %s%s"),
> +	     chroot_dir, filename);
>        if (canon != filename)
>  	free ((char *) canon);
>        return;
> @@ -1276,6 +1279,8 @@ main (int argc, char **argv)
>        if (endp == opt_chroot)
>  	opt_chroot = NULL;
> 
> +      chroot_dir = opt_chroot;
> +
>        if (opt_chroot)
>  	{
>  	  /* It is faster to use chroot if we can.  */
-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]