diff --git a/src/lxc/conf.c b/src/lxc/conf.c index a69c4f88d..46320dd00 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -3079,6 +3079,18 @@ int lxc_clear_config_caps(struct lxc_conf *c) return 0; } +int lxc_clear_idmaps(struct lxc_conf *c) +{ + struct lxc_list *it, *next; + + lxc_list_for_each_safe(it, &c->id_map, next) { + lxc_list_del(it); + free(it->elem); + free(it); + } + return 0; +} + int lxc_clear_cgroups(struct lxc_conf *c, const char *key) { struct lxc_list *it,*next; @@ -3182,5 +3194,6 @@ void lxc_conf_free(struct lxc_conf *conf) lxc_clear_hooks(conf, "lxc.hook"); lxc_clear_mount_entries(conf); lxc_clear_saved_nics(conf); + lxc_clear_idmaps(conf); free(conf); } diff --git a/src/lxc/confile.c b/src/lxc/confile.c index a7db1178a..bb02e1c75 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -1945,6 +1945,12 @@ void write_config(FILE *fout, struct lxc_conf *c) } lxc_list_for_each(it, &c->caps) fprintf(fout, "lxc.cap.drop = %s\n", (char *)it->elem); + lxc_list_for_each(it, &c->id_map) { + struct id_map *idmap = it->elem; + fprintf(fout, "lxc.id_map = %c %lu %lu %lu\n", + idmap->idtype == ID_TYPE_UID ? 'u' : 'g', idmap->nsid, + idmap->hostid, idmap->range); + } for (i=0; ihooks[i]) fprintf(fout, "lxc.hook.%s = %s\n",