DEBUG("using '%s' as console", path);
if (!isatty(console->peer))
- return;
+ goto err1;
ts = lxc_console_sigwinch_init(console->peer, console->master);
if (!ts)
return -1;
}
+int lxc_console_set_stdfds(struct lxc_handler *handler)
+{
+ struct lxc_conf *conf = handler->conf;
+ struct lxc_console *console = &conf->console;
+
+ if (console->slave < 0)
+ return 0;
+ if (dup2(console->slave, 0) < 0 ||
+ dup2(console->slave, 1) < 0 ||
+ dup2(console->slave, 2) < 0)
+ {
+ SYSERROR("failed to dup console");
+ return -1;
+ }
+ return 0;
+}
static int lxc_console_cb_tty_stdin(int fd, uint32_t events, void *cbdata,
struct lxc_epoll_descr *descr)
int escape);
extern int lxc_console_getfd(struct lxc_container *c, int *ttynum,
int *masterfd);
+extern int lxc_console_set_stdfds(struct lxc_handler *);
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
-#include <termios.h>
#include <grp.h>
#include <poll.h>
#include <sys/param.h>
if (lsm_process_label_set(lsm_label, 1, 1) < 0)
goto out_warn_father;
+ /* Some init's such as busybox will set sane tty settings on stdin,
+ * stdout, stderr which it thinks is the console. We already set them
+ * the way we wanted on the real terminal, and we want init to do its
+ * setup on its console ie. the pty allocated in lxc_console_create()
+ * so make sure that that pty is stdin,stdout,stderr.
+ */
+ if (lxc_console_set_stdfds(handler) < 0)
+ goto out_warn_father;
+
if (lxc_check_inherited(handler->conf, handler->sigfd))
return -1;