]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
3 weeks agobits: add test for invalid token in cpulist_parse()
WanBingjiang [Wed, 29 Apr 2026 11:08:24 +0000 (19:08 +0800)] 
bits: add test for invalid token in cpulist_parse()

Verify that inputs like 1,2,3abc,4 with trailing garbage after a
valid number are rejected.

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
3 weeks agobits: improve error message for out-of-range cpulist_parse()
WanBingjiang [Wed, 29 Apr 2026 11:00:25 +0000 (19:00 +0800)] 
bits: improve error message for out-of-range cpulist_parse()

Distinguish between invalid list syntax and CPU numbers that exceed
the cpuset size, giving the user a clearer diagnostic.

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
3 weeks agocpuset: Validate full tokens in cpulist_parse()
WanBingjiang [Wed, 29 Apr 2026 03:04:38 +0000 (11:04 +0800)] 
cpuset: Validate full tokens in cpulist_parse()

Prevent silent acceptance of inputs like 1,2,3abc,4 by validating all
characters after each parsed number, not just at the end of the string.

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
3 weeks agobits: fix return value check for cpulist_parse()
WanBingjiang [Wed, 29 Apr 2026 02:19:57 +0000 (10:19 +0800)] 
bits: fix return value check for cpulist_parse()

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
3 weeks agoMerge branch 'findmnt_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Wed, 6 May 2026 11:42:52 +0000 (13:42 +0200)] 
Merge branch 'findmnt_tests' of https://github.com/cgoesche/util-linux-fork

* 'findmnt_tests' of https://github.com/cgoesche/util-linux-fork:
  build: (testcoverage) enable single tool testcoverage check
  tests: (findmnt) add more tests

3 weeks agoMerge branch 'flock' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Wed, 6 May 2026 10:23:06 +0000 (12:23 +0200)] 
Merge branch 'flock' of https://github.com/cgoesche/util-linux-fork

* 'flock' of https://github.com/cgoesche/util-linux-fork:
  tests: (flock) adjust commands to better track test coverage

# Conflicts:
# tests/ts/flock/flock

3 weeks agoMerge branch 'more_fallocate_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Wed, 6 May 2026 10:02:10 +0000 (12:02 +0200)] 
Merge branch 'more_fallocate_tests' of https://github.com/cgoesche/util-linux-fork

* 'more_fallocate_tests' of https://github.com/cgoesche/util-linux-fork:
  fallocate: (man) mention supported file systems for --insert-range
  tests: (fallocate) add --zero-range and --keep-size test
  tests: (fallocate) add --punch-hole test
  tests: (fallocate) --insert-range test

3 weeks agoMerge branch 'enosys_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Wed, 6 May 2026 09:47:39 +0000 (11:47 +0200)] 
Merge branch 'enosys_tests' of https://github.com/cgoesche/util-linux-fork

* 'enosys_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: (enosys) add tests for the --dump option
  tests: (enosys) add a simple test for --list

3 weeks agoMerge branch 'chrt_reset_on_fork_test' of https://github.com/cgoesche/util-linux...
Karel Zak [Wed, 6 May 2026 09:41:58 +0000 (11:41 +0200)] 
Merge branch 'chrt_reset_on_fork_test' of https://github.com/cgoesche/util-linux-fork

* 'chrt_reset_on_fork_test' of https://github.com/cgoesche/util-linux-fork:
  tests: (chrt) add --reset-on-fork test
  tests: (helpers) simple tool to create a child process

# Conflicts:
# meson.build
# tests/helpers/Makemodule.am

3 weeks agoMerge branch 'chrt_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Wed, 6 May 2026 09:35:45 +0000 (11:35 +0200)] 
Merge branch 'chrt_tests' of https://github.com/cgoesche/util-linux-fork

* 'chrt_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: (chrt) add test for the --all-tasks option
  tests: (helpers) add a thread creation helper

3 weeks agoMerge branch 'lsfd--ignore-too-large-syscall-args' of https://github.com/masatake...
Karel Zak [Wed, 6 May 2026 09:34:59 +0000 (11:34 +0200)] 
Merge branch 'lsfd--ignore-too-large-syscall-args' of https://github.com/masatake/util-linux

* 'lsfd--ignore-too-large-syscall-args' of https://github.com/masatake/util-linux:
  lsfd: (cosmetic) adjust indent
  lsfd: ignore too large integer read from /proc/PID/syscall
  lsfd: handle unexpected values read from /proc/PID/syscall

