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] add support hints to test-container


* DJ Delorie:


> diff --git a/support/test-container.c b/support/test-container.c
> index c56b53ed81..0f4362373b 100644
> --- a/support/test-container.c
> +++ b/support/test-container.c
> @@ -609,6 +609,47 @@ rsync (char *src, char *dest, int and_delete)
>  }
>  
>  
> +
> +/* See if we can detect what the user needs to do to get unshare
> +   support working for us.  */
> +void
> +check_for_unshare_hints (void)
> +{
> +  FILE *f;
> +  int i;
> +
> +  /* Default Debian Linux disables user namespaces, but allows a way
> +     to enable them.  */
> +  f = fopen ("/proc/sys/kernel/unprivileged_userns_clone", "r");
> +  if (f)

No implicit NULL check, please.

> @@ -873,7 +914,11 @@ main (int argc, char **argv)
>        /* Older kernels may not support all the options, or security
>  	 policy may block this call.  */
>        if (errno == EINVAL || errno == EPERM)
> -	FAIL_UNSUPPORTED ("unable to unshare user/fs: %s", strerror (errno));
> +	{
> +	  if (errno == EPERM)
> +	    check_for_unshare_hints ();
> +	  FAIL_UNSUPPORTED ("unable to unshare user/fs: %s", strerror (errno));
> +	}

errno has been clobbered at this point.  You need to save its value
before calling check_for_unshare_hints.

Thanks,
Florian


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