]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
11 days agolib/loopdev: avoid null pointer dereferences [coverity]
Karel Zak [Thu, 23 Oct 2025 10:34:08 +0000 (12:34 +0200)] 
lib/loopdev: avoid null pointer dereferences [coverity]

Signed-off-by: Karel Zak <kzak@redhat.com>
12 days agoMerge branch 'optstr-test' of https://github.com/crobinso/util-linux
Karel Zak [Wed, 22 Oct 2025 09:25:01 +0000 (11:25 +0200)] 
Merge branch 'optstr-test' of https://github.com/crobinso/util-linux

* 'optstr-test' of https://github.com/crobinso/util-linux:
  tests: optstr: test redundant commas

12 days agoMerge branch 'PR/losetup-remove' of https://github.com/karelzak/util-linux-work
Karel Zak [Wed, 22 Oct 2025 09:24:14 +0000 (11:24 +0200)] 
Merge branch 'PR/losetup-remove' of https://github.com/karelzak/util-linux-work

* 'PR/losetup-remove' of https://github.com/karelzak/util-linux-work:
  losetup: improve command line option processing
  lostup: report EACCES on loop-control
  losetup: improve --remove documentation
  losetup: make --remove a long-only option with mutual exclusivity
  lib/loopdev: introduce loopcxt_get_device_nr() helper
  losetup: add error feedback for --remove command

12 days agomount: add note about systemd and --all historical context
Karel Zak [Wed, 22 Oct 2025 08:42:36 +0000 (10:42 +0200)] 
mount: add note about systemd and --all historical context

Add information that mount -a was originally designed for init scripts
but many modern systemd-based distributions use systemd units instead
for mounting filesystems on boot in a more sophisticated way.

Signed-off-by: Karel Zak <kzak@redhat.com>
12 days agomount: improve --all documentation regarding swap areas
Karel Zak [Wed, 22 Oct 2025 08:36:32 +0000 (10:36 +0200)] 
mount: improve --all documentation regarding swap areas

The --all option description did not mention that swap entries in
fstab are silently ignored. Add a note clarifying this behavior and
pointing users to swapon --all for enabling swap devices and files.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agolosetup: improve command line option processing
Karel Zak [Tue, 21 Oct 2025 09:45:54 +0000 (11:45 +0200)] 
losetup: improve command line option processing

The options --detach, --remove, and --set-capacity are mutually
exclusive. We can assume the device name follows the options, which is
better than assuming the device name is specified as an option's
argument. This also allows the use of the existing mutually-exclusive
check.

 # losetup --remove --detach loop0
 losetup: /dev/--detach: remove failed: Success
 losetup: /dev/loop0: remove failed: Device or resource busy

is ugly.

Reported-by: Benno Schulenberg <bensberg@telfort.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agolostup: report EACCES on loop-control
Karel Zak [Tue, 21 Oct 2025 08:58:36 +0000 (10:58 +0200)] 
lostup: report EACCES on loop-control

Don't start scanning /dev/loop* after a failed access to
/dev/loop-control. It's a waste of time, and the user does not receive
a relevant error message.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agolosetup: improve --remove documentation
Karel Zak [Thu, 16 Oct 2025 10:16:27 +0000 (12:16 +0200)] 
losetup: improve --remove documentation

Rewrite the --remove option description to clearly explain the
difference between --detach and --remove. Add a new LOOP DEVICE
LIFECYCLE section that describes the three stages: creation,
detachment, and removal, with corresponding ioctl names.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agolosetup: make --remove a long-only option with mutual exclusivity
Karel Zak [Thu, 16 Oct 2025 09:56:08 +0000 (11:56 +0200)] 
losetup: make --remove a long-only option with mutual exclusivity

Change --remove from '-R, --remove' to a long-only option '--remove'.
This makes it consistent with other administrative options and adds
mutual exclusivity with other major actions like -d, -D, -a, -c, -f,
-j, -l, and -O.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agolib/loopdev: introduce loopcxt_get_device_nr() helper
Karel Zak [Thu, 16 Oct 2025 09:42:03 +0000 (11:42 +0200)] 
lib/loopdev: introduce loopcxt_get_device_nr() helper

Add a new static helper function loopcxt_get_device_nr() to extract
the loop device number from the device path. This eliminates code
duplication in loopcxt_remove_device() and loopcxt_add_device().

