2
0
mirror of git://github.com/lxc/lxc synced 2025-08-22 06:51:39 +00:00

Merge pull request #4089 from brauner/2022-02-22.fixes

ttys: ensure container_ttys= env variable is set correctly
This commit is contained in:
Stéphane Graber 2022-02-22 10:52:37 -05:00 committed by GitHub
commit 642052d58c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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 {