Stanislav Brabec [Sun, 21 Jul 2024 13:01:42 +0000 (15:01 +0200)]
agetty: Prevent cursor escape
Starting with 5de97519, it is possible to escape the login dialog on the
screen by arrow characters or using escape sequences.
Since full processing of escape sequences and ignore them would be
complicated, use a work around: instead of sending ESC to output, send a
printable character.
It could cause a rendering regression in a very obscure condition: compiled
without IUTF8, encoding is ISO-11548-1 and BRAILLE PATTERN DOTS-1245 is
part of login name. I believe that it is out of supported combinations.
John Keeping [Tue, 6 Aug 2024 17:17:29 +0000 (18:17 +0100)]
libmount: propagate first error of multiple filesystem types
Use the same error handling logic as do_mount_by_pattern() to better
handle the case where EROFS is returned from the first filesystem in a
list but subsequent filesystems overwrite this status with, for example,
ENODEV.
This allows read-only devices to mount without the user needing to
explicitly specify "ro" while specifying a list of potential
filesystems, some of which may not be available.
John Keeping [Tue, 6 Aug 2024 17:16:00 +0000 (18:16 +0100)]
libmount: extract common error handling function
Extract the logic for whether to continue trying more filesystem types
to a function so that it can be reused to make this consistent between
do_mount_by_pattern() and do_mount_by_types().
Karel Zak [Thu, 26 Dec 2024 10:34:10 +0000 (11:34 +0100)]
fstab.5 mount.8: add note about field separator
The value of the mount option X-mount.idmap= can contain spaces as
separators between mappings. Unfortunately, this conflicts with the
fstab format where fields are separated by spaces. Using quotes does
not solve this issue because fields are separated before they are
parsed.
This limitation of the fstab parser within libmount is due to backward
compatibility. The fstab format is a de-facto standard and is parsed
by many tools and libraries, including third-party shell scripts. It
would not be practical to introduce any improvements in libmount that
would make fstabs unparseable in other places.
Users must understand that in-field spaces must be escaped by \040.
For example, X-mount.idmap="0:0:1\040500:1000:1".
Addresses: https://github.com/util-linux/util-linux/issues/2829 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 52dc9260d469a3731f49c5a78b23f38f2314789e)
Skip tmpfs-sensitive tests if fstype cannot be determined
In certain isolation environments (f.e. Debian's sbuild+unshare),
`/proc/mounts` does not have an entry for the directory we're building in.
Then, findmnt as used in the tests returns nothing. As the build directory
might very well be on tmpfs (and often is, in Debian), disable the two tests
known to fail on tmpfs.
In yet another scenario, if ran in a Docker/podman container, the fstype
will read "overlay", which in the end can also be tmpfs, and we see problems
there, too.
Karel Zak [Mon, 14 Oct 2024 09:45:32 +0000 (11:45 +0200)]
libfdisk: make sure libblkid uses the same sector size
Libfdisk uses libblkid to check for filesystems on the device. It
makes sense for both libraries to share the logical sector size
setting, as this setting can be modified by using the fdisk command
line.
We do not see this as an issue, as filesystem detection rarely depends
on sector size (with the exception of some RAIDs). Additionally,
libblkid is usually intelligent enough to check multiple locations
independently of the current device's sector size setting.
Addresses: https://github.com/util-linux/util-linux/pull/3235 Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 7ada6547fcd1f649fadaa8021ff21e3e0f431459)
Karel Zak [Wed, 9 Oct 2024 07:54:41 +0000 (09:54 +0200)]
libblkid: add FSLASTBLOCK for swaparea
Suggested-by: Peter Rajnoha <prajnoha@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 0567efc790d4426df3001c6f8a19e276f114a450)
The exFAT specification lists valid value ranges for the superblock
fields. Validate the fields interpreted by the libblkid prober to avoid
undefined behaviour.
Michal Suchanek [Tue, 24 Sep 2024 07:19:39 +0000 (09:19 +0200)]
partx: Fix example in man page
The example is:
partx -d --nr :-1 /dev/sdd
Removes the last partition on _/dev/sdd_.
The documentation says:
M:
Specifies the lower limit only (e.g. --nr 2:).
:N
Specifies the upper limit only (e.g. --nr :4).
In the above example the lower limit is not set and the upper is set to
the last partition, meaning all partitions. The lower limit should be
set instead.
Karel Zak [Thu, 22 Aug 2024 06:56:52 +0000 (08:56 +0200)]
more: make sure we have data on stderr
more(1) uses more_poll() to monitor data on stdin, stderr, and
signals. It is used before read_command(), but this function only
reads from stderr. Therefore, if any other non-stderr event occurs,
this function will wait on read(). In this case, more(1) will not
react to signals anymore. We need to ensure that more(1) only waits in
more_poll().
Try
for x in {1..1000}; do echo "line $x"; done | more
to reproduce.
Reported-by: Radka Skvarilova <rskvaril@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 640b9480bd3efc0f4bc7f38a785d02cda70ec5c3)
John Paul Adrian Glaubitz points out that libseccomp needs to release 2.6.0,
too.
Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de> Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
(cherry picked from commit 5ebf0edb0a0531cba801c7791543c610725bf944)
tv_usec is an unspecified signed integer type.
The format string %u assumes an unsigned int, which is incorrect.
Especially on 32bit big-endian, where it can lead to invalid values.
Zhaoming Luo [Mon, 9 Dec 2024 02:11:54 +0000 (10:11 +0800)]
hwclock: Remove ioperm declare as it causes nested extern declare warning
The extern declaration causes the following warning:
```
CC sys-utils/hwclock-hwclock-cmos.o
sys-utils/hwclock-cmos.c: In function 'i386_iopl':
sys-utils/hwclock-cmos.c:356:20: warning: nested extern declaration of 'ioperm' [-Wnested-externs]
356 | extern int ioperm(unsigned long from, unsigned long num, int turn_on);
| ^~~~~~
sys-utils/hwclock-cmos.c:356:20: warning: redundant redeclaration of 'ioperm' [-Wredundant-decls]
In file included from sys-utils/hwclock-cmos.c:68:
/usr/include/i386-gnu/sys/io.h:29:12: note: previous declaration of 'ioperm' with type 'int(long unsigned int, long unsigned int, int)'
29 | extern int ioperm (unsigned long int __from, unsigned long int __num,
| ^~~~~~
CCLD hwclock
```
nilfsuser5678 [Fri, 29 Nov 2024 17:27:12 +0000 (17:27 +0000)]
libmount: exec mount helpers with posixly correct argument order
This improves compatibility with non-gnu userspaces.
On systems where the libc provides posix getopt instead of gnu getopt,
mount helpers which use getopt to parse arguments will not parse
options which appear after non-option arguments. This patch ensures
mount/unmount work as expected in this situation.
With --file, shen the file is created by mkswap, stat() fails with -ENOENT
and the st_mode field is not populated, so the IS_REG() check fails. But if
we created by mkswap, we know it's just a regular file and we should apply
the selinux label.
Reported in https://bugzilla.redhat.com/show_bug.cgi?id=2324811#c56.
The directory can be directly used by libuuid, for example, by running
"uuidgen --time" as root, even if the uuidd daemon is not installed.
In this case, we must create a clock.txt file with the uuidd group to
prevent any potential ownership mismatch if the uuidd daemon is
installed later. The 2xxx mode (setgid) forces open(O_CREAT) in
libuuid to create the file with the uuidd group.
Please note that mode 2755 is the standard used for years in RHEL.
Xi Ruoyao [Wed, 3 Apr 2024 07:29:34 +0000 (15:29 +0800)]
lsfd: Refactor the pidfd logic into lsfd-pidfd.c
We'll reuse these logic for pidfd support on Linux >= 6.9. This should
be a no-functional change.
Besides moving the code, this change also renames anon_pidfd_data to
pidfd_data, and removes a redundant nullity check for free (because
free(NULL) will just do nothing per the C standard).
Based on https://github.com/util-linux/util-linux/pull/3018
The syscall numbers should not be hardcoded in the header file. If we
really need them, there is UL_CHECK_SYSCALL() to define the numbers
for different architectures. I doubt it's really necessary. Just
update your kernel header files to get the latest kernel updates ...
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.