The helper function supports both /dev/loop<N> and /dev/loop/<N>
formats and provides consistent error handling with debug logging.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agolosetup: add error feedback for --remove command
Karel Zak [Thu, 16 Oct 2025 09:22:47 +0000 (11:22 +0200)] 
losetup: add error feedback for --remove command

The remove_loop() function was silently failing without providing
any feedback to the user. This also fixes incorrect indentation
(spaces instead of tabs).

Signed-off-by: Karel Zak <kzak@redhat.com>
Reported-by: Benno Schulenberg <bensberg@telfort.nl>
2 weeks agotests: optstr: test redundant commas
Cole Robinson [Fri, 17 Oct 2025 15:11:38 +0000 (11:11 -0400)] 
tests: optstr: test redundant commas

optstr, used for parsing mount option lists, eats leading,
trailing, and duplicated commas, but I can't find any test coverage
for that behavior.

Amend the existing optstr test to hit all the cases I can think of

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2 weeks agotreewide: use is_dotdir_dirent() helper
Karel Zak [Wed, 15 Oct 2025 13:46:06 +0000 (15:46 +0200)] 
treewide: use is_dotdir_dirent() helper

This simplifies the code by using the is_dotdir_dirent() helper
function instead of manual strcmp() checks for "." and ".." directory
entries across multiple utilities.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agotests: (configs) add sorting and masking test
Karel Zak [Wed, 15 Oct 2025 13:30:06 +0000 (15:30 +0200)] 
tests: (configs) add sorting and masking test

Add a new test that verifies:
- Main config file appears first
- Drop-in files are sorted alphabetically
- Files from /etc mask same-named files from /usr
- Priority ordering is correct (etc > usr)

The test creates mmm.conf in both /etc and /usr to verify
that the /etc version takes precedence and /usr version is
masked (not included in output).

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: simplify merge error checking
Karel Zak [Wed, 15 Oct 2025 13:18:05 +0000 (15:18 +0200)] 
lib/configs: simplify merge error checking

Combine the three config_merge_list() calls into a single
conditional statement to reduce repetitive error checking.
The calls are short-circuited on first failure.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: eliminate counter variable
Karel Zak [Wed, 15 Oct 2025 13:15:02 +0000 (15:15 +0200)] 
lib/configs: eliminate counter variable

Remove the counter variable and return list_count_entries()
directly. This simplifies the code by calculating the count
only when needed (on success path) rather than tracking it
throughout the function.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: add head parameter to configs_refer_filename()
Karel Zak [Wed, 15 Oct 2025 13:11:25 +0000 (15:11 +0200)] 
lib/configs: add head parameter to configs_refer_filename()

Allow configs_refer_filename() to add entries at either the head
or tail of the list by adding a 'head' parameter. This simplifies
the code for adding the main config file, eliminating the need to
add to the tail and then move to the head.

When head=1, use list_add() to prepend to the list.
When head=0, use list_add_tail() to append to the list.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: simplify variable names
Karel Zak [Wed, 15 Oct 2025 13:04:24 +0000 (15:04 +0200)] 
lib/configs: simplify variable names

Shorten variable and parameter names for better readability:

Parameters:
- etc_subdir -> etcdir
- run_subdir -> rundir
- usr_subdir -> usrdir
- config_name -> confname
- config_suffix -> suffix

Local variables:
- etc_file_list -> etc_list
- run_file_list -> run_list
- usr_file_list -> usr_list

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: merge new_list_entry() and configs_add_filename()
Karel Zak [Wed, 15 Oct 2025 12:59:44 +0000 (14:59 +0200)] 
lib/configs: merge new_list_entry() and configs_add_filename()

Introduce configs_refer_filename() which merges the functionality
of new_list_entry() and configs_add_filename() while avoiding
unnecessary string duplication.

The new function takes ownership of the filename pointer directly
instead of using strdup(), which eliminates one allocation per
config file entry. Callers no longer need to free the filename
after adding it to the list, as ownership is transferred to the
list element.

This improves both performance and code clarity by making the
ownership semantics explicit.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: refactor directory list merging
Karel Zak [Wed, 15 Oct 2025 12:52:29 +0000 (14:52 +0200)] 
lib/configs: refactor directory list merging

The original implementation used complex nested loops to merge
configuration file lists from different directories. This commit
simplifies the code by introducing a new config_merge_list()
function that handles the merging logic.