4 weeks agobuild: (testcoverage) enable single tool testcoverage check
Christian Goeschel Ndjomouo [Sun, 3 May 2026 21:21:05 +0000 (17:21 -0400)] 
build: (testcoverage) enable single tool testcoverage check

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (findmnt) add more tests
Christian Goeschel Ndjomouo [Sun, 3 May 2026 20:15:44 +0000 (16:15 -0400)] 
tests: (findmnt) add more tests

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (enosys) add tests for the --dump option
Christian Goeschel Ndjomouo [Thu, 23 Apr 2026 19:51:02 +0000 (15:51 -0400)] 
tests: (enosys) add tests for the --dump option

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agofallocate: (man) mention supported file systems for --insert-range
Christian Goeschel Ndjomouo [Tue, 5 May 2026 13:55:22 +0000 (09:55 -0400)] 
fallocate: (man) mention supported file systems for --insert-range

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (fallocate) add --zero-range and --keep-size test
Christian Goeschel Ndjomouo [Sat, 2 May 2026 21:57:48 +0000 (17:57 -0400)] 
tests: (fallocate) add --zero-range and --keep-size test

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (fallocate) add --punch-hole test
Christian Goeschel Ndjomouo [Sat, 2 May 2026 18:09:06 +0000 (14:09 -0400)] 
tests: (fallocate) add --punch-hole test

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (fallocate) --insert-range test
Christian Goeschel Ndjomouo [Fri, 1 May 2026 22:25:21 +0000 (18:25 -0400)] 
tests: (fallocate) --insert-range test

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agolib/fileutils: fix fopen_at_no_link() comment formatting
Karel Zak [Tue, 5 May 2026 11:47:32 +0000 (13:47 +0200)] 
lib/fileutils: fix fopen_at_no_link() comment formatting

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agoMerge branch 'script_toctou' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Tue, 5 May 2026 11:40:52 +0000 (13:40 +0200)] 
Merge branch 'script_toctou' of https://github.com/cgoesche/util-linux-fork

* 'script_toctou' of https://github.com/cgoesche/util-linux-fork:
  script: use fopen_at_no_link() for log file opening to prevent TOCTOU
  lib: (fileutils) new fopen_at_no_link routine

4 weeks agoMerge branch 'libfdisk-gpt-numeric-bits-0-2' of https://github.com/JamieMagee/util...
Karel Zak [Tue, 5 May 2026 11:25:47 +0000 (13:25 +0200)] 
Merge branch 'libfdisk-gpt-numeric-bits-0-2' of https://github.com/JamieMagee/util-linux

* 'libfdisk-gpt-numeric-bits-0-2' of https://github.com/JamieMagee/util-linux:
  libfdisk: gpt: drop pointless unsigned >= 0 check
  libfdisk: gpt: use ul_strtou16 for attribute bit parsing
  libfdisk: gpt: accept numeric attribute bits 0-2

4 weeks agoMerge branch 'clean_up_test_scripts' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Tue, 5 May 2026 11:14:34 +0000 (13:14 +0200)] 
Merge branch 'clean_up_test_scripts' of https://github.com/cgoesche/util-linux-fork

* 'clean_up_test_scripts' of https://github.com/cgoesche/util-linux-fork:
  tests: do not mix string and array
  tests: use bash parameter substitution instead of echo & sed
  tests: remove unneeded $ in arithmetic expressions
  tests: use find instead of ls for more robust processing
  tests: directly check exitcode for stability and code simplicity
  tests: (lib) avoid repetitive file openings with identical redirects
  tests: quote TS_{OUTPUT,ERRLOG} variables

4 weeks agoMerge branch 'macos-prep' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 5 May 2026 11:00:19 +0000 (13:00 +0200)] 
Merge branch 'macos-prep' of https://github.com/t-8ch/util-linux

* 'macos-prep' of https://github.com/t-8ch/util-linux:
  meson: gate hwclock on LINUX
  meson: gate choom on LINUX
  meson: gate losetup on LINUX
  meson: gate chmem on LINUX
  meson: gate lsmem on LINUX
  meson: gate utmpdump on LINUX
  meson: gate last on LINUX
  meson: gate partx on linux/blkpg.h
  meson: gate setterm on sys/klog.h
  meson: move sys/klog.h check into generic header checks
  meson: only build test_enosys when HAVE_FALLOCATE
  test_strerror: drop include asm-generic/errno-base.h

4 weeks agoscript: use fopen_at_no_link() for log file opening to prevent TOCTOU
Christian Goeschel Ndjomouo [Sat, 25 Apr 2026 19:45:17 +0000 (15:45 -0400)] 
script: use fopen_at_no_link() for log file opening to prevent TOCTOU

When no logfile name is provided script(1) uses a default name.
If the default file already exists as sym/hardlink, as checked by the
die_if_link() function, and the --force option is NOT provided,
the program will terminate. Otherwise, it opens the file after
forking a child process, creating a TOCTOU window that allows an
attacker to replace the default file with a link.

This patch moves the log file opening logic from log_start() to
its own function log_open() and uses a openat() + fdopen() wrap
enabled by the internal fopen_at_no_link() helper. It also adds a new
member to struct script_log, namely 'flags', set by log_associate()
if the latter function's new @flags parameter is set. This culminates
to an eventual log file opening with fopen_at_no_link() or fopen(),
depending on log->flags. This is primarily important for security
reasons as it allows us to prevent opening a logfile if it is a symlink
and due to the atomic nature of openat(2) the TOCTOU window is essentially
closed. As a result, die_if_link() becomes dead code and is therefore
removed.

Additionally, we open log files before we fork, so we can avoid
allocation of resources for the child process, if something goes
wrong with log file opening.

Closes: #4280
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agolibfdisk: gpt: drop pointless unsigned >= 0 check
Jamie Magee [Mon, 4 May 2026 16:00:55 +0000 (09:00 -0700)] 
libfdisk: gpt: drop pointless unsigned >= 0 check

GPT_ATTRBIT_REQ is 0 and val is uint16_t, so 'val >= GPT_ATTRBIT_REQ' is always true. CodeQL flagged it; keep only the upper bound.

4 weeks agotests: (chrt) add --reset-on-fork test
Christian Goeschel Ndjomouo [Thu, 23 Apr 2026 03:42:22 +0000 (23:42 -0400)] 
tests: (chrt) add --reset-on-fork test

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (helpers) simple tool to create a child process
Christian Goeschel Ndjomouo [Thu, 23 Apr 2026 01:01:43 +0000 (21:01 -0400)] 
tests: (helpers) simple tool to create a child process

This basic helper program can be used to create a child process
to test process attribute inheritances between parent and
child processes, e.g. real-time scheduling attributes with chrt(1)
or utilization clamp settings with uclampset(1), where options
like --reset-on-fork need to be tested.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agolibfdisk: gpt: use ul_strtou16 for attribute bit parsing
Jamie Magee [Mon, 4 May 2026 15:47:59 +0000 (08:47 -0700)] 
libfdisk: gpt: use ul_strtou16 for attribute bit parsing

Replace bare strtol() with ul_strtou16() which folds the errno/end-pointer/empty-input checks into one call and uses a uint16_t result type matching the bit-index domain. Also add udevadm settle between write/read sfdisk calls in the new attribute subtests.

4 weeks agomeson: gate hwclock on LINUX
Thomas Weißschuh [Wed, 29 Apr 2026 12:10:13 +0000 (14:10 +0200)] 
meson: gate hwclock on LINUX

This tool uses Linux-specific API, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate choom on LINUX
Thomas Weißschuh [Wed, 29 Apr 2026 12:40:57 +0000 (14:40 +0200)] 
meson: gate choom on LINUX

This tool uses Linux-specific API, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate losetup on LINUX
Thomas Weißschuh [Wed, 29 Apr 2026 12:34:57 +0000 (14:34 +0200)] 
meson: gate losetup on LINUX

This tool uses Linux-specific API, encode this in the build system.
Also the parts of libcommon providing loopback handling are gated
behind LINUX.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate chmem on LINUX
Thomas Weißschuh [Wed, 22 Apr 2026 21:21:02 +0000 (23:21 +0200)] 
meson: gate chmem on LINUX

This tool uses Linux-specific API, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate lsmem on LINUX
Thomas Weißschuh [Wed, 22 Apr 2026 21:17:45 +0000 (23:17 +0200)] 
meson: gate lsmem on LINUX

This tool uses Linux-specific API, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate utmpdump on LINUX
Thomas Weißschuh [Wed, 22 Apr 2026 21:10:53 +0000 (23:10 +0200)] 
meson: gate utmpdump on LINUX

This tool uses Linux-specific API, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate last on LINUX
Thomas Weißschuh [Wed, 22 Apr 2026 21:07:45 +0000 (23:07 +0200)] 
meson: gate last on LINUX

This tool uses Linux-specific API, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate partx on linux/blkpg.h
Thomas Weißschuh [Wed, 29 Apr 2026 12:11:22 +0000 (14:11 +0200)] 
meson: gate partx on linux/blkpg.h

The target needs this header, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate setterm on sys/klog.h
Thomas Weißschuh [Wed, 29 Apr 2026 12:12:51 +0000 (14:12 +0200)] 
meson: gate setterm on sys/klog.h

The target needs this header, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: move sys/klog.h check into generic header checks
Thomas Weißschuh [Wed, 29 Apr 2026 12:12:31 +0000 (14:12 +0200)] 
meson: move sys/klog.h check into generic header checks

The check will be reused for different tools.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: only build test_enosys when HAVE_FALLOCATE
Thomas Weißschuh [Wed, 29 Apr 2026 12:19:52 +0000 (14:19 +0200)] 
meson: only build test_enosys when HAVE_FALLOCATE

The test program calls fallocate(), so don't try to build it when that
is not available.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agotest_strerror: drop include asm-generic/errno-base.h
Thomas Weißschuh [Wed, 29 Apr 2026 12:20:45 +0000 (14:20 +0200)] 
test_strerror: drop include asm-generic/errno-base.h

This inclusios has multiple issues:
* It is Linux-only.
* The asm/ namespace is not an offical UAPI.
* Its definitions may be wrong if the architecture does not use it.
* It is unnecessary in the first place.

Drop it, and let errno.h do the job.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agotests: (enosys) add a simple test for --list
Christian Goeschel Ndjomouo [Thu, 23 Apr 2026 18:43:16 +0000 (14:43 -0400)] 
tests: (enosys) add a simple test for --list

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (chrt) add test for the --all-tasks option
Christian Goeschel Ndjomouo [Wed, 22 Apr 2026 02:46:19 +0000 (22:46 -0400)] 
tests: (chrt) add test for the --all-tasks option

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (helpers) add a thread creation helper
Christian Goeschel Ndjomouo [Wed, 22 Apr 2026 00:56:26 +0000 (20:56 -0400)] 
tests: (helpers) add a thread creation helper

This simple helper can be used to create an arbitrary amount
of threads to be used in test scripts for tools like chrt(1).
chrt(1) can perform tasks on multiple threads for a process
and to conveniently test this 'test_threads_create' can be
used to spawn threads for a specified amount of time to act on.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agochrt: Fix confusing error messages when priority argument is required
Rong Zhang [Sat, 25 Apr 2026 20:29:57 +0000 (04:29 +0800)] 
chrt: Fix confusing error messages when priority argument is required

While making the priority argument optional for non-prio policies, some
confusing error messages were accidentally exposed to users for cases
that do need a priority argument.

  $ chrt true #1
  chrt: invalid priority argument: 'true'
  $ chrt 1 #2
  chrt: failed to set pid 0's policy: Operation not permitted
  $ sudo chrt 1 #3
  chrt: no command specified
  $ chrt --other 1 #4
  chrt: unsupported priority value for the policy: 1: see --max for valid range

The error message #1 is caused by mixing `have_prio' and `need_prio'
together. Therefore, it always tries to parse the first positional
argument as a priority when `--pid' is not given. #2 shows that
set_sched() is meaninglessly called even when too few arguments are
specified.

At first glance, the error message #3 seems to be correct, but it turns
out to be very wrong -- the only positional argument in this case must
be regarded as a command, and commit 223a502b0208 ("chrt: (man,usage)
mark the priority value as optional in the synopses") also clearly
stated the same in the help message and the manual. In other words, #4
should have tried to execute `1' from PATH.

Fix #1 by decoupling `need_prio' from the priority parsing routine.

Fix #2 by parsing the first argument as a priority only when it's not
the only argument.

Fix #3 and #4 by consuming optind immediately when parsing priority
argument, instead of postponing it with inconsistent conditions (I have
an intuition that the previous code path was vibe-coded...)

Now #1 returns

  chrt: policy SCHED_RR requires a priority argument

... #2, #3 return

  chrt: no command or priority specified

... and #4 returns

  chrt: failed to execute 1: No such file or directory

... which are more sensible and helpful.

This doesn't break existing usage patterns:

  $ chrt --other true
  $ chrt --other 0 true
  $ chrt --other 1 true
  chrt: unsupported priority value for the policy: 1: see --max for valid range
  $ chrt --other echo meow
  meow

Fixes: 4c425142844d ("chrt: Allow optional priority for non‑prio policies without --pid")
Signed-off-by: Rong Zhang <i@rong.moe>
4 weeks agochrt: Only show current scheduling policy when pid is given
Rong Zhang [Sat, 25 Apr 2026 20:19:39 +0000 (04:19 +0800)] 
chrt: Only show current scheduling policy when pid is given

The `--verbose' option is completely broken when `--pid' is not
specified, as it tries to show the current scheduling policy for
nothing:

  $ chrt --verbose --other 0 true
  chrt: failed to get pid -1's policy: Invalid argument

Fix it by only showing the current scheduling policy if `--pid' and
`--verbose' are both given.

  $ chrt --verbose --other 0 true
  pid 1549197's new scheduling policy: SCHED_OTHER
  pid 1549197's new scheduling priority: 0
  pid 1549197's new runtime parameter: 2800000

Fixes: 13346d4d28cd ("chrt: Only display current settings when no policy is specified")
Signed-off-by: Rong Zhang <i@rong.moe>
4 weeks agotests: do not mix string and array
Christian Goeschel Ndjomouo [Fri, 10 Apr 2026 19:15:36 +0000 (15:15 -0400)] 
tests: do not mix string and array

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: use bash parameter substitution instead of echo & sed
Christian Goeschel Ndjomouo [Fri, 10 Apr 2026 19:02:34 +0000 (15:02 -0400)] 
tests: use bash parameter substitution instead of echo & sed

This helps simplify the code and avoids unnecessary resource
allocations due to the process and pipe creations caused by
invocations of sed and echo.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: remove unneeded $ in arithmetic expressions
Christian Goeschel Ndjomouo [Fri, 10 Apr 2026 18:38:34 +0000 (14:38 -0400)] 
tests: remove unneeded $ in arithmetic expressions

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: use find instead of ls for more robust processing
Christian Goeschel Ndjomouo [Fri, 10 Apr 2026 18:23:27 +0000 (14:23 -0400)] 
tests: use find instead of ls for more robust processing

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: directly check exitcode for stability and code simplicity
Christian Goeschel Ndjomouo [Fri, 10 Apr 2026 17:47:30 +0000 (13:47 -0400)] 
tests: directly check exitcode for stability and code simplicity

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: (lib) avoid repetitive file openings with identical redirects
Christian Goeschel Ndjomouo [Fri, 10 Apr 2026 14:40:43 +0000 (10:40 -0400)] 
tests: (lib) avoid repetitive file openings with identical redirects

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: quote TS_{OUTPUT,ERRLOG} variables
Christian Goeschel Ndjomouo [Fri, 10 Apr 2026 13:44:09 +0000 (09:44 -0400)] 
tests: quote TS_{OUTPUT,ERRLOG} variables

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agoMerge branch 'master' of https://github.com/stanislav-brabec/util-linux
Karel Zak [Mon, 4 May 2026 11:26:40 +0000 (13:26 +0200)] 
Merge branch 'master' of https://github.com/stanislav-brabec/util-linux

