From 0d0c96722c45cad6758288d7d456f1b3e4db1cf4 Mon Sep 17 00:00:00 2001 From: "David L. Leskovec" Date: Mon, 9 Jun 2008 22:51:32 +0000 Subject: [PATCH] Mon Jun 9 15:42:34 PST 2008 David L. Leskovec * src/lxc_driver.c: Make console element is output only. Always open new PTY when starting a container. Fix string overrun when storing console name in VM def struct --- ChangeLog | 8 +++++++- src/lxc_driver.c | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85d0fbe76f..1aead245c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jun 9 15:42:34 PST 2008 David L. Leskovec + + * src/lxc_driver.c: Console element is output only. Always open new + PTY when starting a container. + Fix string overrun when storing console name in VM def struct + Mon Jun 9 13:14:00 BST 2008 Richard W.M. Jones Better error messages in xend driver. @@ -56,7 +62,7 @@ Thu Jun 5 14:10:00 BST 2008 Richard W.M. Jones Wed Jun 4 23:02:21 PST 2008 David L. Leskovec - * src/lxc_driver.c: Add sanity of tty pid before kill() + * src/lxc_driver.c: Add sanity check of tty pid before kill() Ignore ECHILD errors during VM cleanup Call functions to store tty pid and cleanup tty pid file * src/lxc_conf.h: Add function to verify container process exists diff --git a/src/lxc_driver.c b/src/lxc_driver.c index e765afa679..33fa766bea 100644 --- a/src/lxc_driver.c +++ b/src/lxc_driver.c @@ -41,6 +41,7 @@ #include "lxc_driver.h" #include "driver.h" #include "internal.h" +#include "memory.h" #include "util.h" #include "memory.h" @@ -484,7 +485,7 @@ static int lxcSetupTtyTunnel(virConnectPtr conn, char *ptsStr; if (0 < strlen(vmDef->tty)) { - *ttyDev = open(vmDef->tty, O_RDWR|O_NOCTTY|O_NONBLOCK); + *ttyDev = posix_openpt(O_RDWR|O_NOCTTY|O_NONBLOCK); if (*ttyDev < 0) { lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "open() tty failed: %s", strerror(errno)); @@ -513,8 +514,11 @@ static int lxcSetupTtyTunnel(virConnectPtr conn, goto setup_complete; } /* This value needs to be stored in the container configuration file */ - if (STRNEQ(ptsStr, vmDef->tty)) { - strcpy(vmDef->tty, ptsStr); + VIR_FREE(vmDef->tty); + if (!(vmDef->tty = strdup(ptsStr))) { + lxcError(conn, NULL, VIR_ERR_NO_MEMORY, + _("unable to get storage for vm tty name")); + goto setup_complete; } /* Enter raw mode, so all characters are passed directly to child */