Changes:
- Add config_merge_list() to merge lists with duplicate detection
- Add config_cmp() comparison function using strcoll() (consistent
  with alphasort() behavior from scandirat())
- Add configs_add_filename() helper to reduce code duplication
- Simplify ul_configs_file_list() by replacing ~120 lines of
  merging logic with 3 calls to config_merge_list()
- Remove intermediate etc_run_file_list, merge directly to output
- Update read_dir() to return 0/-ENOMEM instead of entry count
- Use list_count_entries() to get final count

The new config_merge_list() moves entries directly from source
lists to the destination list without extra allocations, making
it more efficient than the previous approach.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoupdate .gitignore
Karel Zak [Wed, 15 Oct 2025 09:48:26 +0000 (11:48 +0200)] 
update .gitignore

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agotests: (configs) check for scandirat()
Karel Zak [Wed, 15 Oct 2025 09:34:26 +0000 (11:34 +0200)] 
tests: (configs) check for scandirat()

The function may be unsupported on musl libc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: simplify suffix verification
Karel Zak [Wed, 15 Oct 2025 08:32:26 +0000 (10:32 +0200)] 
lib/configs: simplify suffix verification

Use ul_endswith() to simplify the code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/fileutils: add is_dotdir_dirent()
Karel Zak [Wed, 15 Oct 2025 08:30:34 +0000 (10:30 +0200)] 
lib/fileutils: add is_dotdir_dirent()

This code pattern is repeated on many places, let's move it to
simple inline function.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agotests: (configs) add file listings to expected output
Karel Zak [Tue, 14 Oct 2025 11:20:42 +0000 (13:20 +0200)] 
tests: (configs) add file listings to expected output

Add sorted file listings to the configs test output to help debug
platform-specific test failures. Each subtest now outputs the actual
files created in the test directory before running the config helper,
making it easier to identify issues with filesystem ordering or file
creation problems.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/config: fix file counter
Karel Zak [Tue, 14 Oct 2025 10:59:05 +0000 (12:59 +0200)] 
lib/config: fix file counter

We need to count only files in the final list, not in the temporary
lists.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: introduce config_mk_path() helper
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agotests: add regression tests for ul_configs_file_list()
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/configs: add test program for ul_configs_file_list()
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib/config: Make /run path configurable
Karel Zak [Thu, 9 Oct 2025 18:35:26 +0000 (20:35 +0200)] 
lib/config: Make /run path configurable

Avoid hardcoded paths when writing regression tests.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoMerge branch 'fix/umount_no_verbose_for_non_root' of https://github.com/cgoesche...
Karel Zak [Tue, 14 Oct 2025 08:58:08 +0000 (10:58 +0200)] 
Merge branch 'fix/umount_no_verbose_for_non_root' of https://github.com/cgoesche/util-linux-fork

* 'fix/umount_no_verbose_for_non_root' of https://github.com/cgoesche/util-linux-fork:
  umount: consider helper return status for success message

2 weeks agoMerge branch 'test--lsfd-revise-rpi5' of https://github.com/masatake/util-linux
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

2 weeks agoMerge branch 'fix/test_libmount_explicit_rw' of https://github.com/cgoesche/util...
Karel Zak [Tue, 14 Oct 2025 08:52:31 +0000 (10:52 +0200)] 
Merge branch 'fix/test_libmount_explicit_rw' of https://github.com/cgoesche/util-linux-fork

* 'fix/test_libmount_explicit_rw' of https://github.com/cgoesche/util-linux-fork:
  tests: (libmount) improve explicit loop read-write mount check

2 weeks agoMerge branch 'fix/mount_bash_comp' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Tue, 14 Oct 2025 08:45:14 +0000 (10:45 +0200)] 
Merge branch 'fix/mount_bash_comp' of https://github.com/cgoesche/util-linux-fork

* 'fix/mount_bash_comp' of https://github.com/cgoesche/util-linux-fork:
  bash-completion: (mount) add missing options

2 weeks agoMerge branch 'feat/add_json_opt_lslogins' of https://github.com/cgoesche/util-linux...
Karel Zak [Tue, 14 Oct 2025 08:43:13 +0000 (10:43 +0200)] 
Merge branch 'feat/add_json_opt_lslogins' of https://github.com/cgoesche/util-linux-fork

* 'feat/add_json_opt_lslogins' of https://github.com/cgoesche/util-linux-fork:
  bash-completion: (lslogins) add --list-columns option
  lslogins: (man) add --list-columns description
  lslogins: add -H and --list-columns option; declutter --help output
  lslogins: (man) add --json information
  bash-completion: (lslogins) add --json completion
  tests: (lslogins) test --json output mode
  lslogins: add JSON output format mode

2 weeks agoMerge branch 'feat/add_usage_list_cols_option_macro' of https://github.com/cgoesche...
Karel Zak [Tue, 14 Oct 2025 08:38:07 +0000 (10:38 +0200)] 
Merge branch 'feat/add_usage_list_cols_option_macro' of https://github.com/cgoesche/util-linux-fork

* 'feat/add_usage_list_cols_option_macro' of https://github.com/cgoesche/util-linux-fork:
  treewide: consolidate --list-columns option in usage() to USAGE_LIST_COLUMNS_OPTION()
  include/c.h: add USAGE_LIST_COLUMNS_OPTION() macro

2 weeks agoMerge branch 'tests--kill-make-test-bits' of https://github.com/masatake/util-linux
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

2 weeks agoMerge branch 'fix/improve_dmesg_bash_comp' of https://github.com/cgoesche/util-linux...
Karel Zak [Tue, 14 Oct 2025 08:32:55 +0000 (10:32 +0200)] 
Merge branch 'fix/improve_dmesg_bash_comp' of https://github.com/cgoesche/util-linux-fork

* 'fix/improve_dmesg_bash_comp' of https://github.com/cgoesche/util-linux-fork:
  bash-completion: dmesg: remove redundant completion for --buffer-size
  bash-completion: dmesg: complete filenames for --kmsg-file
  bash-completion: dmesg: add missing long options

2 weeks agoMerge branch 'master' of https://github.com/stanislav-brabec/util-linux
Karel Zak [Tue, 14 Oct 2025 08:29:08 +0000 (10:29 +0200)] 
Merge branch 'master' of https://github.com/stanislav-brabec/util-linux

* 'master' of https://github.com/stanislav-brabec/util-linux:
  agetty: Process all data from ul_nl_process()

2 weeks agotests: (libmount) improve explicit loop read-write mount check
Christian Goeschel Ndjomouo [Mon, 13 Oct 2025 18:53:59 +0000 (14:53 -0400)] 
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>
2 weeks agobash-completion: (mount) add missing options
Christian Goeschel Ndjomouo [Mon, 13 Oct 2025 17:42:17 +0000 (13:42 -0400)] 
bash-completion: (mount) add missing options

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agoumount: consider helper return status for success message
Christian Goeschel Ndjomouo [Sun, 12 Oct 2025 03:09:27 +0000 (23:09 -0400)] 
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>
3 weeks agoci: roll back the version of checkout for "build (compat, ubuntu:18.04)"
Masatake YAMATO [Sat, 11 Oct 2025 22:25:17 +0000 (07:25 +0900)] 
ci: roll back the version of checkout for "build (compat, ubuntu:18.04)"

With the change 28af8ed133ff15d50b5e2d644c6617d0a3e17033, we got the
following error at "Post repository checkout" stage on "build (compat, ubuntu:18.04)":

  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)

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 weeks agobash-completion: (lslogins) add --list-columns option
Christian Goeschel Ndjomouo [Sat, 11 Oct 2025 20:16:42 +0000 (16:16 -0400)] 
bash-completion: (lslogins) add --list-columns option

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
3 weeks agolslogins: (man) add --list-columns description
Christian Goeschel Ndjomouo [Sat, 11 Oct 2025 20:13:58 +0000 (16:13 -0400)] 
lslogins: (man) add --list-columns description

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
3 weeks agolslogins: add -H and --list-columns option; declutter --help output
Christian Goeschel Ndjomouo [Sat, 11 Oct 2025 19:46:57 +0000 (15:46 -0400)] 
lslogins: add -H and --list-columns option; declutter --help output

