[lxc-devel] [PATCH] Set umask before populating /dev and restore it after.

Serge Hallyn serge.hallyn at canonical.com
Tue Jan 8 03:26:44 UTC 2013


Quoting Alexander Vladimirov (alexander.idkfa.vladimirov at gmail.com):
> According to docs, mknod clears each permission bit whose
> corresponding bit in the process umask is set, so we should fix it
> before creating device nodes.
> ---

d'oh.  Thank you.

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

>  src/lxc/conf.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index 85d72c9..c0a270f 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -963,6 +963,7 @@ static int setup_autodev(char *root)
>  	struct lxc_devs *d;
>  	char path[MAXPATHLEN];
>  	int i;
> +	mode_t cmask;
>  
>  	INFO("Creating initial consoles under %s/dev\n", root);
>  
> @@ -974,6 +975,7 @@ static int setup_autodev(char *root)
>  		run_makedev(path);
>  
>  	INFO("Populating /dev under %s\n", root);
> +	cmask = umask(S_IXUSR | S_IXGRP | S_IXOTH);
>  	for (i = 0; i < sizeof(lxc_devs) / sizeof(lxc_devs[0]); i++) {
>  		d = &lxc_devs[i];
>  		ret = snprintf(path, MAXPATHLEN, "%s/dev/%s", root, d->name);
> @@ -985,6 +987,7 @@ static int setup_autodev(char *root)
>  			return -1;
>  		}
>  	}
> +	umask(cmask);
>  
>  	INFO("Populated /dev under %s\n", root);
>  	return 0;
> -- 
> 1.8.1
> 
> 
> ------------------------------------------------------------------------------
> Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
> and more. Get SQL Server skills now (including 2012) with LearnDevNow -
> 200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
> SALE $99.99 this month only - learn more at:
> http://p.sf.net/sfu/learnmore_122512
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list