]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
12 days agofsck.minix(man): Fix asciidoctor table
Tobias Stoeckmann [Wed, 8 Apr 2026 19:24:20 +0000 (21:24 +0200)] 
fsck.minix(man): Fix asciidoctor table

Building with asciidoctor 2.0.26 triggers an error message. Even though
the build succeeds, let's fix the table by adding whitespaces:

```
asciidoctor: ERROR: fsck.minix.8.adoc: line 31: dropping cells from incomplete row detected end of table
```

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agotests: add helper program and test for lib/pidutils.c
Christian Goeschel Ndjomouo [Tue, 7 Apr 2026 17:33:39 +0000 (13:33 -0400)] 
tests: add helper program and test for lib/pidutils.c

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
12 days agolib: (pidutils.c) allow zero and negative numbers for PIDs
Christian Goeschel Ndjomouo [Sun, 5 Apr 2026 02:15:04 +0000 (22:15 -0400)] 
lib: (pidutils.c) allow zero and negative numbers for PIDs

kill(1) and kill(2) man pages clearly state that 0 and negative
numbers can be used. Therefore let us adapt the internal helper
function ul_parse_pid_str() to permit this value range, as the
previous behavior regressed the kill(1) PID parsing behavior.

The uncommon value range can be controlled with two new flags
UL_PID_ZERO and UL_PID_NEGATIVE, ORed together they will allow
0 and negative values down to INT_MIN. Otherwise they can be
passed individually to only allow either. If 0 is passed only
1 upto INT_MAX values are allowed.

Closes: #4194
Closes: #4195
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
12 days agolibblkid: Ignore secondary LUKS2 header in blkid_do_safeprobe()
silentcreek [Sat, 4 Apr 2026 21:26:01 +0000 (21:26 +0000)] 
libblkid: Ignore secondary LUKS2 header in blkid_do_safeprobe()

The secondary LUKS2 header can match file data content on other
filesystems (e.g. an image file of a LUKS2 device stored on XFS whose
data blocks happen to land at device offsets where blkid looks for the
secondary LUKS2 header). This causes blkid to report a crypto_LUKS
superblock instead of the real filesystem.

Add a new flag BLKID_PROBE_FL_SAFEPROBE and skip scanning for the
secondary LUKS2 header in blkid_do_safeprobe(). The secondary LUKS2
header is only important for wipefs which uses a promiscuous probe.

Fixes: #4170
Fixes: 8bee1a2
Signed-off-by: Timo Sigurdsson <public_timo.s@silentcreek.de>
--
v2: Fix conflict with BLKID_FL_TINY_DEV flag
v3: Use pr->prob_flags instead of pr->flags
v4: Use original mask again as the use prob_flags resolves the conflict

12 days agoMerge branch 'bits_unsigned_integer_underflow' of https://github.com/cgoesche/util...
Karel Zak [Wed, 8 Apr 2026 10:58:56 +0000 (12:58 +0200)] 
Merge branch 'bits_unsigned_integer_underflow' of https://github.com/cgoesche/util-linux-fork

* 'bits_unsigned_integer_underflow' of https://github.com/cgoesche/util-linux-fork:
  tests: (bits) add --width tests for invalid values
  bits: prevent unsigned integer underflow and long-lived loop
  lib: (cpuset.c) dont calculate allocation size for 0 ncpus

12 days agoMerge branch 'agetty_chroot_chdir' of https://github.com/stoeckmann/util-linux
Karel Zak [Wed, 8 Apr 2026 10:41:35 +0000 (12:41 +0200)] 
Merge branch 'agetty_chroot_chdir' of https://github.com/stoeckmann/util-linux

* 'agetty_chroot_chdir' of https://github.com/stoeckmann/util-linux:
  agetty: Always call chdir after chroot

12 days agologin-utils/auth: Drop pam_setcred
Tobias Stoeckmann [Tue, 7 Apr 2026 17:53:09 +0000 (19:53 +0200)] 
login-utils/auth: Drop pam_setcred

The credentials are not needed right before pam_end. Drop the call,
which avoids the requirement of cleaning them up again.

While at it, supply the last retcode into pam_end, even though it's
always 0 anyway.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agosu: Clean up PAM resources on all error paths
Tobias Stoeckmann [Fri, 3 Apr 2026 07:40:24 +0000 (09:40 +0200)] 
su: Clean up PAM resources on all error paths

In most cases, PAM resources are already cleaned up in error paths. Some
exceptions exist though.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agologin: Clean up PAM resources on error path
Tobias Stoeckmann [Fri, 3 Apr 2026 07:38:43 +0000 (09:38 +0200)] 
login: Clean up PAM resources on error path

If PAM_REINITIALIZEE_CRED fails at this point, PAM_ESTABLISH_CRED
succeeded before. Clean up credentials with PAM_DELETE_CRED in this case
just to be sure.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agoman: Drop ENVIRONMENT intro text
Tobias Stoeckmann [Tue, 7 Apr 2026 16:19:23 +0000 (18:19 +0200)] 
man: Drop ENVIRONMENT intro text

A few ENVIRONMENT sections had intro texts. Drop them to unify the look
(and they did not contain useful information).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agoswaplabel(man): Fix indentation
Tobias Stoeckmann [Tue, 7 Apr 2026 16:15:04 +0000 (18:15 +0200)] 
swaplabel(man): Fix indentation

Other environment variable descriptions start at the beginning of the
line.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agoman: Sort ENVIRONMENT variables alphabetically
Tobias Stoeckmann [Tue, 7 Apr 2026 16:13:53 +0000 (18:13 +0200)] 
man: Sort ENVIRONMENT variables alphabetically

This matches other sections, e.g. OPTIONS.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agomkfs.cramfs(man): Add ENVIRONMENT section
Tobias Stoeckmann [Tue, 7 Apr 2026 16:04:08 +0000 (18:04 +0200)] 
mkfs.cramfs(man): Add ENVIRONMENT section

Document LOCK_BLOCK_DEVICE, which is supported by the tool.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agomkfs.bfs(man): Add ENVIRONMENT section
Tobias Stoeckmann [Tue, 7 Apr 2026 16:03:15 +0000 (18:03 +0200)] 
mkfs.bfs(man): Add ENVIRONMENT section

Document LOCK_BLOCK_DEVICE, which is supported by the tool.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agolslocks(man): Merge environment sections
Tobias Stoeckmann [Tue, 7 Apr 2026 16:01:45 +0000 (18:01 +0200)] 
lslocks(man): Merge environment sections

The manual page contains two ENVIRONMENT sections. Merge them into one.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
12 days agonsenter: Fix AT_HANDLE_FID on musl
Aleksi Hannula [Tue, 7 Apr 2026 11:52:16 +0000 (14:52 +0300)] 
nsenter: Fix AT_HANDLE_FID on musl

Signed-off-by: Aleksi Hannula <ahannula4+nixgit@gmail.com>
12 days agotests: skip SIGRTMAX check on s390x/QEMU
Christian Goeschel Ndjomouo [Sat, 4 Apr 2026 18:29:55 +0000 (14:29 -0400)] 
tests: skip SIGRTMAX check on s390x/QEMU

The CI fails the kill/name_to_number test when SIGRTMAX-0 (64)
is checked for s390x packaging. Although SIGRTMAX is a valid
signal number, kill(2) still returns EINVAL. This seems to be
related to the fact that QEMU reserves a signal number from
the high real-time signal range for internal usage, which
limits the maximum real-time signal number range.

We already check for the QEMU_USER environment variable, let us
also check if the QEMU emulator is mapped in memory for PID 1
to get more reliable information. In addition to that lets skip
RTMAX checks on s390x and QEMU emulated environments.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
13 days agoMerge branch 'PR/script-fix-arg-permutation' of https://github.com/karelzak/util...
Karel Zak [Tue, 7 Apr 2026 18:59:42 +0000 (20:59 +0200)] 
Merge branch 'PR/script-fix-arg-permutation' of https://github.com/karelzak/util-linux-work

* 'PR/script-fix-arg-permutation' of https://github.com/karelzak/util-linux-work:
  script: fix command and command_norm memory leaks
  script: fix backward compatibility for options after non-option args

13 days agoMerge branch 'PR/mkswap-test-pagesize' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 7 Apr 2026 18:58:48 +0000 (20:58 +0200)] 
Merge branch 'PR/mkswap-test-pagesize' of https://github.com/karelzak/util-linux-work

* 'PR/mkswap-test-pagesize' of https://github.com/karelzak/util-linux-work:
  tests: mkswap file-existing subtest add explicit page size

13 days agoagetty: Always use syslog
Tobias Stoeckmann [Tue, 7 Apr 2026 18:40:33 +0000 (20:40 +0200)] 
agetty: Always use syslog

No known systems exist which use agetty and are neither Linux, GNU,
nor FreeBSD. Even MinGW/MSYS use syslog.

Alternative systems which could use the fallback do not build agetty,
e.g. OpenIndiana or other such systems.

This gets rid of a bug in custom /dev/console code in which the
formatter could be modified by a link to agetty containing more
printf modifiers in its name.

It's not worth to fix it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agoagetty: Always call chdir after chroot
Tobias Stoeckmann [Tue, 7 Apr 2026 18:33:30 +0000 (20:33 +0200)] 
agetty: Always call chdir after chroot

Since chroot only changes the root directory but not current working
directory, change the current working directory as well. This rebases
all possible future relative paths into the chroot environment as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agoMerge branch 'PR/nsenter-pidfd-reuse' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 7 Apr 2026 16:06:00 +0000 (18:06 +0200)] 
Merge branch 'PR/nsenter-pidfd-reuse' of https://github.com/karelzak/util-linux-work

* 'PR/nsenter-pidfd-reuse' of https://github.com/karelzak/util-linux-work:
  nsenter: keep PID:inode validated pidfd open

13 days agoMerge branch 'PR/libmount-btrfs-raid-mounted' of https://github.com/karelzak/util...
Karel Zak [Tue, 7 Apr 2026 16:04:30 +0000 (18:04 +0200)] 
Merge branch 'PR/libmount-btrfs-raid-mounted' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-btrfs-raid-mounted' of https://github.com/karelzak/util-linux-work:
  tests: add btrfs RAID is-mounted test for libmount
  libmount: return btrfs rootfs from get_btrfs_fs_root()
  libmount: use match_source for mountinfo comparison

13 days agotests: mkswap file-existing subtest add explicit page size
Karel Zak [Tue, 7 Apr 2026 15:33:57 +0000 (17:33 +0200)] 
tests: mkswap file-existing subtest add explicit page size

The file-existing subtest fails on platforms with large native page
sizes (e.g. 64 KiB on aarch64) because the 40 KiB swap image is
too small. Add -p 4096 to match the other subtests.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agoscript: fix command and command_norm memory leaks
Karel Zak [Tue, 7 Apr 2026 13:25:17 +0000 (15:25 +0200)] 
script: fix command and command_norm memory leaks

Always own ctl.command by using xstrdup() for the -c optarg path
(the -- path already allocates via ul_strv_join), and free both
ctl.command and ctl.command_norm at exit.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agoscript: fix backward compatibility for options after non-option args
Karel Zak [Tue, 7 Apr 2026 13:20:04 +0000 (15:20 +0200)] 
script: fix backward compatibility for options after non-option args

The commit 7268e79b added "+" to the getopt_long() options string to
support the "--" separator for specifying commands. The "+" prefix
makes getopt stop processing at the first non-option argument, which
breaks the traditional "script file -c command" usage.

Fix this by pre-scanning argv for "--" before getopt, separating the
command arguments, and removing the "+" prefix to restore GNU getopt
argument permutation.

Addresses: 7268e79bc5365034a6e5b38ac5d9bf635e2dafc2
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agoMerge branch 'fix_grammar_in_su_manpage' of https://github.com/cgoesche/util-linux...
Karel Zak [Tue, 7 Apr 2026 14:49:59 +0000 (16:49 +0200)] 
Merge branch 'fix_grammar_in_su_manpage' of https://github.com/cgoesche/util-linux-fork

* 'fix_grammar_in_su_manpage' of https://github.com/cgoesche/util-linux-fork:
  su: fix grammar on man page

13 days agotests: (bits) add --width tests for invalid values
Christian Goeschel Ndjomouo [Mon, 6 Apr 2026 21:42:17 +0000 (17:42 -0400)] 
tests: (bits) add --width tests for invalid values

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
13 days agobits: prevent unsigned integer underflow and long-lived loop
Christian Goeschel Ndjomouo [Mon, 6 Apr 2026 21:15:20 +0000 (17:15 -0400)] 
bits: prevent unsigned integer underflow and long-lived loop

If 0 is allowed for --width it will culminate to a wraparound
due to an unsigned integer underflow when a size_t for-loop
control variable, namely 'n', is setup. n is the result of
cpuset_nbits(size) - 1, where size is set by cpuset_alloc()
which was called with 0 (width) for the @ncpus parameter that
will make it so that @size remains 0 as the calculated memory
allocation size yields zero as well. Therefore the sum for 'n'
will be -1 that wraps around to UINT_MAX and end creates a
long-lived for loop.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
13 days agoinclude/statfs_magic.h: revert portable struct statfs headers
Karel Zak [Tue, 7 Apr 2026 14:45:55 +0000 (16:45 +0200)] 
include/statfs_magic.h: revert portable struct statfs headers

Revert changes from commits 1af964d935 and 5f66e252c1c2.

Adding sys/mount.h, sys/vfs.h, and related includes to statfs_magic.h
caused build failures on older systems (e.g., Ubuntu) due to a
collision between sys/mount.h and linux/fs.h -- both define MS_RDONLY,
the first as an enum and the second as a macro.

The previous fix (guarding sys/mount.h with !defined(MS_RDONLY)) was
insufficient because on some systems linux/fs.h itself chains into
sys/mount.h, making the guard unreachable.

The correct approach is to keep statfs_magic.h minimal (only magic
numbers and sys/statfs.h) and let callers include the necessary
struct statfs headers. Currently, all callers of statfs_magic.h are
Linux-only (libmount requires sys/vfs.h, hardlink's USE_REFLINK
requires HAVE_LINUX_FIEMAP_H), so the Darwin-specific sys/mount.h
include is unreachable anyway.

Sorry for the mess, and sorry I had not used a PR for this.

Fixes: 1af964d935 ("include/statfs_magic.h: add portable struct statfs headers for Darwin")
Fixes: 5f66e252c1 ("include/statfs_magic.h: avoid sys/mount.h and linux/fs.h collision")
Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agolib: (cpuset.c) dont calculate allocation size for 0 ncpus
Christian Goeschel Ndjomouo [Mon, 6 Apr 2026 21:07:33 +0000 (17:07 -0400)] 
lib: (cpuset.c) dont calculate allocation size for 0 ncpus

If ncpus is not checked against the value 0, subsequent macros
CPU_ALLOC_SIZE and cpuset_nbits() will return garbage (0), which
can cause issues when memory has to be allocated or initialized
in callers where the size is assumed to be > 0. So let us return
NULL for 0 ncpus.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
13 days agoinclude/statfs_magic.h: avoid sys/mount.h and linux/fs.h collision
Karel Zak [Tue, 7 Apr 2026 13:34:13 +0000 (15:34 +0200)] 
include/statfs_magic.h: avoid sys/mount.h and linux/fs.h collision

Guard the sys/mount.h include with !defined(MS_RDONLY) to prevent
redefinition errors when linux/fs.h has already been included (e.g.,
in fstrim.c). This follows the same pattern used in libmount.h.in.

Fixes: 1af964d935 ("include/statfs_magic.h: add portable struct statfs headers for Darwin")
Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agolibcommon: move pidfd-utils.c to Linux-only sources
Karel Zak [Tue, 7 Apr 2026 12:46:06 +0000 (14:46 +0200)] 
libcommon: move pidfd-utils.c to Linux-only sources

The pidfd-utils.c uses Linux-specific APIs (pidfd_open, statx, etc.)
and all its consumers are Linux-only tools. Move it under the LINUX
guard in both meson and autotools build systems.

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agoinclude/statfs_magic.h: add portable struct statfs headers for Darwin
Morgan Jones [Mon, 6 Apr 2026 01:03:54 +0000 (18:03 -0700)] 
include/statfs_magic.h: add portable struct statfs headers for Darwin

Fixes the build on Darwin since struct statfs is in sys/mount.h
and sys/vfs.h doesn't even exist. Just conditionally include all the
headers.

[kzak@redhat.com: - removed lib/pidfd-utils.c change]

Signed-off-by: Karel Zak <kzak@redhat.com>
13 days agoMerge branch 'debug_readability' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 12:18:52 +0000 (14:18 +0200)] 
Merge branch 'debug_readability' of https://github.com/stoeckmann/util-linux

* 'debug_readability' of https://github.com/stoeckmann/util-linux:
  debug: Change debug masknames variable name
  debug: Link __UL_DBG_ macros together
  debug: Use macro definitions more often
  debug: Unify variable names
  debug: Unify debug mask output
  debug: Turn mask unsigned
  debug: Introduce UL_DEBUG_ALL

13 days agoMerge branch 'last_numbers' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 12:16:47 +0000 (14:16 +0200)] 
Merge branch 'last_numbers' of https://github.com/stoeckmann/util-linux

* 'last_numbers' of https://github.com/stoeckmann/util-linux:
  last: Use strtou32_or_err for -n arguments
  last: Improve max records parsing

13 days agoMerge branch 'lsclocks_missing_newline_in_usage' of https://github.com/cgoesche/util...
Karel Zak [Tue, 7 Apr 2026 12:15:31 +0000 (14:15 +0200)] 
Merge branch 'lsclocks_missing_newline_in_usage' of https://github.com/cgoesche/util-linux-fork

* 'lsclocks_missing_newline_in_usage' of https://github.com/cgoesche/util-linux-fork:
  lsclocks: add missing newline character in option description

13 days agoMerge branch 'fix-mkswap-file-perms' of https://github.com/jwueller/util-linux
Karel Zak [Tue, 7 Apr 2026 12:11:02 +0000 (14:11 +0200)] 
Merge branch 'fix-mkswap-file-perms' of https://github.com/jwueller/util-linux

* 'fix-mkswap-file-perms' of https://github.com/jwueller/util-linux:
  mkswap: Fix --file chmod(2) check when file exists

13 days agoMerge branch 'man_env' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 12:08:19 +0000 (14:08 +0200)] 
Merge branch 'man_env' of https://github.com/stoeckmann/util-linux

* 'man_env' of https://github.com/stoeckmann/util-linux:
  man: Document debug environment variables
  lscpu(man): Move options into correct section
  lsblk(man): Add COLORS section
  man: Add libsmartcols environment variables

13 days agoMerge branch 'chrt_elaborate_on_sched_ext_policy' of https://github.com/cgoesche...
Karel Zak [Tue, 7 Apr 2026 11:49:32 +0000 (13:49 +0200)] 
Merge branch 'chrt_elaborate_on_sched_ext_policy' of https://github.com/cgoesche/util-linux-fork

* 'chrt_elaborate_on_sched_ext_policy' of https://github.com/cgoesche/util-linux-fork:
  chrt: (man) explain which kernel config options are needed for SCHED_EXT

13 days agowrite, mesg: add S_ISCHR() check for terminal device paths
Karel Zak [Tue, 7 Apr 2026 11:49:02 +0000 (13:49 +0200)] 
write, mesg: add S_ISCHR() check for terminal device paths

Verify that the target path is a character device before proceeding.
This hardens both utilities against symlink-to-regular-file attacks
as a defense-in-depth measure.

Note that the TOCTOU race condition between stat() and freopen()/open()
is only theoretical -- on modern Linux systems /dev/pts/ is a
kernel-managed devpts filesystem where unprivileged users cannot create
or replace entries, and the setgid tty privilege only grants write
access to terminal devices, not to arbitrary files.

13 days agoMerge branch 'matching_formatters' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 10:41:15 +0000 (12:41 +0200)] 
Merge branch 'matching_formatters' of https://github.com/stoeckmann/util-linux

* 'matching_formatters' of https://github.com/stoeckmann/util-linux:
  Use correct formatters for given data types

13 days agoMerge branch 'code_typos' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 10:32:58 +0000 (12:32 +0200)] 
Merge branch 'code_typos' of https://github.com/stoeckmann/util-linux

* 'code_typos' of https://github.com/stoeckmann/util-linux:
  su: Remove obsolete code comment
  Fix grammar and typos in code comments

13 days agoMerge branch 'pager_sigpipe' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 10:30:23 +0000 (12:30 +0200)] 
Merge branch 'pager_sigpipe' of https://github.com/stoeckmann/util-linux

* 'pager_sigpipe' of https://github.com/stoeckmann/util-linux:
  lib/pager: Fix SIGPIPE handling

13 days agoMerge branch 'err_fullstop' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 10:27:34 +0000 (12:27 +0200)] 
Merge branch 'err_fullstop' of https://github.com/stoeckmann/util-linux

* 'err_fullstop' of https://github.com/stoeckmann/util-linux:
  Fix spacing in err messages
  Remove ending punctation from err messages

13 days agodebug: Change debug masknames variable name
Tobias Stoeckmann [Fri, 3 Apr 2026 10:31:44 +0000 (12:31 +0200)] 
debug: Change debug masknames variable name

The concatenation for the mask itself is lib_debug_mask, so do the same
for masknames, i.e. add debug into its name.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agodebug: Link __UL_DBG_ macros together
Tobias Stoeckmann [Fri, 3 Apr 2026 09:08:36 +0000 (11:08 +0200)] 
debug: Link __UL_DBG_ macros together

__UL_DBG_CALL can be used by __UL_DBG_OBJ which can be used by __UL_DBG,
which puts the flag check into a single line without duplications.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agodebug: Use macro definitions more often
Tobias Stoeckmann [Fri, 3 Apr 2026 08:52:06 +0000 (10:52 +0200)] 
debug: Use macro definitions more often

Improve readability by using macro definitions instead of explicitly
concatenating variable names in various places.

While at it, fixed formatting.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agodebug: Unify variable names
Tobias Stoeckmann [Fri, 3 Apr 2026 08:48:11 +0000 (10:48 +0200)] 
debug: Unify variable names

If variables mean the same thing, they should have also the same name.
Improves readability.

Add a single comment for the whole header file which specifies what
these identifiers mean.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agodebug: Unify debug mask output
Tobias Stoeckmann [Fri, 3 Apr 2026 08:35:38 +0000 (10:35 +0200)] 
debug: Unify debug mask output

Always format with 0x08x to also cover internal flags. These would be
printed anyway, but now it's always properly formatted.

Keep 0x06x in ul_debug_print_masks since these flags are never supposed
to have any private bits (above UL_DEBUG_ALL) set.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agoMerge branch 'getgrp_range' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 10:01:49 +0000 (12:01 +0200)] 
Merge branch 'getgrp_range' of https://github.com/stoeckmann/util-linux

* 'getgrp_range' of https://github.com/stoeckmann/util-linux:
  pwdutils: Set errno with out of range UIDs/GIDs

13 days agodebug: Turn mask unsigned
Tobias Stoeckmann [Fri, 3 Apr 2026 08:16:48 +0000 (10:16 +0200)] 
debug: Turn mask unsigned

The debug mask is a bitmask, so use an unsigned type. This also matches
the string formatters, since x/X expect an unsigned data type.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agoMerge branch 'unshare_indentation' of https://github.com/stoeckmann/util-linux
Karel Zak [Tue, 7 Apr 2026 08:53:51 +0000 (10:53 +0200)] 
Merge branch 'unshare_indentation' of https://github.com/stoeckmann/util-linux

* 'unshare_indentation' of https://github.com/stoeckmann/util-linux:
  unshare: Fix code indentation

13 days agoMerge branch 'fix_incomplete_filename_comp_umount' of https://github.com/cgoesche...
Karel Zak [Tue, 7 Apr 2026 08:47:30 +0000 (10:47 +0200)] 
Merge branch 'fix_incomplete_filename_comp_umount' of https://github.com/cgoesche/util-linux-fork

* 'fix_incomplete_filename_comp_umount' of https://github.com/cgoesche/util-linux-fork:
  bash-completion: complete relative path for filenames as well

13 days agoman: Document debug environment variables
Tobias Stoeckmann [Thu, 2 Apr 2026 15:31:03 +0000 (17:31 +0200)] 
man: Document debug environment variables

Document all debug environment variables affecting the tool. These
variables have an effect if the debug init function is called.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
13 days agomkswap: Fix --file chmod(2) check when file exists
Johannes Wüller [Sat, 4 Apr 2026 18:03:06 +0000 (20:03 +0200)] 
mkswap: Fix --file chmod(2) check when file exists

The documentation claims that `--size` will resize the `--file`, but
it ends up failing like this:

    # mkswap --file /swapfile --size 4G
    Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
    no label, UUID=1523588e-412a-4f25-8fac-aeaf638101aa
    # mkswap --file /swapfile --size 4G
    mkswap: cannot set permissions on swap file /swapfile: Success

There seems to have been a typo in the chmod(2) return value comparison.
It checked for `< 9` rather than `< 0`, which would usually indicate
failure. After the fix:

    # mkswap --file /swapfile --size 4G
    Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
    no label, UUID=6be7c450-761c-442d-8d9a-3e8cd93506b5
    # mkswap --file /swapfile --size 4G
    mkswap: /swapfile: warning: wiping old swap signature.
    Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
    no label, UUID=617a793e-84b1-471d-96c5-c099f8b157db

The operation no longer fails, as validated by the added test.

2 weeks agochrt: (man) explain which kernel config options are needed for SCHED_EXT
Christian Goeschel Ndjomouo [Sun, 5 Apr 2026 19:14:07 +0000 (15:14 -0400)] 
chrt: (man) explain which kernel config options are needed for SCHED_EXT

On systems running kernel version 6.12+ it is still possible
that the syscall to set SCHED_EXT fails with EINVAL, this can
happen when certain kernel configuration options have not been
set. The list of required options can be found here:
https://docs.kernel.org/scheduler/sched-ext.html#switching-to-and-from-sched-ext

Let's document this in the man page to give users a heads up.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agolast: Use strtou32_or_err for -n arguments
Tobias Stoeckmann [Sat, 4 Apr 2026 16:07:09 +0000 (18:07 +0200)] 
last: Use strtou32_or_err for -n arguments

The maximum amount of records is an unsigned int. Use the correct parser
function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agolast: Improve max records parsing
Tobias Stoeckmann [Sat, 4 Apr 2026 16:04:49 +0000 (18:04 +0200)] 
last: Improve max records parsing

The maximum amount of records to print can be specified in two different
ways: Either with -n/--limit or by specifying the number as argument,
i.e. -number.

The current parser does not check for possible overflow with -number
arguments and mixes -number arguments with -n arguments.

Properly split these two notations and use strtou32_or_err for overflow
checks.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agosu: fix grammar on man page
Christian Goeschel Ndjomouo [Sat, 4 Apr 2026 12:05:12 +0000 (08:05 -0400)] 
su: fix grammar on man page

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agosu: Remove obsolete code comment
Tobias Stoeckmann [Fri, 3 Apr 2026 07:48:55 +0000 (09:48 +0200)] 
su: Remove obsolete code comment

This su implementation always depends on PAM.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoFix grammar and typos in code comments
Tobias Stoeckmann [Fri, 3 Apr 2026 07:48:33 +0000 (09:48 +0200)] 
Fix grammar and typos in code comments

No functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoUse correct formatters for given data types
Tobias Stoeckmann [Fri, 3 Apr 2026 15:48:09 +0000 (17:48 +0200)] 
Use correct formatters for given data types

Use required formatters for given data types (signedness).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agolib/pager: Fix SIGPIPE handling
Tobias Stoeckmann [Sat, 4 Apr 2026 08:07:53 +0000 (10:07 +0200)] 
lib/pager: Fix SIGPIPE handling

Reset the child pid only after comparison with waitpid result.
Currently, this leads to returning -1 or 1, which ultimately leads
to exit code 1 in case of a SIGPIPE. This is the behavior as of 2.41,
which means that no regression between releases occurred. Yet, fix it
nonetheless.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agopwdutils: Set errno with out of range UIDs/GIDs
Tobias Stoeckmann [Fri, 3 Apr 2026 13:58:40 +0000 (15:58 +0200)] 
pwdutils: Set errno with out of range UIDs/GIDs

If a UID/GID is larger than its respective data type allows (but smaller
than uint64_t), then tools like newgrp erroneously assume that the user
or group simply does not exist.

Set errno to indicate that the supplied UID/GID is out of range instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agodebug: Introduce UL_DEBUG_ALL
Tobias Stoeckmann [Fri, 3 Apr 2026 08:12:18 +0000 (10:12 +0200)] 
debug: Introduce UL_DEBUG_ALL

Use a common macro definition for all *_DEBUG_ALL definitions. Sometimes
they slightly differ, yet they always mean the same thing.

Unifying these definitions also helps when parsing the mask, since "all"
would be set to 0xFFFF in debug code if not overwritten by debug mask
names.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agounshare: Fix code indentation
Tobias Stoeckmann [Fri, 3 Apr 2026 07:35:20 +0000 (09:35 +0200)] 
unshare: Fix code indentation

Adjust indentation to clarify where these if and else blocks belong.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoFix spacing in err messages
Tobias Stoeckmann [Fri, 3 Apr 2026 07:29:25 +0000 (09:29 +0200)] 
Fix spacing in err messages

If strings are concatenated in source code, keep extra spacing in mind.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoRemove ending punctation from err messages
Tobias Stoeckmann [Thu, 2 Apr 2026 21:09:37 +0000 (23:09 +0200)] 
Remove ending punctation from err messages

Since err() appends more data separated by a colon, do not add a
fullstop to error message.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agolsclocks: add missing newline character in option description
Christian Goeschel Ndjomouo [Fri, 3 Apr 2026 02:07:52 +0000 (22:07 -0400)] 
lsclocks: add missing newline character in option description

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agobash-completion: complete relative path for filenames as well
Christian Goeschel Ndjomouo [Thu, 2 Apr 2026 19:49:45 +0000 (15:49 -0400)] 
bash-completion: complete relative path for filenames as well

Commit 1a76e3e only helped with the completion of directory
names for relative paths. Let us complete filenames too for
completeness (no pun intended).

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agolscpu(man): Move options into correct section
Tobias Stoeckmann [Thu, 2 Apr 2026 15:29:17 +0000 (17:29 +0200)] 
lscpu(man): Move options into correct section

Link help-version.adoc into OPTIONS section instead of ENVIRONMENT.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agolsblk(man): Add COLORS section
Tobias Stoeckmann [Thu, 2 Apr 2026 15:27:23 +0000 (17:27 +0200)] 
lsblk(man): Add COLORS section

Since lsblk supports colors, link in COLORS description.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoman: Add libsmartcols environment variables
Tobias Stoeckmann [Thu, 2 Apr 2026 15:23:32 +0000 (17:23 +0200)] 
man: Add libsmartcols environment variables

Link env-smartcols.adoc into manual pages of tools linked with
libsmartcols. Most tools have this documentation already, but some lack
it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agopo: merge changes
Karel Zak [Wed, 1 Apr 2026 11:24:58 +0000 (13:24 +0200)] 
po: merge changes

2 weeks agopo: update uk.po (from translationproject.org)
Yuri Chornoivan [Wed, 1 Apr 2026 11:24:48 +0000 (13:24 +0200)] 
po: update uk.po (from translationproject.org)

2 weeks agopo: update ro.po (from translationproject.org)
Remus-Gabriel Chelu [Wed, 1 Apr 2026 11:24:48 +0000 (13:24 +0200)] 
po: update ro.po (from translationproject.org)

2 weeks agopo: update pt.po (from translationproject.org)
Pedro Albuquerque [Wed, 1 Apr 2026 11:24:48 +0000 (13:24 +0200)] 
po: update pt.po (from translationproject.org)

2 weeks agopo: update ko.po (from translationproject.org)
Seong-ho Cho [Wed, 1 Apr 2026 11:24:48 +0000 (13:24 +0200)] 
po: update ko.po (from translationproject.org)

2 weeks agopo: update fr.po (from translationproject.org)
Frédéric Marchal [Wed, 1 Apr 2026 11:24:48 +0000 (13:24 +0200)] 
po: update fr.po (from translationproject.org)

2 weeks agopo: update de.po (from translationproject.org)
Mario Blättermann [Wed, 1 Apr 2026 11:24:48 +0000 (13:24 +0200)] 
po: update de.po (from translationproject.org)

2 weeks agopo: update ar.po (from translationproject.org)
Zayed Al-Saidi [Wed, 1 Apr 2026 11:24:48 +0000 (13:24 +0200)] 
po: update ar.po (from translationproject.org)

2 weeks agopo-man: merge changes
Karel Zak [Wed, 1 Apr 2026 11:24:45 +0000 (13:24 +0200)] 
po-man: merge changes

2 weeks agopo-man: update ro.po (from translationproject.org)
Remus-Gabriel Chelu [Wed, 1 Apr 2026 11:24:32 +0000 (13:24 +0200)] 
po-man: update ro.po (from translationproject.org)

2 weeks agopo-man: update de.po (from translationproject.org)
Mario Blättermann [Wed, 1 Apr 2026 11:24:32 +0000 (13:24 +0200)] 
po-man: update de.po (from translationproject.org)

2 weeks agopo-man: update ar.po (from translationproject.org)
Zayed Al-Saidi [Wed, 1 Apr 2026 11:24:32 +0000 (13:24 +0200)] 
po-man: update ar.po (from translationproject.org)

2 weeks agodocs: update v2.42-ReleaseNotes
Karel Zak [Wed, 1 Apr 2026 10:47:40 +0000 (12:47 +0200)] 
docs: update v2.42-ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 039b4343caeaf2e06f37ec52cfd288479d7b200c)

2 weeks agotools: git-version-next filter tags by stable branch version
Karel Zak [Wed, 1 Apr 2026 10:13:17 +0000 (12:13 +0200)] 
tools: git-version-next filter tags by stable branch version

Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit ab7a9dc172b27191ed27eabcec7f099215d2e8a6)

2 weeks agolibfdisk: dos: validate EBR link within extended partition bounds
Karel Zak [Wed, 25 Mar 2026 10:54:42 +0000 (11:54 +0100)] 
libfdisk: dos: validate EBR link within extended partition bounds

The read_extended() function follows EBR chain links without checking
that the target offset falls within the master extended partition.
A malformed EBR link can point outside the extended area.

Add a bounds check before read_pte() to stop the chain walk when the
next EBR offset is outside [ext_start, ext_end]. This is self-defense
during parsing; it does not restrict what the user can create.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibblkid: dos: validate EBR data and links within extended partition
Karel Zak [Wed, 25 Mar 2026 10:54:28 +0000 (11:54 +0100)] 
libblkid: dos: validate EBR data and links within extended partition

The parse_dos_extended() function processes EBR (Extended Boot Record)
chains, but does not properly validate that partitions and links stay
within the master extended partition area [ex_start, ex_start+ex_size).

For EBR data partitions at index 0 and 1, there are no bounds checks
at all, unlike entries at index 2 and 3. This allows a crafted disk
image to register partitions at arbitrary sectors via uint32_t overflow
in the abs_start calculation (cur_start + start wraps to a small value).

Fix by:
 - using 64-bit arithmetic for the abs_start calculation to avoid
   uint32_t wraparound
 - applying the extended partition area bounds check to all EBR data
   entries, not just index >= 2
 - validating EBR link targets stay within the extended area and
   advance forward (preventing backward links that could loop)