This moves the list of available columns from the --help output
to the '--list-columns' option and makes the usage information
more readable.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
3 weeks agolslogins: (man) add --json information
Christian Goeschel Ndjomouo [Sat, 11 Oct 2025 17:07:36 +0000 (13:07 -0400)] 
lslogins: (man) add --json information

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
3 weeks agobash-completion: (lslogins) add --json completion
Christian Goeschel Ndjomouo [Sat, 11 Oct 2025 16:58:25 +0000 (12:58 -0400)] 
bash-completion: (lslogins) add --json completion

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
3 weeks agotests: (lslogins) test --json output mode
Christian Goeschel Ndjomouo [Sat, 11 Oct 2025 16:40:40 +0000 (12:40 -0400)] 
tests: (lslogins) test --json output mode

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
3 weeks agolslogins: add JSON output format mode
Christian Goeschel Ndjomouo [Sat, 11 Oct 2025 15:56:30 +0000 (11:56 -0400)] 
lslogins: add JSON output format mode

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>
3 weeks agotreewide: consolidate --list-columns option in usage() to USAGE_LIST_COLUMNS_OPTION()
Christian Goeschel Ndjomouo [Sat, 11 Oct 2025 00:15:51 +0000 (20:15 -0400)] 
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>
3 weeks agoinclude/c.h: add USAGE_LIST_COLUMNS_OPTION() macro
Christian Goeschel Ndjomouo [Fri, 10 Oct 2025 23:17:42 +0000 (19:17 -0400)] 
include/c.h: add USAGE_LIST_COLUMNS_OPTION() macro

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>
3 weeks agots/kill/decode: compare decoded output in an architecture-independent way
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>
3 weeks agots/kill/decode: check the availability of "sed"
Masatake YAMATO [Fri, 10 Oct 2025 21:10:36 +0000 (06:10 +0900)] 
ts/kill/decode: check the availability of "sed"

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 weeks agobash-completion: dmesg: remove redundant completion for --buffer-size
Christian Goeschel Ndjomouo [Fri, 10 Oct 2025 20:48:39 +0000 (16:48 -0400)] 
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>
3 weeks agobash-completion: dmesg: complete filenames for --kmsg-file
Christian Goeschel Ndjomouo [Fri, 10 Oct 2025 20:47:01 +0000 (16:47 -0400)] 
bash-completion: dmesg: complete filenames for --kmsg-file

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
3 weeks agobash-completion: dmesg: add missing long options
Christian Goeschel Ndjomouo [Fri, 10 Oct 2025 20:18:29 +0000 (16:18 -0400)] 
bash-completion: dmesg: add missing long options

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
3 weeks agots/kill/decode: consider arch dependent signum/name association
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.

Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Link: https://github.com/util-linux/util-linux/issues/3774
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 weeks agoagetty: Process all data from ul_nl_process()
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.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
3 weeks agoMerge branch 'master' of https://github.com/stanislav-brabec/util-linux
Karel Zak [Thu, 9 Oct 2025 08:20:09 +0000 (10:20 +0200)] 
Merge branch 'master' of https://github.com/stanislav-brabec/util-linux

* 'master' of https://github.com/stanislav-brabec/util-linux:
  netaddrq: Fix crash if there are no IP addresses

3 weeks agoMerge branch 'run_issue_d' of https://github.com/schubi2/util-linux
Karel Zak [Thu, 9 Oct 2025 08:19:44 +0000 (10:19 +0200)] 
Merge branch 'run_issue_d' of https://github.com/schubi2/util-linux

