mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-21 21:47:33 +00:00
lxccontainer: fix temporary path removal
Needed-by: https://github.com/lxc/lxd/issues/5227 Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
6437f1c173
commit
ecce75a68c
@ -4976,6 +4976,7 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
|
|||||||
char template[PATH_MAX], path[PATH_MAX];
|
char template[PATH_MAX], path[PATH_MAX];
|
||||||
pid_t pid, init_pid;
|
pid_t pid, init_pid;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
bool is_dir;
|
||||||
int ret = -1, fd = -EBADF;
|
int ret = -1, fd = -EBADF;
|
||||||
|
|
||||||
if (!c || !c->lxc_conf) {
|
if (!c || !c->lxc_conf) {
|
||||||
@ -5006,7 +5007,8 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR(sb.st_mode)) {
|
is_dir = (S_ISDIR(sb.st_mode) != 0);
|
||||||
|
if (is_dir) {
|
||||||
sret = mkdtemp(template);
|
sret = mkdtemp(template);
|
||||||
if (!sret) {
|
if (!sret) {
|
||||||
SYSERROR("Could not create shmounts temporary dir");
|
SYSERROR("Could not create shmounts temporary dir");
|
||||||
@ -5089,6 +5091,9 @@ static int do_lxcapi_mount(struct lxc_container *c, const char *source,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
(void)umount2(template, MNT_DETACH);
|
(void)umount2(template, MNT_DETACH);
|
||||||
|
if (is_dir)
|
||||||
|
(void)rmdir(template);
|
||||||
|
else
|
||||||
(void)unlink(template);
|
(void)unlink(template);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
Loading…
Reference in New Issue
Block a user