Stanislav Brabec [Wed, 19 Jun 2024 15:31:34 +0000 (17:31 +0200)]
umount, losetup: Document loop destroy behavior
The loop device detach runs asynchronously in the background. It can cause
unexpected errors. Document the possible existence of the loop device after
exit of losetup -d or umount and need of "udevadm settle".
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit fc67f18be51f57ee9a59a0f8f7ad16f284a24a3e)
lscpu: Skip aarch64 decode path for rest of the architectures
lscpu behaves differently when run sudo vs non-sudo on AMD architectures.
On sudo runs, it adds a BIOS model name and BIOS CPU family which it
does not add for the latter. However since this parsing from the DMI is
primarily catered to aarch64, for AMD platform the BIOS model name is
printed out as follows "AMD XXX Processor *Unknown* CPU @ X.XGHz" due
to the part number is not populated on the platform.
The issue boils down to an unconditional call to arm_decode() which
attempts to read the DMI path and populate the processor information
such as processor version and part number which is set to Unknown on AMD
CPUs.
81d6de9 (lscpu: remove the old code) changed the DMI path from
/sys/firmware/dmi/entries/4-0/raw (non-existent) to
/sys/firmware/dmi/tables/dmi (existent) which has brought this latent
issue to light as DMI was starting to be parsed incorrectly.
Therefore, do not perform aarch64 parsing for other architectures.
Before
------
$ lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
$ sudo lscpu
Vendor ID: AuthenticAMD
BIOS Vendor ID: Advanced Micro Devices, Inc.
Model name: AMD EPYC XXXX X-Core Processor
BIOS Model name: AMD EPYC XXXX X-Core Processor Unknown CPU @ X.XGHz
BIOS CPU family: 107
CPU family: 26
After
-----
$ lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
$ sudo lscpu
Vendor ID: AuthenticAMD
Model name: AMD EPYC XXXX X-Core Processor
CPU family: 26
Fixes: 81d6de9 ("lscpu: remove the old code") Co-developed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Pratik R. Sampat <pratikrajesh.sampat@amd.com>
(cherry picked from commit 50a3efab6d126b28fcdcc28f1a0cd5cd596ae357)
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>