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
c4333195
Unverified
Commit
c4333195
authored
Jan 02, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: adapt idmap helpers
- mapped_hostid_entry() - idmap_add() Closes #2033. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
2b33c8bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
24 deletions
+17
-24
conf.c
src/lxc/conf.c
+17
-24
No files found.
src/lxc/conf.c
View file @
c4333195
...
...
@@ -3722,8 +3722,8 @@ static int run_userns_fn(void *data)
return
d
->
fn
(
d
->
arg
);
}
static
struct
id_map
*
mapped_hostid_entry
(
struct
lxc_conf
*
conf
,
unsigned
id
,
enum
idtype
idtype
)
static
struct
id_map
*
find_mapped_hostid_entry
(
struct
lxc_conf
*
conf
,
unsigned
id
,
enum
idtype
idtype
)
{
struct
lxc_list
*
it
;
struct
id_map
*
map
;
...
...
@@ -3740,14 +3740,6 @@ static struct id_map *mapped_hostid_entry(struct lxc_conf *conf, unsigned id,
}
}
if
(
!
retmap
)
return
NULL
;
retmap
=
malloc
(
sizeof
(
*
retmap
));
if
(
!
retmap
)
return
NULL
;
memcpy
(
retmap
,
map
,
sizeof
(
*
retmap
));
return
retmap
;
}
...
...
@@ -3755,27 +3747,28 @@ static struct id_map *mapped_hostid_entry(struct lxc_conf *conf, unsigned id,
* Allocate a new {g,u}id mapping for the given {g,u}id. Re-use an already
* existing one or establish a new one.
*/
static
struct
id_map
*
idmap
_add
(
struct
lxc_conf
*
conf
,
uid_t
id
,
enum
idtype
type
)
static
struct
id_map
*
mapped_hostid
_add
(
struct
lxc_conf
*
conf
,
uid_t
id
,
enum
idtype
type
)
{
int
hostid_mapped
;
struct
id_map
*
entry
=
NULL
;
struct
id_map
*
entry
=
NULL
,
*
tmp
=
NULL
;
entry
=
malloc
(
sizeof
(
*
entry
));
if
(
!
entry
)
return
NULL
;
/* Reuse existing mapping. */
entry
=
mapped_hostid_entry
(
conf
,
id
,
type
);
if
(
entry
)
return
entry
;
tmp
=
find_
mapped_hostid_entry
(
conf
,
id
,
type
);
if
(
tmp
)
return
memcpy
(
entry
,
tmp
,
sizeof
(
*
entry
))
;
/* Find new mapping. */
hostid_mapped
=
find_unmapped_nsid
(
conf
,
type
);
if
(
hostid_mapped
<
0
)
{
DEBUG
(
"failed to find free mapping for id %d"
,
id
);
DEBUG
(
"Failed to find free mapping for id %d"
,
id
);
free
(
entry
);
return
NULL
;
}
entry
=
malloc
(
sizeof
(
*
entry
));
if
(
!
entry
)
return
NULL
;
entry
->
idtype
=
type
;
entry
->
nsid
=
hostid_mapped
;
entry
->
hostid
=
(
unsigned
long
)
id
;
...
...
@@ -3884,10 +3877,10 @@ int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
/* Check whether the {g,u}id of the user has a mapping. */
if
(
!
host_uid_map
)
host_uid_map
=
idmap
_add
(
conf
,
euid
,
ID_TYPE_UID
);
host_uid_map
=
mapped_hostid
_add
(
conf
,
euid
,
ID_TYPE_UID
);
if
(
!
host_gid_map
)
host_gid_map
=
idmap
_add
(
conf
,
egid
,
ID_TYPE_GID
);
host_gid_map
=
mapped_hostid
_add
(
conf
,
egid
,
ID_TYPE_GID
);
if
(
!
host_uid_map
)
{
DEBUG
(
"failed to find mapping for uid %d"
,
euid
);
...
...
@@ -4095,12 +4088,12 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
/* Check whether the {g,u}id of the user has a mapping. */
if
(
!
host_uid_map
)
host_uid_map
=
idmap
_add
(
conf
,
euid
,
ID_TYPE_UID
);
host_uid_map
=
mapped_hostid
_add
(
conf
,
euid
,
ID_TYPE_UID
);
else
host_uid_map
=
container_root_uid
;
if
(
!
host_gid_map
)
host_gid_map
=
idmap
_add
(
conf
,
egid
,
ID_TYPE_GID
);
host_gid_map
=
mapped_hostid
_add
(
conf
,
egid
,
ID_TYPE_GID
);
else
host_gid_map
=
container_root_gid
;
...
...
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