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
16fcdacc
Unverified
Commit
16fcdacc
authored
Mar 17, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: parse idmap=<path> mount option for rootfs
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
f6815906
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
11 deletions
+30
-11
conf.c
src/lxc/conf.c
+13
-6
conf.h
src/lxc/conf.h
+1
-1
confile.c
src/lxc/confile.c
+16
-4
No files found.
src/lxc/conf.c
View file @
16fcdacc
...
@@ -2103,7 +2103,7 @@ const char *lxc_mount_options_info[LXC_MOUNT_MAX] = {
...
@@ -2103,7 +2103,7 @@ const char *lxc_mount_options_info[LXC_MOUNT_MAX] = {
};
};
/* Remove "optional", "create=dir", and "create=file" from mntopt */
/* Remove "optional", "create=dir", and "create=file" from mntopt */
void
parse_lxc_mntopts
(
struct
lxc_mount_options
*
opts
,
char
*
mnt_opts
)
int
parse_lxc_mntopts
(
struct
lxc_mount_options
*
opts
,
char
*
mnt_opts
)
{
{
for
(
size_t
i
=
LXC_MOUNT_CREATE_DIR
;
i
<
LXC_MOUNT_MAX
;
i
++
)
{
for
(
size_t
i
=
LXC_MOUNT_CREATE_DIR
;
i
<
LXC_MOUNT_MAX
;
i
++
)
{
...
@@ -2135,13 +2135,15 @@ void parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts)
...
@@ -2135,13 +2135,15 @@ void parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts)
len
=
strlcpy
(
opts
->
userns_path
,
p2
,
idmap_path
-
p2
+
1
);
len
=
strlcpy
(
opts
->
userns_path
,
p2
,
idmap_path
-
p2
+
1
);
if
(
len
>=
sizeof
(
opts
->
userns_path
))
if
(
len
>=
sizeof
(
opts
->
userns_path
))
WARN
(
"Excessive idmap path length for
\"
idmap=<path>
\"
LXC specific mount option"
);
return
syserror_set
(
-
EIO
,
"Excessive idmap path length for
\"
idmap=<path>
\"
LXC specific mount option"
);
else
if
(
is_empty_string
(
opts
->
userns_path
))
return
syserror_set
(
-
EINVAL
,
"Missing idmap path for
\"
idmap=<path>
\"
LXC specific mount option"
);
TRACE
(
"Parse LXC specific mount option
\"
idmap=%s
\"
"
,
opts
->
userns_path
);
TRACE
(
"Parse LXC specific mount option
\"
idmap=%s
\"
"
,
opts
->
userns_path
);
break
;
break
;
default:
default:
WARN
(
"Unknown LXC specific mount option"
);
return
syserror_set
(
-
EINVAL
,
"Unknown LXC specific mount option"
);
break
;
}
}
p2
=
strchr
(
p
,
','
);
p2
=
strchr
(
p
,
','
);
...
@@ -2150,6 +2152,8 @@ void parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts)
...
@@ -2150,6 +2152,8 @@ void parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts)
else
else
memmove
(
p
,
p2
+
1
,
strlen
(
p2
+
1
)
+
1
);
memmove
(
p
,
p2
+
1
,
strlen
(
p2
+
1
)
+
1
);
}
}
return
0
;
}
}
static
int
mount_entry_create_dir_file
(
const
struct
mntent
*
mntent
,
static
int
mount_entry_create_dir_file
(
const
struct
mntent
*
mntent
,
...
@@ -2227,7 +2231,10 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
...
@@ -2227,7 +2231,10 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
return
-
1
;
return
-
1
;
}
}
parse_lxc_mntopts
(
&
opts
,
mntent
->
mnt_opts
);
ret
=
parse_lxc_mntopts
(
&
opts
,
mntent
->
mnt_opts
);
if
(
ret
<
0
)
return
ret
;
ret
=
parse_propagationopts
(
mntent
->
mnt_opts
,
&
pflags
);
ret
=
parse_propagationopts
(
mntent
->
mnt_opts
,
&
pflags
);
if
(
ret
<
0
)
if
(
ret
<
0
)
...
...
src/lxc/conf.h
View file @
16fcdacc
...
@@ -529,7 +529,7 @@ __hidden extern int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), v
...
@@ -529,7 +529,7 @@ __hidden extern int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), v
const
char
*
fn_name
);
const
char
*
fn_name
);
__hidden
extern
int
parse_mntopts
(
const
char
*
mntopts
,
unsigned
long
*
mntflags
,
char
**
mntdata
);
__hidden
extern
int
parse_mntopts
(
const
char
*
mntopts
,
unsigned
long
*
mntflags
,
char
**
mntdata
);
__hidden
extern
int
parse_propagationopts
(
const
char
*
mntopts
,
unsigned
long
*
pflags
);
__hidden
extern
int
parse_propagationopts
(
const
char
*
mntopts
,
unsigned
long
*
pflags
);
__hidden
extern
void
parse_lxc_mntopts
(
struct
lxc_mount_options
*
opts
,
char
*
mnt_opts
);
__hidden
extern
int
parse_lxc_mntopts
(
struct
lxc_mount_options
*
opts
,
char
*
mnt_opts
);
__hidden
extern
void
tmp_proc_unmount
(
struct
lxc_conf
*
lxc_conf
);
__hidden
extern
void
tmp_proc_unmount
(
struct
lxc_conf
*
lxc_conf
);
__hidden
extern
void
suggest_default_idmap
(
void
);
__hidden
extern
void
suggest_default_idmap
(
void
);
__hidden
extern
FILE
*
make_anonymous_mount_file
(
struct
lxc_list
*
mount
,
bool
include_nesting_helpers
);
__hidden
extern
FILE
*
make_anonymous_mount_file
(
struct
lxc_list
*
mount
,
bool
include_nesting_helpers
);
...
...
src/lxc/confile.c
View file @
16fcdacc
...
@@ -2790,7 +2790,7 @@ static int set_config_rootfs_mount(const char *key, const char *value,
...
@@ -2790,7 +2790,7 @@ static int set_config_rootfs_mount(const char *key, const char *value,
static
int
set_config_rootfs_options
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_rootfs_options
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
__do_free
char
*
mdata
=
NULL
,
*
opts
=
NULL
;
__do_free
char
*
dup
=
NULL
,
*
mdata
=
NULL
,
*
opts
=
NULL
;
unsigned
long
mflags
=
0
,
pflags
=
0
;
unsigned
long
mflags
=
0
,
pflags
=
0
;
struct
lxc_rootfs
*
rootfs
=
&
lxc_conf
->
rootfs
;
struct
lxc_rootfs
*
rootfs
=
&
lxc_conf
->
rootfs
;
int
ret
;
int
ret
;
...
@@ -2799,18 +2799,30 @@ static int set_config_rootfs_options(const char *key, const char *value,
...
@@ -2799,18 +2799,30 @@ static int set_config_rootfs_options(const char *key, const char *value,
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
0
;
return
0
;
ret
=
parse_mntopts
(
value
,
&
mflags
,
&
mdata
);
dup
=
strdup
(
value
);
if
(
!
dup
)
return
-
ENOMEM
;
ret
=
parse_lxc_mntopts
(
&
rootfs
->
mnt_opts
,
dup
);
if
(
ret
<
0
)
return
ret
;
ret
=
parse_mntopts
(
dup
,
&
mflags
,
&
mdata
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
ret
=
parse_propagationopts
(
value
,
&
pflags
);
ret
=
parse_propagationopts
(
dup
,
&
pflags
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
ret
=
set_config_string_item
(
&
opts
,
value
);
ret
=
set_config_string_item
(
&
opts
,
dup
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret_errno
(
ENOMEM
);
return
ret_errno
(
ENOMEM
);
if
(
rootfs
->
mnt_opts
.
create_dir
||
rootfs
->
mnt_opts
.
create_file
||
rootfs
->
mnt_opts
.
optional
||
rootfs
->
mnt_opts
.
relative
)
return
syserror_set
(
-
EINVAL
,
"Invalid LXC specifc mount option for rootfs mount"
);
rootfs
->
mountflags
=
mflags
|
pflags
;
rootfs
->
mountflags
=
mflags
|
pflags
;
rootfs
->
options
=
move_ptr
(
opts
);
rootfs
->
options
=
move_ptr
(
opts
);
rootfs
->
data
=
move_ptr
(
mdata
);
rootfs
->
data
=
move_ptr
(
mdata
);
...
...
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