conf{ile}: detect ns{g,u}id mapping for root

Closes #2033. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent db7cfe23
...@@ -2573,6 +2573,8 @@ struct lxc_conf *lxc_conf_init(void) ...@@ -2573,6 +2573,8 @@ struct lxc_conf *lxc_conf_init(void)
lxc_list_init(&new->caps); lxc_list_init(&new->caps);
lxc_list_init(&new->keepcaps); lxc_list_init(&new->keepcaps);
lxc_list_init(&new->id_map); lxc_list_init(&new->id_map);
new->root_nsuid_map = NULL;
new->root_nsgid_map = NULL;
lxc_list_init(&new->includes); lxc_list_init(&new->includes);
lxc_list_init(&new->aliens); lxc_list_init(&new->aliens);
lxc_list_init(&new->environment); lxc_list_init(&new->environment);
......
...@@ -282,7 +282,15 @@ struct lxc_conf { ...@@ -282,7 +282,15 @@ struct lxc_conf {
signed long personality; signed long personality;
struct utsname *utsname; struct utsname *utsname;
struct lxc_list cgroup; struct lxc_list cgroup;
struct {
struct lxc_list id_map; struct lxc_list id_map;
/* Pointer to the idmap entry for the container's root uid in
* the id_map list. Do not free! */
struct id_map *root_nsuid_map;
/* Pointer to the idmap entry for the container's root gid in
* the id_map list. Do not free! */
struct id_map *root_nsgid_map;
};
struct lxc_list network; struct lxc_list network;
int auto_mounts; int auto_mounts;
struct lxc_list mount_list; struct lxc_list mount_list;
......
...@@ -1681,6 +1681,16 @@ static int set_config_idmaps(const char *key, const char *value, ...@@ -1681,6 +1681,16 @@ static int set_config_idmaps(const char *key, const char *value,
idmap->range = range; idmap->range = range;
idmaplist->elem = idmap; idmaplist->elem = idmap;
lxc_list_add_tail(&lxc_conf->id_map, idmaplist); lxc_list_add_tail(&lxc_conf->id_map, idmaplist);
if (!lxc_conf->root_nsuid_map && idmap->idtype == ID_TYPE_UID)
if (idmap->nsid == 0)
lxc_conf->root_nsuid_map = idmap;
if (!lxc_conf->root_nsuid_map && idmap->idtype == ID_TYPE_GID)
if (idmap->nsid == 0)
lxc_conf->root_nsgid_map = idmap;
idmap = NULL; idmap = NULL;
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment