diff --git a/config/templates/archlinux.common.conf.in b/config/templates/archlinux.common.conf.in index 7da478f81..e8c8800c2 100644 --- a/config/templates/archlinux.common.conf.in +++ b/config/templates/archlinux.common.conf.in @@ -2,7 +2,7 @@ lxc.include = @LXCTEMPLATECONFIG@/common.conf # Allow for 6 tty devices by default -lxc.tty = 6 +lxc.tty.max = 6 # Set the halt/stop signals lxc.signal.halt=SIGRTMIN+4 diff --git a/config/templates/common.conf.in b/config/templates/common.conf.in index a01348489..27925221d 100644 --- a/config/templates/common.conf.in +++ b/config/templates/common.conf.in @@ -7,7 +7,7 @@ lxc.tty.dir = lxc lxc.pts = 1024 # Setup 4 tty devices -lxc.tty = 4 +lxc.tty.max = 4 # Drop some harmful capabilities lxc.cap.drop = mac_admin mac_override sys_time sys_module sys_rawio diff --git a/config/templates/openwrt.common.conf.in b/config/templates/openwrt.common.conf.in index e9e4e51cc..8877c498e 100644 --- a/config/templates/openwrt.common.conf.in +++ b/config/templates/openwrt.common.conf.in @@ -1,6 +1,6 @@ # Default console settings lxc.tty.dir = lxc -lxc.tty = 4 +lxc.tty.max = 4 lxc.pts = 1024 # Default capabilities diff --git a/config/templates/sabayon.common.conf.in b/config/templates/sabayon.common.conf.in index 21e3148b1..0251ab5c9 100644 --- a/config/templates/sabayon.common.conf.in +++ b/config/templates/sabayon.common.conf.in @@ -7,7 +7,7 @@ lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed lxc.pts = 1024 # Setup 1 tty devices for lxc-console command -lxc.tty = 1 +lxc.tty.max = 1 # Needed for systemd distro lxc.autodev = 1 diff --git a/config/templates/voidlinux.common.conf.in b/config/templates/voidlinux.common.conf.in index 9e49fd7b8..c287b45c5 100644 --- a/config/templates/voidlinux.common.conf.in +++ b/config/templates/voidlinux.common.conf.in @@ -2,7 +2,7 @@ lxc.include = @LXCTEMPLATECONFIG@/common.conf # Allow for 6 tty devices by default -lxc.tty = 6 +lxc.tty.max = 6 # Set $VIRTUALIZATION so runit doesn't try to mount filesystems or start udevd lxc.environment=VIRTUALIZATION=lxc diff --git a/doc/lxc.container.conf.sgml.in b/doc/lxc.container.conf.sgml.in index 9a1b233c0..076efc455 100644 --- a/doc/lxc.container.conf.sgml.in +++ b/doc/lxc.container.conf.sgml.in @@ -718,7 +718,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + @@ -747,7 +747,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + diff --git a/src/lxc/conf.h b/src/lxc/conf.h index a56f172c7..82da42e33 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -330,7 +330,8 @@ struct lxc_conf { struct lxc_list caps; struct lxc_list keepcaps; struct lxc_tty_info tty_info; - char *pty_names; // comma-separated list of lxc.tty pty names + /* Comma-separated list of lxc.tty.max pty names. */ + char *pty_names; struct lxc_console console; struct lxc_rootfs rootfs; char *ttydir; diff --git a/src/lxc/confile.c b/src/lxc/confile.c index c218e0329..dc5a175a9 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -76,7 +76,7 @@ lxc_log_define(lxc_confile, lxc); lxc_config_define(personality); lxc_config_define(pts); -lxc_config_define(tty); +lxc_config_define(tty_max); lxc_config_define(tty_dir); lxc_config_define(apparmor_profile); lxc_config_define(apparmor_allow_incomplete); @@ -137,13 +137,18 @@ static struct lxc_config_t config[] = { { "lxc.arch", set_config_personality, get_config_personality, clr_config_personality, }, { "lxc.pts", set_config_pts, get_config_pts, clr_config_pts, }, { "lxc.tty.dir", set_config_tty_dir, get_config_tty_dir, clr_config_tty_dir, }, + { "lxc.tty.max", set_config_tty_max, get_config_tty_max, clr_config_tty_max, }, /* REMOVE IN LXC 3.0 legacy devttydir key */ { "lxc.devttydir", set_config_tty_dir, get_config_tty_dir, clr_config_tty_dir, }, - { "lxc.tty", set_config_tty, get_config_tty, clr_config_tty, }, + /* REMOVE IN LXC 3.0 + legacy tty key + */ + { "lxc.tty", set_config_tty_max, get_config_tty_max, clr_config_tty_max, }, + { "lxc.apparmor.profile", set_config_apparmor_profile, get_config_apparmor_profile, clr_config_apparmor_profile, }, { "lxc.apparmor.allow_incomplete", set_config_apparmor_allow_incomplete, get_config_apparmor_allow_incomplete, clr_config_apparmor_allow_incomplete, }, { "lxc.selinux.context", set_config_selinux_context, get_config_selinux_context, clr_config_selinux_context, }, @@ -1313,8 +1318,8 @@ on_error: return -1; } -static int set_config_tty(const char *key, const char *value, - struct lxc_conf *lxc_conf, void *data) +static int set_config_tty_max(const char *key, const char *value, + struct lxc_conf *lxc_conf, void *data) { /* Set config value to default. */ if (lxc_config_value_empty(value)) { @@ -2795,8 +2800,8 @@ static int get_config_pts(const char *key, char *retv, int inlen, return lxc_get_conf_int(c, retv, inlen, c->pts); } -static int get_config_tty(const char *key, char *retv, int inlen, - struct lxc_conf *c, void *data) +static int get_config_tty_max(const char *key, char *retv, int inlen, + struct lxc_conf *c, void *data) { return lxc_get_conf_int(c, retv, inlen, c->tty); } @@ -3368,8 +3373,8 @@ static inline int clr_config_pts(const char *key, struct lxc_conf *c, return 0; } -static inline int clr_config_tty(const char *key, struct lxc_conf *c, - void *data) +static inline int clr_config_tty_max(const char *key, struct lxc_conf *c, + void *data) { c->tty = 0; return 0; diff --git a/src/lxc/console.h b/src/lxc/console.h index fefdb19e2..2453d60d4 100644 --- a/src/lxc/console.h +++ b/src/lxc/console.h @@ -110,7 +110,7 @@ extern int lxc_console_mainloop_add(struct lxc_epoll_descr *, struct lxc_conf * extern void lxc_console_sigwinch(int sig); /* - * Connect to one of the ptys given to the container via lxc.tty. + * Connect to one of the ptys given to the container via lxc.tty.max. * - allocates either the current controlling pty (default) or a user specified * pty as peer pty for the containers tty * - sets up SIGWINCH handler, winsz, and new terminal settings @@ -123,10 +123,10 @@ extern int lxc_console(struct lxc_container *c, int ttynum, int escape); /* - * Allocate one of the ptys given to the container via lxc.tty. Returns an open - * fd to the allocated pty. + * Allocate one of the ptys given to the container via lxc.tty.max. Returns an + * open fd to the allocated pty. * Set ttynum to -1 to allocate the first available pty, or to a value within - * the range specified by lxc.tty to allocate a specific pty. + * the range specified by lxc.tty.max to allocate a specific pty. */ extern int lxc_console_getfd(struct lxc_container *c, int *ttynum, int *masterfd); diff --git a/src/tests/console.c b/src/tests/console.c index 351f47ae7..c47f25344 100644 --- a/src/tests/console.c +++ b/src/tests/console.c @@ -145,7 +145,7 @@ static int test_console(const char *lxcpath, goto out2; } c->load_config(c, NULL); - c->set_config_item(c, "lxc.tty", TTYCNT_STR); + c->set_config_item(c, "lxc.tty.max", TTYCNT_STR); c->save_config(c, NULL); c->want_daemonize(c, true); if (!c->startl(c, 0, NULL)) { diff --git a/src/tests/get_item.c b/src/tests/get_item.c index b73b09c3d..e0fd7b603 100644 --- a/src/tests/get_item.c +++ b/src/tests/get_item.c @@ -83,6 +83,11 @@ int main(int argc, char *argv[]) goto out; } fprintf(stderr, "%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2); + + + /* REMOVE IN LXC 3.0 + legacy lxc.tty key + */ if (!c->set_config_item(c, "lxc.tty", "4")) { fprintf(stderr, "%d: failed to set tty\n", __LINE__); goto out; diff --git a/src/tests/lxc-test-checkpoint-restore b/src/tests/lxc-test-checkpoint-restore index 09ec1e131..27c83b4be 100755 --- a/src/tests/lxc-test-checkpoint-restore +++ b/src/tests/lxc-test-checkpoint-restore @@ -32,7 +32,7 @@ lxc-create -t ubuntu -n $name || FAIL "creating container" cat >> "$(lxc-config lxc.lxcpath)/$name/config" </dev/null || echo "lxc.rootfs.path = $rootfs_path" >> $config_path/config cat <> $config_path/config lxc.uts.name = $name -lxc.tty = 4 +lxc.tty.max = 4 lxc.pts = 1024 lxc.cap.drop = sys_module mac_admin mac_override sys_time diff --git a/templates/lxc-archlinux.in b/templates/lxc-archlinux.in index defea748a..d0ca12846 100644 --- a/templates/lxc-archlinux.in +++ b/templates/lxc-archlinux.in @@ -121,7 +121,7 @@ systemctl enable systemd-resolved ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf EOF # enable getty on active ttys - local nttys=$(cat "${config_path}/config" ${shared_config} ${common_config} | grep "^lxc.tty" | head -n1 | cut -d= -f2 | tr -d "[:blank:]") + local nttys=$(cat "${config_path}/config" ${shared_config} ${common_config} | grep "^lxc.tty.max" | head -n1 | cut -d= -f2 | tr -d "[:blank:]") local devttydir=$(cat "${config_path}/config" ${shared_config} ${common_config} | grep "^lxc.tty.dir" | head -n1 | cut -d= -f2 | tr -d "[:blank:]") local devtty="" # bind getty instances to /dev//tty* if lxc.tty.dir is set diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in index e93c9e59d..36572df5d 100644 --- a/templates/lxc-busybox.in +++ b/templates/lxc-busybox.in @@ -344,7 +344,7 @@ cat <> $path/config lxc.signal.halt = SIGUSR1 lxc.rebootsignal = SIGTERM lxc.uts.name = $name -lxc.tty = 1 +lxc.tty.max = 1 lxc.pts = 1 lxc.cap.drop = sys_module mac_admin mac_override sys_time diff --git a/templates/lxc-cirros.in b/templates/lxc-cirros.in index c5e864c24..a5a8c5e9f 100644 --- a/templates/lxc-cirros.in +++ b/templates/lxc-cirros.in @@ -120,7 +120,7 @@ cat >> "$path/config" < /dev/null || echo "lxc.rootfs.path = $rootfs" >> "$path/config" cat <> $path/config -lxc.tty = $num_tty +lxc.tty.max = $num_tty lxc.uts.name = $hostname lxc.arch = $arch lxc.pts=1023 @@ -795,8 +795,8 @@ if [ -z "$rootfs" ]; then fi # determine the number of ttys - default is 4 -if grep -q '^lxc.tty' "$config" 2> /dev/null ; then - num_tty=$(awk -F= '/^lxc.tty[ \t]+=/{ print $2 }' "$config") +if grep -q '^lxc.tty.max' "$config" 2> /dev/null ; then + num_tty=$(awk -F= '/^lxc.tty.max[ \t]+=/{ print $2 }' "$config") else num_tty=4 fi diff --git a/templates/lxc-gentoo.in b/templates/lxc-gentoo.in index e16366603..9b84283e7 100644 --- a/templates/lxc-gentoo.in +++ b/templates/lxc-gentoo.in @@ -706,7 +706,7 @@ ${conf_arch_line} # set the hostname lxc.uts.name = ${name} -lxc.tty = ${tty} +lxc.tty.max = ${tty} ${conf_rootfs_line} ${portage_mount} diff --git a/templates/lxc-openmandriva.in b/templates/lxc-openmandriva.in index daf4bc08a..a55216543 100644 --- a/templates/lxc-openmandriva.in +++ b/templates/lxc-openmandriva.in @@ -229,7 +229,7 @@ copy_configuration() grep -q "^lxc.rootfs.path" $config_path/config 2>/dev/null || echo "lxc.rootfs.path = $rootfs_path" >> $config_path/config cat <> $config_path/config lxc.uts.name = $name -lxc.tty = 4 +lxc.tty.max = 4 lxc.pts = 1024 lxc.cap.drop = sys_module mac_admin mac_override sys_time lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed diff --git a/templates/lxc-pld.in b/templates/lxc-pld.in index 3f994a92b..49a8149aa 100644 --- a/templates/lxc-pld.in +++ b/templates/lxc-pld.in @@ -138,7 +138,7 @@ configure_pld_systemd() > ${rootfs_path}/etc/systemd/system/getty@.service # Setup getty service on the 4 ttys we are going to allow in the - # default config. Number should match lxc.tty + # default config. Number should match lxc.tty.max for i in 1 2 3 4; do ln -sf ../getty@.service ${rootfs_path}/etc/systemd/system/getty.target.wants/getty@tty${i}.service done @@ -239,7 +239,7 @@ copy_configuration() # Most of below settings should be taken as defaults from # lxc.include = /usr/share/lxc/config/common.conf lxc.uts.name = $utsname -lxc.tty = 4 +lxc.tty.max = 4 lxc.pts = 1024 # Consider if below line is right for systemd container lxc.mount.fstab = $config_path/fstab