Karel Zak [Wed, 15 Apr 2026 11:07:05 +0000 (13:07 +0200)]
Merge branch 'printf-integers' of https://github.com/t-8ch/util-linux
* 'printf-integers' of https://github.com/t-8ch/util-linux:
fdisk: use the correct format specifiers for integer types
lib/procfs: return uint64_t from procfs_process_get_stat_nth()
chrt: pass correct integer types to printf
hardlink: avoid format string error for dev_t
strutils: fix printf formats
Karel Zak [Wed, 15 Apr 2026 11:01:36 +0000 (13:01 +0200)]
Merge branch 'kill_decode_test_known_fail' of https://github.com/cgoesche/util-linux-fork
* 'kill_decode_test_known_fail' of https://github.com/cgoesche/util-linux-fork:
tests: (kill/decode) mark test as known-fail for inconsistent s390x/QEMU instances
Karel Zak [Wed, 15 Apr 2026 10:37:38 +0000 (12:37 +0200)]
Merge branch 'ci/meson' of https://github.com/t-8ch/util-linux
* 'ci/meson' of https://github.com/t-8ch/util-linux:
ci: drop dependency from meson to autotools jobs
ci: run CHECK phase for meson
ci: run 'make checkusage' only for autotools build
meson: build test_scols_termreduce
The mcookie utility wants to report the source of randomness, but even
prints getrandom if it failed to retrieve data through it.
Fix this modifying the return data type of ul_random_get_bytes. Instead
of returning a boolean, the actual source is returned. This avoids any
potential TOCTOU or erroneous output.
Karel Zak [Wed, 15 Apr 2026 09:09:59 +0000 (11:09 +0200)]
Merge branch 'newgrp_less_confusing_error_message' of https://github.com/cgoesche/util-linux-fork
* 'newgrp_less_confusing_error_message' of https://github.com/cgoesche/util-linux-fork:
treewide: use err() instead of errx() where ul_get{userpw,grp}_str() fails
lib: (pwdutils.c) improve error return protocol for callers
Karel Zak [Wed, 15 Apr 2026 08:41:57 +0000 (10:41 +0200)]
Merge branch 'unshare_clear_environ' of https://github.com/cgoesche/util-linux-fork
* 'unshare_clear_environ' of https://github.com/cgoesche/util-linux-fork:
nsenter: use clearenv() only when it is available
tests: (unshare) add --clear-env option tests
tests: (test_strerror.c) use ARRAY_SIZE for better readability/portability
tests: (test_strerror.c) add EPERM errno support
bash-completion: (unshare) add --clear-env option
unshare: (manpage) fix minor typos
unshare: new option to prevent environment variable inheritance
The -z argument is only used for parsing without any modification of the
input string. Skip the duplication to fix memory leaks if -z is supplied
multiple times.
The -r arguments are collected in range_files array, which contains
strings which are used for opening files and error messages. Remove
duplication which simplifies memory handling and reduces binary size.
Supplying -s multiple times leaks memory. The given optarg is
eventually set in a struct passwd and line 1657 is the only alternative
that sets a constant string, i.e. the data is neither freed nor
modified.
Fix potential memory leaks and clarify that content of these strings
is never modified. Won't happen since this is test code, but adjust it
for completeness.
The -f arguments are collected in files array, which contains strings
which are used for opening files and error messages. Remove duplication
which simplifies memory handling and reduces binary size.
Thomas Weißschuh [Sun, 12 Apr 2026 06:08:26 +0000 (08:08 +0200)]
lib/procfs: return uint64_t from procfs_process_get_stat_nth()
This functions uses ul_strtoul64() to parse the number. As indicated by
the name that can only handle uint64_t values. Passing it a pointer to
uintmax_t can produce a compiler warning.
Thomas Weißschuh [Sun, 12 Apr 2026 06:04:38 +0000 (08:04 +0200)]
meson: build test_scols_termreduce
Build the test helper for the libsmartcols tests.
The helper expects libsmartcols.h to be in "$builddir/libsmartcols/src",
so make sure meson also places it there.
The %.*s modifier requires an int as precision argument, not an unsigned
int. Instead of just turning the domain_len and name_len fields into
int, this refactoring makes it easier to verify that only two fixed
values are ever used and avoids many int/size_t casts:
Since fullnames_mode field already specifies which values domain_len and
name_len will take, these fields can be turned into local variables.
No special checks required when parsing 'w' argument.
Setting domain_len and name_len as close as possible to their usages as
%.*s modifier arguments shows that the relevant if-else-blocks are always
evaluated and only allow two values.
This leads to smaller binary size because less instructions are needed
(e.g. these variables do not need pointer dereferences anymore).
In total, around 160 bytes on x86_64 are saved.
lib: (pwdutils.c) improve error return protocol for callers
In some cases libc does not properly set errno when no passwd
or group entry was found by getpwnam or getgrnam like functions.
This becomes an issue when callers have to provide coherent error
messages with err(). Therefore, let us improve the errno protocol
in internal wrapper functions for the above mentioned and set errno
when libc does not.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Leonid Znamenok [Thu, 9 Apr 2026 12:39:40 +0000 (16:39 +0400)]
fdisk: fix trailing whitespace in user reply from readline completion
Readline appends a space after tab-completed filenames, which becomes
part of the string returned by get_user_reply(). This causes "No such
file or directory" when loading a script file via the 'I' command.
Karel Zak [Thu, 9 Apr 2026 13:08:30 +0000 (15:08 +0200)]
lib/pidutils, lib/pidfd-utils: use _() instead of N_() in err() calls
N_() only marks a string for translation extraction but does not
translate at runtime. Use _() to ensure the error messages are
actually translated when displayed.
Karel Zak [Thu, 9 Apr 2026 12:58:25 +0000 (14:58 +0200)]
Merge branch 'allow_negative_pids' of https://github.com/cgoesche/util-linux-fork
* 'allow_negative_pids' of https://github.com/cgoesche/util-linux-fork:
tests: add helper program and test for lib/pidutils.c
lib: (pidutils.c) allow zero and negative numbers for PIDs
Karel Zak [Thu, 9 Apr 2026 12:49:17 +0000 (14:49 +0200)]
Merge branch 'pam_resources' of https://github.com/stoeckmann/util-linux
* 'pam_resources' of https://github.com/stoeckmann/util-linux:
login-utils/auth: Drop pam_setcred
su: Clean up PAM resources on all error paths
login: Clean up PAM resources on error path
Karel Zak [Thu, 9 Apr 2026 12:30:39 +0000 (14:30 +0200)]
lsblk: show mountpoints for all multi-device filesystem members
/proc/self/mountinfo lists only one member device per mount, so other
devices in multi-device filesystems appear unmounted. Add a group cache
that discovers multi-device groups and propagates mount entries to all
members.
For btrfs, device groups are enumerated from /sys/fs/btrfs/<uuid>/devices/.
For ZFS, pool names are collected from mountinfo (fstype=zfs) and devices
are matched via blkid properties (fstype=zfs_member, label=poolname).
Mount entries are cached in the group during scan, so the per-device
lookup is a simple iteration of cached entries without re-scanning
mountinfo.
Addresses: https://github.com/util-linux/util-linux/issues/4145
Addresses: https://github.com/util-linux/util-linux/pull/4198 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 9 Apr 2026 08:39:52 +0000 (10:39 +0200)]
irqtop: use irqtop_puts() for pre-formatted table data
Avoid unnecessary printf formatting when outputting pre-formatted
table strings. The new irqtop_puts() writes data directly via
fputs/waddstr without extra buffer allocation, appending a specified
number of trailing newlines.
This also reduces the buffer size requirements for the vw_printw()
slang fallback, which is now only used for the short header line.
Karel Zak [Thu, 9 Apr 2026 08:16:30 +0000 (10:16 +0200)]
irqtop: add vw_printw() fallback for slang builds
The vw_printw() function and OK macro are ncurses-specific and not
available in slang's curses compatibility layer. This causes build
failures when configuring with --with-slang.
Add configure/meson checks for vw_printw() availability and provide
a portable fallback implementation using vsnprintf() and waddstr()
when the function is not available.
Addresses: https://github.com/util-linux/util-linux/issues/4177 Signed-off-by: Karel Zak <kzak@redhat.com>
eject: tolerate ILLEGAL REQUEST on ALLOW_MEDIUM_REMOVAL
Some USB devices using the UAS driver do not support the SCSI
ALLOW_MEDIUM_REMOVAL command and return ILLEGAL REQUEST (sense
key 0x05). Previously, eject_scsi() treated any non-zero
driver_status as fatal, aborting before attempting START_STOP.
Now, when the device reports DRIVER_SENSE with sense key ILLEGAL
REQUEST, we continue to the START_STOP eject commands instead
of bailing out.
libblkid: Fix type access in zfs_extract_guid_name
Check if enough space is left for a 32 bit value before parsing it. This
is not a technical out of boundary issue, because due to alignment,
enough bytes are available.
It is possible to trigger an out of boundary read in zfs_process_value
if debugging is activated.
The debug message erroneously uses %*s (field width) instead of %.*s
(precision), which might lead to string output going past the boundary
of memory mapped buffer.
Fix this with proper casting: The value is always smaller than
VDEV_PHYS_SIZE (112 KB) at this stage, easily fitting into int.
A parse_dev debug line erroneously uses %*s instead of %.*s. While this
does not lead to out of boundary access because the line is properly
NUL-escaped by fgets, the output is incorrect.
Simply replace the ending char with NUL for debug, since the line is
modified a few lines below anyway. This offers more safety for
refactoring in the future if fgets is ever replaced with getline,
possibly leading to lines longer than INT_MAX.
The function blkid_probe_log_csum_mismatch is only used for debugging
purposes. Simplify the code to avoid any form of modifier for %s.
Right now, %*s is incorrect because it specifies the field width, not
the precision. This could theoretically lead to issues, but since this
function is always called with sizes of 8 or 32, it is safe.
Just make sure that the strings are always NUL-terminated, even if size
is 0 or larger than 256.
Two manual pages recently linked into the build lacked translation
entries, leading to asciidoctor warnings. Fix these by adding them:
```
unconfigured in /home/runner/work/util-linux/util-linux/po-man/po4a.cfg: ../liblastlog2/man/ll2_new_context.3.adoc
unconfigured in /home/runner/work/util-linux/util-linux/po-man/po4a.cfg: ../liblastlog2/man/ll2_unref_context.3.adoc
```
lib: (pidutils.c) allow zero and negative numbers for PIDs
kill(1) and kill(2) man pages clearly state that 0 and negative
numbers can be used. Therefore let us adapt the internal helper
function ul_parse_pid_str() to permit this value range, as the
previous behavior regressed the kill(1) PID parsing behavior.
The uncommon value range can be controlled with two new flags
UL_PID_ZERO and UL_PID_NEGATIVE, ORed together they will allow
0 and negative values down to INT_MIN. Otherwise they can be
passed individually to only allow either. If 0 is passed only
1 upto INT_MAX values are allowed.
Closes: #4194 Closes: #4195 Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
libblkid: Ignore secondary LUKS2 header in blkid_do_safeprobe()
The secondary LUKS2 header can match file data content on other
filesystems (e.g. an image file of a LUKS2 device stored on XFS whose
data blocks happen to land at device offsets where blkid looks for the
secondary LUKS2 header). This causes blkid to report a crypto_LUKS
superblock instead of the real filesystem.
Add a new flag BLKID_PROBE_FL_SAFEPROBE and skip scanning for the
secondary LUKS2 header in blkid_do_safeprobe(). The secondary LUKS2
header is only important for wipefs which uses a promiscuous probe.
Fixes: #4170 Fixes: 8bee1a2 Signed-off-by: Timo Sigurdsson <public_timo.s@silentcreek.de>
--
v2: Fix conflict with BLKID_FL_TINY_DEV flag
v3: Use pr->prob_flags instead of pr->flags
v4: Use original mask again as the use prob_flags resolves the conflict
If PAM_REINITIALIZEE_CRED fails at this point, PAM_ESTABLISH_CRED
succeeded before. Clean up credentials with PAM_DELETE_CRED in this case
just to be sure.
The CI fails the kill/name_to_number test when SIGRTMAX-0 (64)
is checked for s390x packaging. Although SIGRTMAX is a valid
signal number, kill(2) still returns EINVAL. This seems to be
related to the fact that QEMU reserves a signal number from
the high real-time signal range for internal usage, which
limits the maximum real-time signal number range.
We already check for the QEMU_USER environment variable, let us
also check if the QEMU emulator is mapped in memory for PID 1
to get more reliable information. In addition to that lets skip
RTMAX checks on s390x and QEMU emulated environments.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>