Karel Zak [Thu, 9 Oct 2025 20:19:40 +0000 (22:19 +0200)]
lib/configs: introduce config_mk_path() helper
Refactor main_configs() and read_dir() to use a new helper function
that combines path construction with existence and type checking.
This reduces code duplication and simplifies the logic.
Karel Zak [Thu, 9 Oct 2025 20:04:19 +0000 (22:04 +0200)]
tests: add regression tests for ul_configs_file_list()
Add comprehensive test script for configuration file list functionality
with the following test cases:
- main-etc: Main config file in /etc
- main-usr: Main config file fallback to /usr
- dropin-etc: Drop-in files from /etc
- dropin-usr: Drop-in files from /usr
- combined: Main config + drop-ins from multiple directories
- masking: Same basename in multiple directories (masking behavior)
- no-project: Configuration without project subdirectory
The tests verify proper file discovery, priority ordering across /etc,
/run, and /usr directories, and file masking behavior according to the
Configuration Files Specification.
Karel Zak [Thu, 9 Oct 2025 20:02:24 +0000 (22:02 +0200)]
lib/configs: add test program for ul_configs_file_list()
Add a test program with command line options to test the configuration
file list functionality. The test program allows specifying custom paths
for /etc, /run, and /usr directories, project name, config name, and suffix.
This enables testing the priority ordering and file discovery logic
of ul_configs_file_list() from the command line.
Karel Zak [Tue, 14 Oct 2025 08:54:14 +0000 (10:54 +0200)]
Merge branch 'test--lsfd-revise-rpi5' of https://github.com/masatake/util-linux
* 'test--lsfd-revise-rpi5' of https://github.com/masatake/util-linux:
tests: (lsfd/mkfds-unix-dgram) skip if the unix diag netlink interface is not available
tests: (lsfd-functions.sh) make lsfd_check_sockdiag usable in subtests
tests: (lsfd/mkfds-unix-stream-requiring-sockdiag) revise the test description
Karel Zak [Tue, 14 Oct 2025 08:35:26 +0000 (10:35 +0200)]
Merge branch 'tests--kill-make-test-bits' of https://github.com/masatake/util-linux
* 'tests--kill-make-test-bits' of https://github.com/masatake/util-linux:
ts/kill/decode: compare decoded output in an architecture-independent way
ts/kill/decode: check the availability of "sed"
ts/kill/decode: consider arch dependent signum/name association
tests: (libmount) improve explicit loop read-write mount check
Some kernel configurations will affect default mount behavior
and add extra mount options. As a result, the $TS_OUTPUT will not
reliably match on all kernels. Therefore it is better to simply
test whether 'rw' is an option and not write the full options
list to $TS_OUTPUT.
Adresses: #3765 Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
umount: consider helper return status for success message
If a helper function was executed to unmount, we simply return
without any user feedback. That can unintentionally surpress
verbose messages (`--verbose`) for non-root users who use udisks2
to mount filesystems, and unmount via the unmount.udisks2 helper.
It would be better to check the helper return status as well for
completeness and a more reliable way to test the success of the
unmount operation.
mnt_context_get_helper_status() is only called if the helper was
executed, i.e. mnt_context_helper_executed == 1, anything else
wouldnt make sense anyways.
Addresses: #3790 Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Post job cleanup.
/usr/bin/docker exec 94db032be2efb37ea68b3ce562ce52ba3dea047f5ac970aabb7fded075116c20 sh -c "cat /etc/*release | grep ^ID"
/__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /__e/node20/bin/node)
This adds the -J and --json options that enable JSON output mode
for the libsmartcols table. JSON output can be especially useful if
another program wants to consume lslogins's data in an easily parse-
able and language independent format.
Each keys's value will be converted into an appropriate JSON data
type, i.e. integers are numbers, empty values are null and others
are strings.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
treewide: consolidate --list-columns option in usage() to USAGE_LIST_COLUMNS_OPTION()
This consolidates the --list-columns description in the usage()
of ls-like tools to the USAGE_LIST_COLUMNS_OPTION() macro. It
makes it simplier and ensures a consistent definition.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
With this new macro we no longer have to redundantly specify
`fputs(_(" -H, --list-columns...` in the usage() function of ls-like tools, as it
will be consolidated to the USAGE_LIST_COLUMNS_OPTION() macro.
USAGE_LIST_COLUMNS_OPTION() aligns the option description to the other descriptions
in the usage() output in the same way as USAGE_HELP_OPTIONS().
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Masatake YAMATO [Fri, 10 Oct 2025 21:51:51 +0000 (06:51 +0900)]
ts/kill/decode: compare decoded output in an architecture-independent way
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Fixed: https://github.com/util-linux/util-linux/issues/3774 Signed-off-by: Masatake YAMATO <yamato@redhat.com>
bash-completion: dmesg: remove redundant completion for --buffer-size
The option --buffer-size already infers that its the optional argument
is a size value. In addition to that, when the option is completed the
user will have to delete the word 'size' from the command line and type
the desired value, which is not an ideal user experience.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Masatake YAMATO [Fri, 10 Oct 2025 20:41:25 +0000 (05:41 +0900)]
ts/kill/decode: consider arch dependent signum/name association
In the original code, the signal bits passed to the decode test were
sampled on x86_64. As reported in #3774, the association between signal
number and its name is architecture dependent.
With this change, the test case calculates the signal bits from signal
names at runtime instead of hardcoding.
Stanislav Brabec [Fri, 10 Oct 2025 11:17:26 +0000 (13:17 +0200)]
agetty: Process all data from ul_nl_process()
However select() normally triggers immediately after a partial read, it does not
happen for netlink socket. It keeps unprocessed data until the next netlink
message appears. It causes raising processing delays.
Always read all data. It also potentially decreases number of issue redraws.
Karel Zak [Thu, 9 Oct 2025 08:17:45 +0000 (10:17 +0200)]
Merge branch 'PR/sprintf-replace' of https://github.com/karelzak/util-linux-work
* 'PR/sprintf-replace' of https://github.com/karelzak/util-linux-work:
hwclock: use snprintf() instead of sprintf()
lib/mbsalign: use snprintf() instead of sprintf()
col: use snprintf() instead of sprintf()
libfdisk: use snprintf() instead of sprintf()
lsfd: use snprintf() instead of sprintf()
pipesz: use snprintf() instead of sprintf()
dmesg: use snprintf() instead of sprintf()
lsipc: use snprintf() instead of sprintf()
libblkid: use snprintf() instead of sprintf()
If there are no IP addresses, ul_netaddrq_bestaddr() returns threshold
ULNETLINK_RATING_BAD, but there were no addresses in the best array, and
best_ifaceq remains unset, which caused crash. Setting the initial
threshold to __ULNETLINK_RATING_MAX and checking for that value fixes that.
And more, it also allows to accept IP addresses with ULNETLINK_RATING_BAD
rating.
Karel Zak [Tue, 7 Oct 2025 10:48:41 +0000 (12:48 +0200)]
lib/mbsalign: use snprintf() instead of sprintf()
Add bufsiz parameter to mbs_safe_encode_to_buffer() and
mbs_invalid_encode_to_buffer() functions to enable safe buffer
operations. Track remaining buffer size internally using int
variable and convert all sprintf() calls to snprintf().
Add buffer overflow protection by checking snprintf() return
values and verifying sufficient space before memcpy() and
direct writes. Break encoding loop early if buffer space
is exhausted.
This change improves code safety by preventing potential buffer
overflows and makes buffer size limits explicit in the API.
Karel Zak [Mon, 6 Oct 2025 12:31:29 +0000 (14:31 +0200)]
Merge branch 'fix/rename_annotation_opt_to_annotate' of https://github.com/cgoesche/util-linux-fork
* 'fix/rename_annotation_opt_to_annotate' of https://github.com/cgoesche/util-linux-fork:
man-common: rename annotation.adoc to annotate.adoc
swapon: use ANNOTATE_OPTION as enum name for --annotate
swapon: rename the new --annotation option to --annotate
swapon: (usage) make the help text fit within 80 columns again
Karel Zak [Mon, 6 Oct 2025 12:29:50 +0000 (14:29 +0200)]
Merge branch 'kill--line-oriented-list' of https://github.com/masatake/util-linux
* 'kill--line-oriented-list' of https://github.com/masatake/util-linux:
kill (-l/-L): print one signal per line when stdout is not a TTY
kill: (refactor) rename parameter to better reflect its purpose
swapon: rename the new --annotation option to --annotate
The form --annotation gave the impression that after the subsequent
"=" comes the text that each column name should be annotated with.
Furthermore, the other two options with optional arguments (--show
and --discard) are in the imperative, so follow that style and use
--annotate instead.
(In the bargain, this allows aligning the descriptions in the help
text perfectly again.)
Also, improve the description of --annotate in the man page somewhat.
swapon: (usage) make the help text fit within 80 columns again
Recent commit 72829b08fe added four extra spaces to each description
in the usage text, causing some lines to be wider than 80 characters.
Undo that addition, to make the help text fit again in 80 columns.
Also, put the equals sign for the new --annotation option inside the
square brackets instead of mistakenly before them.
UL_NL_SOFT_ERROR can be issued if kernel sends unpaired RTM_DELADDR. It
should not happen, but it can happen due to race condition. And it happened
in some kernel versions. It is not reason to exit the processing loop.
When duplicating struct ul_nl_addr, set address to ifa_local, if it is set
to ifa_local in the source. This fixes the address for PtP IPv4 network
interfaces and avoids UL_NL_SOFT_ERROR during address removal.
Karel Zak [Thu, 2 Oct 2025 12:44:10 +0000 (14:44 +0200)]
ci: add bash-completion consistency check to CODECHECK
Add 'make checkcompletion' to the GitHub CI CODECHECK phase to verify
bash-completion files consistency for all future pull requests. This
ensures that all user-facing programs have proper bash-completion
scripts registered in both autotools and meson build systems.
Karel Zak [Thu, 2 Oct 2025 12:07:53 +0000 (14:07 +0200)]
tools: rewrite checkcompletion.sh to be source-based
The original checkcompletion.sh checked compiled binaries in the build
directory, which was unreliable and build-dependent. The new version
performs comprehensive source-based verification by:
1. Extracting program names from */Makemodule.am files (bin_PROGRAMS,
sbin_PROGRAMS, usrbin_exec_PROGRAMS, usrsbin_exec_PROGRAMS)
2. Verifying three-way consistency:
- Programs defined in Makemodule.am files
- bash-completion files in bash-completion/ directory
- Entries in bash-completion/Makemodule.am
- Entries in meson.build
3. Properly handling special cases:
- Programs that don't need completion (system tools like login, agetty)
- Programs with special install hooks (runuser, lastb symlinks)
The script now provides clear categorized output:
- Programs missing bash-completion files
- bash-completion files not registered in Makemodule.am
- Orphaned bash-completion files without programs
This makes it easier to maintain bash-completion consistency and catch
issues before release.
Masatake YAMATO [Thu, 2 Oct 2025 16:21:21 +0000 (01:21 +0900)]
lsns: don't abort if /proc/self/ns/user is absent; probe other ns entries
In 7d5036fdafe0 ("lsns: show namespaces only kept alive by open file
descriptors"), I added code that calls stat(2) on /proc/self/ns/user
and made lsns exit after reporting an error if the call failed. I
assumed /proc/self/ns/user would be available on all platforms.
As Axel Karjalainen reported (link below), that assumption was
wrong: on some platforms, the file is absent. Exiting for this reason
is undesirable.
The stat(2) call is used to obtain the dev_t of the backing device of
nsfs. However, /proc/self/ns/user is not the only source; calling
stat(2) on other namespace files under /proc/self/ns yields the same
dev_t. This change iterates over entries under /proc/self/ns and uses
the first one whose stat(2) succeeds.
Karel Zak [Thu, 2 Oct 2025 11:38:13 +0000 (13:38 +0200)]
bash-completion: add bits to dist tarball
The bits command was added in commit 6e1301d59 (text-utils: add bits
command) but the bash-completion file was not added to the autotools
Makemodule.am, causing it to be missing from release tarballs.
This resulted in meson build failures when using the tarball with
bash-completion installed, as meson.build references the file but
it doesn't exist in the tarball.
Fixes: https://github.com/util-linux/util-linux/issues/3766 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 2 Oct 2025 09:52:52 +0000 (11:52 +0200)]
Merge branch 'PR/agetty-issue-read' of https://github.com/karelzak/util-linux-work
* 'PR/agetty-issue-read' of https://github.com/karelzak/util-linux-work:
lib/configs: improve readability
agetty: use standard path macros
build-sys: make sure _PATH_SYSCONFDIR is defined
The current \4 and \6 issue file escapes implementation is inferior. It
uses get getifaddrs() to get a list of IP addresses. This function does not
provide enough information to discriminate between stable IP addresses and
ephemeral addresses. As a result, especially \6 often gives unreliable
results.
The code is actually unable to get list of all interfaces, so a proper out
of the box IP address reporting depends on external tools that generate
issue file with the interfaces list.
The netlink messages are already used, but only as a change notifier. The
contents is not used, even if it contains exact information about the
change. As a result, change processing is triggered even for unrelated
network changes like IPv6 router advertisement.
The new implementation uses the new netaddrq library. It reports more
reliable results especially for IPv6.
Additionally, two new escapes are implemented:
\a Report all interfaces and assigned addresses that are considered as
reliable.
\A Report all interfaces and all assigned addresses.
TODO:
To prevent overflooding of the console, the list is currently limited to 12
interfaces. It would be nice to make it configurable.
Two pass processing of issue files. First pass just collects IP protocols
and list of interfaces (in future interface patterns). Now it always
processes both IPv4 and IPv6 on all interfaces. Not so bad, as \a is smart
enough to display just the useful part.
Maybe implement more options and formatting support for \a and \A.
Maybe implement interface filter globs or regexps for \a and \A. Still not
so bad, as \a automatically skips interfaces without reliable addresses
(e. g. lo or TUN).
To support netlink and IP address processing, two new library files were
added:
netlink: Generic netlink message processing code converting netlink
messages to calls of callbacks with a pre-processed data.
netaddrq: A code that gets and maintains linked list of the current
interfaces and assigned IP addresses. It also provides a rating of IP
addresses based on its "quality", i. e. type of address, validity, lifetime
etc.
Karel Zak [Wed, 1 Oct 2025 13:13:02 +0000 (15:13 +0200)]
Merge branch 'feat/swapon_translate_col_names' of https://github.com/cgoesche/util-linux-fork
* 'feat/swapon_translate_col_names' of https://github.com/cgoesche/util-linux-fork:
bash-completion: (swapon) add --annotation option
swapon: document --annotation option on the man page
swapon: control column header tooltips with --annotation
swapon: annotate column header names with OSC8 hyperlinks
lib/strutils: add helper function for --annotation option
libsmartcols: new scols_column_{refer,get}_annotation routines
Lukas Herbolt [Wed, 1 Oct 2025 11:54:50 +0000 (13:54 +0200)]
fallocate: allow O_CREATE if mode is FALLOC_FL_WRITE_ZEROES
With the new flag we can create the ZEROED allcoated files directly and not
in the two steps. Removing FALLOC_FL_WRITE_ZEROES from the flags of not using
O_CREATE on open().
Karel Zak [Wed, 1 Oct 2025 11:54:08 +0000 (13:54 +0200)]
Merge branch 'configs3' of https://github.com/schubi2/util-linux
* 'configs3' of https://github.com/schubi2/util-linux:
Using fix issue dir path "/usr/lib" for agetty
agetty: using configs lib for parsing issue files
libcommon: added lib "configs" for parsing configuration files in the correct order
Masatake YAMATO [Sun, 31 Aug 2025 01:03:03 +0000 (10:03 +0900)]
lsfd: refer to /proc/$pid/map_files if a mapped file is masked
To extract file information, lsfd called stat(2) on the the file name
found in /proc/$pid/maps. However, lsfd may retrieve information for
the wrong file if the file is bind-mount'ed after the process maps the
file.
To obtain the information about the originally mapped file, this
change makes lsfd call fstat(2) on the corresponding entry under
/proc/$pid/map_files avoiding the bind-mount ambiguity.
swapon: control column header tooltips with --annotation
Whether column header names should be annotated can be specified
with the --annotation option which takes the following three
arguments: 'auto', 'never' and 'always', where the former is the
default and makes it so that annotations are only added when the
output device is a terminal. If the option is omitted the 'auto'
behavior should be expected.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
swapon: annotate column header names with OSC8 hyperlinks
Column header names are annotated with OSC8 hyperlinks to
provide tooltips with a description of the column.
This is mainly motivated by the fact that column headers
are currently not translated, so as an alternative we will
provide a column description translated according to the
environment locale setting.
Addresses: #1291 Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
lib/strutils: add helper function for --annotation option
This function helps evaluates the --annotation option argument
and determines whether annotations are enabled or not.
It is identical to the hyperlinkwanted() routine, and although
that forms some form of redundancy, it is intentionally kept
seperate for potential future changes.
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Karel Zak [Wed, 24 Sep 2025 08:06:04 +0000 (10:06 +0200)]
Merge branch 'PR/Benno-23Sep' of https://github.com/karelzak/util-linux-work
* 'PR/Benno-23Sep' of https://github.com/karelzak/util-linux-work:
fallocate: (man,usage) correct the alphabetical sorting of the options
fallocate: (man) slightly improve the grammar of two sentences
fallocate: redo four tweaks that were accidentally undone
column: (usage) wrap two descriptions, to make them fit within 80 columns
column: (usage) correct the description of --wrap-separator
getopt: (usage) make the description of -U fit within 80 columns
Karel Zak [Wed, 24 Sep 2025 08:05:26 +0000 (10:05 +0200)]
Merge branch 'master' of https://github.com/wuguanghao3/util-linux
* 'master' of https://github.com/wuguanghao3/util-linux:
losetup: Add the --remove/-R parameter to remove loop devices
losetup: rename function *_delete_* to *_detach_*
libsmartcols: new scols_column_{refer,get}_annotation routines
The new routines can be used to add an annotation to columns
which are intended to serve as descriptions for column headers.
These annotations are formatted with OSC8 escape sequences and
then sent to the output stream. A supporting terminal can then
display the formatted string as a tooltip.
This can be fairly useful when an application wants to provide
a translated description for a column header name, since the
latter is sometimes a mere abbreviation and not necessarily
telling enough.
Addresses: #1291 Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>