From 035a43547eb501b3db9da6780635652d906600c1 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Mon, 20 Apr 2020 15:14:49 +0800 Subject: [PATCH] add judge whether have mount /dev entry 1.Should not populate devices 2.Should not setup devpts Signed-off-by: haozi007 --- src/lxc/conf.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index b67e138d..5155824a 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -2064,17 +2064,19 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs, return -errno; } - ret = fchmod(console->slave, S_IXUSR | S_IXGRP); - if (ret < 0) { - SYSERROR("Failed to set mode \"0%o\" to \"%s\"", - S_IXUSR | S_IXGRP, console->name); - return -errno; - } + if (console->slave > 0) { + ret = fchmod(console->slave, S_IXUSR | S_IXGRP); + if (ret < 0) { + SYSERROR("Failed to set mode \"0%o\" to \"%s\"", + S_IXUSR | S_IXGRP, console->name); + return -errno; + } - ret = safe_mount(console->name, path, "none", MS_BIND, 0, rootfs_path); - if (ret < 0) { - ERROR("Failed to mount \"%s\" on \"%s\"", console->name, path); - return -1; + ret = safe_mount(console->name, path, "none", MS_BIND, 0, rootfs_path); + if (ret < 0) { + ERROR("Failed to mount \"%s\" on \"%s\"", console->name, path); + return -1; + } } DEBUG("Mounted pts device \"%s\" onto \"%s\"", console->name, path); -- 2.25.2