mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 17:12:14 +00:00
ttys: ensure container_ttys= env variable is set correctly
Fixes: #4088 Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
8ef019a6ce
commit
1e4631641e
@ -1089,17 +1089,20 @@ static int lxc_allocate_ttys(struct lxc_conf *conf)
|
||||
return -ENOMEM;
|
||||
|
||||
for (size_t i = 0; i < conf->ttys.max; i++) {
|
||||
int pty_nr = -1;
|
||||
struct lxc_terminal_info *tty = &ttys->tty[i];
|
||||
|
||||
ret = lxc_devpts_terminal(conf->devpts_fd, &tty->ptx,
|
||||
&tty->pty, &pty_nr, false);
|
||||
&tty->pty, &tty->pty_nr, false);
|
||||
if (ret < 0) {
|
||||
conf->ttys.max = i;
|
||||
return syserror_set(-ENOTTY, "Failed to create tty %zu", i);
|
||||
}
|
||||
ret = strnprintf(tty->name, sizeof(tty->name), "pts/%d", tty->pty_nr);
|
||||
if (ret < 0)
|
||||
return syserror("Failed to create tty %zu", i);
|
||||
|
||||
DEBUG("Created tty with ptx fd %d and pty fd %d and index %d",
|
||||
tty->ptx, tty->pty, pty_nr);
|
||||
tty->ptx, tty->pty, tty->pty_nr);
|
||||
tty->busy = -1;
|
||||
}
|
||||
|
||||
@ -1180,6 +1183,7 @@ static int lxc_create_ttys(struct lxc_handler *handler)
|
||||
SYSERROR("Failed to set \"container_ttys=%s\"", conf->ttys.tty_names);
|
||||
goto on_error;
|
||||
}
|
||||
TRACE("Set \"container_ttys=%s\"", conf->ttys.tty_names);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -4163,6 +4167,7 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
|
||||
for (size_t i = 0; i < ttys_max; i++) {
|
||||
terminal_info = &info_new->tty[i];
|
||||
terminal_info->busy = -1;
|
||||
terminal_info->pty_nr = -1;
|
||||
terminal_info->ptx = -EBADF;
|
||||
terminal_info->pty = -EBADF;
|
||||
}
|
||||
|
@ -1371,6 +1371,7 @@ void lxc_terminal_info_init(struct lxc_terminal_info *terminal)
|
||||
terminal->ptx = -EBADF;
|
||||
terminal->pty = -EBADF;
|
||||
terminal->busy = -1;
|
||||
terminal->pty_nr = -1;
|
||||
}
|
||||
|
||||
void lxc_terminal_init(struct lxc_terminal *terminal)
|
||||
|
@ -29,6 +29,9 @@ struct lxc_terminal_info {
|
||||
|
||||
/* whether the terminal is currently used */
|
||||
int busy;
|
||||
|
||||
/* the number of the terminal */
|
||||
int pty_nr;
|
||||
};
|
||||
|
||||
struct lxc_terminal_state {
|
||||
|
Loading…
Reference in New Issue
Block a user