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.
Karel Zak [Tue, 27 Feb 2024 17:38:02 +0000 (18:38 +0100)]
hexdump: check blocksize when display data
hexdump(1) stores input to buffer and apply format unit when prints
the output. The unit can move pointer which points to the buffer, but
code does not check for limits.
Fixes: https://github.com/util-linux/util-linux/issues/2806 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit dfa1ad272528a92384adac523cf2f2949b767d8d)
Karel Zak [Mon, 26 Feb 2024 11:44:10 +0000 (12:44 +0100)]
libmount: report kernel message from new API
This is a very minimalistic implementation for v2.40 designed to print
error messages from the kernel. It exclusively displays errors, and
the patch does not introduce any new library interface for this
purpose. Instead, it simply replaces hardcoded messages within
libmount with kernel messages.
It's worth noting that the final implementation will necessitate
per-hook error handling in libmount and likely a new library API to
access other types of messages (warnings, notices, etc.).
Thomas Weißschuh [Fri, 23 Feb 2024 07:15:32 +0000 (08:15 +0100)]
meson: run compiler checks with -D_GNU_SOURCE when necessary
Through the addition of default_options: c_std=c99 some build-time
checks were incorrect. Explicitly add -D_GNU_SOURCE where necessary.
Fixes: 6240e4458cdf ("build: use -std=c99 and -std=c++11 by default") Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
(cherry picked from commit 1eeabbb42649f8334b6330689fec54325591fe2f)
Jan Kara [Wed, 21 Feb 2024 17:30:50 +0000 (18:30 +0100)]
libmount: don't hold write fd to mounted device
Avoid holding writeable fd to a loop device that is being mounted. In
the hardened configurations (CONFIG_BLK_DEV_WRITE_MOUNTED = n) the
kernel wants to make sure nobody else has the block device writeably
open when mounting so this makes the mount fail.
Reported-by: JunChao Sun <sunjunchao2870@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Christian Brauner <brauner@kernel.org>
(cherry picked from commit 1cde32f323e0970f6c7f35940dcc0aea97b821e5)