lslocks: don't abort gathering per-process information even if opening a /proc/[0-9]* fails
If a process ($pid) taking a lock is gone while running lslocks,
gathering per-process information for the process may fail in opening
/proc/$pid. Though lslocks should work with incomplete information,
the original code stopped gathering per-process information for the
other processes.
As a result of the original behavior, tests/ts/lslocks/lslocks really
failed in an environment where multiple test cases ran simultaneously.
Karel Zak [Tue, 16 Apr 2024 09:08:50 +0000 (11:08 +0200)]
Merge branch 'stable/meson-version-script-libblkid' of https://github.com/jwillikers/util-linux into stable/v2.40
* 'stable/meson-version-script-libblkid' of https://github.com/jwillikers/util-linux:
meson: Only use the --version-script linker flag where it is supported
Karel Zak [Tue, 16 Apr 2024 09:07:35 +0000 (11:07 +0200)]
Merge branch 'stable/optional-libmount' of https://github.com/jwillikers/util-linux into stable/v2.40
* 'stable/optional-libmount' of https://github.com/jwillikers/util-linux:
meson: Remove libblkid dependency on libmount
meson: Only build libmount when required
meson: Use libblkid as a dependency
meson: Use libmount as a dependency
lsns: tolerate lsns_ioctl(fd, NS_GET_{PARENT,USERNS}) failing with ENOSYS
With the original code, "lsns/filedesc" test case failed on
"build (qemu-user, s390x)" and "build (qemu-user, riscv64)".
On the platforms, lsns_ioctl(fd, NS_GET_{PARENT,USERNS}) failed
with ENOSYS. The error stoped the iteration for gathering
information from /proc/[0-9]+. As a result, lsns printed
nothing. We don't expect this behavior.
Thomas Weißschuh [Sat, 13 Apr 2024 07:42:39 +0000 (09:42 +0200)]
Revert "lib/pager: Apply pager-specific fixes only when needed"
Less is not always detectable, as it can be hidden behind symlinks or
wrapper as for example in a default Debian installation.
Also testing for the literal string "less" does not match full path
specifications like "/usr/bin/less".
Jordan Williams [Mon, 8 Apr 2024 16:37:01 +0000 (11:37 -0500)]
meson: Remove libblkid dependency on libmount
I added this incorrect dependency between libblkid and libmount.
The option to build libblkid should be allowed whether or not the
build-libmount feature is allowed.
Jordan Williams [Fri, 5 Apr 2024 14:49:17 +0000 (07:49 -0700)]
meson: Only build libmount when required
It is not currently possible to build any part of util-linux without
building libmount when using Meson.
The libuuid library is commonly used on macOS, where it is not possible
to build libmount.
To address this, this PR makes it possible to build without libmount and
libblkid.
Options have been added to allow toggling whether to build targets that
require libmount.
This makes it possible to fully disable building libmount.
The python object had to be defined outside of the meson.build file in
libmount/python since this may no longer be included.
The python object is used for tests.
Jordan Williams [Mon, 15 Apr 2024 13:02:05 +0000 (08:02 -0500)]
meson: Use libblkid as a dependency
Several utilities depend on libblkid internally.
Currently, link_with and global include directories are used to
associate targets with libblkid.
This PR uses Meson's dependencies argument for targets to define this
relationship instead.
This carries include directories along with the library to link.
An additional dependency is declared for the static libblkid library.
A couple of executables use this dependency explicitly.
Jordan Williams [Fri, 5 Apr 2024 15:33:22 +0000 (08:33 -0700)]
meson: Use libmount as a dependency
Several utilities depend on libmount internally.
Currently, link_with and global include directories are used to
associate targets with libmount.
This PR uses Meson's dependencies argument for targets to define this
relationship instead.
This carries include directories along with the library to link.
An additional dependency is declared for the static libmount library.
A couple of executables use this dependency explicitly.
Karel Zak [Mon, 15 Apr 2024 07:16:40 +0000 (09:16 +0200)]
Merge branch 'stable-meson-optional-rt' of https://github.com/jwillikers/util-linux into stable/v2.40
* 'stable-meson-optional-rt' of https://github.com/jwillikers/util-linux:
meson: Only pick up the rt library once
meson: Add build-lsfd option and make rt dependency optional
Jordan Williams [Tue, 9 Apr 2024 21:58:27 +0000 (16:58 -0500)]
meson: Add build-lsfd option and make rt dependency optional
A dependency on the rt library is unnecessarily required when checking
for the clock_gettime and timer_create functions.
This causes the build to fail if the rt library is not found.
This should not fail the build as rt is only required for the checks.
Additionally, the lsfd executable and some tests require rt.
There is currently no option to toggle building lsfd.
This PR makes it possible to build without the rt library.
Function checks no longer require rt for the build.
The function checks for the rt library only run when rt is available.
This PR adds an option to allow building without lsfd.
This makes it possible to build without the executable that requires rt.
To not require rt for the test, a additional check has been added.
The effected tests won't be built unless rt has been found.
3dd79293b5b655da9d913dedd8facb08959a7826 added -I option.
However, the code used bit flags (FL_DF and FL_DF_INODES) wrongly;
the code broke the output of -D option.
Karel Zak [Fri, 5 Apr 2024 08:55:21 +0000 (10:55 +0200)]
Merge branch 'lsfd--debug-endpoint' of https://github.com/masatake/util-linux into stable/v2.40
* 'lsfd--debug-endpoint' of https://github.com/masatake/util-linux:
tests: (test_mkfds::sockdiag) verify the recieved message to detect whether the socket is usable or not
lsfd: add LSFD_DEBUG env var for debugging
Commit 5d71d711d07a ("libblkid: topolicy/ioctl: use union for multiple data types")
incorrectly assumed that set_ulong and set_int refer to the type
returned by the kernel. Instead the different function pointer names
refer to the types of the function pointers.
However all ioctls, except for the later added BLKGETDISKSEQ, return
32bit integers.
This made libblkid also interpret the upper 32bits too, leading to
garbage values.
Introduce a new member 'kernel_size' to also handle the 64bit
BLKGETDISKSEQ.
Jordan Williams [Fri, 29 Mar 2024 19:00:01 +0000 (14:00 -0500)]
meson: Fix false positive detection of mempcpy on macOS
The has_function check incorrectly detects mempcpy on macOS.
This function is not available on macOS and should not be detected.
Likely, this has to do with Meson's detection of compiler built-ins.
Using a specific prefix and defining _GNU_SOURCE fixes the detection.
Karel Zak [Mon, 1 Apr 2024 10:14:50 +0000 (12:14 +0200)]
libblkid: Fix segfault when blkid.conf doesn't exist
* Move 'line' and 'uevent' to the beginning of the LIBECONF code.
* Remove unwanted space between function name and arguments.
* Check for 'line' pointer before dereferencing.
References: https://github.com/util-linux/util-linux/pull/2883 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 7e357241b413a01c37b0b4d064bc0a47e3259361)
Jordan Williams [Fri, 29 Mar 2024 21:56:43 +0000 (16:56 -0500)]
meson: Don't define HAVE_ENVIRON_DECL when environ is unavailable
HAVE_ENVIRON_DECL is being defined to 0 by cfg_data.set10().
The code only checks whether or not is defined.
This leads to it not being declared appropriately.
Use cfg_data.set() instead of cfg_data.set10() to define it when true.
Karel Zak [Tue, 26 Mar 2024 11:45:24 +0000 (12:45 +0100)]
lsipc: fix semaphore USED counter
The code incorrectly counts only with the first item in the linked
list (due to a typo). It seems rather fragile to use "semds" and
"semdsp" as variable names in the same code ...
# lsipc -gs
Old:
KEY ID PERMS OWNER NSEMS RESOURCE DESCRIPTION LIMIT USED USE%
SEMMNI Number of semaphore identifiers 32000 3 0.01%
SEMMNS Total number of semaphores 1024000000 369 0.00%
SEMMSL Max semaphores per semaphore set. 32000 - -
SEMOPM Max number of operations per semop(2) 500 - -
SEMVMX Semaphore max value 32767 - -
Fixed:
KEY ID PERMS OWNER NSEMS RESOURCE DESCRIPTION LIMIT USED USE%
SEMMNI Number of semaphore identifiers 32000 3 0.01%
SEMMNS Total number of semaphores 1024000000 156 0.00%
SEMMSL Max semaphores per semaphore set. 32000 - -
SEMOPM Max number of operations per semop(2) 500 - -
SEMVMX Semaphore max value 32767 - -
Addresses: https://issues.redhat.com/browse/RHEL-30269 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit fa45a6e516065f489b1cfb924ec3fc06960e0839)
Tim Hallmann [Sun, 24 Mar 2024 19:14:30 +0000 (20:14 +0100)]
rev: Check for wchar conversion errors
Commit c9cc84621ca98ef85499e83ca56f05f12055f193 introduced a regression
where only the actual EOF is handled, not other error conditions
returning WEOF. This leads to an infinite loop upon encountering
conversion errors. For example (using LC_CTYPE="en_US.UTF-8"):
Jordan Williams [Wed, 20 Mar 2024 16:41:49 +0000 (11:41 -0500)]
meson: Only build blkzone and blkpr if the required linux header exists
Checks for the required headers for blkzone and blkptr are done for
Autotools.
This logic wasn't carried over to Meson.
This PR just adds the same checks.
Reported-by: Heikki Ylipiessa <heikki.ylipiessa@suse.com> Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
(cherry picked from commit 7d16145c4696772bb5438a43a482f68fbf046370)
Karel Zak [Wed, 20 Mar 2024 13:33:35 +0000 (14:33 +0100)]
Merge branch 'test_mkfds-sockdiag' of https://github.com/masatake/util-linux into stable/v2.40
* 'test_mkfds-sockdiag' of https://github.com/masatake/util-linux:
tests: (lsfd) skip some cases if NETLINK_SOCK_DIAG for AF_UNIX is not available
tests: (test_mkfds::sockdiag) new factory
tests: (lsfd-functions.bash,cosmetic) unify the style to define functions
tests: (lsfd) fix typoes in an error name
Bug-Debian: 1066843 Signed-off-by: Chris Hofstaedtler <zeha@debian.org> Reported-by: Francesco Potortì <Potorti@isti.cnr.it>
(cherry picked from commit f494d3f8c33ffd5c98716717a7fe974ae0e9d08a)
The blamed commit converted script to use the generic pty code that
was added by commit 6954895cae34 ("lib/pty-session: add generic PTY
container code").
Commit ec10634e7ec4 says the new pty stuff is based on script.
However, there is difference in signal handling.
Before the commit, only the signals that the script was interested
in were blocked and handled by signalfd.
After the commit, all signals are blocked and only the interested
signals are handled.
This causes regression in the following scenario:
1. run `script` via /etc/profile.d for ssh session
2. login to a ssh session using bash
3. run `sudo -i`
4. wait until ssh session timeout
Stanislav Brabec [Wed, 28 Feb 2024 14:06:14 +0000 (15:06 +0100)]
setterm: Document behavior of redirection
Debugging an error of setterm, I realized that setterm --powerdown operates
on stdout but setterm --powersave operates on stdin. Such unexpected
behavior should be documented.
I prefer a less accurate generic "always redirect both stdin and stdout"
over recommending of the correct I/O stream for each option separately.