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
503e11fd
Unverified
Commit
503e11fd
authored
Mar 25, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: use lxc_list_new() everywhere
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
abd9627a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
25 deletions
+21
-25
conf.c
src/lxc/conf.c
+21
-25
No files found.
src/lxc/conf.c
View file @
503e11fd
...
...
@@ -286,7 +286,7 @@ static int run_buffer(char *buffer)
if
(
!
f
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to popen() %s"
,
buffer
);
output
=
m
alloc
(
LXC_LOG_BUFFER_SIZE
);
output
=
z
alloc
(
LXC_LOG_BUFFER_SIZE
);
if
(
!
output
)
return
log_error_errno
(
-
1
,
ENOMEM
,
"Failed to allocate memory for %s"
,
buffer
);
...
...
@@ -357,7 +357,7 @@ int run_script_argv(const char *name, unsigned int hook_version,
return
-
EFBIG
;
}
buffer
=
m
alloc
(
size
);
buffer
=
z
alloc
(
size
);
if
(
!
buffer
)
return
-
ENOMEM
;
...
...
@@ -797,7 +797,7 @@ static bool append_ttyname(char **pp, char *name)
size_t
size
;
if
(
!*
pp
)
{
*
pp
=
m
alloc
(
strlen
(
name
)
+
strlen
(
"container_ttys="
)
+
1
);
*
pp
=
z
alloc
(
strlen
(
name
)
+
strlen
(
"container_ttys="
)
+
1
);
if
(
!*
pp
)
return
false
;
...
...
@@ -2655,10 +2655,9 @@ struct lxc_conf *lxc_conf_init(void)
int
i
;
struct
lxc_conf
*
new
;
new
=
m
alloc
(
sizeof
(
*
new
));
new
=
z
alloc
(
sizeof
(
*
new
));
if
(
!
new
)
return
NULL
;
memset
(
new
,
0
,
sizeof
(
*
new
));
new
->
loglevel
=
LXC_LOG_LEVEL_NOTSET
;
new
->
personality
=
-
1
;
...
...
@@ -4036,7 +4035,7 @@ static struct id_map *mapped_nsid_add(const struct lxc_conf *conf, unsigned id,
if
(
!
map
)
return
NULL
;
retmap
=
m
alloc
(
sizeof
(
*
retmap
));
retmap
=
z
alloc
(
sizeof
(
*
retmap
));
if
(
!
retmap
)
return
NULL
;
...
...
@@ -4075,7 +4074,7 @@ static struct id_map *mapped_hostid_add(const struct lxc_conf *conf, uid_t id,
int
hostid_mapped
;
struct
id_map
*
tmp
=
NULL
;
entry
=
m
alloc
(
sizeof
(
*
entry
));
entry
=
z
alloc
(
sizeof
(
*
entry
));
if
(
!
entry
)
return
NULL
;
...
...
@@ -4139,13 +4138,12 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
return
log_debug
(
NULL
,
"Failed to find mapping for gid %d"
,
egid
);
/* Allocate new {g,u}id map list. */
idmap
=
malloc
(
sizeof
(
*
idmap
)
);
idmap
=
lxc_list_new
(
);
if
(
!
idmap
)
return
NULL
;
lxc_list_init
(
idmap
);
/* Add container root to the map. */
tmplist
=
malloc
(
sizeof
(
*
tmplist
)
);
tmplist
=
lxc_list_new
(
);
if
(
!
tmplist
)
return
NULL
;
/* idmap will now keep track of that memory. */
...
...
@@ -4154,7 +4152,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
if
(
container_root_uid
)
{
/* Add container root to the map. */
tmplist
=
malloc
(
sizeof
(
*
tmplist
)
);
tmplist
=
lxc_list_new
(
);
if
(
!
tmplist
)
return
NULL
;
/* idmap will now keep track of that memory. */
...
...
@@ -4162,7 +4160,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
lxc_list_add_tail
(
idmap
,
tmplist
);
}
tmplist
=
malloc
(
sizeof
(
*
tmplist
)
);
tmplist
=
lxc_list_new
(
);
if
(
!
tmplist
)
return
NULL
;
/* idmap will now keep track of that memory. */
...
...
@@ -4170,7 +4168,7 @@ static struct lxc_list *get_minimal_idmap(const struct lxc_conf *conf,
lxc_list_add_tail
(
idmap
,
tmplist
);
if
(
container_root_gid
)
{
tmplist
=
malloc
(
sizeof
(
*
tmplist
)
);
tmplist
=
lxc_list_new
(
);
if
(
!
tmplist
)
return
NULL
;
/* idmap will now keep track of that memory. */
...
...
@@ -4440,20 +4438,19 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
egid
=
getegid
();
/* Allocate new {g,u}id map list. */
idmap
=
malloc
(
sizeof
(
*
idmap
)
);
idmap
=
lxc_list_new
(
);
if
(
!
idmap
)
goto
on_error
;
lxc_list_init
(
idmap
);
/* Find container root. */
lxc_list_for_each
(
cur
,
&
conf
->
id_map
)
{
struct
id_map
*
tmpmap
;
tmplist
=
malloc
(
sizeof
(
*
tmplist
)
);
tmplist
=
lxc_list_new
(
);
if
(
!
tmplist
)
goto
on_error
;
tmpmap
=
m
alloc
(
sizeof
(
*
tmpmap
));
tmpmap
=
z
alloc
(
sizeof
(
*
tmpmap
));
if
(
!
tmpmap
)
{
free
(
tmplist
);
goto
on_error
;
...
...
@@ -4515,7 +4512,7 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
if
(
host_uid_map
&&
(
host_uid_map
!=
container_root_uid
))
{
/* Add container root to the map. */
tmplist
=
malloc
(
sizeof
(
*
tmplist
)
);
tmplist
=
lxc_list_new
(
);
if
(
!
tmplist
)
goto
on_error
;
lxc_list_add_elem
(
tmplist
,
host_uid_map
);
...
...
@@ -4525,7 +4522,7 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
host_uid_map
=
NULL
;
if
(
host_gid_map
&&
(
host_gid_map
!=
container_root_gid
))
{
tmplist
=
malloc
(
sizeof
(
*
tmplist
)
);
tmplist
=
lxc_list_new
(
);
if
(
!
tmplist
)
goto
on_error
;
lxc_list_add_elem
(
tmplist
,
host_gid_map
);
...
...
@@ -4675,10 +4672,9 @@ int userns_exec_mapped_root(const char *path, int path_fd,
TRACE
(
"Chowned %d(%s) to -1:%d"
,
target_fd
,
path
,
hostgid
);
}
idmap
=
malloc
(
sizeof
(
*
idmap
)
);
idmap
=
lxc_list_new
(
);
if
(
!
idmap
)
return
-
ENOMEM
;
lxc_list_init
(
idmap
);
/* "u:0:rootuid:1" */
ret
=
add_idmap_entry
(
idmap
,
ID_TYPE_UID
,
0
,
container_host_uid
,
1
);
...
...
@@ -4810,7 +4806,7 @@ static char *getuname(void)
if
(
bufsize
==
-
1
)
bufsize
=
1024
;
buf
=
m
alloc
(
bufsize
);
buf
=
z
alloc
(
bufsize
);
if
(
!
buf
)
return
NULL
;
...
...
@@ -4838,7 +4834,7 @@ static char *getgname(void)
if
(
bufsize
==
-
1
)
bufsize
=
1024
;
buf
=
m
alloc
(
bufsize
);
buf
=
z
alloc
(
bufsize
);
if
(
!
buf
)
return
NULL
;
...
...
@@ -4977,14 +4973,14 @@ struct lxc_list *sort_cgroup_settings(struct lxc_list *cgroup_settings)
struct
lxc_cgroup
*
cg
=
NULL
;
struct
lxc_list
*
it
=
NULL
,
*
item
=
NULL
,
*
memsw_limit
=
NULL
;
result
=
malloc
(
sizeof
(
*
result
)
);
result
=
lxc_list_new
(
);
if
(
!
result
)
return
NULL
;
lxc_list_init
(
result
);
/* Iterate over the cgroup settings and copy them to the output list. */
lxc_list_for_each
(
it
,
cgroup_settings
)
{
item
=
m
alloc
(
sizeof
(
*
item
));
item
=
z
alloc
(
sizeof
(
*
item
));
if
(
!
item
)
{
free_cgroup_settings
(
result
);
return
NULL
;
...
...
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