Re: unshare regression in 2.42-rc1

From: Christian Albrecht Goeschel Ndjomouo

Date: Sun Mar 22 2026 - 08:57:39 EST


Hi Chris,

Thank you for pointing out this regression.

The problem is that if ul_getuserpw_str() cannot find any user with the provided
UID or username, the unshare internal helper function get_user() will error out
and stop argument parsing, even if a valid numeric value was provided. Previously,
the code would fallback to simply converting the string to an unsigned int and use
it for the uid_t, so I added that behavior back.

I found this issue to be true for the --map-group option as well, so I went ahead and fixed
both cases in this latest patch: https://github.com/util-linux/util-linux/pull/4134/changes/c74df906b67b2f9930662ca4e1ba04c21569d529

Please let us know if this fixed the problem on your end.

Regards,

Christian Goeschel Ndjomouo

________________________________________
From: Chris Hofstaedtler <zeha@xxxxxxxxxx>
Sent: Sunday, March 22, 2026 7:37 AM
To: Karel Zak
Cc: linux-kernel@xxxxxxxxxxxxxxx; linux-fsdevel@xxxxxxxxxxxxxxx; util-linux@xxxxxxxxxxxxxxx; Christian Albrecht Goeschel Ndjomouo; Helmut Grohne
Subject: unshare regression in 2.42-rc1

Hi Karel, Christian,

Debian CI found a regression in the unshare command when using
--map-user with numeric UIDs. This worked in 2.41 and earlier:

% unshare --version && unshare --user --map-auto --map-user=65536 id
unshare from util-linux 2.41.3
uid=65536 gid=65534(nogroup) groups=65534(nogroup)

And is broken in 2.42-rc1:

% unshare --version && unshare --user --map-auto --map-user=65536 id
unshare from util-linux 2.42-rc1
unshare: failed to parse uid '65536'

Note the following (true in both cases):
$ grep 65536 /etc/passwd
%

I suspect (but did not verify yet) this was introduced in
commit 0a7fb806118bc4418e231081bd13c69bbc31b988
> unshare: use the new ul_get{grp,userpw}_str() routines
>
> This change refactors get_group() and get_user(), so that it
> uses the new routines ul_getgrp_str() and ul_getuserpw_str(),
> to simplify the code and remove the overkill mem allocations.
https://github.com/util-linux/util-linux/commit/0a7fb806118bc4418e231081bd13c69bbc31b988<https://github.com/util-linux/util-linux/commit/0a7fb806118bc4418e231081bd13c69bbc31b988>

Thanks to Helmut Grohne for reducing the failed debvm CI run to the
short unshare command.

Best,
Chris