From: Alexander Vladimirov Date: Tue, 8 Jan 2013 01:08:54 +0000 (+0800) Subject: Set umask before populating /dev and restore it after. X-Git-Tag: lxc-0.9.0.alpha3~1^2~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a32201c5a442c2732861aeee1a5f70909718b90;p=thirdparty%2Flxc.git Set umask before populating /dev and restore it after. 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. Signed-off-by: Alexander Vladimirov Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 4f041dca4..1c02850a2 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;