mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 16:18:16 +00:00
confile: add getter for lxc.environment
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
90ec7b6e17
commit
aa0db7d356
@ -192,6 +192,8 @@ static int set_config_group(const char *, const char *, struct lxc_conf *);
|
||||
static int get_config_group(struct lxc_container *, const char *, char *, int);
|
||||
|
||||
static int set_config_environment(const char *, const char *, struct lxc_conf *);
|
||||
static int get_config_environment(struct lxc_container *, const char *, char *, int);
|
||||
|
||||
static int set_config_init_cmd(const char *, const char *, struct lxc_conf *);
|
||||
static int set_config_init_uid(const char *, const char *, struct lxc_conf *);
|
||||
static int set_config_init_gid(const char *, const char *, struct lxc_conf *);
|
||||
@ -263,7 +265,7 @@ static struct lxc_config_t config[] = {
|
||||
{ "lxc.start.order", set_config_start, get_config_start, NULL},
|
||||
{ "lxc.monitor.unshare", set_config_monitor, get_config_monitor, NULL},
|
||||
{ "lxc.group", set_config_group, get_config_group, NULL},
|
||||
{ "lxc.environment", set_config_environment, NULL, NULL},
|
||||
{ "lxc.environment", set_config_environment, get_config_environment, NULL},
|
||||
{ "lxc.init_cmd", set_config_init_cmd, NULL, NULL},
|
||||
{ "lxc.init_uid", set_config_init_uid, NULL, NULL},
|
||||
{ "lxc.init_gid", set_config_init_gid, NULL, NULL},
|
||||
@ -2709,30 +2711,12 @@ static int lxc_get_limit_entry(struct lxc_conf *c, char *retv, int inlen,
|
||||
return fulllen;
|
||||
}
|
||||
|
||||
static int lxc_get_item_environment(struct lxc_conf *c, char *retv, int inlen)
|
||||
{
|
||||
int len, fulllen = 0;
|
||||
struct lxc_list *it;
|
||||
|
||||
if (!retv)
|
||||
inlen = 0;
|
||||
else
|
||||
memset(retv, 0, inlen);
|
||||
|
||||
lxc_list_for_each(it, &c->environment) {
|
||||
strprint(retv, inlen, "%s\n", (char *)it->elem);
|
||||
}
|
||||
return fulllen;
|
||||
}
|
||||
|
||||
int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
|
||||
int inlen)
|
||||
{
|
||||
const char *v = NULL;
|
||||
|
||||
if (strcmp(key, "lxc.environment") == 0)
|
||||
return lxc_get_item_environment(c, retv, inlen);
|
||||
else if (strcmp(key, "lxc.init_cmd") == 0)
|
||||
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);
|
||||
@ -3973,3 +3957,20 @@ static int get_config_group(struct lxc_container *c, const char *key,
|
||||
}
|
||||
return fulllen;
|
||||
}
|
||||
|
||||
static int get_config_environment(struct lxc_container *c, const char *key,
|
||||
char *retv, int inlen)
|
||||
{
|
||||
int len, fulllen = 0;
|
||||
struct lxc_list *it;
|
||||
|
||||
if (!retv)
|
||||
inlen = 0;
|
||||
else
|
||||
memset(retv, 0, inlen);
|
||||
|
||||
lxc_list_for_each(it, &c->lxc_conf->environment) {
|
||||
strprint(retv, inlen, "%s\n", (char *)it->elem);
|
||||
}
|
||||
return fulllen;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user