Commit 9a8ca1cf authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mount: convert uid and gid properties according with userns

uid and gid are shown in the init userns. We are going to restore mounts
in a target userns, so we need to set these options in the target
userns.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent aabba6b2
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "cr_options.h" #include "cr_options.h"
#include "sysfs_parse.h" #include "sysfs_parse.h"
#include "seccomp.h" #include "seccomp.h"
#include "namespaces.h"
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/fdinfo.pb-c.h" #include "protobuf/fdinfo.pb-c.h"
#include "protobuf/mnt.pb-c.h" #include "protobuf/mnt.pb-c.h"
...@@ -852,6 +854,8 @@ static int do_opt2flag(char *opt, unsigned *flags, ...@@ -852,6 +854,8 @@ static int do_opt2flag(char *opt, unsigned *flags,
size_t uoff = 0; size_t uoff = 0;
while (1) { while (1) {
unsigned int id;
end = strchr(opt, ','); end = strchr(opt, ',');
if (end) if (end)
*end = '\0'; *end = '\0';
...@@ -862,7 +866,15 @@ static int do_opt2flag(char *opt, unsigned *flags, ...@@ -862,7 +866,15 @@ static int do_opt2flag(char *opt, unsigned *flags,
break; break;
} }
if (opts[i].opt == NULL) { if (sscanf(opt, "gid=%d", &id) == 1) {
uoff += sprintf(unknown + uoff, "gid=%d", userns_gid(id));
unknown[uoff] = ',';
uoff++;
} else if (sscanf(opt, "uid=%d", &id) == 1) {
uoff += sprintf(unknown + uoff, "uid=%d", userns_uid(id));
unknown[uoff] = ',';
uoff++;
} else if (opts[i].opt == NULL) {
if (!unknown) { if (!unknown) {
pr_err("Unknown option [%s]\n", opt); pr_err("Unknown option [%s]\n", opt);
return -1; return -1;
......
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