[lxc-devel] [lxc/master] conf: mount devpts without "max" on EINVAL
brauner on Github
lxc-bot at linuxcontainers.org
Mon Jul 30 13:56:58 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 441 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180730/b657464d/attachment.bin>
-------------- next part --------------
From dfbd4730392d069e9f06051779676411f81fa4ad Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 30 Jul 2018 15:55:09 +0200
Subject: [PATCH] conf: mount devpts without "max" on EINVAL
The "max" option to devpts got introduced in kernel 3.4.
Closes #2490.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/conf.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index ff9bd091b..bc35c9ff6 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1612,7 +1612,7 @@ static const struct id_map *find_mapped_nsid_entry(struct lxc_conf *conf, unsign
static int lxc_setup_devpts(struct lxc_conf *conf)
{
int ret;
- const char *default_devpts_mntopts = "gid=5,newinstance,ptmxmode=0666,mode=0620";
+ char default_devpts_mntopts[] = "gid=5,newinstance,ptmxmode=0666,mode=0620";
char devpts_mntopts[256];
if (conf->pty_max <= 0) {
@@ -1642,9 +1642,20 @@ static int lxc_setup_devpts(struct lxc_conf *conf)
/* mount new devpts instance */
ret = mount("devpts", "/dev/pts", "devpts", MS_NOSUID | MS_NOEXEC, devpts_mntopts);
if (ret < 0) {
+ /* try mounting without "max" */
+ if (errno == EINVAL) {
+ devpts_mntopts[sizeof(default_devpts_mntopts) - 1] = '\0';
+ ret = mount("devpts", "/dev/pts", "devpts",
+ MS_NOSUID | MS_NOEXEC, devpts_mntopts);
+ if (ret < 0) {
+ SYSERROR("Failed to mount new devpts instance");
+ return -1;
+ }
+ }
+
/* try mounting without gid=5 */
- ret = mount("devpts", "/dev/pts", "devpts",
- MS_NOSUID | MS_NOEXEC, devpts_mntopts + sizeof("gid=5"));
+ ret = mount("devpts", "/dev/pts", "devpts", MS_NOSUID | MS_NOEXEC,
+ devpts_mntopts + sizeof("gid=5"));
if (ret < 0) {
SYSERROR("Failed to mount new devpts instance");
return -1;
More information about the lxc-devel
mailing list