~serge-hallyn/ubuntu/quantal/lxc/lxc-user-ns

« back to all changes in this revision

Viewing changes to src/lxc/confile.c

  • Committer: Serge Hallyn
  • Date: 2012-10-29 16:51:57 UTC
  • Revision ID: serge.hallyn@ubuntu.com-20121029165157-xw2nxym7eo0ocxu4
Add user namespaces patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
static int config_ttydir(const char *, char *, struct lxc_conf *);
53
53
static int config_aa_profile(const char *, char *, struct lxc_conf *);
54
54
static int config_cgroup(const char *, char *, struct lxc_conf *);
 
55
static int config_idmap(const char *, char *, struct lxc_conf *);
55
56
static int config_mount(const char *, char *, struct lxc_conf *);
56
57
static int config_rootfs(const char *, char *, struct lxc_conf *);
57
58
static int config_rootfs_mount(const char *, char *, struct lxc_conf *);
86
87
        { "lxc.pts",                  config_pts                  },
87
88
        { "lxc.tty",                  config_tty                  },
88
89
        { "lxc.devttydir",            config_ttydir               },
89
 
        { "lxc.aa_profile",            config_aa_profile          },
 
90
        { "lxc.aa_profile",           config_aa_profile           },
90
91
        { "lxc.cgroup",               config_cgroup               },
 
92
        { "lxc.id_map",                config_idmap                },
91
93
        { "lxc.mount",                config_mount                },
92
94
        { "lxc.rootfs.mount",         config_rootfs_mount         },
93
95
        { "lxc.rootfs",               config_rootfs               },
930
932
        return -1;
931
933
}
932
934
 
 
935
static int config_idmap(const char *key, char *value, struct lxc_conf *lxc_conf)
 
936
{
 
937
        char *token = "lxc.id_map";
 
938
        char *subkey;
 
939
        struct lxc_list *idmaplist = NULL;
 
940
        struct id_map *idmap = NULL;
 
941
        int hostid, nsid, range;
 
942
        char type;
 
943
        int ret;
 
944
 
 
945
        subkey = strstr(key, token);
 
946
 
 
947
        if (!subkey)
 
948
                return -1;
 
949
 
 
950
        if (!strlen(subkey))
 
951
                return -1;
 
952
 
 
953
        idmaplist = malloc(sizeof(*idmaplist));
 
954
        if (!idmaplist)
 
955
                goto out;
 
956
 
 
957
        idmap = malloc(sizeof(*idmap));
 
958
        if (!idmap)
 
959
                goto out;
 
960
        memset(idmap, 0, sizeof(*idmap));
 
961
 
 
962
        idmaplist->elem = idmap;
 
963
 
 
964
        lxc_list_add_tail(&lxc_conf->id_map, idmaplist);
 
965
 
 
966
        ret = sscanf(value, "%c %d %d %d", &type, &hostid, &nsid, &range);
 
967
        INFO("read %d elements", ret);
 
968
        if (ret != 4)
 
969
                goto out;
 
970
        INFO("type %c hostid %d nsid %d range %d", type, hostid, nsid, range);
 
971
        if (type == 'U')
 
972
                idmap->idtype = ID_TYPE_UID;
 
973
        else if (type == 'G')
 
974
                idmap->idtype = ID_TYPE_GID;
 
975
        else 
 
976
                goto out;
 
977
        idmap->hostid = hostid;
 
978
        idmap->nsid = nsid;
 
979
        idmap->range = range;
 
980
 
 
981
        return 0;
 
982
 
 
983
out:
 
984
        if (idmaplist)
 
985
                free(idmaplist);
 
986
 
 
987
        if (idmap) {
 
988
                free(idmap);
 
989
        }
 
990
 
 
991
        return -1;
 
992
}
 
993
 
933
994
static int config_fstab(const char *key, char *value, struct lxc_conf *lxc_conf)
934
995
{
935
996
        if (strlen(value) >= MAXPATHLEN) {