* 'master' of https://github.com/stanislav-brabec/util-linux:
  Link against libcommon_logindefs.la and libcommon_shells.la
  Fix build with libeconf

4 weeks agomeson: gate tunelp on linux/lp.h
Thomas Weißschuh [Wed, 22 Apr 2026 21:26:45 +0000 (23:26 +0200)] 
meson: gate tunelp on linux/lp.h

The target needs this header, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agoLink against libcommon_logindefs.la and libcommon_shells.la
Stanislav Brabec [Mon, 4 May 2026 01:50:59 +0000 (03:50 +0200)] 
Link against libcommon_logindefs.la and libcommon_shells.la

Instead of linking with logindefs.c and shells.c library files, link
against libcommon_logindefs.la and libcommon_shells.la and handle possibly
needed econf libs there.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
4 weeks agoFix build with libeconf
Stanislav Brabec [Thu, 30 Apr 2026 03:24:41 +0000 (05:24 +0200)] 
Fix build with libeconf

Building with libeconf fails. Fix the build:
- Add missing includes.
- Make open_etc_shells() public, as required by login.c.
- shells.c requires linking against libeconf. To prevent linking of all
  binaries with libeconf, split shells.c out of libcommon to libcommon_shells and
  use it only if it is really needed.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
4 weeks agomeson: gate rfkill on linux/rfkill.h
Thomas Weißschuh [Wed, 22 Apr 2026 21:24:04 +0000 (23:24 +0200)] 
meson: gate rfkill on linux/rfkill.h

The target needs this header, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate more on sys/signalfd.h
Thomas Weißschuh [Wed, 22 Apr 2026 21:15:04 +0000 (23:15 +0200)] 
meson: gate more on sys/signalfd.h

The target needs this header, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate vipw on shadow.h
Thomas Weißschuh [Wed, 22 Apr 2026 21:12:53 +0000 (23:12 +0200)] 
meson: gate vipw on shadow.h

The target needs this header, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate lslogins on shadow.h
Thomas Weißschuh [Wed, 22 Apr 2026 21:10:58 +0000 (23:10 +0200)] 
meson: gate lslogins on shadow.h

The target needs this header, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: gate liblastlog2 on lastlog.h
Thomas Weißschuh [Wed, 22 Apr 2026 20:51:53 +0000 (22:51 +0200)] 
meson: gate liblastlog2 on lastlog.h

The target needs this header, encode this in the build system.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: test for headers earlier
Thomas Weißschuh [Wed, 22 Apr 2026 20:51:43 +0000 (22:51 +0200)] 
meson: test for headers earlier

Some upcoming changes will require the header test results earlier, move
them up. Also remove all the conditional header tests, there is no
downside to always test for all of them.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agosulogin: guard oneline() behind __linux__
Thomas Weißschuh [Wed, 22 Apr 2026 21:01:28 +0000 (23:01 +0200)] 
sulogin: guard oneline() behind __linux__

This function is only used on Linux, so also put it behind the ifdef to
avoid an unused function otherwise.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agomeson: respect build-dmesg for test_dmesg
Thomas Weißschuh [Wed, 22 Apr 2026 21:29:00 +0000 (23:29 +0200)] 
meson: respect build-dmesg for test_dmesg

If dmesg can not be built, test_dmesg can't be either.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
4 weeks agotests: (flock) adjust commands to better track test coverage
Christian Goeschel Ndjomouo [Sun, 3 May 2026 01:31:20 +0000 (21:31 -0400)] 
tests: (flock) adjust commands to better track test coverage

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agolibfdisk: gpt: accept numeric attribute bits 0-2
Jamie Magee [Sat, 2 May 2026 05:00:43 +0000 (22:00 -0700)] 
libfdisk: gpt: accept numeric attribute bits 0-2

gpt_entry_attrs_from_string() applied the GUID-specific range check
(48-63) to every numeric input. As a result, bare numeric bits 0, 1
and 2 were silently rejected. Those bits are RequiredPartition,
NoBlockIOProtocol and LegacyBIOSBootable, so the only way to set
them was by name.

That trips up any tool that emits attributes as a numeric list.
systemd-repart, for instance, formats Flags= as a comma-separated
list of decimal bit numbers, so Flags=0x4 (LegacyBIOSBootable) was
silently lost.

Split the numeric validation by source token:

  - bare <bit> accepts {0,1,2} or [48,63];
  - GUID:<bit> stays at [48,63]; the GUID: prefix belongs to the
    GUID-specific range only;
  - bits 3-47 are still rejected (UEFI-reserved).

Two drive-by fixes in the same block:

  - 'end == str' compared strtol's end pointer to the function's
    input rather than the current parse position; replace with
    'end == p'.
  - The diagnostic for an unsupported numeric bit printed p after
    the GUID: strip, so "GUID:5" came out as "5". Save the token
    start and pass that to fdisk_warnx().

Tests cover the new accepted forms (bare 0-2, mixed "<n>,GUID:<m>",
hex) and the still-rejected reserved range.

Fixes: https://github.com/util-linux/util-linux/issues/3353
Reference: https://github.com/systemd/systemd/issues/35591
Signed-off-by: Jamie Magee <jamie.magee@gmail.com>
4 weeks agolib: (fileutils) new fopen_at_no_link routine
Christian Goeschel Ndjomouo [Mon, 27 Apr 2026 00:50:53 +0000 (20:50 -0400)] 
lib: (fileutils) new fopen_at_no_link routine

This function wraps around openat(2), fstat(2), ftruncate(2) and
fdopen(3) to create a file stream that is not a symbolic or hard
link in a race-free manner. It achieves this by implictly setting
the O_NOFOLLOW bit to openat(2) opening flags and later checks if
any hardlinks are registered for the file pointing to the acquired
file descriptor.

If all checks pass a pointer to the file stream handler is returned.

The relevance for this function becomes apparent in script(2) where
the default logfile is not allowed to be a link unless the --force
option is passed and where the current method is vulnerable to a
TOCTOU attack. It also helps with the code clarity as it moves the
complexity of opening link free file streams to an internal helper
and prevents scope creep as well as keeping the code base focused
on its most relevant concern, which is recording the input/output.

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agoMerge branch 'fallocate_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Thu, 30 Apr 2026 08:24:50 +0000 (10:24 +0200)] 
Merge branch 'fallocate_tests' of https://github.com/cgoesche/util-linux-fork

* 'fallocate_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: (fallocate) test the --collapse-range option

4 weeks agoMerge branch 'column_heap_corruption' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Thu, 30 Apr 2026 07:48:55 +0000 (09:48 +0200)] 
Merge branch 'column_heap_corruption' of https://github.com/cgoesche/util-linux-fork

* 'column_heap_corruption' of https://github.com/cgoesche/util-linux-fork:
  column: fix missing out-of-bounds check in table reordering

4 weeks agoMerge branch 'chsh_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Thu, 30 Apr 2026 07:47:47 +0000 (09:47 +0200)] 
Merge branch 'chsh_tests' of https://github.com/cgoesche/util-linux-fork

* 'chsh_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: regression tests for chsh(1)

4 weeks agotests: (fallocate) test the --collapse-range option
Christian Goeschel Ndjomouo [Fri, 24 Apr 2026 00:19:55 +0000 (20:19 -0400)] 
tests: (fallocate) test the --collapse-range option

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agocolumn: fix missing out-of-bounds check in table reordering
Christian Goeschel Ndjomouo [Sat, 25 Apr 2026 21:01:06 +0000 (17:01 -0400)] 
column: fix missing out-of-bounds check in table reordering

When the --table-order option is used we allocate memory on
the heap for the actual amount of columns we receive from
the input, and later store the wanted column struct objects,
specified in the --table-order list, in that memory space.

We do this by iterating over the order list and incrementing
the heap pointer with a counter variable. This leads to a
buffer overflow when the amount of input columns is smaller
than the amount of columns specified in the table order list.

To prevent this we iterate over the order list for as long as
the counter is smaller than the number of input columns.

Closes: #4281
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agotests: regression tests for chsh(1)
Christian Goeschel Ndjomouo [Mon, 20 Apr 2026 21:44:30 +0000 (17:44 -0400)] 
tests: regression tests for chsh(1)

Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
4 weeks agoMerge branch 'libsmartcols/filter-fixes' of https://github.com/t-8ch/util-linux
Karel Zak [Wed, 29 Apr 2026 10:13:19 +0000 (12:13 +0200)] 
Merge branch 'libsmartcols/filter-fixes' of https://github.com/t-8ch/util-linux

* 'libsmartcols/filter-fixes' of https://github.com/t-8ch/util-linux:
  libsmartcols: (tests) fix failure reporting in filter test
  libsmartcols: drop superfluous call yo yylex_init()
  libsmartcols: (tests) fix filter test name

4 weeks agoMerge branch 'PR/lsmem-cleanup' of https://github.com/karelzak/util-linux-work
Karel Zak [Wed, 29 Apr 2026 10:10:28 +0000 (12:10 +0200)] 
Merge branch 'PR/lsmem-cleanup' of https://github.com/karelzak/util-linux-work

* 'PR/lsmem-cleanup' of https://github.com/karelzak/util-linux-work:
  lsmem: sort longopts[] alphabetically
  lsmem: improve usage() output
  lsmem: use bool for struct lsmem members

4 weeks agoMerge branch 'PR/cfdisk-cleanup' of https://github.com/karelzak/util-linux-work
Karel Zak [Wed, 29 Apr 2026 10:09:53 +0000 (12:09 +0200)] 
Merge branch 'PR/cfdisk-cleanup' of https://github.com/karelzak/util-linux-work

* 'PR/cfdisk-cleanup' of https://github.com/karelzak/util-linux-work:
  cfdisk: remove unnecessary cursor repositioning on exit
  cfdisk: fix memory leak of original_layout table

4 weeks agoMerge branch 'PR/last-phantom-detection' of https://github.com/karelzak/util-linux...
Karel Zak [Wed, 29 Apr 2026 10:09:41 +0000 (12:09 +0200)] 
Merge branch 'PR/last-phantom-detection' of https://github.com/karelzak/util-linux-work

* 'PR/last-phantom-detection' of https://github.com/karelzak/util-linux-work:
  last: fix phantom detection for unset loginuid and X11 sessions

4 weeks agoMerge branch 'feat/4288' of https://github.com/echoechoin/util-linux
Karel Zak [Wed, 29 Apr 2026 10:06:27 +0000 (12:06 +0200)] 
Merge branch 'feat/4288' of https://github.com/echoechoin/util-linux

* 'feat/4288' of https://github.com/echoechoin/util-linux:
  bash-completion: add --expand option for bits
  bits: add tests for --expand option
  bits: add --expand option to output individual bit IDs

4 weeks agoMerge branch 'fix_issue/4272' of https://github.com/echoechoin/util-linux
Karel Zak [Wed, 29 Apr 2026 09:28:45 +0000 (11:28 +0200)] 
Merge branch 'fix_issue/4272' of https://github.com/echoechoin/util-linux

* 'fix_issue/4272' of https://github.com/echoechoin/util-linux:
  test_sigreceive: use ul_getuserpw_str() for user name/UID parsing
  renice: use proper types and strutils for ID parsing

4 weeks agoMerge branch 'feat/3887/rename' of https://github.com/echoechoin/util-linux
Karel Zak [Wed, 29 Apr 2026 08:07:20 +0000 (10:07 +0200)] 
Merge branch 'feat/3887/rename' of https://github.com/echoechoin/util-linux

* 'feat/3887/rename' of https://github.com/echoechoin/util-linux:
  rename: fix buffer overflow by using PATH_MAX instead of unreliable st_size
  rename: add --copy option to copy instead of rename

4 weeks agotest_sigreceive: use ul_getuserpw_str() for user name/UID parsing
WanBingjiang [Wed, 29 Apr 2026 07:01:23 +0000 (15:01 +0800)] 
test_sigreceive: use ul_getuserpw_str() for user name/UID parsing

4 weeks agorenice: use proper types and strutils for ID parsing
WanBingjiang [Thu, 23 Apr 2026 09:49:07 +0000 (17:49 +0800)] 
renice: use proper types and strutils for ID parsing

Use ul_strtou32() instead of strtol() to parse PID/UID/GID and reject
negative values. Use strtos32_or_err() for priority. Change 'who' type
to uid_t and adjust getprio()/donice(). Use %u for unsigned IDs.

Addresses: https://github.com/util-linux/util-linux/issues/4272
Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
5 weeks agobash-completion: add --expand option for bits
WanBingjiang [Mon, 27 Apr 2026 09:12:11 +0000 (17:12 +0800)] 
bash-completion: add --expand option for bits

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
5 weeks agobits: add tests for --expand option
WanBingjiang [Mon, 27 Apr 2026 06:59:50 +0000 (14:59 +0800)] 
bits: add tests for --expand option

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
5 weeks agobits: add --expand option to output individual bit IDs
WanBingjiang [Mon, 27 Apr 2026 06:51:25 +0000 (14:51 +0800)] 
bits: add --expand option to output individual bit IDs

Add -e/--expand output mode that prints each set bit as a
comma-separated list without range compression. This is useful
for scripting when individual IDs are needed (e.g., CPU ID iteration).

Example: bits --expand 1,3-5,7 → 1,3,4,5,7
Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
5 weeks agolibsmartcols: (tests) fix failure reporting in filter test
Thomas Weißschuh [Tue, 28 Apr 2026 17:38:46 +0000 (19:38 +0200)] 
libsmartcols: (tests) fix failure reporting in filter test

The pipeline executes the calls to ts_init_subtest and
ts_finalize_subtest in a subshell. This breaks their functionality
and test failures are not reported properly.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 weeks agolibsmartcols: drop superfluous call yo yylex_init()
Thomas Weißschuh [Tue, 28 Apr 2026 22:08:09 +0000 (00:08 +0200)] 
libsmartcols: drop superfluous call yo yylex_init()

The lexer is already initialized with yylex_init_extra(),
making the call to yylex_init() superfluous.
Furthermore this is leaking memory.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 weeks agolibsmartcols: (tests) fix filter test name
Thomas Weißschuh [Tue, 28 Apr 2026 17:38:08 +0000 (19:38 +0200)] 
libsmartcols: (tests) fix filter test name

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
5 weeks agolsmem: sort longopts[] alphabetically
Karel Zak [Tue, 28 Apr 2026 13:36:13 +0000 (15:36 +0200)] 
lsmem: sort longopts[] alphabetically

Signed-off-by: Karel Zak <kzak@redhat.com>
5 weeks agolsmem: improve usage() output
Karel Zak [Tue, 28 Apr 2026 13:35:37 +0000 (15:35 +0200)] 
lsmem: improve usage() output

Sort options alphabetically and use [=<when>] consistently for
--summary (matching --annotate and other tools).

Signed-off-by: Karel Zak <kzak@redhat.com>
5 weeks agolsmem: use bool for struct lsmem members
Karel Zak [Tue, 28 Apr 2026 13:31:31 +0000 (15:31 +0200)] 
lsmem: use bool for struct lsmem members

