#include "cgroup.h"
#include "conf.h"
#include "confile_utils.h"
+#include "console.h"
#include "error.h"
#include "log.h"
#include "lxclock.h"
return;
if (current_config == conf)
current_config = NULL;
- free(conf->console.log_path);
- free(conf->console.path);
+ lxc_pty_conf_free(&conf->console);
free(conf->rootfs.mount);
free(conf->rootfs.bdev_type);
free(conf->rootfs.options);
return ret;
}
+
+int lxc_make_controlling_pty(int fd)
+{
+ int ret;
+
+ setsid();
+
+ ret = ioctl(fd, TIOCSCTTY, (char *)NULL);
+ if (ret < 0)
+ return -1;
+
+ return 0;
+}
+
+int lxc_login_pty(int fd)
+{
+ int ret;
+
+ ret = lxc_make_controlling_pty(fd);
+ if (ret < 0)
+ return -1;
+
+ ret = lxc_console_set_stdfds(fd);
+ if (ret < 0)
+ return -1;
+
+ if (fd > STDERR_FILENO)
+ close(fd);
+
+ return 0;
+}
+
+void lxc_pty_info_init(struct lxc_pty_info *pty)
+{
+ pty->name[0] = '\0';
+ pty->master = -EBADF;
+ pty->slave = -EBADF;
+ pty->busy = -1;
+}
+
+void lxc_pty_init(struct lxc_console *pty)
+{
+ memset(pty, 0, sizeof(*pty));
+ pty->slave = -EBADF;
+ pty->master = -EBADF;
+ pty->peer = -EBADF;
+ pty->log_fd = -EBADF;
+ lxc_pty_info_init(&pty->peerpty);
+}
+
+void lxc_pty_conf_free(struct lxc_console *console)
+{
+ free(console->log_path);
+ free(console->path);
+}
extern int lxc_console_cb_con(int fd, uint32_t events, void *data,
struct lxc_epoll_descr *descr);
+extern int lxc_make_controlling_pty(int fd);
+extern int lxc_login_pty(int fd);
+extern void lxc_pty_conf_free(struct lxc_console *console);
+extern void lxc_pty_info_init(struct lxc_pty_info *pty);
+extern void lxc_pty_init(struct lxc_console *pty);
+
#endif
int lxc_init(const char *name, struct lxc_handler *handler)
{
+ int ret;
const char *loglevel;
struct lxc_conf *conf = handler->conf;