Karel Zak [Mon, 11 May 2026 09:12:43 +0000 (11:12 +0200)]
Merge branch 'fix/bits_return_value_check' of https://github.com/echoechoin/util-linux
* 'fix/bits_return_value_check' of https://github.com/echoechoin/util-linux:
bits: add --fail-width option to reject out-of-range CPU numbers
bits: add test for invalid token in cpulist_parse()
bits: improve error message for out-of-range cpulist_parse()
cpuset: Validate full tokens in cpulist_parse()
bits: fix return value check for cpulist_parse()
Karel Zak [Wed, 6 May 2026 11:28:16 +0000 (13:28 +0200)]
tests: add ts_finalize_subtest before continue in loops
In loops where ts_skip_subtest is called before continue,
add ts_finalize_subtest to properly close the subtest block
before skipping to the next iteration.
Karel Zak [Wed, 6 May 2026 11:25:05 +0000 (13:25 +0200)]
tests: move ts_finalize_subtest after if/else blocks
Move ts_finalize_subtest out of individual if/else branches and
place it unconditionally after the entire block. This enforces
the ts_init_subtest/ts_finalize_subtest pairing introduced in
the previous commit.
Previously, ts_skip_subtest or ts_failed_subtest was used as a
terminal action instead of ts_finalize_subtest. Now each subtest
is a proper init/finalize block, with ts_skip_subtest and
ts_failed_subtest only setting state within the block.
Karel Zak [Wed, 6 May 2026 11:19:11 +0000 (13:19 +0200)]
tests: add subtest status tracking to ts_finalize_subtest
Add TS_SUBFAILED and TS_SUBSKIPPED flags that are set by
ts_failed_subtest and ts_skip_subtest respectively, and
cleared by ts_init_subtest.
ts_finalize_subtest now checks these flags before running the
diff comparison. If the subtest was already marked as failed or
skipped, it respects that status instead of unconditionally
running ts_gen_diff (which could report OK over a previous
failure).
Remove ts_init_core_env from ts_skip_subtest — environment
reset is now handled exclusively by ts_finalize_subtest, making
ts_init_subtest/ts_finalize_subtest the only paired open/close
for every subtest.
Add runtime guards: ts_init_subtest and ts_finalize both call
ts_failed if TS_SUBNAME is still set from a previous subtest
that was never finalized. This makes missing ts_finalize_subtest
calls a hard test failure, detectable in CI.
Karel Zak [Mon, 4 May 2026 12:15:45 +0000 (14:15 +0200)]
meson: check slang headers only when slang library is found
The slcurses.h and slang*.h headers were detected unconditionally
in the generic header check loop. When the headers existed on the
system but slang was not actually used (ncurses preferred), irqtop
and cfdisk would include slcurses.h instead of ncurses.h, causing
build failures for ncurses-specific functions like vw_printw() and
resizeterm().
Move slang header checks after slang library detection, guarded by
lib_slang.found(), matching the autotools behavior where these
headers are only checked with --with-slang.
Karel Zak [Mon, 4 May 2026 12:04:34 +0000 (14:04 +0200)]
meson: rename logindefs_c to lib_common_logindefs
Rename the logindefs static library variable from logindefs_c to
lib_common_logindefs for consistency with lib_common_shells and
the autotools libcommon_logindefs.la naming.
Karel Zak [Mon, 4 May 2026 12:02:39 +0000 (14:02 +0200)]
meson: split shells.c out of lib_common into lib_common_shells
Remove shells.c from lib_common_sources and build it as a separate
static library (lib_common_shells) with lib_econf dependency.
Link lib_common_shells only into binaries that use the econf-dependent
shell enumeration functions (is_known_shell, print_shells,
open_etc_shells): chsh, su, runuser, login.
Other binaries that only need ul_default_shell() get it from
lib_common via default_shell.c and don't need libeconf.
Karel Zak [Mon, 4 May 2026 11:59:47 +0000 (13:59 +0200)]
build-sys: drop libcommon_shells from binaries that only need ul_default_shell
Now that ul_default_shell() lives in libcommon, binaries that only
call this function no longer need to link against libcommon_shells
(and transitively libeconf).
Remove libcommon_shells linkage from: flock, unshare, nsenter,
script, scriptlive, more.
Keep libcommon_shells for: login, chsh, su, runuser — these use
is_known_shell(), print_shells() or open_etc_shells() which depend
on libeconf.
Karel Zak [Mon, 4 May 2026 11:57:41 +0000 (13:57 +0200)]
lib: split ul_default_shell() from shells.c into default_shell.c
Move ul_default_shell() and UL_SHELL_* flags into a new
lib/default_shell.c and include/default_shell.h pair, and add the
new file to libcommon (autotools and meson).
ul_default_shell() has no dependency on libeconf -- it simply checks
$SHELL, passwd, and falls back to _PATH_BSHELL. Separating it from
shells.c (which depends on libeconf for /etc/shells enumeration)
allows binaries that only need the default shell lookup (flock,
script, scriptlive, more, exec_shell.c users) to avoid unnecessary
libeconf linkage.
Update callers that only use ul_default_shell() to include
default_shell.h instead of shells.h.
This patch enables support for the PID:inode address format.
It removes a sentinel value from ctl->pid that controls the PID
parsing behavior and introduces a dedicated variable parse_pid
(member of struct chrt_ctl), which makes the code a bit more
readable and coherent.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Masatake YAMATO [Wed, 6 May 2026 09:39:13 +0000 (18:39 +0900)]
tests: (lsfd/option-inet{,-udp}) make UDPLite related test case skippable
Fixes #4311
Linux 7.1-rc1 has removed UDP Lite.
In the test case lsfd/option-inet, UDP Lite was must.
This change moves UDPLite related test parts to a new test
case lsfd/option-inet-udp and makes lsfd/option-inet-udp
skippable on the platform where UDPLite is not implemented.
Karel Zak [Thu, 7 May 2026 11:44:36 +0000 (13:44 +0200)]
Merge branch 'fix/drop_caches_container' of https://github.com/echoechoin/util-linux
* 'fix/drop_caches_container' of https://github.com/echoechoin/util-linux:
tests: skip fallocate/zero-range test when /proc/sys/vm/drop_caches is not writable
WanBingjiang [Thu, 7 May 2026 07:27:31 +0000 (15:27 +0800)]
tests: skip fallocate/zero-range test when /proc/sys/vm/drop_caches is not writable
The build (compat, ubuntu:18.04) CI job runs inside a Docker container
where /proc/sys/vm/drop_caches is read-only. Falling back to fallocate
--report-holes with stale VFS cache yields 0 holes instead of 1, causing
the test to fail.
WanBingjiang [Thu, 7 May 2026 01:47:25 +0000 (09:47 +0800)]
bits: add --fail-width option to reject out-of-range CPU numbers
By default, cpulist_parse() silently ignores values wider than the
cpuset size (fail=0). The new -f/--fail-width flag switches to fail=1,
causing bits to error out with "bit list wider than cpuset size" when
any CPU number exceeds the --width limit.
AndyLau-SOC [Wed, 6 May 2026 12:14:31 +0000 (20:14 +0800)]
docs: clarify wipefs --force description for partition-table signatures
The current description states that --force "is required in order to erase
a partition-table signature on a block device", which is misleading.
According to the source code (do_wipe() in wipefs.c), --force is needed
for mounted filesystems and for nested partition tables on non-whole-disk
devices, not for all partition tables on all block devices.
Update the text to say "a nested partition-table signature on a non-whole
disk device", consistent with the note earlier in the man page.
Karel Zak [Wed, 6 May 2026 10:02:10 +0000 (12:02 +0200)]
Merge branch 'more_fallocate_tests' of https://github.com/cgoesche/util-linux-fork
* 'more_fallocate_tests' of https://github.com/cgoesche/util-linux-fork:
fallocate: (man) mention supported file systems for --insert-range
tests: (fallocate) add --zero-range and --keep-size test
tests: (fallocate) add --punch-hole test
tests: (fallocate) --insert-range test
Karel Zak [Wed, 6 May 2026 09:58:50 +0000 (11:58 +0200)]
more: align MORE_SHELL_LINES semantics with less(1)
Change MORE_SHELL_LINES to subtract lines from lines_per_screen
(like LESS_SHELL_LINES in less(1)) rather than setting the absolute
number of lines per screenful.
The block is moved after lines_per_screen is finalized (either from
the default lines_per_page - 1 or from an explicit -n/--lines), so
it correctly adjusts both cases. Values that are zero or would exceed
lines_per_screen are silently ignored.
Addresses: https://github.com/util-linux/util-linux/issues/3476 Co-authored-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Wed, 6 May 2026 09:47:39 +0000 (11:47 +0200)]
Merge branch 'enosys_tests' of https://github.com/cgoesche/util-linux-fork
* 'enosys_tests' of https://github.com/cgoesche/util-linux-fork:
tests: (enosys) add tests for the --dump option
tests: (enosys) add a simple test for --list
Karel Zak [Wed, 6 May 2026 09:41:58 +0000 (11:41 +0200)]
Merge branch 'chrt_reset_on_fork_test' of https://github.com/cgoesche/util-linux-fork
* 'chrt_reset_on_fork_test' of https://github.com/cgoesche/util-linux-fork:
tests: (chrt) add --reset-on-fork test
tests: (helpers) simple tool to create a child process
Karel Zak [Wed, 6 May 2026 09:35:45 +0000 (11:35 +0200)]
Merge branch 'chrt_tests' of https://github.com/cgoesche/util-linux-fork
* 'chrt_tests' of https://github.com/cgoesche/util-linux-fork:
tests: (chrt) add test for the --all-tasks option
tests: (helpers) add a thread creation helper
Karel Zak [Wed, 6 May 2026 09:34:59 +0000 (11:34 +0200)]
Merge branch 'lsfd--ignore-too-large-syscall-args' of https://github.com/masatake/util-linux
* 'lsfd--ignore-too-large-syscall-args' of https://github.com/masatake/util-linux:
lsfd: (cosmetic) adjust indent
lsfd: ignore too large integer read from /proc/PID/syscall
lsfd: handle unexpected values read from /proc/PID/syscall
Leefancy [Tue, 5 May 2026 10:01:36 +0000 (12:01 +0200)]
sfdisk: add --no-device-names option
Add --no-device-names option to suppress device names in --dump output,
using partition numbers instead (e.g., "1 : ..." rather than
"/dev/sda1 : ...").
The new libfdisk API:
- fdisk_script_disable_devnames()
- fdisk_script_has_devnames()
[kzak@redhat.com: - fix gtk-doc comments format
- move new symbols to FDISK_2_43
- simplify error handling in command_dump
- fix man page to mention --dump
- move --no-device-names in usage() with --no-* group]
Signed-off-by: Leefancy <lijian01@kylinos.cn> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 5 May 2026 11:40:52 +0000 (13:40 +0200)]
Merge branch 'script_toctou' of https://github.com/cgoesche/util-linux-fork
* 'script_toctou' of https://github.com/cgoesche/util-linux-fork:
script: use fopen_at_no_link() for log file opening to prevent TOCTOU
lib: (fileutils) new fopen_at_no_link routine
Karel Zak [Tue, 5 May 2026 11:21:10 +0000 (13:21 +0200)]
tests: fix remaining shellcheck warnings
- fstab-devname: remove broken '|| >>' pattern (SC2188), the bare
redirection after || has no command
- fstab-all: quote $(basename ...) to prevent word splitting (SC2046)
- libmount/lock, fsck/ismounted: use ':' no-op with bare file
truncation redirections (SC2188)
Karel Zak [Tue, 5 May 2026 11:14:34 +0000 (13:14 +0200)]
Merge branch 'clean_up_test_scripts' of https://github.com/cgoesche/util-linux-fork
* 'clean_up_test_scripts' of https://github.com/cgoesche/util-linux-fork:
tests: do not mix string and array
tests: use bash parameter substitution instead of echo & sed
tests: remove unneeded $ in arithmetic expressions
tests: use find instead of ls for more robust processing
tests: directly check exitcode for stability and code simplicity
tests: (lib) avoid repetitive file openings with identical redirects
tests: quote TS_{OUTPUT,ERRLOG} variables
Karel Zak [Tue, 5 May 2026 11:00:19 +0000 (13:00 +0200)]
Merge branch 'macos-prep' of https://github.com/t-8ch/util-linux
* 'macos-prep' of https://github.com/t-8ch/util-linux:
meson: gate hwclock on LINUX
meson: gate choom on LINUX
meson: gate losetup on LINUX
meson: gate chmem on LINUX
meson: gate lsmem on LINUX
meson: gate utmpdump on LINUX
meson: gate last on LINUX
meson: gate partx on linux/blkpg.h
meson: gate setterm on sys/klog.h
meson: move sys/klog.h check into generic header checks
meson: only build test_enosys when HAVE_FALLOCATE
test_strerror: drop include asm-generic/errno-base.h
script: use fopen_at_no_link() for log file opening to prevent TOCTOU
When no logfile name is provided script(1) uses a default name.
If the default file already exists as sym/hardlink, as checked by the
die_if_link() function, and the --force option is NOT provided,
the program will terminate. Otherwise, it opens the file after
forking a child process, creating a TOCTOU window that allows an
attacker to replace the default file with a link.
This patch moves the log file opening logic from log_start() to
its own function log_open() and uses a openat() + fdopen() wrap
enabled by the internal fopen_at_no_link() helper. It also adds a new
member to struct script_log, namely 'flags', set by log_associate()
if the latter function's new @flags parameter is set. This culminates
to an eventual log file opening with fopen_at_no_link() or fopen(),
depending on log->flags. This is primarily important for security
reasons as it allows us to prevent opening a logfile if it is a symlink
and due to the atomic nature of openat(2) the TOCTOU window is essentially
closed. As a result, die_if_link() becomes dead code and is therefore
removed.
Additionally, we open log files before we fork, so we can avoid
allocation of resources for the child process, if something goes
wrong with log file opening.
Closes: #4280 Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests: (helpers) simple tool to create a child process
This basic helper program can be used to create a child process
to test process attribute inheritances between parent and
child processes, e.g. real-time scheduling attributes with chrt(1)
or utilization clamp settings with uclampset(1), where options
like --reset-on-fork need to be tested.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Jamie Magee [Mon, 4 May 2026 15:47:59 +0000 (08:47 -0700)]
libfdisk: gpt: use ul_strtou16 for attribute bit parsing
Replace bare strtol() with ul_strtou16() which folds the errno/end-pointer/empty-input checks into one call and uses a uint16_t result type matching the bit-index domain. Also add udevadm settle between write/read sfdisk calls in the new attribute subtests.
Thomas Weißschuh [Wed, 29 Apr 2026 12:20:45 +0000 (14:20 +0200)]
test_strerror: drop include asm-generic/errno-base.h
This inclusios has multiple issues:
* It is Linux-only.
* The asm/ namespace is not an offical UAPI.
* Its definitions may be wrong if the architecture does not use it.
* It is unnecessary in the first place.
This simple helper can be used to create an arbitrary amount
of threads to be used in test scripts for tools like chrt(1).
chrt(1) can perform tasks on multiple threads for a process
and to conveniently test this 'test_threads_create' can be
used to spawn threads for a specified amount of time to act on.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Rong Zhang [Sat, 25 Apr 2026 20:29:57 +0000 (04:29 +0800)]
chrt: Fix confusing error messages when priority argument is required
While making the priority argument optional for non-prio policies, some
confusing error messages were accidentally exposed to users for cases
that do need a priority argument.
$ chrt true #1
chrt: invalid priority argument: 'true'
$ chrt 1 #2
chrt: failed to set pid 0's policy: Operation not permitted
$ sudo chrt 1 #3
chrt: no command specified
$ chrt --other 1 #4
chrt: unsupported priority value for the policy: 1: see --max for valid range
The error message #1 is caused by mixing `have_prio' and `need_prio'
together. Therefore, it always tries to parse the first positional
argument as a priority when `--pid' is not given. #2 shows that
set_sched() is meaninglessly called even when too few arguments are
specified.
At first glance, the error message #3 seems to be correct, but it turns
out to be very wrong -- the only positional argument in this case must
be regarded as a command, and commit 223a502b0208 ("chrt: (man,usage)
mark the priority value as optional in the synopses") also clearly
stated the same in the help message and the manual. In other words, #4
should have tried to execute `1' from PATH.
Fix #1 by decoupling `need_prio' from the priority parsing routine.
Fix #2 by parsing the first argument as a priority only when it's not
the only argument.
Fix #3 and #4 by consuming optind immediately when parsing priority
argument, instead of postponing it with inconsistent conditions (I have
an intuition that the previous code path was vibe-coded...)
Now #1 returns
chrt: policy SCHED_RR requires a priority argument
... #2, #3 return
chrt: no command or priority specified
... and #4 returns
chrt: failed to execute 1: No such file or directory
... which are more sensible and helpful.
This doesn't break existing usage patterns:
$ chrt --other true
$ chrt --other 0 true
$ chrt --other 1 true
chrt: unsupported priority value for the policy: 1: see --max for valid range
$ chrt --other echo meow
meow
Fixes: 4c425142844d ("chrt: Allow optional priority for non‑prio policies without --pid") Signed-off-by: Rong Zhang <i@rong.moe>
Link against libcommon_logindefs.la and libcommon_shells.la
Instead of linking with logindefs.c and shells.c library files, link
against libcommon_logindefs.la and libcommon_shells.la and handle possibly
needed econf libs there.
Stanislav Brabec [Thu, 30 Apr 2026 03:24:41 +0000 (05:24 +0200)]
Fix build with libeconf
Building with libeconf fails. Fix the build:
- Add missing includes.
- Make open_etc_shells() public, as required by login.c.
- shells.c requires linking against libeconf. To prevent linking of all
binaries with libeconf, split shells.c out of libcommon to libcommon_shells and
use it only if it is really needed.