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
f4900711
Unverified
Commit
f4900711
authored
Jan 03, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: detect if devpts can be mounted with gid=5
Closes #2033. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
4160c3a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
27 deletions
+32
-27
conf.c
src/lxc/conf.c
+32
-27
No files found.
src/lxc/conf.c
View file @
f4900711
...
...
@@ -1416,20 +1416,46 @@ static int setup_pivot_root(const struct lxc_rootfs *rootfs)
return
0
;
}
static
int
lxc_setup_devpts
(
int
num_pts
)
static
struct
id_map
*
find_mapped_nsid_entry
(
struct
lxc_conf
*
conf
,
unsigned
id
,
enum
idtype
idtype
)
{
struct
lxc_list
*
it
;
struct
id_map
*
map
;
struct
id_map
*
retmap
=
NULL
;
lxc_list_for_each
(
it
,
&
conf
->
id_map
)
{
map
=
it
->
elem
;
if
(
map
->
idtype
!=
idtype
)
continue
;
if
(
id
>=
map
->
nsid
&&
id
<
map
->
nsid
+
map
->
range
)
{
retmap
=
map
;
break
;
}
}
return
retmap
;
}
static
int
lxc_setup_devpts
(
struct
lxc_conf
*
conf
)
{
int
ret
;
const
char
*
default_devpts_mntopts
=
"newinstance,ptmxmode=0666,mode=0620,gid=5"
;
const
char
*
default_devpts_mntopts
;
char
devpts_mntopts
[
256
];
if
(
!
num_pts
)
{
if
(
conf
->
pts
<=
0
)
{
DEBUG
(
"no new devpts instance will be mounted since no pts "
"devices are requested"
);
return
0
;
}
if
(
!
find_mapped_nsid_entry
(
conf
,
5
,
ID_TYPE_GID
))
default_devpts_mntopts
=
"newinstance,ptmxmode=0666,mode=0620"
;
else
default_devpts_mntopts
=
"newinstance,ptmxmode=0666,mode=0620,gid=5"
;
ret
=
snprintf
(
devpts_mntopts
,
sizeof
(
devpts_mntopts
),
"%s,max=%d"
,
default_devpts_mntopts
,
num_
pts
);
default_devpts_mntopts
,
conf
->
pts
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
devpts_mntopts
))
return
-
1
;
...
...
@@ -1452,7 +1478,7 @@ static int lxc_setup_devpts(int num_pts)
}
/* Mount new devpts instance. */
ret
=
mount
(
"devpts"
,
"/dev/pts"
,
"devpts"
,
MS_
MGC_VAL
,
devpts_mntopts
);
ret
=
mount
(
"devpts"
,
"/dev/pts"
,
"devpts"
,
MS_
NOSUID
|
MS_NOEXEC
,
devpts_mntopts
);
if
(
ret
<
0
)
{
SYSERROR
(
"failed to mount new devpts instance"
);
return
-
1
;
...
...
@@ -3323,7 +3349,7 @@ int lxc_setup(struct lxc_handler *handler)
return
-
1
;
}
if
(
lxc_setup_devpts
(
lxc_conf
->
pts
))
{
if
(
lxc_setup_devpts
(
lxc_conf
))
{
ERROR
(
"failed to setup the new pts instance"
);
return
-
1
;
}
...
...
@@ -3731,27 +3757,6 @@ static int run_userns_fn(void *data)
return
d
->
fn
(
d
->
arg
);
}
static
struct
id_map
*
find_mapped_nsid_entry
(
struct
lxc_conf
*
conf
,
unsigned
id
,
enum
idtype
idtype
)
{
struct
lxc_list
*
it
;
struct
id_map
*
map
;
struct
id_map
*
retmap
=
NULL
;
lxc_list_for_each
(
it
,
&
conf
->
id_map
)
{
map
=
it
->
elem
;
if
(
map
->
idtype
!=
idtype
)
continue
;
if
(
id
>=
map
->
nsid
&&
id
<
map
->
nsid
+
map
->
range
)
{
retmap
=
map
;
break
;
}
}
return
retmap
;
}
static
struct
id_map
*
mapped_nsid_add
(
struct
lxc_conf
*
conf
,
unsigned
id
,
enum
idtype
idtype
)
{
...
...
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