<!--
If set, the container will have a new pseudo tty
instance, making this private to it. The value specifies
- the maximum number of pseudo ttys allowed for a pts
+ the maximum number of pseudo ttys allowed for a pty
instance (this limitation is not implemented yet).
-->
もし設定された場合、コンテナは新しい pseudo tty インスタンスを持ち、それを自身のプライベートとします。
- この値は pts インスタンスに許可される pseudo tty の最大数を指定します (この制限はまだ実装されていません)。
+ この値は pty インスタンスに許可される pseudo tty の最大数を指定します (この制限はまだ実装されていません)。
</para>
</listitem>
</varlistentry>
<!--
If set, the container will have a new pseudo tty
instance, making this private to it. The value specifies
- the maximum number of pseudo ttys allowed for a pts
+ the maximum number of pseudo ttys allowed for a pty
instance (this limitation is not implemented yet).
-->
만약 지정되었다면, 컨테이너는 새 pseudo tty 인스턴스를 갖는다. 그리고 이것을 자기자신 전용으로 만든다. 지정하는 값은 pseudo tty의 최대 개수를 지정한다. (이 제한은 아직 구현되지 않았다)
<para>
If set, the container will have a new pseudo tty
instance, making this private to it. The value specifies
- the maximum number of pseudo ttys allowed for a pts
+ the maximum number of pseudo ttys allowed for a pty
instance (this limitation is not implemented yet).
</para>
</listitem>
struct winsize *winp)
{
char buf[PATH_MAX];
- int ptx, pts;
+ int ptx, pty;
ptx = open(_PATH_DEVPTMX, O_RDWR);
if (ptx == -1)
if (unlockpt(ptx))
goto fail;
- if (ptsname_r(ptx, buf, sizeof buf))
+ if (ptyname_r(ptx, buf, sizeof buf))
goto fail;
- pts = open(buf, O_RDWR | O_NOCTTY);
- if (pts == -1)
+ pty = open(buf, O_RDWR | O_NOCTTY);
+ if (pty == -1)
goto fail;
/* XXX Should we ignore errors here? */
if (termp)
- tcsetattr(pts, TCSAFLUSH, termp);
+ tcsetattr(pty, TCSAFLUSH, termp);
if (winp)
- ioctl(pts, TIOCSWINSZ, winp);
+ ioctl(pty, TIOCSWINSZ, winp);
*aptx = ptx;
- *apts = pts;
+ *apts = pty;
if (name != NULL)
strcpy(name, buf);
#include <sys/ioctl.h>
/*
- * Create pseudo tty ptx pts pair with @__name and set terminal
+ * Create pseudo tty ptx pty pair with @__name and set terminal
* attributes according to @__termp and @__winp and return handles for both
* ends in @__aptx and @__apts.
*/
static inline void lxc_attach_terminal_close_pts(struct lxc_terminal *terminal)
{
- close_prot_errno_disarm(terminal->pts);
+ close_prot_errno_disarm(terminal->pty);
}
static inline void lxc_attach_terminal_close_peer(struct lxc_terminal *terminal)
payload.ipc_socket = ipc_sockets[1];
payload.options = options;
payload.init_ctx = init_ctx;
- payload.terminal_pts_fd = terminal.pts;
+ payload.terminal_pts_fd = terminal.pty;
payload.exec_function = exec_function;
payload.exec_payload = exec_payload;
struct lxc_terminal_info *tty = &ttys->tty[i];
tty->ptx = -EBADF;
- tty->pts = -EBADF;
- ret = openpty(&tty->ptx, &tty->pts, NULL, NULL, NULL);
+ tty->pty = -EBADF;
+ ret = openpty(&tty->ptx, &tty->pty, NULL, NULL, NULL);
if (ret < 0) {
ttys->max = i;
return log_error_errno(-ENOTTY, ENOTTY, "Failed to create tty %zu", i);
}
- ret = ttyname_r(tty->pts, tty->name, sizeof(tty->name));
+ ret = ttyname_r(tty->pty, tty->name, sizeof(tty->name));
if (ret < 0) {
ttys->max = i;
- return log_error_errno(-ENOTTY, ENOTTY, "Failed to retrieve name of tty %zu pts", i);
+ return log_error_errno(-ENOTTY, ENOTTY, "Failed to retrieve name of tty %zu pty", i);
}
- DEBUG("Created tty \"%s\" with ptx fd %d and pts fd %d",
- tty->name, tty->ptx, tty->pts);
+ DEBUG("Created tty \"%s\" with ptx fd %d and pty fd %d",
+ tty->name, tty->ptx, tty->pty);
/* Prevent leaking the file descriptors to the container */
ret = fd_cloexec(tty->ptx, true);
SYSWARN("Failed to set FD_CLOEXEC flag on ptx fd %d of tty device \"%s\"",
tty->ptx, tty->name);
- ret = fd_cloexec(tty->pts, true);
+ ret = fd_cloexec(tty->pty, true);
if (ret < 0)
- SYSWARN("Failed to set FD_CLOEXEC flag on pts fd %d of tty device \"%s\"",
- tty->pts, tty->name);
+ SYSWARN("Failed to set FD_CLOEXEC flag on pty fd %d of tty device \"%s\"",
+ tty->pty, tty->name);
tty->busy = -1;
}
for (int i = 0; i < ttys->max; i++) {
struct lxc_terminal_info *tty = &ttys->tty[i];
close_prot_errno_disarm(tty->ptx);
- close_prot_errno_disarm(tty->pts);
+ close_prot_errno_disarm(tty->pty);
}
free_disarm(ttys->tty);
struct lxc_terminal_info *tty = &ttys->tty[i];
ttyfds[0] = tty->ptx;
- ttyfds[1] = tty->pts;
+ ttyfds[1] = tty->pty;
ret = lxc_abstract_unix_send_fds(sock, ttyfds, 2, NULL, 0);
if (ret < 0)
break;
- TRACE("Sent tty \"%s\" with ptx fd %d and pts fd %d to parent",
- tty->name, tty->ptx, tty->pts);
+ TRACE("Sent tty \"%s\" with ptx fd %d and pty fd %d to parent",
+ tty->name, tty->ptx, tty->pty);
}
if (ret < 0)
static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
const struct lxc_terminal *console,
- int pts_mnt_fd)
+ int pty_mnt_fd)
{
int ret;
char path[PATH_MAX];
if (ret < 0 && errno != EEXIST)
return log_error_errno(-errno, errno, "Failed to create console");
- ret = fchmod(console->pts, S_IXUSR | S_IXGRP);
+ ret = fchmod(console->pty, S_IXUSR | S_IXGRP);
if (ret < 0)
return log_error_errno(-errno, errno, "Failed to set mode \"0%o\" to \"%s\"", S_IXUSR | S_IXGRP, console->name);
- if (pts_mnt_fd >= 0) {
- ret = move_mount(pts_mnt_fd, "", -EBADF, path, MOVE_MOUNT_F_EMPTY_PATH);
+ if (pty_mnt_fd >= 0) {
+ ret = move_mount(pty_mnt_fd, "", -EBADF, path, MOVE_MOUNT_F_EMPTY_PATH);
if (!ret) {
DEBUG("Moved mount \"%s\" onto \"%s\"", console->name, path);
goto finish;
if (ret && errno != ENOSYS)
return log_error_errno(-1, errno,
"Failed to mount %d(%s) on \"%s\"",
- pts_mnt_fd, console->name, path);
+ pty_mnt_fd, console->name, path);
}
ret = safe_mount(console->name, path, "none", MS_BIND, 0, rootfs_path);
if (ret < 0)
- return log_error_errno(-1, errno, "Failed to mount %d(%s) on \"%s\"", pts_mnt_fd, console->name, path);
+ return log_error_errno(-1, errno, "Failed to mount %d(%s) on \"%s\"", pty_mnt_fd, console->name, path);
finish:
- DEBUG("Mounted pts device %d(%s) onto \"%s\"", pts_mnt_fd, console->name, path);
+ DEBUG("Mounted pty device %d(%s) onto \"%s\"", pty_mnt_fd, console->name, path);
return 0;
}
static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
const struct lxc_terminal *console,
- char *ttydir, int pts_mnt_fd)
+ char *ttydir, int pty_mnt_fd)
{
int ret;
char path[PATH_MAX], lxcpath[PATH_MAX];
if (ret < 0 && errno != EEXIST)
return log_error_errno(-errno, errno, "Failed to create console");
- ret = fchmod(console->pts, S_IXUSR | S_IXGRP);
+ ret = fchmod(console->pty, S_IXUSR | S_IXGRP);
if (ret < 0)
return log_error_errno(-errno, errno, "Failed to set mode \"0%o\" to \"%s\"", S_IXUSR | S_IXGRP, console->name);
/* bind mount console->name to '/dev/<ttydir>/console' */
- if (pts_mnt_fd >= 0) {
- ret = move_mount(pts_mnt_fd, "", -EBADF, lxcpath, MOVE_MOUNT_F_EMPTY_PATH);
+ if (pty_mnt_fd >= 0) {
+ ret = move_mount(pty_mnt_fd, "", -EBADF, lxcpath, MOVE_MOUNT_F_EMPTY_PATH);
if (!ret) {
DEBUG("Moved mount \"%s\" onto \"%s\"", console->name, lxcpath);
goto finish;
if (ret && errno != ENOSYS)
return log_error_errno(-1, errno,
"Failed to mount %d(%s) on \"%s\"",
- pts_mnt_fd, console->name, lxcpath);
+ pty_mnt_fd, console->name, lxcpath);
}
ret = safe_mount(console->name, lxcpath, "none", MS_BIND, 0, rootfs_path);
if (ret < 0)
- return log_error_errno(-1, errno, "Failed to mount %d(%s) on \"%s\"", pts_mnt_fd, console->name, lxcpath);
+ return log_error_errno(-1, errno, "Failed to mount %d(%s) on \"%s\"", pty_mnt_fd, console->name, lxcpath);
DEBUG("Mounted \"%s\" onto \"%s\"", console->name, lxcpath);
finish:
static int lxc_setup_console(const struct lxc_rootfs *rootfs,
const struct lxc_terminal *console, char *ttydir,
- int pts_mnt_fd)
+ int pty_mnt_fd)
{
if (!ttydir)
- return lxc_setup_dev_console(rootfs, console, pts_mnt_fd);
+ return lxc_setup_dev_console(rootfs, console, pty_mnt_fd);
- return lxc_setup_ttydir_console(rootfs, console, ttydir, pts_mnt_fd);
+ return lxc_setup_ttydir_console(rootfs, console, ttydir, pty_mnt_fd);
}
static int parse_mntopt(char *opt, unsigned long *flags, char **data, size_t size)
new->console.peer = -1;
new->console.proxy.busy = -1;
new->console.proxy.ptx = -1;
- new->console.proxy.pts = -1;
+ new->console.proxy.pty = -1;
new->console.ptx = -1;
- new->console.pts = -1;
+ new->console.pty = -1;
new->console.name[0] = '\0';
memset(&new->console.ringbuf, 0, sizeof(struct lxc_ringbuf));
new->maincmd_fd = -1;
int lxc_setup(struct lxc_handler *handler)
{
- __do_close int pts_mnt_fd = -EBADF;
+ __do_close int pty_mnt_fd = -EBADF;
int ret;
const char *lxcpath = handler->lxcpath, *name = handler->name;
struct lxc_conf *lxc_conf = handler->conf;
}
if (wants_console(&lxc_conf->console)) {
- pts_mnt_fd = open_tree(-EBADF, lxc_conf->console.name,
+ pty_mnt_fd = open_tree(-EBADF, lxc_conf->console.name,
OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC | AT_EMPTY_PATH);
- if (pts_mnt_fd < 0)
+ if (pty_mnt_fd < 0)
SYSTRACE("Failed to create detached mount for container's console \"%s\"",
lxc_conf->console.name);
else
return log_error(-1, "Failed to \"/proc\" LSMs");
ret = lxc_setup_console(&lxc_conf->rootfs, &lxc_conf->console,
- lxc_conf->ttys.dir, pts_mnt_fd);
+ lxc_conf->ttys.dir, pty_mnt_fd);
if (ret < 0)
return log_error(-1, "Failed to setup console");
struct lxc_handler *handler;
int console_fd;
/* The path that is bind mounted from /dev/console, if any. We don't
- * want to use `--ext-mount-map auto`'s result here because the pts
+ * want to use `--ext-mount-map auto`'s result here because the pty
* device may have a different path (e.g. if the pty number is
* different) on the target host. NULL if lxc.console.path = "none".
*/
os.action = "restore";
os.user = opts;
os.c = c;
- os.console_fd = c->lxc_conf->console.pts;
+ os.console_fd = c->lxc_conf->console.pty;
os.criu_version = criu_version;
os.handler = handler;
* setup on its console ie. the pty allocated in lxc_terminal_setup() so
* make sure that that pty is stdin,stdout,stderr.
*/
- if (handler->conf->console.pts >= 0) {
+ if (handler->conf->console.pty >= 0) {
if (handler->daemonize || !handler->conf->is_execute)
- ret = set_stdfds(handler->conf->console.pts);
+ ret = set_stdfds(handler->conf->console.pty);
else
- ret = lxc_terminal_set_stdfds(handler->conf->console.pts);
+ ret = lxc_terminal_set_stdfds(handler->conf->console.pty);
if (ret < 0) {
ERROR("Failed to redirect std{in,out,err} to pty file descriptor %d",
- handler->conf->console.pts);
+ handler->conf->console.pty);
goto out_warn_father;
}
}
close_prot_errno_disarm(handler->sigfd);
- if (handler->conf->console.pts < 0 && handler->daemonize) {
+ if (handler->conf->console.pty < 0 && handler->daemonize) {
if (devnull_fd < 0) {
devnull_fd = open_devnull();
if (devnull_fd < 0)
tty = &ttys->tty[i];
tty->busy = -1;
tty->ptx = ttyfds[0];
- tty->pts = ttyfds[1];
- TRACE("Received pty with ptx fd %d and pts fd %d from child", tty->ptx, tty->pts);
+ tty->pty = ttyfds[1];
+ TRACE("Received pty with ptx fd %d and pty fd %d from child", tty->ptx, tty->pty);
}
if (ret < 0)
close(terminal->proxy.ptx);
terminal->proxy.ptx = -1;
- close(terminal->proxy.pts);
- terminal->proxy.pts = -1;
+ close(terminal->proxy.pty);
+ terminal->proxy.pty = -1;
terminal->proxy.busy = -1;
/* This is the proxy terminal that will be given to the client, and
* that the real terminal ptx will send to / recv from.
*/
- ret = openpty(&terminal->proxy.ptx, &terminal->proxy.pts, NULL,
+ ret = openpty(&terminal->proxy.ptx, &terminal->proxy.pty, NULL,
NULL, NULL);
if (ret < 0) {
SYSERROR("Failed to open proxy terminal");
return -1;
}
- ret = ttyname_r(terminal->proxy.pts, terminal->proxy.name,
+ ret = ttyname_r(terminal->proxy.pty, terminal->proxy.name,
sizeof(terminal->proxy.name));
if (ret < 0) {
- SYSERROR("Failed to retrieve name of proxy terminal pts");
+ SYSERROR("Failed to retrieve name of proxy terminal pty");
goto on_error;
}
goto on_error;
}
- ret = fd_cloexec(terminal->proxy.pts, true);
+ ret = fd_cloexec(terminal->proxy.pty, true);
if (ret < 0) {
- SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal pts");
+ SYSERROR("Failed to set FD_CLOEXEC flag on proxy terminal pty");
goto on_error;
}
- ret = lxc_setup_tios(terminal->proxy.pts, &oldtermio);
+ ret = lxc_setup_tios(terminal->proxy.pty, &oldtermio);
if (ret < 0)
goto on_error;
goto on_error;
terminal->tty_state = ts;
- terminal->peer = terminal->proxy.pts;
+ terminal->peer = terminal->proxy.pty;
terminal->proxy.busy = sockfd;
ret = lxc_terminal_mainloop_add_peer(terminal);
if (ret < 0)
goto on_error;
- NOTICE("Opened proxy terminal with ptx fd %d and pts fd %d",
- terminal->proxy.ptx, terminal->proxy.pts);
+ NOTICE("Opened proxy terminal with ptx fd %d and pty fd %d",
+ terminal->proxy.ptx, terminal->proxy.pty);
return 0;
on_error:
if (terminal->proxy.busy != fd)
return;
- lxc_mainloop_del_handler(terminal->descr, terminal->proxy.pts);
+ lxc_mainloop_del_handler(terminal->descr, terminal->proxy.pty);
lxc_terminal_peer_proxy_free(terminal);
}
close(terminal->ptx);
terminal->ptx = -1;
- if (terminal->pts >= 0)
- close(terminal->pts);
- terminal->pts = -1;
+ if (terminal->pty >= 0)
+ close(terminal->pty);
+ terminal->pty = -1;
if (terminal->log_fd >= 0)
close(terminal->log_fd);
{
int ret;
- ret = openpty(&terminal->ptx, &terminal->pts, NULL, NULL, NULL);
+ ret = openpty(&terminal->ptx, &terminal->pty, NULL, NULL, NULL);
if (ret < 0) {
SYSERROR("Failed to open terminal");
return -1;
}
- ret = ttyname_r(terminal->pts, terminal->name, sizeof(terminal->name));
+ ret = ttyname_r(terminal->pty, terminal->name, sizeof(terminal->name));
if (ret < 0) {
- SYSERROR("Failed to retrieve name of terminal pts");
+ SYSERROR("Failed to retrieve name of terminal pty");
goto err;
}
goto err;
}
- ret = fd_cloexec(terminal->pts, true);
+ ret = fd_cloexec(terminal->pty, true);
if (ret < 0) {
- SYSERROR("Failed to set FD_CLOEXEC flag on terminal pts");
+ SYSERROR("Failed to set FD_CLOEXEC flag on terminal pty");
goto err;
}
{
terminal->name[0] = '\0';
terminal->ptx = -EBADF;
- terminal->pts = -EBADF;
+ terminal->pty = -EBADF;
terminal->busy = -1;
}
void lxc_terminal_init(struct lxc_terminal *terminal)
{
memset(terminal, 0, sizeof(*terminal));
- terminal->pts = -EBADF;
+ terminal->pty = -EBADF;
terminal->ptx = -EBADF;
terminal->peer = -EBADF;
terminal->log_fd = -EBADF;
if (strcmp(terminal->name, "") == 0)
return 0;
- ret = userns_exec_mapped_root(terminal->name, terminal->pts, c);
+ ret = userns_exec_mapped_root(terminal->name, terminal->pty, c);
if (ret < 0) {
return log_error(-1, "Failed to chown terminal %d(%s)",
- terminal->pts, terminal->name);
+ terminal->pty, terminal->name);
}
- TRACE("Chowned terminal %d(%s)", terminal->pts, terminal->name);
+ TRACE("Chowned terminal %d(%s)", terminal->pty, terminal->name);
return 0;
}
struct lxc_epoll_descr;
struct lxc_terminal_info {
- /* the path name of the pts side */
+ /* the path name of the pty side */
char name[PATH_MAX];
/* the file descriptor of the ptx */
int ptx;
- /* the file descriptor of the pts */
- int pts;
+ /* the file descriptor of the pty */
+ int pty;
/* whether the terminal is currently used */
int busy;
};
struct lxc_terminal {
- int pts;
+ int pty;
int ptx;
int peer;
struct lxc_terminal_info proxy;
/**
* Create a new terminal:
- * - calls openpty() to allocate a ptx/pts pair
- * - sets the FD_CLOEXEC flag on the ptx/pts fds
+ * - calls openpty() to allocate a ptx/pty pair
+ * - sets the FD_CLOEXEC flag on the ptx/pty fds
* - allocates either the current controlling terminal (default) or a user
- * specified terminal as proxy for the newly created ptx/pts pair
+ * specified terminal as proxy for the newly created ptx/pty pair
* - sets up SIGWINCH handler, winsz, and new terminal settings
* (Handlers for SIGWINCH and I/O are not registered in a mainloop.)
*/
* lxc_terminal_winsz: propagate winsz from one terminal to another
*
* @srcfd
- * - terminal to get size from (typically a pts pty)
+ * - terminal to get size from (typically a pty pty)
* @dstfd
* - terminal to set size on (typically a ptx pty)
*/