From: Christian Brauner Date: Tue, 6 Apr 2021 08:30:38 +0000 (+0200) Subject: conf: fix setups where /dev is outside of LXC's control X-Git-Tag: lxc-5.0.0~218^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f0a3b6e48bf84a1405affeb52b8cdb4b19fcfce;p=thirdparty%2Flxc.git conf: fix setups where /dev is outside of LXC's control Fixes: #3770 Suggested-by: Ruben Jenster Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 37bf28d34..11c177b86 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -3457,12 +3457,6 @@ int lxc_setup(struct lxc_handler *handler) return log_error(-1, "Failed to mount \"/dev\""); } - lxc_conf->rootfs.dfd_dev = open_at(lxc_conf->rootfs.dfd_mnt, "dev", - PROTECT_OPATH_DIRECTORY, - PROTECT_LOOKUP_BENEATH_XDEV, 0); - if (lxc_conf->rootfs.dfd_dev < 0 && errno != ENOENT) - return log_error_errno(-errno, errno, "Failed to open \"/dev\""); - /* Do automatic mounts (mainly /proc and /sys), but exclude those that * need to wait until other stuff has finished. */ @@ -3481,6 +3475,11 @@ int lxc_setup(struct lxc_handler *handler) return log_error(-1, "Failed to setup mount entries"); } + lxc_conf->rootfs.dfd_dev = open_at(lxc_conf->rootfs.dfd_mnt, "dev", + PROTECT_OPATH_DIRECTORY, PROTECT_LOOKUP_BENEATH_XDEV, 0); + if (lxc_conf->rootfs.dfd_dev < 0 && errno != ENOENT) + return log_error_errno(-errno, errno, "Failed to open \"/dev\""); + if (lxc_conf->is_execute) { if (execveat_supported()) { int fd;