return 0;
}
-int lxc_console_create(struct lxc_conf *conf)
+int lxc_pty_create(struct lxc_console *console)
{
int ret, saved_errno;
- struct lxc_console *console = &conf->console;
-
- if (!conf->rootfs.path) {
- INFO("Container does not have a rootfs. The console will be "
- "shared with the host");
- return 0;
- }
-
- if (console->path && !strcmp(console->path, "none")) {
- INFO("No console was requested");
- return 0;
- }
process_lock();
- ret = openpty(&console->master, &console->slave, console->name, NULL, NULL);
+ ret = openpty(&console->master, &console->slave, console->name, NULL,
+ NULL);
saved_errno = errno;
process_unlock();
if (ret < 0) {
goto err;
}
+ return 0;
+
+err:
+ lxc_console_delete(console);
+ return -ENODEV;
+}
+
+int lxc_console_create(struct lxc_conf *conf)
+{
+ int ret;
+ struct lxc_console *console = &conf->console;
+
+ if (!conf->rootfs.path) {
+ INFO("Container does not have a rootfs. The console will be "
+ "shared with the host");
+ return 0;
+ }
+
+ if (console->path && !strcmp(console->path, "none")) {
+ INFO("No console was requested");
+ return 0;
+ }
+
+ ret = lxc_pty_create(console);
+ if (ret < 0)
+ return -1;
+
/* create console log file */
ret = lxc_console_create_log_file(console);
if (ret < 0)
* automatically chowned to the uid/gid of the unprivileged user. For this
* ttys_shift_ids() can be called.)
*/
+extern int lxc_pty_create(struct lxc_console *console);
+
+/**
+ * lxc_console_create: Create a new pty.
+ * - In addition to lxc_pty_create() also sets up all pty logs.
+ */
extern int lxc_console_create(struct lxc_conf *);
/*