Commit 8fd50f35 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

dump: dump tmpfs from a target userns

It's required to dump uid-s and gid-s from this userns.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 011231af
...@@ -1164,9 +1164,8 @@ static int devpts_parse(struct mount_info *pm) ...@@ -1164,9 +1164,8 @@ static int devpts_parse(struct mount_info *pm)
static int tmpfs_dump(struct mount_info *pm) static int tmpfs_dump(struct mount_info *pm)
{ {
int ret = -1; int ret = -1, fd = -1, userns_pid = -1;
char tmpfs_path[PSFDS]; char tmpfs_path[PSFDS];
int fd = -1;
struct cr_img *img; struct cr_img *img;
fd = open_mountpoint(pm); fd = open_mountpoint(pm);
...@@ -1184,7 +1183,10 @@ static int tmpfs_dump(struct mount_info *pm) ...@@ -1184,7 +1183,10 @@ static int tmpfs_dump(struct mount_info *pm)
sprintf(tmpfs_path, "/proc/self/fd/%d", fd); sprintf(tmpfs_path, "/proc/self/fd/%d", fd);
ret = cr_system(-1, img_raw_fd(img), -1, "tar", (char *[]) if (root_ns_mask & CLONE_NEWUSER)
userns_pid = root_item->pid.real;
ret = cr_system_userns(-1, img_raw_fd(img), -1, "tar", (char *[])
{ "tar", "--create", { "tar", "--create",
"--gzip", "--gzip",
"--no-unquote", "--no-unquote",
...@@ -1194,7 +1196,7 @@ static int tmpfs_dump(struct mount_info *pm) ...@@ -1194,7 +1196,7 @@ static int tmpfs_dump(struct mount_info *pm)
"--preserve-permissions", "--preserve-permissions",
"--sparse", "--sparse",
"--numeric-owner", "--numeric-owner",
"--directory", tmpfs_path, ".", NULL }); "--directory", tmpfs_path, ".", NULL }, userns_pid);
if (ret) if (ret)
pr_err("Can't dump tmpfs content\n"); pr_err("Can't dump tmpfs content\n");
......
...@@ -1183,15 +1183,15 @@ int collect_namespaces(bool for_dump) ...@@ -1183,15 +1183,15 @@ int collect_namespaces(bool for_dump)
{ {
int ret; int ret;
ret = collect_mnt_namespaces(for_dump); ret = collect_user_namespaces(for_dump);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = collect_net_namespaces(for_dump); ret = collect_mnt_namespaces(for_dump);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = collect_user_namespaces(for_dump); ret = collect_net_namespaces(for_dump);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
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