Karel Zak [Mon, 25 May 2026 11:33:34 +0000 (13:33 +0200)]
pipesz: merge help/version getopt loop into main loop
The main() function scanned command-line options in two passes: the
first pass checked for --help/--version, and the second processed
normal options. When getopt_long encountered an unknown option in the
first pass, it printed an error message. The same error was then
printed again during the second pass, resulting in a duplicate
"unrecognized option" message.
Fix this by merging the first getopt_long loop into the main one,
following the standard util-linux convention.
Fixes: https://github.com/util-linux/util-linux/issues/3817 Signed-off-by: Karel Zak <kzak@redhat.com>
Furkan Caliskan [Fri, 15 May 2026 05:37:25 +0000 (08:37 +0300)]
chrt: Add uclamp reset support via -1 sentinel
Passing -1 to --clamp-min or --clamp-max sets the corresponding
sched_attr field to UINT32_MAX, which tells the kernel to reset
the utilization clamp to its system default. Resetting requires
kernel >= 5.11, otherwise the syscall will fail with EINVAL.
Karel Zak [Wed, 20 May 2026 10:44:21 +0000 (12:44 +0200)]
agetty: guard conditional function declarations in header
Wrap agetty_update_utmp() declaration with #ifdef SYSV_STYLE and
agetty_issue_is_changed()/agetty_reload() with #ifdef AGETTY_RELOAD
to match the guards on their definitions.
Thomas Weißschuh [Tue, 19 May 2026 20:54:44 +0000 (22:54 +0200)]
tests: fold ts_failed_subtest into ts_failed
The differences between ts_failed_subtest and ts_failed are miniminal.
Make ts_failed usable from subtest context and remove the now unnecessary
ts_failed_subtest.
Thomas Weißschuh [Tue, 19 May 2026 20:46:01 +0000 (22:46 +0200)]
tests: fold ts_skip_subtest into ts_skip
The differences between ts_skip_subtest and ts_skip are miniminal.
Make ts_skip usable from subtest context and remove the now unnecessary
ts_skip_subtest.
This allows subtests to make use of all of the convenient helpers built
around ts_skip.
Leonid Znamenok [Tue, 19 May 2026 18:41:57 +0000 (22:41 +0400)]
tests: (cramfs) restore umask after creating test input files
The cramfs doubles/mkfs/mkfs-endianness tests set "umask 133" to get
deterministic permission bits on the test input files. The umask was
never restored, so it stayed in effect for every command run later in
the test, including the build-tree mount/umount/mkfs.cramfs helpers.
When such a helper is a libtool wrapper script that has to relink its
real binary on first use (fast_install=yes), the relink runs under the
leaked umask 133 and the resulting .libs/lt-* binary is created without
execute bits (mode 0644). The wrapper then fails to exec it with
"Permission denied" (EACCES). Because the broken binary is cached, every
subsequent test using that helper fails as well:
Karel Zak [Tue, 19 May 2026 08:54:57 +0000 (10:54 +0200)]
pam_lastlog2: fix libpam linking in autotools build
Move -lpam from LDFLAGS to LIBADD. When -lpam is in LDFLAGS it
appears on the linker command line before object files, so the
--as-needed linker flag (default on Fedora) discards it before
seeing any undefined PAM symbols. This results in pam_lastlog2.so
missing libpam.so in its ELF NEEDED entries.
The module then fails to load with dlopen() if the calling process
does not itself link against libpam (e.g., systemd in Fedora 44+):
PAM unable to dlopen(pam_lastlog2.so): undefined symbol: pam_syslog
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2453457 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 19 May 2026 08:18:44 +0000 (10:18 +0200)]
libblkid: (dasd) guard against uint64 underflow in LDL size calculation
When an LDL volume label has ldl_version < 0xf2, the partition
size is derived from the device size. If the device is smaller
than the partition start offset (3 blocks), the subtraction
wraps around producing a bogus partition size.
Karel Zak [Tue, 19 May 2026 08:12:41 +0000 (10:12 +0200)]
libblkid: (dasd) add buffer size guards to helper functions
Add explicit buffer size parameters to dasd_get_volser(),
dasd_get_dsnam(), is_dasd_cdl_label(), is_dasd_ldl_label()
and is_dasd_f4_label() so that these functions can protect
against buffer overflows without relying on callers to pass
correctly sized buffers.
The conversion functions still follow the DASD standard field
sizes (DASD_VOLSER_LENGTH, sizeof DS1DSNAM), but clamp to the
buffer size as a safety net. The label detection functions
derive their minimum sizes from the actual struct offsets and
magic constants rather than hardcoded numbers.
Adam Sampson [Mon, 18 May 2026 13:41:40 +0000 (14:41 +0100)]
tests: test_scols_termreduce needs libsmartcols
This helper needs libsmartcols, so it can't be built if util-linux is
configured with --disable-libsmartcols. (It's still reasonable to want
to run the test suite in this case, for example if you're configuring
util-linux to only build libuuid.)
Karel Zak [Mon, 18 May 2026 09:59:17 +0000 (11:59 +0200)]
Merge branch 'macos' of https://github.com/t-8ch/util-linux
* 'macos' of https://github.com/t-8ch/util-linux:
ci: add a macos workflow
test_threads_create: add a macOS fallback
meson: gate test_child_create on sys/prctl.h
ctrlaltdel: pass correct integer types to printf
meson: gate irqtop on sys/epoll.h and cpu_set_t
meson: gate lsirq on cpu_set_t
meson: gate lsipc on LINUX
meson: gate pivot_root on LINUX
meson: gate lscpu on LINUX and cpu_set_t
meson: add build-lscpu option
Karel Zak [Mon, 18 May 2026 09:36:24 +0000 (11:36 +0200)]
Merge branch 'fincore_test' of https://github.com/cgoesche/util-linux-fork
* 'fincore_test' of https://github.com/cgoesche/util-linux-fork:
tests: (fincore) add --cachestat option test
fincore: define HAVE_CACHESTAT on fallback
Karel Zak [Mon, 18 May 2026 08:45:20 +0000 (10:45 +0200)]
readprofile: (man) clarify not designed for privilege-elevation use
Add a note to the DESCRIPTION that readprofile is a diagnostic tool
not intended for security-sensitive contexts (setuid, setgid, sudo).
Remove the suggestion to make readprofile set-user-ID 0 from the -r
option, and drop sudo from the example.
ionmeo [Wed, 13 May 2026 15:57:11 +0000 (11:57 -0400)]
license: switch from BSD 4-clause to 3-clause
Remove the advertising clause (clause 3) and renumber the
non-endorsement clause from 4 to 3 in all files containing the
BSD 4-clause license, following the notice issued by UC Berkeley
(quoted below).
Additional changes:
- Add SPDX-License-Identifier: BSD-3-Clause to each affected file.
- Remove the BSD-4-Clause-UC entry from README.licensing.
- Delete Documentation/licenses/COPYING.BSD-4-Clause-UC.
To all licensees, and distributors of software officially
licensed under a UC Berkeley version of the BSD license:
As you may know, certain software officially licensed by UC
Berkeley using the original 4-clause BSD license required that
further distributions of products containing all or portions of
the software acknowledge within their advertising materials that
such products contain software developed by UC Berkeley and its
contributors.
Specifically, the provision reads:
"3. All advertising materials mentioning features or use of
this software must display the following acknowledgement:
This product includes software developed by the University
of California, Berkeley and its contributors."
Effective immediately, licensees and distributors are no longer
required to include the acknowledgement within advertising
materials. Accordingly, the advertising clause 3 of the original
4-clause BSD license for any and all software officially licensed
by UC Berkeley, is hereby deleted in its entirety.
Michael Katz
Executive Director
Intellectual Property and Industry Research Alliances
University of California, Berkeley
Furkan Caliskan [Thu, 14 May 2026 11:52:22 +0000 (14:52 +0300)]
chrt: Add support for SCHED_FLAG_UTIL_CLAMP
The SCHED_FLAG_UTIL_CLAMP_MIN and SCHED_FLAG_UTIL_CLAMP_MAX flags
allow users to set utilization hints for tasks. The minimum clamp
tells the scheduler to place the task on a CPU with enough capacity,
while the maximum clamp prevents unnecessary CPU frequency boosting.
Both accept a value in the range 0-1024, where 1024 represents 100%
of maximum CPU capacity. Mainly useful on heterogeneous systems.
Add -U/--clamp-min and -X/--clamp-max options to allow users to
set these hints for any scheduling policy.
Karel Zak [Thu, 14 May 2026 10:13:39 +0000 (12:13 +0200)]
agetty: move fakehost to struct agetty_options
Move the file-scope fakehost variable into struct agetty_options
and drop the separate fakehost parameter from agetty_update_utmp()
and agetty_init_login_argv().
Karel Zak [Thu, 14 May 2026 10:06:12 +0000 (12:06 +0200)]
agetty: move usage() and parse_args() before main()
Reorder functions so that output_version(), usage() and
parse_args() appear before main(), matching the convention used
across the project. Remove the now unnecessary forward
declarations for these functions.
Karel Zak [Thu, 14 May 2026 09:54:01 +0000 (11:54 +0200)]
agetty: move login argv initialization to utils.c
Introduce agetty_init_login_argv() that consolidates the login
command line setup: setting the program name, check_username(),
login_options_to_argv() with replace_u(), and the -h/-H/-f/--
flag logic.
Move LOGIN_ARGV_MAX to the shared header. The check_username(),
login_options_to_argv() and replace_u() helpers become static
in utils.c.
Karel Zak [Thu, 14 May 2026 09:21:48 +0000 (11:21 +0200)]
agetty: split out issue file functions to issuefile.c
Move issue file parsing, display and reload functions to a new
issuefile.c file: agetty_print_issue_file(), agetty_eval_issue_file(),
agetty_show_issue(), agetty_issue_is_changed(), agetty_reload(),
read_os_release(), output_special_char(), and all issuedir/issuefile
read helpers and network interface display functions.
Keep do_prompt(), get_logname() and wait_for_term_input() in
agetty.c as they are tightly coupled to the main login flow.
Karel Zak [Thu, 14 May 2026 09:11:01 +0000 (11:11 +0200)]
agetty: move struct issue and related defines to agetty.h
Move struct issue (renamed to struct agetty_issue),
ISSUE_SUPPORT, ISSUEDIR_SUPPORT, AGETTY_RELOAD and USE_NETLINK
defines to the shared header file in preparation for splitting
the issue file functions to a separate source file.
Karel Zak [Thu, 14 May 2026 08:37:35 +0000 (10:37 +0200)]
agetty: split out speed table and baud code to tty.c
Move speedtab[], struct Speedtab, bcode() and list_speeds() to a
new tty.c file as agetty_bcode() and agetty_list_speeds(). The
speed table is kept static in tty.c.
Add agetty_fprint_speed() to print the numeric baud rate for a
given speed code, replacing the open-coded speedtab[] lookup in
output_special_char() case 'b'.
Karel Zak [Thu, 14 May 2026 08:08:30 +0000 (10:08 +0200)]
agetty: move utility functions to utils.c
Move agetty_update_utmp(), agetty_xgethostname() and
agetty_xgetdomainname() to utils.c.
Move the SYSV_STYLE detection to agetty.h so it is available to
all split-out files. Change agetty_update_utmp() to take fakehost
as a parameter instead of accessing a file-scope static variable.
Karel Zak [Thu, 14 May 2026 07:41:12 +0000 (09:41 +0200)]
agetty: move struct options and F_* flags to agetty.h
Move struct options (renamed to struct agetty_options), MAX_SPEED
and all F_* flag definitions to the shared header file, making
them available to the split-out source files.
Karel Zak [Wed, 13 May 2026 13:18:13 +0000 (15:18 +0200)]
agetty: split out logging functions to utils.c
Move dolog(), agetty_exit_slowly(), agetty_log_err() and
agetty_log_warn() to a new utils.c file. These are foundational
functions used throughout agetty and need to be available to all
the split-out files.
Rename with agetty_ prefix to avoid symbol name collisions now
that the functions are no longer static.
Karel Zak [Wed, 13 May 2026 13:02:27 +0000 (15:02 +0200)]
agetty: move agetty.c to agetty-cmd/ directory
Create a dedicated agetty-cmd/ directory and move the monolithic
agetty.c there as a first step towards splitting it into smaller,
more maintainable files.
Update both autotools and meson build systems accordingly.
Karel Zak [Thu, 14 May 2026 11:05:12 +0000 (13:05 +0200)]
Merge branch 'PR/write-utmp-and-cleanup' of https://github.com/karelzak/util-linux-work
* 'PR/write-utmp-and-cleanup' of https://github.com/karelzak/util-linux-work:
write: cleanup indentation and whitespace
write: use mem2strcpy() for utmp strings
write: always use utmp as fallback
Furkan Caliskan [Wed, 13 May 2026 09:45:09 +0000 (12:45 +0300)]
chrt: Add support for SCHED_FLAG_DL_OVERRUN
When set on a SCHED_DEADLINE task, the kernel sends SIGXCPU to the
task if it exceeds its runtime budget within a period. Without this
flag the task is silently throttled until the next period. Useful
for real-time applications that need to detect when they are not
meeting their timing requirements.
Add -O/--deadline-overrun option to allow users to toggle this
feature using the deadline scheduling class.
Karel Zak [Wed, 13 May 2026 09:22:59 +0000 (11:22 +0200)]
write: use mem2strcpy() for utmp strings
The utmp fields ut_user and ut_line are fixed-size buffers not
guaranteed to be null-terminated. Using strncmp(), snprintf() or
memcmp() directly on these fields can read beyond the buffer content.
Use mem2strcpy() to safely copy utmp fields into properly terminated
local buffers before any string operations.
Karel Zak [Wed, 13 May 2026 09:13:03 +0000 (11:13 +0200)]
write: always use utmp as fallback
The systemd session list may not cover all terminals (e.g., screen,
tmux, or old-style logins). Remove the "if systemd else utmp" pattern
and always fall through to utmp when the target user or tty is not
found in systemd sessions.
Also make sd_get_sessions() and sd_session_get_username() failures
non-fatal — silently fall through to utmp instead of calling errx().
Addresses: https://redhat.atlassian.net/browse/RHEL-157244 Signed-off-by: Karel Zak <kzak@redhat.com>
Furkan Caliskan [Mon, 11 May 2026 14:10:30 +0000 (17:10 +0300)]
chrt: Add support for (GRUB) bandwidth reclaim
The SCHED_DEADLINE policy supports the (GRUB) Greedy Reclamation
of Unused Bandwidth algorithm. This allows tasks to reclaim
bandwidth that are left over by other deadline tasks that finish
their work early, or voluntarily yield the cpu.
Currently, chrt has no way to set the SCHED_FLAG_RECLAIM bit in
the sched_flags field of the sched_attr structure.
Add -G/--reclaim-grub option to allow users to toggle this feature
using the deadline scheduling class.
[kzak@redhat.com: - add missing #ifdef SCHED_FLAG_RECLAIM guards
- add comments to #else/#endif for SCHED_DEADLINE block] Signed-off-by: Furkan Caliskan <frn1furkan10@gmail.com>
Karel Zak [Tue, 12 May 2026 16:01:52 +0000 (18:01 +0200)]
tests: (getino) skip namespace subtests when not supported
Skip namespace subtests when the getino namespace ioctl is not
supported, and skip individual subtests when the corresponding
/proc/self/ns/* entry is not readable.
Karel Zak [Tue, 12 May 2026 13:10:02 +0000 (15:10 +0200)]
tests: (getino) skip namespace subtests when unshare is not supported
The namespace subtests use unshare to create isolated namespaces, but
this fails on QEMU and restricted CI containers where namespace
creation is not available. Skip the namespace subtests in this case.
Karel Zak [Tue, 12 May 2026 11:53:48 +0000 (13:53 +0200)]
Merge branch 'chrt_pidino_support' of https://github.com/cgoesche/util-linux-fork
* 'chrt_pidino_support' of https://github.com/cgoesche/util-linux-fork:
chrt: improve error message for invalid policy value
chrt: remove redundant initializations to 0 in struct members
chrt: deduplicate code for process tasks retrieval
chrt: report actual PID in error message when 0 is specified
tests: (chrt) simple PID:inode address format test
chrt: support the 'PID:inode' address format
Karel Zak [Tue, 12 May 2026 11:33:22 +0000 (13:33 +0200)]
tests: (lsblk) add bcachefs multi-device regression test
Add a dump from a system with a two-device bcachefs filesystem
(sdc1 + sdc2 mounted at /mnt/test) to verify that mount point
propagation works for all member devices.