mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-15 12:06:12 +00:00
Merge pull request #1108 from brauner/2016-07-29/fix_android_part_n
criu: replace tmpnam() with mkstemp()
This commit is contained in:
commit
4b6d675bf7
@ -603,11 +603,13 @@ out_unlock:
|
|||||||
static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_opts *opts, char *criu_version)
|
static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_opts *opts, char *criu_version)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char pidfile[L_tmpnam];
|
|
||||||
struct lxc_handler *handler;
|
struct lxc_handler *handler;
|
||||||
int status, pipes[2] = {-1, -1};
|
int fd, status;
|
||||||
|
int pipes[2] = {-1, -1};
|
||||||
|
char pidfile[] = "criu_restore_XXXXXX";
|
||||||
|
|
||||||
if (!tmpnam(pidfile))
|
fd = mkstemp(pidfile);
|
||||||
|
if (fd < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
handler = lxc_init(c->name, c->lxc_conf, c->config_path);
|
handler = lxc_init(c->name, c->lxc_conf, c->config_path);
|
||||||
@ -756,11 +758,12 @@ static void do_restore(struct lxc_container *c, int status_pipe, struct migrate_
|
|||||||
goto out_fini_handler;
|
goto out_fini_handler;
|
||||||
} else {
|
} else {
|
||||||
int ret;
|
int ret;
|
||||||
FILE *f = fopen(pidfile, "r");
|
FILE *f = fdopen(fd, "r");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
SYSERROR("couldn't read restore's init pidfile %s\n", pidfile);
|
SYSERROR("couldn't read restore's init pidfile %s\n", pidfile);
|
||||||
goto out_fini_handler;
|
goto out_fini_handler;
|
||||||
}
|
}
|
||||||
|
fd = -1;
|
||||||
|
|
||||||
ret = fscanf(f, "%d", (int*) &handler->pid);
|
ret = fscanf(f, "%d", (int*) &handler->pid);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -818,6 +821,9 @@ out:
|
|||||||
close(status_pipe);
|
close(status_pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fd > 0)
|
||||||
|
close(fd);
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user