Skip to contentSkip to conversation

unshare: support --map-users=inner:outer:count as well as outer,inner,count

PATCH Applied Chris Webb 2 participants 2 messages Jan 10, 2023 – Jan 11, 2023 Util-Linux package

lore
Share & tools
lore

Chris Webb

author
#0 lore raw

PATCH v2 1/1 unshare: support --map-users=inner:outer:count as well as outer,inner,count

The argument ordering in /proc/self/[gu]id_map and mount -o X-mount.idmap is consistently inner:outer:count but unshare --map-users and --map-groups were originally defined to expect outer,inner,count instead.

To reduce confusion caused by this mismatch, support a colon-separated inner:outer:count ordering as well as the original comma-separated outer,inner,count argument format. Although we accept both formats, only document the new one in the usage text and deprecate the old format in the man page.

---
v2: Describe deprecation in the unshare(1) man page.

 sys-utils/unshare.1.adoc |  8 +++++--
 sys-utils/unshare.c      | 50 +++++++++++++---------------------------
 2 files changed, 22 insertions(+), 36 deletions(-)
sys-utils/unshare.1.adoc +6 -2
index 030e9a497..08e13373c 100644
@@ -93,14 +93,18 @@ Just before running the program, mount the proc filesystem at _mountpoint_ (defa
 **--map-user=**__uid|name__::
 Run the program only after the current effective user ID has been mapped to _uid_. If this option is specified multiple times, the last occurrence takes precedence. This option implies *--user*.
 
-**--map-users=**__outeruid,inneruid,count__|**auto**::
+**--map-users=**__inneruid:outeruid:count__|**auto**::
 Run the program only after the block of user IDs of size _count_ beginning at _outeruid_ has been mapped to the block of user IDs beginning at _inneruid_. This mapping is created with **newuidmap**(1). If the range of user IDs overlaps with the mapping specified by *--map-user*, then a "hole" will be removed from the mapping. This may result in the highest user ID of the mapping not being mapped. The special value *auto* will map the first block of user IDs owned by the effective user from _/etc/subuid_ to a block starting at user ID 0. If this option is specified multiple times, the last occurrence takes precedence. This option implies *--user*.
++
+Before util-linux version 2.39, this option expected a comma-separated argument of the form _outeruid,inneruid,count_ but that format is now deprecated for consistency with the ordering used in _/proc/[pid]/uid_map_ and the _X-mount.idmap_ mount option.
 
 **--map-group=**__gid|name__::
 Run the program only after the current effective group ID has been mapped to _gid_. If this option is specified multiple times, the last occurrence takes precedence. This option implies *--setgroups=deny* and *--user*.
 
-**--map-groups=**__outergid,innergid,count__|**auto**::
+**--map-groups=**__innergid:outergid:count__|**auto**::
 Run the program only after the block of group IDs of size _count_ beginning at _outergid_ has been mapped to the block of group IDs beginning at _innergid_. This mapping is created with **newgidmap**(1). If the range of group IDs overlaps with the mapping specified by *--map-group*, then a "hole" will be removed from the mapping. This may result in the highest group ID of the mapping not being mapped. The special value *auto* will map the first block of user IDs owned by the effective user from _/etc/subgid_ to a block starting at group ID 0. If this option is specified multiple times, the last occurrence takes precedence. This option implies *--user*.
++
+Before util-linux version 2.39, this option expected a comma-separated argument of the form _outergid,innergid,count_ but that format is now deprecated for consistency with the ordering used in _/proc/[pid]/gid_map_ and the _X-mount.idmap_ mount option.
 
 **--map-auto**::
 Map the first block of user IDs owned by the effective user from _/etc/subuid_ to a block starting at user ID 0. In the same manner, also map the first block of group IDs owned by the effective group from _/etc/subgid_ to a block starting at group ID 0. This option is intended to handle the common case where the first block of subordinate user and group IDs can map the whole user and group ID space. This option is equivalent to specifying *--map-users=auto* and *--map-groups=auto*.
sys-utils/unshare.c +16 -34

74 lines not on this page · raw message

maintainer Applied
#1 lore raw
Quoted 3 lines · Chris Webb
 sys-utils/unshare.1.adoc |  8 +++++--
 sys-utils/unshare.c      | 50 +++++++++++++---------------------------
 2 files changed, 22 insertions(+), 36 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com