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
2a9a80cb
Commit
2a9a80cb
authored
Jan 23, 2014
by
Serge Hallyn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_mapped_rootid: avoid using (uid_t) -1
Signed-off-by:
Serge Hallyn
<
serge.hallyn@ubuntu.com
>
parent
1354955b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
conf.c
src/lxc/conf.c
+9
-4
No files found.
src/lxc/conf.c
View file @
2a9a80cb
...
...
@@ -3134,7 +3134,8 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
* return the host uid to which the container root is mapped, or -1 on
* error
*/
static
uid_t
get_mapped_rootid
(
struct
lxc_conf
*
conf
)
bool
get_mapped_rootid
(
struct
lxc_conf
*
conf
,
enum
idtype
idtype
,
unsigned
long
*
val
)
{
struct
lxc_list
*
it
;
struct
id_map
*
map
;
...
...
@@ -3145,9 +3146,10 @@ static uid_t get_mapped_rootid(struct lxc_conf *conf)
continue
;
if
(
map
->
nsid
!=
0
)
continue
;
return
(
uid_t
)
map
->
hostid
;
*
val
=
map
->
hostid
;
return
true
;
}
return
(
uid_t
)
-
1
;
return
false
;
}
int
mapped_hostid
(
int
id
,
struct
lxc_conf
*
conf
)
...
...
@@ -3304,11 +3306,14 @@ int chown_mapped_root(char *path, struct lxc_conf *conf)
{
uid_t
rootid
;
pid_t
pid
;
unsigned
long
val
;
if
(
(
rootid
=
get_mapped_rootid
(
conf
))
<=
0
)
{
if
(
!
get_mapped_rootid
(
conf
,
ID_TYPE_UID
,
&
val
)
)
{
ERROR
(
"No mapping for container root"
);
return
-
1
;
}
rootid
=
(
uid_t
)
val
;
if
(
geteuid
()
==
0
)
{
if
(
chown
(
path
,
rootid
,
-
1
)
<
0
)
{
ERROR
(
"Error chowning %s"
,
path
);
...
...
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