Replace bit fields with bool and remove unused 'summary' member.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 weeks agoMerge branch 'lsmem_annotate_opt' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Tue, 28 Apr 2026 13:23:28 +0000 (15:23 +0200)] 
Merge branch 'lsmem_annotate_opt' of https://github.com/cgoesche/util-linux-fork

* 'lsmem_annotate_opt' of https://github.com/cgoesche/util-linux-fork:
  lsmem: add column header annotations

5 weeks agocfdisk: remove unnecessary cursor repositioning on exit
Karel Zak [Tue, 28 Apr 2026 13:04:09 +0000 (15:04 +0200)] 
cfdisk: remove unnecessary cursor repositioning on exit

Remove the mvcur() call that moved the cursor to the bottom of the
terminal before endwin(). This pattern was inherited from the original
cfdisk (util-linux 2.2, 1996) and is unnecessary on modern terminals
where endwin() properly restores the terminal state.

The old behavior created extra blank lines between the previous shell
prompt and the new one after exiting cfdisk.

Addresses: https://github.com/util-linux/util-linux/discussions/4259
Signed-off-by: Karel Zak <kzak@redhat.com>
5 weeks agocfdisk: fix memory leak of original_layout table
Karel Zak [Tue, 28 Apr 2026 12:51:14 +0000 (14:51 +0200)] 
cfdisk: fix memory leak of original_layout table

The original_layout table, allocated via fdisk_get_partitions() to
track the on-disk partition layout, was never freed on exit. Add the
missing fdisk_unref_table() call.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 weeks agoMerge branch 'PR/autotools-pkg-config-libs' of https://github.com/karelzak/util-linux...
Karel Zak [Tue, 28 Apr 2026 12:18:36 +0000 (14:18 +0200)] 
Merge branch 'PR/autotools-pkg-config-libs' of https://github.com/karelzak/util-linux-work

* 'PR/autotools-pkg-config-libs' of https://github.com/karelzak/util-linux-work:
  autotools: fix AM_CONDITIONAL for HAVE_UDEV and HAVE_AUDIT
  autotools,meson: drop unnecessary libm from test_pty
  autotools: split MATH_LIBS and ISNAN_LIBS
  autotools: use PKG_CHECK_MODULES for zlib
  autotools: use PKG_CHECK_MODULES for libcap-ng
  autotools: use PKG_CHECK_MODULES for libaudit
  autotools: use PKG_CHECK_MODULES for libudev
  autotools: use $(MATH_LIBS) instead of -lm for hwclock
  autotools: use $(SQLITE3_LIBS) instead of -lsqlite3
  autotools: use $(SELINUX_LIBS) instead of -lselinux
  autotools: use $(ECONF_LIBS) instead of -leconf

5 weeks agoMerge branch 'cross-platform' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 28 Apr 2026 12:17:24 +0000 (14:17 +0200)] 
Merge branch 'cross-platform' of https://github.com/t-8ch/util-linux

* 'cross-platform' of https://github.com/t-8ch/util-linux:
  treewide: avoid unused argument and missing return warnings in fallbacks
  hardlink: (tests) Ignore xattrs
  setpgid: (tests) validate presence of /proc/self/stat
  tests: show kernel type

5 weeks agolast: fix phantom detection for unset loginuid and X11 sessions
Karel Zak [Tue, 28 Apr 2026 11:55:45 +0000 (13:55 +0200)] 
last: fix phantom detection for unset loginuid and X11 sessions

Don't mark a session as phantom when /proc/pid/loginuid exists but
has not been set by pam_loginuid.so (contains the kernel's unset
sentinel value 4294967295).

Skip the /dev/ tty stat() check when the utline starts with ':'
(traditional X11 session registration by xdm/sessreg).

Based on a patch by glangshaw.

Fixes: https://github.com/util-linux/util-linux/issues/4295
Signed-off-by: Karel Zak <kzak@redhat.com>
5 weeks agoMerge branch 'dmesg_tests' of https://github.com/cgoesche/util-linux-fork
Karel Zak [Tue, 28 Apr 2026 11:35:48 +0000 (13:35 +0200)] 
Merge branch 'dmesg_tests' of https://github.com/cgoesche/util-linux-fork

* 'dmesg_tests' of https://github.com/cgoesche/util-linux-fork:
  tests: (dmesg) use more long-opts to better track coverage

5 weeks agoMerge branch 'fix_issue/4271' of https://github.com/echoechoin/util-linux
Karel Zak [Tue, 28 Apr 2026 11:17:58 +0000 (13:17 +0200)] 
Merge branch 'fix_issue/4271' of https://github.com/echoechoin/util-linux

* 'fix_issue/4271' of https://github.com/echoechoin/util-linux:
  dmesg: fix out-of-bounds read when parsing malformed kmsg file

5 weeks agoautotools: fix AM_CONDITIONAL for HAVE_UDEV and HAVE_AUDIT
Karel Zak [Mon, 27 Apr 2026 10:19:30 +0000 (12:19 +0200)] 
autotools: fix AM_CONDITIONAL for HAVE_UDEV and HAVE_AUDIT

Ensure AM_CONDITIONAL is always defined when entering the
else-branch, even when the library is not found. Previously,
when with_udev=auto (default) and libudev was not available,
the conditional was never defined, causing a configure error.