]> git.proxmox.com Git - mirror_lxc.git/commitdiff
conf: improve tty shifting function
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 4 Jun 2017 20:33:48 +0000 (22:33 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 5 Jun 2017 17:17:11 +0000 (19:17 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/start.c
src/lxc/tools/lxc_attach.c

index 7bed9a71650bc1a101b4943c3a93c1b7c073c4b3..6e6edb1934232ed3e9a842646ef0a283264f7e86 100644 (file)
@@ -3831,16 +3831,21 @@ int chown_mapped_root(char *path, struct lxc_conf *conf)
        return ret;
 }
 
-int ttys_shift_ids(struct lxc_conf *c)
+int lxc_ttys_shift_ids(struct lxc_conf *c)
 {
        if (lxc_list_empty(&c->id_map))
                return 0;
 
-       if (strcmp(c->console.name, "") !=0 && chown_mapped_root(c->console.name, c) < 0) {
-               ERROR("Failed to chown %s", c->console.name);
+       if (!strcmp(c->console.name, ""))
+               return 0;
+
+       if (chown_mapped_root(c->console.name, c) < 0) {
+               ERROR("failed to chown console \"%s\"", c->console.name);
                return -1;
        }
 
+       TRACE("chowned console \"%s\"", c->console.name);
+
        return 0;
 }
 
index d8d5a6aeafd413b7d23526299b8c6944bf514da4..2ba1b4a11785a6a84181de699b01813cbce51036 100644 (file)
@@ -472,7 +472,7 @@ extern void lxc_restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf);
 extern int find_unmapped_nsid(struct lxc_conf *conf, enum idtype idtype);
 extern int mapped_hostid(unsigned id, struct lxc_conf *conf, enum idtype idtype);
 extern int chown_mapped_root(char *path, struct lxc_conf *conf);
-extern int ttys_shift_ids(struct lxc_conf *c);
+extern int lxc_ttys_shift_ids(struct lxc_conf *c);
 extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
                         const char *fn_name);
 extern int parse_mntopts(const char *mntopts, unsigned long *mntflags,
index c0a7be5f06ccd4c9702ccd7559b5f768fa921138..bd1c62697300086795f59c489e2fc3d4c5413336 100644 (file)
@@ -481,7 +481,7 @@ struct lxc_handler *lxc_init(const char *name, struct lxc_conf *conf, const char
                goto out_restore_sigmask;
        }
 
-       if (ttys_shift_ids(conf) < 0) {
+       if (lxc_ttys_shift_ids(conf) < 0) {
                ERROR("Failed to shift tty into container.");
                goto out_restore_sigmask;
        }
index d35ec88c10525aa1f43e1c6ecf3f8ea9d2d688d8..c412dbb75f8c1b3a1127d3cd1076cb08711f0572 100644 (file)
@@ -315,7 +315,7 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
        conf->console.descr = &descr;
 
        /* Shift ttys to container. */
-       if (ttys_shift_ids(conf) < 0) {
+       if (lxc_ttys_shift_ids(conf) < 0) {
                ERROR("Failed to shift tty into container");
                goto err1;
        }