]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: add getter for lxc.utsname
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 31 May 2017 05:46:59 +0000 (07:46 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 31 May 2017 08:03:30 +0000 (10:03 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index 49fc770275bc66465a51b69d29aadec97e6d8c0d..fef4c16427ed1d9701dd7d4b9d0b17df3d00202e 100644 (file)
@@ -124,6 +124,8 @@ static int set_config_pivotdir(const char *, const char *, struct lxc_conf *);
 static int get_config_pivotdir(struct lxc_container *, const char *, char *, int);
 
 static int set_config_utsname(const char *, const char *, struct lxc_conf *);
+static int get_config_utsname(struct lxc_container *, const char *, char *, int);
+
 static int set_config_hook(const char *, const char *, struct lxc_conf *lxc_conf);
 static int set_config_network(const char *, const char *, struct lxc_conf *);
 static int set_config_network_type(const char *, const char *, struct lxc_conf *);
@@ -185,7 +187,7 @@ static struct lxc_config_t config[] = {
        { "lxc.rootfs.backend",       set_config_rootfs_backend,       get_config_rootfs_backend,    NULL},
        { "lxc.rootfs",               set_config_rootfs,               get_config_rootfs,            NULL},
        { "lxc.pivotdir",             set_config_pivotdir,             get_config_pivotdir,          NULL},
-       { "lxc.utsname",              set_config_utsname,               NULL, NULL},
+       { "lxc.utsname",              set_config_utsname,              get_config_utsname,           NULL},
        { "lxc.hook.pre-start",       set_config_hook,                  NULL, NULL},
        { "lxc.hook.pre-mount",       set_config_hook,                  NULL, NULL},
        { "lxc.hook.mount",           set_config_hook,                  NULL, NULL},
@@ -2906,9 +2908,7 @@ int lxc_get_config_item(struct lxc_conf *c, const char *key, char *retv,
 {
        const char *v = NULL;
 
-       if (strcmp(key, "lxc.utsname") == 0)
-               v = c->utsname ? c->utsname->nodename : NULL;
-       else if (strcmp(key, "lxc.console.logfile") == 0)
+       if (strcmp(key, "lxc.console.logfile") == 0)
                v = c->console.log_path;
        else if (strcmp(key, "lxc.console") == 0)
                v = c->console.path;
@@ -3860,3 +3860,11 @@ static int get_config_pivotdir(struct lxc_container *c, const char *key,
 {
        return 0;
 }
+
+static int get_config_utsname(struct lxc_container *c, const char *key,
+                             char *retv, int inlen)
+{
+       return lxc_get_conf_str(
+           retv, inlen,
+           c->lxc_conf->utsname ? c->lxc_conf->utsname->nodename : NULL);
+}