Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
a26822c5
Unverified
Commit
a26822c5
authored
Feb 03, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: fd-only devtps setup
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
7f50ec8b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
conf.c
src/lxc/conf.c
+7
-6
No files found.
src/lxc/conf.c
View file @
a26822c5
...
@@ -1508,6 +1508,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
...
@@ -1508,6 +1508,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
char
*
mntopt_sets
[
5
];
char
*
mntopt_sets
[
5
];
char
default_devpts_mntopts
[
256
]
=
"gid=5,newinstance,ptmxmode=0666,mode=0620"
;
char
default_devpts_mntopts
[
256
]
=
"gid=5,newinstance,ptmxmode=0666,mode=0620"
;
struct
lxc_conf
*
conf
=
handler
->
conf
;
struct
lxc_conf
*
conf
=
handler
->
conf
;
struct
lxc_rootfs
*
rootfs
=
&
conf
->
rootfs
;
int
sock
=
handler
->
data_sock
[
0
];
int
sock
=
handler
->
data_sock
[
0
];
if
(
conf
->
pty_max
<=
0
)
if
(
conf
->
pty_max
<=
0
)
...
@@ -1521,7 +1522,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
...
@@ -1521,7 +1522,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
(
void
)
umount2
(
"/dev/pts"
,
MNT_DETACH
);
(
void
)
umount2
(
"/dev/pts"
,
MNT_DETACH
);
/* Create mountpoint for devpts instance. */
/* Create mountpoint for devpts instance. */
ret
=
mkdir
(
"/dev/
pts"
,
0755
);
ret
=
mkdir
at
(
rootfs
->
dev_mntpt_fd
,
"
pts"
,
0755
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create
\"
/dev/pts
\"
directory"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to create
\"
/dev/pts
\"
directory"
);
...
@@ -1551,7 +1552,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
...
@@ -1551,7 +1552,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount new devpts instance"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to mount new devpts instance"
);
DEBUG
(
"Mount new devpts instance with options
\"
%s
\"
"
,
*
opts
);
DEBUG
(
"Mount new devpts instance with options
\"
%s
\"
"
,
*
opts
);
devpts_fd
=
open
at
(
-
EBADF
,
"/dev/pts"
,
O_CLOEXEC
|
O_DIRECTORY
|
O_PATH
|
O_NOFOLLOW
);
devpts_fd
=
open
_at
(
rootfs
->
dev_mntpt_fd
,
"pts"
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH_XDEV
,
0
);
if
(
devpts_fd
<
0
)
{
if
(
devpts_fd
<
0
)
{
devpts_fd
=
-
EBADF
;
devpts_fd
=
-
EBADF
;
TRACE
(
"Failed to create detached devpts mount"
);
TRACE
(
"Failed to create detached devpts mount"
);
...
@@ -1565,7 +1566,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
...
@@ -1565,7 +1566,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
TRACE
(
"Sent devpts file descriptor %d to parent"
,
devpts_fd
);
TRACE
(
"Sent devpts file descriptor %d to parent"
,
devpts_fd
);
/* Remove any pre-existing /dev/ptmx file. */
/* Remove any pre-existing /dev/ptmx file. */
ret
=
remove
(
"/dev/ptmx"
);
ret
=
unlinkat
(
rootfs
->
dev_mntpt_fd
,
"ptmx"
,
0
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
errno
!=
ENOENT
)
if
(
errno
!=
ENOENT
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to remove existing
\"
/dev/ptmx
\"
file"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to remove existing
\"
/dev/ptmx
\"
file"
);
...
@@ -1574,7 +1575,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
...
@@ -1574,7 +1575,7 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
}
}
/* Create dummy /dev/ptmx file as bind mountpoint for /dev/pts/ptmx. */
/* Create dummy /dev/ptmx file as bind mountpoint for /dev/pts/ptmx. */
ret
=
mknod
(
"/dev/
ptmx"
,
S_IFREG
|
0000
,
0
);
ret
=
mknod
at
(
rootfs
->
dev_mntpt_fd
,
"
ptmx"
,
S_IFREG
|
0000
,
0
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
if
(
ret
<
0
&&
errno
!=
EEXIST
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to create dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
DEBUG
(
"Created dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
DEBUG
(
"Created dummy
\"
/dev/ptmx
\"
file as bind mount target"
);
...
@@ -1588,12 +1589,12 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
...
@@ -1588,12 +1589,12 @@ static int lxc_setup_devpts_child(struct lxc_handler *handler)
ERROR
(
"Failed to bind mount
\"
/dev/pts/ptmx
\"
to
\"
/dev/ptmx
\"
"
);
ERROR
(
"Failed to bind mount
\"
/dev/pts/ptmx
\"
to
\"
/dev/ptmx
\"
"
);
/* Remove the dummy /dev/ptmx file we created above. */
/* Remove the dummy /dev/ptmx file we created above. */
ret
=
remove
(
"/dev/ptmx"
);
ret
=
unlinkat
(
rootfs
->
dev_mntpt_fd
,
"ptmx"
,
0
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to remove existing
\"
/dev/ptmx
\"
"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to remove existing
\"
/dev/ptmx
\"
"
);
/* Fallback option: Create symlink /dev/ptmx -> /dev/pts/ptmx. */
/* Fallback option: Create symlink /dev/ptmx -> /dev/pts/ptmx. */
ret
=
symlink
(
"/dev/pts/ptmx"
,
"/dev/ptmx"
);
ret
=
symlink
at
(
"/dev/pts/ptmx"
,
rootfs
->
dev_mntpt_fd
,
"/dev/ptmx"
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to create symlink from
\"
/dev/ptmx
\"
to
\"
/dev/pts/ptmx
\"
"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to create symlink from
\"
/dev/ptmx
\"
to
\"
/dev/pts/ptmx
\"
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment