Commit 5e4a62bf by Daniel Lezcano

fix tty creation using confdir

tty_create uses the old conf directory, fixing this. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 5f4535a3
...@@ -107,32 +107,6 @@ static struct mount_opt mount_opt[] = { ...@@ -107,32 +107,6 @@ static struct mount_opt mount_opt[] = {
{ NULL, 0, 0 }, { NULL, 0, 0 },
}; };
static int read_info(const char *path, const char *file, char *info, size_t len)
{
int fd, ret = -1;
char f[MAXPATHLEN], *token;
snprintf(f, MAXPATHLEN, "%s/%s", path, file);
fd = open(f, O_RDONLY);
if (fd < 0) {
if (errno == ENOENT)
ret = 1;
goto out;
}
ret = read(fd, info, len);
if (ret < 0)
goto out;
token = strstr(info, "\n");
if (token)
*token = '\0';
ret = 0;
out:
close(fd);
return ret;
}
static int delete_info(const char *path, const char *file) static int delete_info(const char *path, const char *file)
{ {
char info[MAXPATHLEN]; char info[MAXPATHLEN];
...@@ -1152,25 +1126,16 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid) ...@@ -1152,25 +1126,16 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
return 0; return 0;
} }
int lxc_create_tty(const char *name, struct lxc_tty_info *tty_info) int lxc_create_tty(const char *name, struct lxc_conf *conf)
{ {
char path[MAXPATHLEN]; struct lxc_tty_info *tty_info = &conf->tty_info;
char tty[4];
int i, ret = -1; int i, ret = -1;
tty_info->nbtty = 0; /* no tty in the configuration */
if (!conf->tty)
if (!conf_has_tty(name))
return 0; return 0;
snprintf(path, MAXPATHLEN, LXCPATH "/%s", name); tty_info->nbtty = conf->tty;
if (read_info(path, "tty", tty, sizeof(tty)) < 0) {
SYSERROR("failed to read tty info");
goto out;
}
tty_info->nbtty = atoi(tty);
tty_info->pty_info = tty_info->pty_info =
malloc(sizeof(*tty_info->pty_info)*tty_info->nbtty); malloc(sizeof(*tty_info->pty_info)*tty_info->nbtty);
......
...@@ -159,7 +159,7 @@ extern int lxc_unconfigure(const char *name); ...@@ -159,7 +159,7 @@ extern int lxc_unconfigure(const char *name);
extern int lxc_create_network(struct lxc_list *networks); extern int lxc_create_network(struct lxc_list *networks);
extern int lxc_assign_network(struct lxc_list *networks, pid_t pid); extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
extern int lxc_create_tty(const char *name, struct lxc_tty_info *tty_info); extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
extern void lxc_delete_tty(struct lxc_tty_info *tty_info); extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
/* /*
......
...@@ -276,7 +276,7 @@ struct lxc_handler *lxc_init(const char *name) ...@@ -276,7 +276,7 @@ struct lxc_handler *lxc_init(const char *name)
goto out_aborting; goto out_aborting;
} }
if (lxc_create_tty(name, &handler->conf.tty_info)) { if (lxc_create_tty(name, &handler->conf)) {
ERROR("failed to create the ttys"); ERROR("failed to create the ttys");
goto out_aborting; goto out_aborting;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment