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
9fee218f
Unverified
Commit
9fee218f
authored
Jul 26, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: s/strtok_r()/lxc_iterate_parts()/g
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
69795191
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
52 deletions
+34
-52
confile.c
src/lxc/confile.c
+34
-52
No files found.
src/lxc/confile.c
View file @
9fee218f
...
@@ -979,9 +979,9 @@ static int set_config_monitor(const char *key, const char *value,
...
@@ -979,9 +979,9 @@ static int set_config_monitor(const char *key, const char *value,
static
int
set_config_group
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_group
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
char
*
groups
,
*
groupptr
,
*
sptr
,
*
token
;
char
*
groups
,
*
token
;
struct
lxc_list
*
grouplist
;
struct
lxc_list
*
grouplist
;
int
ret
=
-
1
;
int
ret
=
0
;
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
lxc_clear_groups
(
lxc_conf
);
return
lxc_clear_groups
(
lxc_conf
);
...
@@ -993,20 +993,17 @@ static int set_config_group(const char *key, const char *value,
...
@@ -993,20 +993,17 @@ static int set_config_group(const char *key, const char *value,
/* In case several groups are specified in a single line split these
/* In case several groups are specified in a single line split these
* groups in a single element for the list.
* groups in a single element for the list.
*/
*/
for
(
groupptr
=
groups
;;
groupptr
=
NULL
)
{
lxc_iterate_parts
(
token
,
groups
,
"
\t
"
)
{
token
=
strtok_r
(
groupptr
,
"
\t
"
,
&
sptr
);
if
(
!
token
)
{
ret
=
0
;
break
;
}
grouplist
=
malloc
(
sizeof
(
*
grouplist
));
grouplist
=
malloc
(
sizeof
(
*
grouplist
));
if
(
!
grouplist
)
if
(
!
grouplist
)
{
ret
=
-
1
;
break
;
break
;
}
grouplist
->
elem
=
strdup
(
token
);
grouplist
->
elem
=
strdup
(
token
);
if
(
!
grouplist
->
elem
)
{
if
(
!
grouplist
->
elem
)
{
free
(
grouplist
);
free
(
grouplist
);
ret
=
-
1
;
break
;
break
;
}
}
...
@@ -1590,7 +1587,7 @@ static int set_config_mount_fstab(const char *key, const char *value,
...
@@ -1590,7 +1587,7 @@ static int set_config_mount_fstab(const char *key, const char *value,
static
int
set_config_mount_auto
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_mount_auto
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
char
*
autos
,
*
autoptr
,
*
sptr
,
*
token
;
char
*
autos
,
*
token
;
int
i
;
int
i
;
int
ret
=
-
1
;
int
ret
=
-
1
;
static
struct
{
static
struct
{
...
@@ -1637,13 +1634,7 @@ static int set_config_mount_auto(const char *key, const char *value,
...
@@ -1637,13 +1634,7 @@ static int set_config_mount_auto(const char *key, const char *value,
if
(
!
autos
)
if
(
!
autos
)
return
-
1
;
return
-
1
;
for
(
autoptr
=
autos
;;
autoptr
=
NULL
)
{
lxc_iterate_parts
(
token
,
autos
,
"
\t
"
)
{
token
=
strtok_r
(
autoptr
,
"
\t
"
,
&
sptr
);
if
(
!
token
)
{
ret
=
0
;
break
;
}
for
(
i
=
0
;
allowed_auto_mounts
[
i
].
token
;
i
++
)
{
for
(
i
=
0
;
allowed_auto_mounts
[
i
].
token
;
i
++
)
{
if
(
!
strcmp
(
allowed_auto_mounts
[
i
].
token
,
token
))
if
(
!
strcmp
(
allowed_auto_mounts
[
i
].
token
,
token
))
break
;
break
;
...
@@ -1651,14 +1642,18 @@ static int set_config_mount_auto(const char *key, const char *value,
...
@@ -1651,14 +1642,18 @@ static int set_config_mount_auto(const char *key, const char *value,
if
(
!
allowed_auto_mounts
[
i
].
token
)
{
if
(
!
allowed_auto_mounts
[
i
].
token
)
{
ERROR
(
"Invalid filesystem to automount
\"
%s
\"
"
,
token
);
ERROR
(
"Invalid filesystem to automount
\"
%s
\"
"
,
token
);
break
;
goto
on_error
;
}
}
lxc_conf
->
auto_mounts
&=
~
allowed_auto_mounts
[
i
].
mask
;
lxc_conf
->
auto_mounts
&=
~
allowed_auto_mounts
[
i
].
mask
;
lxc_conf
->
auto_mounts
|=
allowed_auto_mounts
[
i
].
flag
;
lxc_conf
->
auto_mounts
|=
allowed_auto_mounts
[
i
].
flag
;
}
}
ret
=
0
;
on_error:
free
(
autos
);
free
(
autos
);
return
ret
;
return
ret
;
}
}
...
@@ -1690,7 +1685,7 @@ static int set_config_mount(const char *key, const char *value,
...
@@ -1690,7 +1685,7 @@ static int set_config_mount(const char *key, const char *value,
static
int
set_config_cap_keep
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_cap_keep
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
char
*
keepcaps
,
*
keepptr
,
*
sptr
,
*
token
;
char
*
keepcaps
,
*
token
;
struct
lxc_list
*
keeplist
;
struct
lxc_list
*
keeplist
;
int
ret
=
-
1
;
int
ret
=
-
1
;
...
@@ -1704,29 +1699,26 @@ static int set_config_cap_keep(const char *key, const char *value,
...
@@ -1704,29 +1699,26 @@ static int set_config_cap_keep(const char *key, const char *value,
/* In case several capability keep is specified in a single line
/* In case several capability keep is specified in a single line
* split these caps in a single element for the list.
* split these caps in a single element for the list.
*/
*/
for
(
keepptr
=
keepcaps
;;
keepptr
=
NULL
)
{
lxc_iterate_parts
(
token
,
keepcaps
,
"
\t
"
)
{
token
=
strtok_r
(
keepptr
,
"
\t
"
,
&
sptr
);
if
(
!
token
)
{
ret
=
0
;
break
;
}
if
(
!
strcmp
(
token
,
"none"
))
if
(
!
strcmp
(
token
,
"none"
))
lxc_clear_config_keepcaps
(
lxc_conf
);
lxc_clear_config_keepcaps
(
lxc_conf
);
keeplist
=
malloc
(
sizeof
(
*
keeplist
));
keeplist
=
malloc
(
sizeof
(
*
keeplist
));
if
(
!
keeplist
)
if
(
!
keeplist
)
break
;
goto
on_error
;
keeplist
->
elem
=
strdup
(
token
);
keeplist
->
elem
=
strdup
(
token
);
if
(
!
keeplist
->
elem
)
{
if
(
!
keeplist
->
elem
)
{
free
(
keeplist
);
free
(
keeplist
);
break
;
goto
on_error
;
}
}
lxc_list_add_tail
(
&
lxc_conf
->
keepcaps
,
keeplist
);
lxc_list_add_tail
(
&
lxc_conf
->
keepcaps
,
keeplist
);
}
}
ret
=
0
;
on_error:
free
(
keepcaps
);
free
(
keepcaps
);
return
ret
;
return
ret
;
...
@@ -1735,7 +1727,7 @@ static int set_config_cap_keep(const char *key, const char *value,
...
@@ -1735,7 +1727,7 @@ static int set_config_cap_keep(const char *key, const char *value,
static
int
set_config_cap_drop
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_cap_drop
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
char
*
dropcaps
,
*
dropptr
,
*
sptr
,
*
token
;
char
*
dropcaps
,
*
token
;
struct
lxc_list
*
droplist
;
struct
lxc_list
*
droplist
;
int
ret
=
-
1
;
int
ret
=
-
1
;
...
@@ -1749,26 +1741,23 @@ static int set_config_cap_drop(const char *key, const char *value,
...
@@ -1749,26 +1741,23 @@ static int set_config_cap_drop(const char *key, const char *value,
/* In case several capability drop is specified in a single line
/* In case several capability drop is specified in a single line
* split these caps in a single element for the list.
* split these caps in a single element for the list.
*/
*/
for
(
dropptr
=
dropcaps
;;
dropptr
=
NULL
)
{
lxc_iterate_parts
(
token
,
dropcaps
,
"
\t
"
)
{
token
=
strtok_r
(
dropptr
,
"
\t
"
,
&
sptr
);
if
(
!
token
)
{
ret
=
0
;
break
;
}
droplist
=
malloc
(
sizeof
(
*
droplist
));
droplist
=
malloc
(
sizeof
(
*
droplist
));
if
(
!
droplist
)
if
(
!
droplist
)
break
;
goto
on_error
;
droplist
->
elem
=
strdup
(
token
);
droplist
->
elem
=
strdup
(
token
);
if
(
!
droplist
->
elem
)
{
if
(
!
droplist
->
elem
)
{
free
(
droplist
);
free
(
droplist
);
break
;
goto
on_error
;
}
}
lxc_list_add_tail
(
&
lxc_conf
->
caps
,
droplist
);
lxc_list_add_tail
(
&
lxc_conf
->
caps
,
droplist
);
}
}
ret
=
0
;
on_error:
free
(
dropcaps
);
free
(
dropcaps
);
return
ret
;
return
ret
;
...
@@ -2067,9 +2056,8 @@ static int set_config_uts_name(const char *key, const char *value,
...
@@ -2067,9 +2056,8 @@ static int set_config_uts_name(const char *key, const char *value,
static
int
set_config_namespace_clone
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_namespace_clone
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
char
*
ns
,
*
nsptr
,
*
token
;
char
*
ns
,
*
token
;
int
cloneflag
=
0
;
int
cloneflag
=
0
;
char
*
saveptr
=
NULL
;
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
clr_config_namespace_clone
(
key
,
lxc_conf
,
data
);
return
clr_config_namespace_clone
(
key
,
lxc_conf
,
data
);
...
@@ -2084,9 +2072,8 @@ static int set_config_namespace_clone(const char *key, const char *value,
...
@@ -2084,9 +2072,8 @@ static int set_config_namespace_clone(const char *key, const char *value,
ns
=
strdup
(
value
);
ns
=
strdup
(
value
);
if
(
!
ns
)
if
(
!
ns
)
return
-
1
;
return
-
1
;
nsptr
=
ns
;
for
(;
(
token
=
strtok_r
(
nsptr
,
"
\t
"
,
&
saveptr
));
nsptr
=
NULL
)
{
lxc_iterate_parts
(
token
,
ns
,
"
\t
"
)
{
token
+=
lxc_char_left_gc
(
token
,
strlen
(
token
));
token
+=
lxc_char_left_gc
(
token
,
strlen
(
token
));
token
[
lxc_char_right_gc
(
token
,
strlen
(
token
))]
=
'\0'
;
token
[
lxc_char_right_gc
(
token
,
strlen
(
token
))]
=
'\0'
;
cloneflag
=
lxc_namespace_2_cloneflag
(
token
);
cloneflag
=
lxc_namespace_2_cloneflag
(
token
);
...
@@ -2104,9 +2091,8 @@ static int set_config_namespace_clone(const char *key, const char *value,
...
@@ -2104,9 +2091,8 @@ static int set_config_namespace_clone(const char *key, const char *value,
static
int
set_config_namespace_keep
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_namespace_keep
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
char
*
ns
,
*
nsptr
,
*
token
;
char
*
ns
,
*
token
;
int
cloneflag
=
0
;
int
cloneflag
=
0
;
char
*
saveptr
=
NULL
;
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
clr_config_namespace_keep
(
key
,
lxc_conf
,
data
);
return
clr_config_namespace_keep
(
key
,
lxc_conf
,
data
);
...
@@ -2121,9 +2107,8 @@ static int set_config_namespace_keep(const char *key, const char *value,
...
@@ -2121,9 +2107,8 @@ static int set_config_namespace_keep(const char *key, const char *value,
ns
=
strdup
(
value
);
ns
=
strdup
(
value
);
if
(
!
ns
)
if
(
!
ns
)
return
-
1
;
return
-
1
;
nsptr
=
ns
;
for
(;
(
token
=
strtok_r
(
nsptr
,
"
\t
"
,
&
saveptr
));
nsptr
=
NULL
)
{
lxc_iterate_parts
(
token
,
ns
,
"
\t
"
)
{
token
+=
lxc_char_left_gc
(
token
,
strlen
(
token
));
token
+=
lxc_char_left_gc
(
token
,
strlen
(
token
));
token
[
lxc_char_right_gc
(
token
,
strlen
(
token
))]
=
'\0'
;
token
[
lxc_char_right_gc
(
token
,
strlen
(
token
))]
=
'\0'
;
cloneflag
=
lxc_namespace_2_cloneflag
(
token
);
cloneflag
=
lxc_namespace_2_cloneflag
(
token
);
...
@@ -2422,7 +2407,7 @@ signed long lxc_config_parse_arch(const char *arch)
...
@@ -2422,7 +2407,7 @@ signed long lxc_config_parse_arch(const char *arch)
int
lxc_fill_elevated_privileges
(
char
*
flaglist
,
int
*
flags
)
int
lxc_fill_elevated_privileges
(
char
*
flaglist
,
int
*
flags
)
{
{
char
*
token
,
*
saveptr
=
NULL
;
char
*
token
;
int
i
,
aflag
;
int
i
,
aflag
;
struct
{
struct
{
const
char
*
token
;
const
char
*
token
;
...
@@ -2444,8 +2429,7 @@ int lxc_fill_elevated_privileges(char *flaglist, int *flags)
...
@@ -2444,8 +2429,7 @@ int lxc_fill_elevated_privileges(char *flaglist, int *flags)
return
0
;
return
0
;
}
}
token
=
strtok_r
(
flaglist
,
"|"
,
&
saveptr
);
lxc_iterate_parts
(
token
,
flaglist
,
"|"
)
{
while
(
token
)
{
aflag
=
-
1
;
aflag
=
-
1
;
for
(
i
=
0
;
all_privs
[
i
].
token
;
i
++
)
for
(
i
=
0
;
all_privs
[
i
].
token
;
i
++
)
...
@@ -2456,8 +2440,6 @@ int lxc_fill_elevated_privileges(char *flaglist, int *flags)
...
@@ -2456,8 +2440,6 @@ int lxc_fill_elevated_privileges(char *flaglist, int *flags)
return
-
1
;
return
-
1
;
*
flags
|=
aflag
;
*
flags
|=
aflag
;
token
=
strtok_r
(
NULL
,
"|"
,
&
saveptr
);
}
}
return
0
;
return
0
;
...
...
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