Reported-by: Michele Piccinni <piccinni.michele@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agoloopdev: add LOOPDEV_FL_NOFOLLOW to prevent symlink attacks
Karel Zak [Thu, 19 Feb 2026 12:59:46 +0000 (13:59 +0100)] 
loopdev: add LOOPDEV_FL_NOFOLLOW to prevent symlink attacks

Add a new LOOPDEV_FL_NOFOLLOW flag for loop device context that
prevents symlink following in both path canonicalization and file open.

When set:
- loopcxt_set_backing_file() uses strdup() instead of
  ul_canonicalize_path() (which calls realpath() and follows symlinks)
- loopcxt_setup_device() adds O_NOFOLLOW to open() flags

The flag is set for non-root (restricted) mount operations in
libmount's loop device hook. This prevents a TOCTOU race condition
where an attacker could replace the backing file (specified in
/etc/fstab) with a symlink to an arbitrary root-owned file between
path resolution and open().

Vulnerable Code Flow:

  mount /mnt/point (non-root, SUID)
    mount.c: sanitize_paths() on user args (mountpoint only)
    mnt_context_mount()
      mnt_context_prepare_mount()
        mnt_context_apply_fstab()           <-- source path from fstab
        hooks run at MNT_STAGE_PREP_SOURCE
          hook_loopdev.c: setup_loopdev()
            backing_file = fstab source path ("/home/user/disk.img")
            loopcxt_set_backing_file()       <-- calls realpath() as ROOT
              ul_canonicalize_path()         <-- follows symlinks!
            loopcxt_setup_device()
              open(lc->filename, O_RDWR|O_CLOEXEC)  <-- no O_NOFOLLOW

Two vulnerabilities in the path:

1) loopcxt_set_backing_file() calls ul_canonicalize_path() which uses
   realpath() -- this follows symlinks as euid=0. If the attacker swaps
   the file to a symlink before this call, lc->filename becomes the
   resolved target path (e.g., /root/secret.img).

2) loopcxt_setup_device() opens lc->filename without O_NOFOLLOW. Even
   if canonicalization happened correctly, the file can be swapped to a
   symlink between canonicalize and open.

Addresses: https://github.com/util-linux/util-linux/security/advisories/GHSA-qq4x-vfq4-9h9g
Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib: (strutils.c) add missing string values for boolean <false>
Christian Goeschel Ndjomouo [Thu, 19 Mar 2026 16:03:27 +0000 (12:03 -0400)] 
lib: (strutils.c) add missing string values for boolean <false>

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agonsenter: use clearenv() only when it is available
Christian Goeschel Ndjomouo [Mon, 30 Mar 2026 13:10:52 +0000 (09:10 -0400)] 
nsenter: use clearenv() only when it is available

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agotests: (unshare) add --clear-env option tests
Christian Goeschel Ndjomouo [Sat, 28 Mar 2026 00:27:45 +0000 (20:27 -0400)] 
tests: (unshare) add --clear-env option tests

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agotests: (test_strerror.c) use ARRAY_SIZE for better readability/portability
Christian Goeschel Ndjomouo [Tue, 31 Mar 2026 15:59:13 +0000 (11:59 -0400)] 
tests: (test_strerror.c) use ARRAY_SIZE for better readability/portability

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agotests: (test_strerror.c) add EPERM errno support
Christian Goeschel Ndjomouo [Tue, 31 Mar 2026 15:55:03 +0000 (11:55 -0400)] 
tests: (test_strerror.c) add EPERM errno support

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
2 weeks agodebug: Remove ul_debugobj
Tobias Stoeckmann [Mon, 23 Mar 2026 12:17:31 +0000 (13:17 +0100)] 
debug: Remove ul_debugobj

Merge its functionality into ul_debug_prefix and use proper macros in
tools which still call it directly. This adjusts output, but makes it
actually more readable.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agodebug: Introduce __UL_DBG_OBJ
Tobias Stoeckmann [Fri, 20 Mar 2026 09:39:06 +0000 (10:39 +0100)] 
debug: Introduce __UL_DBG_OBJ

Merges debugobj.h into debug.c and increases flexibility in output:
Just like __UL_DBG any debug output function can be supplied.
Throughout the code, this is always ul_debug by today.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agolsblk: Remove extra whitespace in debug message
Tobias Stoeckmann [Fri, 20 Mar 2026 10:51:58 +0000 (11:51 +0100)] 
lsblk: Remove extra whitespace in debug message

The ul_debugobj function already takes care of initial whitespace.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 weeks agoMerge branch 'less-header-support' of https://github.com/kurok/util-linux
Karel Zak [Tue, 31 Mar 2026 10:10:28 +0000 (12:10 +0200)] 
Merge branch 'less-header-support' of https://github.com/kurok/util-linux

* 'less-header-support' of https://github.com/kurok/util-linux:
  libsmartcols: move scols_table_calculate to SMARTCOLS_2.43 symbol version
  libsmartcols: document scols_table_calculate() constraints
  libsmartcols: fix Since tag for scols_table_calculate()
  build: link test_pager against lib_common in meson too
  build: link test_pager against libcommon
  pager: use ul_strfconcat() instead of fixed-size buffer
  pager: support --header 0,M for column-only freezing
  pager: address review feedback for less --header support
  libsmartcols: add scols_table_calculate to docs sections
  libsmartcols: add scols_table_calculate(), pager: add less --header support