Karel Zak [Tue, 2 Jul 2024 09:14:06 +0000 (11:14 +0200)]
lib/fileutils: add ul_basename()
Unfortunately, the basename() function can be affected by the
creativity of different libc authors, resulting in varying behavior
across implementations.
Instead, use a local implementation to ensure consistency and
portability.
Karel Zak [Tue, 2 Jul 2024 10:05:34 +0000 (12:05 +0200)]
Merge branch 'stable/v2.40/autotools' of https://github.com/t-8ch/util-linux into stable/v2.40
* 'stable/v2.40/autotools' of https://github.com/t-8ch/util-linux:
autotools: Properly order install dependencies of pam_lastlog2
autotools: make pam install path configurable
Thomas Weißschuh [Sun, 30 Jun 2024 09:23:53 +0000 (11:23 +0200)]
autotools: Properly order install dependencies of pam_lastlog2
As pam_lastlog2 is relinked during installation, all its dependencies
need to already be installed.
This is the same issue that affected pylibmount which was fixed in
commit 324330aca644 ("build-sys: Properly order install dependencies of pylibmount").
Extend the logic added in that commit to also apply to pam_lastlog2.
While at it, also move the initial definition of
usesecurelib_exec_LTLIBRARIES into Makefile.am.
Also add "exec" to the target name which is recognized by automake to
mark the targets as architecture-specific.
Karel Zak [Tue, 2 Jul 2024 08:39:12 +0000 (10:39 +0200)]
build-sys: _PATH_VENDORDIR workaround
It appears that certain versions of libeconf do not handle calls to
econf_readDirs() with NULL path. Therefore, let's set the default to
"/usr/etc" if no value is defined by using the "--with-vendordir="
option.
Addresses: https://github.com/util-linux/util-linux/issues/3091 Signed-off-by: Karel Zak <kzak@redhat.com>
Nicholas Vinson [Wed, 15 May 2024 15:14:54 +0000 (11:14 -0400)]
Conditionally add uuid_time64 to sym. version map
The symbol uuid_time64 is conditionally defined. It only exists on
32-bit platforms that use the glibc library and enable support for
the 64-bit time_t type.
For all other platforms, the symbol is undefined. As a result, when
ld.lld version 17 or newer is used with default flags, ld.lld will
reject the symbol map with the error:
version script assignment of 'UUID_2.40' to symbol 'uuid_time64'
failed: symbol not defined
To fix this issue, the reference to uuid_time64 is changed to
uuid_time64*. The change to a glob pattern satisifies ld.lld and allows
the library to link.
After fork() the memory of the calling thread is preserved into the new
process. This also includes TLS.
Make sure to reset the cache after a fork to avoid reuse of cached
values.
Only the TLS of the thread calling fork() is relevant as that is the
only thread that gets forked.
New threads will received newly initialized TLS.
Fixes https://github.com/util-linux/util-linux/issues/3009 Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
(cherry picked from commit a3f1255f1891ddbaf3bb6a32af28569c0e6f3b91)
Thomas Weißschuh [Wed, 12 Jun 2024 21:32:15 +0000 (23:32 +0200)]
lib/sysfs: zero-terminate result of sysfs_blkdev_get_devchain()
sysfs_blkdev_get_devchain() does not zero-terminate its result, but the
caller expects a C-string.
Use ul_buffer_get_string() which includes a trailing zero-byte.
Thomas Weißschuh [Thu, 13 Jun 2024 09:39:34 +0000 (11:39 +0200)]
lib/buffer: introduce ul_buffer_get_string()
Some users need a zero-byte-terminated string.
As the buffer internally already maintains a zero-termination, add a
helper function that exposes this to users.
wdctl: always query device node when sysfs is unavailable
When there is no sysfs at all for the watchdog, fall back to reading
from the device node.
This is also useful if the legacy compat /dev/watchdog device which
never has a sysfs interface.
Karel Zak [Mon, 3 Jun 2024 10:33:01 +0000 (12:33 +0200)]
libmount: fix tree FD usage in subdir hook
* Initialize the tree file descriptor in the hook_subdir.c module if
it has not been initialized yet. (hook_mount.c does not open the
tree if the mount.<type> helper will be executed.)
* Move the function to open the tree to context.c to make it more
generic and usable in more places.
Reported-by: Linus Heckemann <git@sphalerite.org> Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 2a684833d723e29af0ba772b3e6917492c69e023)
Chen Qi [Sat, 25 May 2024 03:41:35 +0000 (11:41 +0800)]
libsmartcols/src/Makemodule.am: ensure filter-scanner/paser.c file is newer than the .h file
In released tarball, for filter-scanner/parser, the .h and the .c
file has the same mtime. The 'make' tool thinks .h is newer than
the .c file, thus deciding to remake it. This will not only cause
unnecessary rebuild, but also parallel make error. For example,
after 'make', when running 'make install', the libmount.la and findmnt
are both rebuilt and findmnt building will somethings error out complaining
'libmount.so: no such file or directory' or 'libmount.so: file format
not recognized'.
Touch the generated .c file to ensure it's newer than the .h file.
In this way, in new released tarballs in the future, there will
be no unnecessary remake.
Jordan Williams [Tue, 7 May 2024 14:40:44 +0000 (09:40 -0500)]
meson: Correctly require the Python.h header for the python dependency
The current solution to require the Python.h header works around a bug
in Meson that has been fixed for version 1.4.1 of Meson.
Refer to https://github.com/mesonbuild/meson/issues/12862.
This change uses an explicit check for the Python.h include.
This verifies the required header exists.
This check is only necessary prior to version 1.4.1 of Meson.
Jordan Williams [Thu, 9 May 2024 21:46:58 +0000 (16:46 -0500)]
meson: Only require Python module when building pylibmount
Only the python executable is required for tests.
Version 1.4.1 of Meson will require the Python.h for find_installation.
This will result in the tests requiring Python.h unnecessarily.
Use find_program to find the Python program for the tests instead.
Jordan Williams [Mon, 13 May 2024 12:25:50 +0000 (07:25 -0500)]
meson: Fix build-python option
The build-python option is for controlling whether or not pylibmount is
built.
Unfortunately, commit b6799cc rendered the option unused.
This change uses the build-python option again.
Karel Zak [Wed, 1 May 2024 19:11:10 +0000 (21:11 +0200)]
Merge branch 'stable/v2.40-meson-more-build-options' of https://github.com/jwillikers/util-linux into stable/v2.40
* 'stable/v2.40-meson-more-build-options' of https://github.com/jwillikers/util-linux: (21 commits)
meson: Add build-lsclocks option
meson: Add build-enosys option
meson: Define _DARWIN_C_SOURCE on macOS as is done in Autotools
strutils.h: Include strings.h header for strncasecmp function
xalloc.h: Include stdio.h header for vasprintf function
meson: Fix build by default and install behavior for build-pipesz option
meson: Add build-fadvise option
meson: Add build-scriptlive option
meson: Add build-script option
meson: Require pty for the su and runuser executables
meson: Add have_pty variable to check if pty is available
meson: Add build-blockdev option
meson: Add build-chcpu option
meson: Use has_type instead of sizeof to detect cpu_set_t type
meson: Add build-setarch option
meson: Add build-rtcwake option
meson: Add build-ldattach option
meson: Add build-blkdiscard option
meson: Add build-fsfreeze option
meson: Add build-blkzone option
...
Jordan Williams [Mon, 22 Apr 2024 14:42:25 +0000 (09:42 -0500)]
meson: Add build-blockdev option
Only build blockdev on Linux.
The BLKROSET macro is used in blockdev.c from blkdev.h.
The blkdev.h header only defines this macro when it is missing on Linux.
Add blockdev to the list of executables, which appears to have been
omitted previously.
Karel Zak [Mon, 22 Apr 2024 12:28:52 +0000 (14:28 +0200)]
lsns: fix netns use
# ip netns add vpn
# lsns -T -t net
Segmentation fault (core dumped)
The function interpolate_missing_namespaces() reads data from /proc.
However, in the case of a persistent namespace, there is no procfs
entry for the namespace. Therefore, this function should ignore it.
Fixes: https://github.com/util-linux/util-linux/issues/2982 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 42880f54894c1d7fd113552ff8474566a2595a0d)
Karel Zak [Mon, 22 Apr 2024 11:09:04 +0000 (13:09 +0200)]
libmount: Fix access check for utab in context
The function mnt_has_regular_utab() properly detects that the utab is
not writable, but this is ignored by the high-level context API. As a
result, the library later attempts to update the file and ends up with
a warning in mount(8):
$ mkdir sys
$ unshare --map-root-user --mount
$ mount --rbind /sys sys
$ umount --lazy sys; echo $?
umount: /home/user/sys: filesystem was unmounted, but failed to update userspace mount table.
16
In this case, the utab should be ignored.
Fixes: https://github.com/util-linux/util-linux/issues/2981 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 97f7bfc0fdf74b6a6e220ba9d2f620386e660b29)