Skip to content

Commit

Permalink
Add support for get_config_item and set_config_item
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Toomey <ptoomey3@biasedcoin.com>
  • Loading branch information
ptoomey3 committed Aug 28, 2015
1 parent 62d0053 commit 68d18db
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lxc/confile.c
Expand Up @@ -2510,6 +2510,10 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
return lxc_get_item_environment(c, retv, inlen);
else if (strcmp(key, "lxc.init_cmd") == 0)
v = c->init_cmd;
else if (strcmp(key, "lxc.init_uid") == 0)
return lxc_get_conf_int(c, retv, inlen, c->init_uid);
else if (strcmp(key, "lxc.init_gid") == 0)
return lxc_get_conf_int(c, retv, inlen, c->init_gid);
else return -1;

if (!v)
Expand Down
26 changes: 26 additions & 0 deletions src/tests/get_item.c
Expand Up @@ -88,6 +88,32 @@ int main(int argc, char *argv[])
}
printf("lxc.arch returned %d %s\n", ret, v2);

if (!c->set_config_item(c, "lxc.init_uid", "100")) {
fprintf(stderr, "%d: failed to set init_uid\n", __LINE__);
ret = 1;
goto out;
}
ret = c->get_config_item(c, "lxc.init_uid", v2, 255);
if (ret < 0) {
fprintf(stderr, "%d: get_config_item(lxc.init_uid) returned %d\n", __LINE__, ret);
ret = 1;
goto out;
}
printf("lxc.init_uid returned %d %s\n", ret, v2);

if (!c->set_config_item(c, "lxc.init_gid", "100")) {
fprintf(stderr, "%d: failed to set init_gid\n", __LINE__);
ret = 1;
goto out;
}
ret = c->get_config_item(c, "lxc.init_gid", v2, 255);
if (ret < 0) {
fprintf(stderr, "%d: get_config_item(lxc.init_gid) returned %d\n", __LINE__, ret);
ret = 1;
goto out;
}
printf("lxc.init_gid returned %d %s\n", ret, v2);

#define HNAME "hostname1"
// demonstrate proper usage:
char *alloced;
Expand Down

0 comments on commit 68d18db

Please sign in to comment.