summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2017-11-09 16:06:33 +0100
committerDenys Vlasenko2017-11-09 16:06:33 +0100
commit1b510900e24459353922a1bc83c0b58bc8bafe1c (patch)
tree191b7ef59be2b29ffa44b0a1a08f27acbad22a90
parentb5a0d9d8673f8c84c0135fbc6227680ee874d261 (diff)
downloadbusybox-1b510900e24459353922a1bc83c0b58bc8bafe1c.zip
busybox-1b510900e24459353922a1bc83c0b58bc8bafe1c.tar.gz
unshare: -r should map root to user, not the other way around
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/unshare.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/util-linux/unshare.c b/util-linux/unshare.c
index a4bbb8c..7c295da 100644
--- a/util-linux/unshare.c
+++ b/util-linux/unshare.c
@@ -339,7 +339,7 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
}
if (opts & OPT_map_root) {
- char uidmap_buf[sizeof("%u 0 1") + sizeof(int)*3];
+ char uidmap_buf[sizeof("0 %u 1") + sizeof(int)*3];
/*
* Since Linux 3.19 unprivileged writing of /proc/self/gid_map
@@ -348,9 +348,9 @@ int unshare_main(int argc UNUSED_PARAM, char **argv)
* in that user namespace.
*/
xopen_xwrite_close(PATH_PROC_SETGROUPS, "deny");
- sprintf(uidmap_buf, "%u 0 1", (unsigned)reuid);
+ sprintf(uidmap_buf, "0 %u 1", (unsigned)reuid);
xopen_xwrite_close(PATH_PROC_UIDMAP, uidmap_buf);
- sprintf(uidmap_buf, "%u 0 1", (unsigned)regid);
+ sprintf(uidmap_buf, "0 %u 1", (unsigned)regid);
xopen_xwrite_close(PATH_PROC_GIDMAP, uidmap_buf);
} else
if (setgrp_str) {