mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 05:03:17 +00:00
open the console later
Open the console at the setup time, otherwise the openeded file descriptor will be considered as an inherited fd and the startup will fail. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
80090207de
commit
28a4b0e55c
@ -1093,6 +1093,7 @@ struct lxc_conf *lxc_conf_init(void)
|
||||
new->utsname = NULL;
|
||||
new->tty = 0;
|
||||
new->pts = 0;
|
||||
new->console.path = NULL;
|
||||
new->console.peer = -1;
|
||||
new->console.master = -1;
|
||||
new->console.slave = -1;
|
||||
|
@ -157,6 +157,7 @@ struct lxc_console {
|
||||
int slave;
|
||||
int master;
|
||||
int peer;
|
||||
char *path;
|
||||
char name[MAXPATHLEN];
|
||||
struct termios *tios;
|
||||
};
|
||||
|
@ -620,7 +620,7 @@ static int config_cap_drop(const char *key, char *value,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int config_console(const char *key, char *value, struct lxc_conf *lxc_conf)
|
||||
static int _config_console(const char *key, char *value, struct lxc_conf *lxc_conf)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@ -635,6 +635,22 @@ static int config_console(const char *key, char *value, struct lxc_conf *lxc_con
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int config_console(const char *key, char *value,
|
||||
struct lxc_conf *lxc_conf)
|
||||
{
|
||||
char *path;
|
||||
|
||||
path = strdup(value);
|
||||
if (!path) {
|
||||
SYSERROR("failed to strdup '%s': %m", value);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lxc_conf->console.path = path;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int config_rootfs(const char *key, char *value, struct lxc_conf *lxc_conf)
|
||||
{
|
||||
if (strlen(value) >= MAXPATHLEN) {
|
||||
|
@ -143,6 +143,7 @@ int lxc_create_console(struct lxc_conf *conf)
|
||||
{
|
||||
struct termios tios;
|
||||
struct lxc_console *console = &conf->console;
|
||||
int fd;
|
||||
|
||||
if (!conf->rootfs)
|
||||
return 0;
|
||||
@ -163,6 +164,14 @@ int lxc_create_console(struct lxc_conf *conf)
|
||||
goto err;
|
||||
}
|
||||
|
||||
fd = open(console->path, O_CLOEXEC | O_RDWR | O_CREAT | O_APPEND, 0600);
|
||||
if (fd < 0) {
|
||||
SYSERROR("failed to open '%s'", console->path);
|
||||
goto err;
|
||||
}
|
||||
|
||||
console->peer = fd;
|
||||
|
||||
if (!isatty(console->peer))
|
||||
return 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user