Karel Zak [Wed, 17 Dec 2025 11:06:35 +0000 (12:06 +0100)]
Merge branch 'feat/su_accept_gid_args' of https://github.com/cgoesche/util-linux-fork
* 'feat/su_accept_gid_args' of https://github.com/cgoesche/util-linux-fork:
unshare: use MAX_OF_UINT_TYPE instead of (type)-1
chfn: enable the use of the username or UID
unshare: use the new ul_get{grp,userpw}_str() routines
login: use new xgetuserpw() instead of xgetpwnam()
chsh: use new xgetuserpw() instead of xgetpwnam()
su: accept group name and GID in -g and -G options
tests: (su) test GID argument in --group option
lib: (pwdutils.c) new library routines to get a group/passwd struct by name or GID/UID
include/c.h: add MAX_OF_UINT_TYPE macro to get max num of an uint type
Chris Webb [Mon, 15 Dec 2025 18:48:29 +0000 (18:48 +0000)]
unshare: fix user namespace bind mounts
unshare --user=<file> always fails because we no longer have CAP_SYS_ADMIN
in the parent user namespace after unsharing to create the new one. As with
unshare --mount=<file>, fork a child to make the bind mount instead.
Chris Webb [Mon, 15 Dec 2025 18:41:08 +0000 (18:41 +0000)]
unshare: remove get_mnt_ino() check in bind_ns_files_from_child()
get_mnt_ino() was originally introduced in c84f2590 where it was used
in a loop to wait for the parent process to unshare the mount namespace
before binding the namespace in its child.
The parent and child processes are now synchronised with eventfd, so
remove this vestigial check and the now-unused get_mnt_ino() function.
This allows bind_ns_files_from_child() to be used even when the mount
namespace isn't amongst the namespaces being unshared.
Chris Webb [Sun, 14 Dec 2025 23:18:33 +0000 (23:18 +0000)]
unshare: add --owner to set user namespace owner uid and gid
As well as the mappings between lower and upper ids, a user namespace is
associated with an owner user and group in its parent. These are set from
the uid and gid when the unshare() call is made, and determine which user
in the parent namespace has CAP_SYS_ADMIN in the child and can setns()
into it.
Add an --owner=<uid>:<gid> option which allows a privileged user to
create a user namespace on behalf of another user, mapping parent ids
and/or bind-mounting the namespace with privileges that the new owner
would not have.
Simplify the control flow around map_ids_from_child() vs mapping them
inline to avoid too many special cases. We reset mapuser and mapgroup to
-1 to signal that the mapping has been delegated to the child helper.
For completeness, we maintain the semantics of --map-root-user and
--map-current-user, binding the invoking user to root or itself in the
new namespace. However, when --owner is used, these must be handled by
a forked child as with --map-users and --map-groups.
Karel Zak [Wed, 10 Dec 2025 11:01:06 +0000 (12:01 +0100)]
Merge branch 'fix/consolidate_validate_pfd_ino' of https://github.com/cgoesche/util-linux-fork
* 'fix/consolidate_validate_pfd_ino' of https://github.com/cgoesche/util-linux-fork:
lib: (pidutils.c) use uint64_t instead of ino_t for seamless cross-compatibility
kill: use uint64_t as type for kill_control->pidfd_ino
lib: (pidfd-utils.c) remove extraneous _GNU_SOURCE feature test macro
lib: (pidfd-utils) new helper function to retrieve pidfd inode number
lib: (pidfd-utils.c) add a helper routine to check the pidfd fs type
kill: replace USE_KILL_WITH_PIDFD_INO ifdef with USE_PIDFD_INO_SUPPORT
include: (pidfd-utils.h) conditionally define pidfd inode support
libmount: add pidfs magic number for fstype check
include: (statfs_magic.h) add pidfs magic number
kill: use ul_get_valid_pidfd_or_err() to validate user provided pidfd inodes
include: add helper routines for opening and validating pidfds
Karel Zak [Tue, 9 Dec 2025 12:12:41 +0000 (13:12 +0100)]
libblkid: Keep NTFS name unmodified and mount driver independent
We need stable filesystem names (types) even though there are multiple
filesystem drivers. libmount now provides a way to map the stable
fs-types to various mount-types.
Karel Zak [Tue, 9 Dec 2025 12:02:11 +0000 (13:02 +0100)]
libmount: add option to override fs-type with mount-type
This patch introduces an internal libmount method to convert fs-type
(as provided by libblkid or udevd) to mount-type to specify a different
mount driver.
Currently, the mapping from fs-type to mount-type is hardcoded in
libmount as a temporary solution. The final implementation should
provide configuration files (e.g., /etc/mount/fs.d/<name>) for these
mappings.
The current default mapping is implemented only for NTFS. It can be
modified during compilation with:
./configure --with-ntfs-mounttype=TYPE
or
meson setup build -D ntfs-mounttype=TYPE
The default is "ntfs3".
Addresses: https://github.com/util-linux/util-linux/pull/3618
Addresses: https://github.com/systemd/systemd/pull/39982 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 25 Nov 2025 11:56:07 +0000 (12:56 +0100)]
libmount: read from udev, add --disable-libmount-udev-support
The library traditionally uses libblkid to obtain device properties
(such as FS-type if not specified). This can be a relatively costly
operation to scan the device and requires read access to the device.
All relevant libblkid information is usually cached by the udev DB.
This commit adds the possibility to reuse the information from udev,
with a fallback to libblkid if udev is not available.
Karel Zak [Mon, 8 Dec 2025 08:59:41 +0000 (09:59 +0100)]
Merge branch 'fix/login_shell_arg_null_str' of https://github.com/cgoesche/util-linux-fork
* 'fix/login_shell_arg_null_str' of https://github.com/cgoesche/util-linux-fork:
login: duplicate --shell argument to avoid nulling through explicit_bzero()
include: add helper routines for opening and validating pidfds
With the new ul_get_valid_pidfd_or_err() routine util-linux
tools can now simply validate pidfd inode numbers before
opening a file descriptor for a given PID.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Karel Zak [Thu, 4 Dec 2025 13:26:40 +0000 (14:26 +0100)]
Merge branch 'feat/login_shell_option' of https://github.com/cgoesche/util-linux-fork
* 'feat/login_shell_option' of https://github.com/cgoesche/util-linux-fork:
login: document -s and --shell on the man page
login: define shell to log in to with -s or --shell
Karel Zak [Wed, 3 Dec 2025 10:40:57 +0000 (11:40 +0100)]
Merge branch 'fix/issue_3865' of https://github.com/lord2y/util-linux
* 'fix/issue_3865' of https://github.com/lord2y/util-linux:
login-utils, sys-utils: use _PATH_BSHELL consistently
*: use ul_default_shell() for interactive shell spawning
lib: introduce ul_default_shell() for consistent shell resolution
Karel Zak [Wed, 3 Dec 2025 10:14:13 +0000 (11:14 +0100)]
Merge branch 'feat/check_bash_comp_integrity' of https://github.com/cgoesche/util-linux-fork
* 'feat/check_bash_comp_integrity' of https://github.com/cgoesche/util-linux-fork:
bash-completion: (lslogins) fix typo in long option
tools: (checkcompletion.sh) test the integrity of long options completion
tools: new helper for extraction of program long options from source files
Martin Minkus [Wed, 3 Dec 2025 03:51:05 +0000 (19:51 -0800)]
libfdisk: modernize ZFS GPT type description
The GPT type GUID 6A898CC3-1DD2-11B2-99A6-080020736631 is currently
described as "Solaris /usr & Apple ZFS". This reflects early Solaris
and Apple experiments with ZFS, but today the same GUID is widely used
by OpenZFS implementations on Linux, illumos, FreeBSD, and other
platforms to mark ZFS pool member partitions.
Apple's ZFS work was discontinued long ago, while OpenZFS has become
the actively maintained and de facto standard implementation. Update
the human-readable description to the simpler and more accurate:
"ZFS pool member"
A short comment is added to note the GUID’s historical Solaris /usr
origin and its brief use by Apple. Only the description string is
changed; the GUID itself and its semantics remain unchanged.
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.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Alessandro Ratti [Sun, 23 Nov 2025 15:26:37 +0000 (16:26 +0100)]
login-utils, sys-utils: use _PATH_BSHELL consistently
Remove local DEFAULT_SHELL definitions and hardcoded "/bin/sh" strings
in favor of the standard _PATH_BSHELL macro from <paths.h>. This
provides consistency across the codebase while following libc
conventions.
These tools already perform their own passwd lookups and only need a
fallback value, so they don't require the full ul_default_shell()
resolution logic.
Affected tools:
- su(1): already checks pw_shell validity
- sulogin(8): emergency login with explicit shell handling
- setpriv(1): already has passwd entry for environment setup
Alessandro Ratti [Sun, 23 Nov 2025 15:24:52 +0000 (16:24 +0100)]
*: use ul_default_shell() for interactive shell spawning
Update tools that spawn interactive shells to use ul_default_shell()
for consistent shell resolution. This ensures these tools respect both
$SHELL and the user's configured shell from the passwd database before
falling back to _PATH_BSHELL.
Affected tools:
- script(1): fixes history truncation when invoked without $SHELL
- scriptlive(1): consistent with script(1) behavior
- flock(1): for -c command execution
- more(1): for shell escape feature
- exec_shell (used by unshare(1) and nsenter(1))
This change addresses user reports of data loss due to tools defaulting
to /bin/sh instead of the user's configured shell, particularly affecting
command history with different HISTSIZE configurations.
Alessandro Ratti [Sun, 23 Nov 2025 15:20:57 +0000 (16:20 +0100)]
lib: introduce ul_default_shell() for consistent shell resolution
Add a new ul_default_shell() function to provide consistent shell
resolution across util-linux tools. The function follows a priority
order: $SHELL environment variable, user's shell from passwd database,
and finally _PATH_BSHELL as fallback.
The function supports flags to control its behavior:
- UL_SHELL_NOENV: skip $SHELL environment variable check
- UL_SHELL_NOPWD: skip passwd database lookup
This addresses the issue where tools like script(1) would default to
/bin/sh without respecting the user's configured shell, potentially
causing data loss.
Addresses: https://github.com/util-linux/util-linux/issues/3865 Suggested-by: Karel Zak <kzak@redhat.com> Suggested-by: Thomas Weißschuh <thomas@t-8ch.de> Signed-off-by: Alessandro Ratti <alessandro@0x65c.net>
lib: (pwdutils.c) new library routines to get a group/passwd struct by name or GID/UID
In some tools users can specify groups/users by their name but not
the GID or UID. To enable this in a trivial manner util-linux tools
can now call the ul_getgrp_str(), ul_getuserpw_str(), xgetgroup()
and xgetuserpw() routines to achieve this.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Karel Zak [Thu, 27 Nov 2025 15:46:22 +0000 (16:46 +0100)]
whereis: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in dirlist_add_subdir() and
lookup() functions. These warnings are reported by gcc 15 which
defaults to the C23 standard.
The strchr() and strrchr() functions return pointers into const strings,
so the receiving variables must be declared as const char *.
Karel Zak [Thu, 27 Nov 2025 15:43:38 +0000 (16:43 +0100)]
logger: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in valid_structured_data_param()
and valid_structured_data_id() functions. These warnings are reported by
gcc 15 which defaults to the C23 standard.
The strchr() and strstr() functions return pointers into const strings,
so the receiving variables must be declared as const char *.
Karel Zak [Thu, 27 Nov 2025 15:38:18 +0000 (16:38 +0100)]
lsfd: fix const qualifier warning in strnrstr
Fix const qualifier discarded warning in strnrstr().
This warning is reported by gcc 15 which defaults to the C23 standard.
The function returns a non-const pointer into the haystack parameter,
and callers modify the string through that pointer. Therefore, the
haystack parameter should be char * rather than const char *.
Karel Zak [Thu, 27 Nov 2025 15:35:56 +0000 (16:35 +0100)]
lsfd: fix const qualifier warning in new_counter_spec
Fix const qualifier discarded warning in new_counter_spec().
This warning is reported by gcc 15 which defaults to the C23 standard.
The function modifies the input string by inserting a null terminator
to split it into name and expression parts, so the parameter should
be char * rather than const char *.
Karel Zak [Thu, 27 Nov 2025 15:28:41 +0000 (16:28 +0100)]
libblkid: fix const qualifier warning in blkid_parse_tag_string
Fix const qualifier discarded warning in blkid_parse_tag_string().
This warning is reported by gcc 15 which defaults to the C23 standard.
The strchr() function returns a pointer into a const string, so
introduce a separate 'eq' variable to hold this const pointer for
finding the '=' separator. Also move the 'cp' variable declaration
into the block where it's actually used for quote handling.
Karel Zak [Thu, 27 Nov 2025 15:24:11 +0000 (16:24 +0100)]
libmount: fix const qualifier warning in mnt_parse_mountinfo_line
Fix const qualifier discarded warning in mnt_parse_mountinfo_line().
This warning is reported by gcc 15 which defaults to the C23 standard.
The strstr() function returns a pointer into a const string, so
introduce a separate 'sep' variable to hold this const pointer,
keeping 'p' for non-const unmangle() results that need to be freed.
Karel Zak [Thu, 27 Nov 2025 14:45:55 +0000 (15:45 +0100)]
libmount: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in optlist_add_flags(),
mnt_opt_value_with(), and mnt_optstr_apply_flags() functions.
These warnings are reported by gcc 15 which defaults to the C23 standard.
The strchr() and strstr() functions return pointers into const strings,
so the receiving variables must be declared as const char *.
Karel Zak [Thu, 27 Nov 2025 14:41:21 +0000 (15:41 +0100)]
lsns: fix const qualifier warnings for C23
Fix const qualifier discarded warnings in read_persistent_namespaces()
and is_path_included() functions. These warnings are reported by gcc 15
which defaults to the C23 standard.
The strchr() and strstr() functions return pointers into const strings,
so the receiving variables must be declared as const char *.
Karel Zak [Thu, 27 Nov 2025 09:32:15 +0000 (10:32 +0100)]
Merge branch 'lsfd--tun-netns' of https://github.com/masatake/util-linux
* 'lsfd--tun-netns' of https://github.com/masatake/util-linux:
lsfd: add TUN.DEVNETNS column
tests: (lsfd::mkfds-cdev-tun,refactor) make the case extensible
lsfd: (doc) fix English in SOCK.NETNS description
lsfd: (cleanup) add missing "break" in a case statement
lsfd: (cleanup) return 0 instead of false
lsfd: (refactor) introduce tundata struct
Karel Zak [Thu, 27 Nov 2025 09:27:07 +0000 (10:27 +0100)]
lib, lscpu: fix const qualifier discarded warnings in bsearch
Fix compilation warnings from newer compilers with stricter
const-correctness checks. When bsearch() searches in const arrays,
the result pointer must also be const to avoid discarding the
const qualifier.
Fixed in:
- lib/color-names.c: searching in static const basic_schemes[]
- sys-utils/lscpu-cputype.c: searching in const pattern arrays
The warnings were:
lib/color-names.c:62:13: error: assignment discards 'const'
qualifier from pointer target type
[-Werror=discarded-qualifiers]