* 'run_issue_d' of https://github.com/schubi2/util-linux:
  parsing /run/issue.d/* too

3 weeks agoMerge branch 'PR/sprintf-replace' of https://github.com/karelzak/util-linux-work
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()

3 weeks agotests: (lsfd/mkfds-unix-dgram) skip if the unix diag netlink interface is not available
Masatake YAMATO [Thu, 9 Oct 2025 06:00:31 +0000 (15:00 +0900)] 
tests: (lsfd/mkfds-unix-dgram) skip if the unix diag netlink interface is not available

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 weeks agotests: (lsfd-functions.sh) make lsfd_check_sockdiag usable in subtests
Masatake YAMATO [Thu, 9 Oct 2025 05:51:31 +0000 (14:51 +0900)] 
tests: (lsfd-functions.sh) make lsfd_check_sockdiag usable in subtests

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 weeks agotests: (lsfd/mkfds-unix-stream-requiring-sockdiag) revise the test description
Masatake YAMATO [Thu, 9 Oct 2025 05:44:44 +0000 (14:44 +0900)] 
tests: (lsfd/mkfds-unix-stream-requiring-sockdiag) revise the test description

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
3 weeks agonetaddrq: Fix crash if there are no IP addresses
Stanislav Brabec [Tue, 7 Oct 2025 23:14:32 +0000 (01:14 +0200)] 
netaddrq: Fix crash if there are no IP addresses

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.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
3 weeks agoparsing /run/issue.d/* too
Stefan Schubert [Tue, 7 Oct 2025 15:24:37 +0000 (17:24 +0200)] 
parsing /run/issue.d/* too

3 weeks agohwclock: use snprintf() instead of sprintf()
Karel Zak [Tue, 7 Oct 2025 11:00:37 +0000 (13:00 +0200)] 
hwclock: use snprintf() instead of sprintf()

Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agolib/mbsalign: use snprintf() instead of sprintf()
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agocol: use snprintf() instead of sprintf()
Karel Zak [Tue, 7 Oct 2025 10:12:05 +0000 (12:12 +0200)] 
col: use snprintf() instead of sprintf()

Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agolibfdisk: use snprintf() instead of sprintf()
Karel Zak [Tue, 7 Oct 2025 10:10:08 +0000 (12:10 +0200)] 
libfdisk: use snprintf() instead of sprintf()

Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agolsfd: use snprintf() instead of sprintf()
Karel Zak [Tue, 7 Oct 2025 10:02:44 +0000 (12:02 +0200)] 
lsfd: use snprintf() instead of sprintf()

Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agopipesz: use snprintf() instead of sprintf()
Karel Zak [Tue, 7 Oct 2025 09:58:55 +0000 (11:58 +0200)] 
pipesz: use snprintf() instead of sprintf()

Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agodmesg: use snprintf() instead of sprintf()
Karel Zak [Tue, 7 Oct 2025 09:57:06 +0000 (11:57 +0200)] 
dmesg: use snprintf() instead of sprintf()

Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agolsipc: use snprintf() instead of sprintf()
Karel Zak [Tue, 7 Oct 2025 09:56:44 +0000 (11:56 +0200)] 
lsipc: use snprintf() instead of sprintf()

Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agokill.1.adoc: update the description for -l/-L option
Masatake YAMATO [Mon, 6 Oct 2025 17:17:02 +0000 (02:17 +0900)] 
kill.1.adoc: update the description for -l/-L option

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
4 weeks agolibblkid: use snprintf() instead of sprintf()
Karel Zak [Mon, 6 Oct 2025 13:04:24 +0000 (15:04 +0200)] 
libblkid: use snprintf() instead of sprintf()

Replace sprintf() calls with snprintf() to ensure proper bounds
checking when formatting strings.

In encode.c, the check now validates snprintf() return value instead
of pre-checking buffer size, providing more robust error handling.

In probe.c, snprintf() is used with proper size calculation based on
remaining buffer space.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agoMerge branch 'fix/rename_annotation_opt_to_annotate' of https://github.com/cgoesche...
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

4 weeks agoMerge branch 'master' of https://github.com/stanislav-brabec/util-linux
Karel Zak [Mon, 6 Oct 2025 12:31:07 +0000 (14:31 +0200)] 
Merge branch 'master' of https://github.com/stanislav-brabec/util-linux

* 'master' of https://github.com/stanislav-brabec/util-linux:
  netlink process_addr(): Ignore UL_NL_SOFT_ERROR
  ul_nl_addr_dup(): Fix address comparison

4 weeks agoMerge branch 'kill--line-oriented-list' of https://github.com/masatake/util-linux
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

4 weeks agoMerge branch 'PR/tools-checkcompletion-rewrite' of https://github.com/karelzak/util...
Karel Zak [Mon, 6 Oct 2025 12:27:16 +0000 (14:27 +0200)] 
Merge branch 'PR/tools-checkcompletion-rewrite' of https://github.com/karelzak/util-linux-work

* 'PR/tools-checkcompletion-rewrite' of https://github.com/karelzak/util-linux-work:
  ci: add bash-completion consistency check to CODECHECK
  bash-completion: add lsfd
  bash-completion: add blkpr
  tools: rewrite checkcompletion.sh to be source-based

4 weeks agoman-common: rename annotation.adoc to annotate.adoc
Christian Goeschel Ndjomouo [Mon, 6 Oct 2025 00:35:18 +0000 (20:35 -0400)] 
man-common: rename annotation.adoc to annotate.adoc

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agoswapon: use ANNOTATE_OPTION as enum name for --annotate
Christian Goeschel Ndjomouo [Mon, 6 Oct 2025 00:31:23 +0000 (20:31 -0400)] 
swapon: use ANNOTATE_OPTION as enum name for --annotate

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agoswapon: rename the new --annotation option to --annotate
Benno Schulenberg [Mon, 6 Oct 2025 00:24:41 +0000 (20:24 -0400)] 
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.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
4 weeks agoswapon: (usage) make the help text fit within 80 columns again
Benno Schulenberg [Mon, 6 Oct 2025 00:20:01 +0000 (20:20 -0400)] 
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.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
4 weeks agonetlink process_addr(): Ignore UL_NL_SOFT_ERROR
Stanislav Brabec [Sun, 5 Oct 2025 00:53:17 +0000 (02:53 +0200)] 
netlink process_addr(): Ignore UL_NL_SOFT_ERROR

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.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
4 weeks agoul_nl_addr_dup(): Fix address comparison
Stanislav Brabec [Sun, 5 Oct 2025 00:29:00 +0000 (02:29 +0200)] 
ul_nl_addr_dup(): Fix address comparison

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.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
4 weeks agokill (-l/-L): print one signal per line when stdout is not a TTY
Masatake YAMATO [Fri, 3 Oct 2025 20:45:41 +0000 (05:45 +0900)] 
kill (-l/-L): print one signal per line when stdout is not a TTY

It helps using kill -l/-L in a script.

    $ ./kill -L
     1 HUP      2 INT      3 QUIT     4 ILL      5 TRAP
     6 ABRT     6 IOT      7 BUS      8 FPE      9 KILL
     ...
    $ ./kill -L | cat
    1 HUP
    2 INT
    3 QUIT
    ...

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
4 weeks agokill: (refactor) rename parameter to better reflect its purpose
Masatake YAMATO [Fri, 3 Oct 2025 20:21:35 +0000 (05:21 +0900)] 
kill: (refactor) rename parameter to better reflect its purpose

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
4 weeks agoci: add bash-completion consistency check to CODECHECK
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agobash-completion: add lsfd
Karel Zak [Thu, 2 Oct 2025 12:35:43 +0000 (14:35 +0200)] 
bash-completion: add lsfd

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agobash-completion: add blkpr
Karel Zak [Thu, 2 Oct 2025 12:17:42 +0000 (14:17 +0200)] 
bash-completion: add blkpr

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agotools: rewrite checkcompletion.sh to be source-based
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agolsns: don't abort if /proc/self/ns/user is absent; probe other ns entries
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.

Reported-by: Axel Karjalainen <axel@axka.fi>
Link: https://github.com/util-linux/util-linux/pull/2902#issuecomment-3348630885
Fixes: 7d5036fdafe0 ("lsns: show namespaces only kept alive by open file descriptors")
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
4 weeks agobash-completion: add bits to dist tarball
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>
4 weeks agoMerge remote-tracking branch 'github/dependabot/github_actions/actions/checkout-5'
Karel Zak [Thu, 2 Oct 2025 10:13:41 +0000 (12:13 +0200)] 
Merge remote-tracking branch 'github/dependabot/github_actions/actions/checkout-5'

4 weeks agoMerge branch 'master' of https://github.com/stanislav-brabec/util-linux
Karel Zak [Thu, 2 Oct 2025 09:57:12 +0000 (11:57 +0200)] 
Merge branch 'master' of https://github.com/stanislav-brabec/util-linux

* 'master' of https://github.com/stanislav-brabec/util-linux:
  agetty: Implement netlink based IP processing
  New netlink library

4 weeks agolib/configs: initialize FD to -1
Karel Zak [Thu, 2 Oct 2025 09:55:55 +0000 (11:55 +0200)] 
lib/configs: initialize FD to -1

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agoMerge branch 'PR/agetty-issue-read' of https://github.com/karelzak/util-linux-work
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

4 weeks agoMerge branch 'PR/libsmartcols-uri-cleanup' of https://github.com/karelzak/util-linux...
Karel Zak [Thu, 2 Oct 2025 09:51:43 +0000 (11:51 +0200)] 
Merge branch 'PR/libsmartcols-uri-cleanup' of https://github.com/karelzak/util-linux-work

* 'PR/libsmartcols-uri-cleanup' of https://github.com/karelzak/util-linux-work:
  libsmartcols: small uri and annotation cleanup