Util-Linux package development
 help / color / mirror / Atom feed
From: Daniel Gerber <dg@atufi.org>
To: Sean Anderson <seanga2@gmail.com>
Cc: dottedmag@dottedmag.net, id@mbekkema.name, jpeach@apache.org,
	kzak@redhat.com, util-linux@vger.kernel.org
Subject: Re: [PATCH v2 0/6] unshare: Add support for mapping ranges of user/group IDs
Date: Fri, 14 Jan 2022 11:29:21 +0100	[thread overview]
Message-ID: <874k664nlq.fsf@atufi.org> (raw)
In-Reply-To: <20211124182618.1801447-1-seanga2@gmail.com>

Hi,

Thanks for this feature. I've been trying it out... (This is with lib-musl-x86_64.)

Automatic mapping works:

$ unshare --map-users=auto cat /proc/self/uid_map
         0     100000      65536

But parsing id ranges does not:

$ unshare --map-users=100000,0,65536 cat /proc/self/uid_map
unshare: could not parse ID: '100000,0,65536'

Fix:
---
diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c
index 443358952..52bd9702a 100644
--- a/sys-utils/unshare.c
+++ b/sys-utils/unshare.c
@@ -388,7 +388,7 @@ static int uint_to_id(const char *name, size_t sz)
 	char buf[UID_BUFSIZ];

 	mem2strcpy(buf, name, sz, sizeof(buf));
-	return strtoul_or_err(name, _("could not parse ID"));
+	return strtoul_or_err(buf, _("could not parse ID"));
 }

 /**
---

Then, the value passed to newuidmap is still incorrect:

$ unshare --map-users=100000,0,65536 cat /proc/self/uid_map
newuidmap: uid range [0-655360) -> [100000-755360) not allowed

$ unshare --map-users=100000,0,0065536 cat /proc/self/uid_map
         0     100000      65536

The count value gets zero-padded to the right at some place I've not pinned down.


Also, I would suggest adopting the same argument order as in /proc/<pid>/uid_map and newuidmap -- inner,outer,count.

This doc string has it reversed:
---
/**
 * struct map_range - A range of IDs to map
 * @outer: First ID inside the namespace
 * @inner: First ID outside the namespace
---

And this one has inconsistent terminology:
---
 * get_map_range() - Parse a mapping range from a string
 * @s: A string of the format upper,lower,count
 *
 * Parse a string of the form upper,lower,count into a new mapping range.
---


--
Daniel Gerber

  parent reply	other threads:[~2022-01-14 10:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-24 18:26 [PATCH v2 0/6] unshare: Add support for mapping ranges of user/group IDs Sean Anderson
2021-11-24 18:26 ` [PATCH v2 1/6] include/c: Add abs_diff macro Sean Anderson
2021-11-24 18:26 ` [PATCH v2 2/6] unshare: Add waitchild helper Sean Anderson
2021-11-24 18:26 ` [PATCH v2 3/6] unshare: Add some helpers for forking and synchronizing Sean Anderson
2021-11-24 18:26 ` [PATCH v2 4/6] unshare: Add options to map blocks of user/group IDs Sean Anderson
2021-11-24 18:26 ` [PATCH v2 5/6] unshare: Add option to automatically create user and group maps Sean Anderson
2021-11-24 18:26 ` [PATCH v2 6/6] unshare: Document --map-{groups,users,auto} Sean Anderson
2021-12-01 15:16 ` [PATCH v2 0/6] unshare: Add support for mapping ranges of user/group IDs Karel Zak
2022-01-14 10:29 ` Daniel Gerber [this message]
2022-01-14 14:42   ` Sean Anderson
2022-01-14 17:15     ` Daniel Gerber
2022-01-15  0:53       ` Sean Anderson
2022-01-18 11:50   ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874k664nlq.fsf@atufi.org \
    --to=dg@atufi.org \
    --cc=dottedmag@dottedmag.net \
    --cc=id@mbekkema.name \
    --cc=jpeach@apache.org \
    --cc=kzak@redhat.com \
    --cc=seanga2@gmail.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox