LiviaMedeiros [Mon, 16 Dec 2024 10:40:37 +0000 (11:40 +0100)]
tests: add skips when IPv6 is not supported
Before this change on systems with disabled IPv6 (e.g. `CONFIG_IPV6 is
not set` in kernel config), `lsfd/mkfds-tcp6` and `lsfd/mkfds-udp6` were
failing, and `lsfd/option-inet` was hanging forever, making it
impossible to complete the tests.
Karel Zak [Tue, 10 Dec 2024 11:24:59 +0000 (12:24 +0100)]
Merge branch 'ft-algorithm-params' of https://github.com/LiviaMedeiros/util-linux
* 'ft-algorithm-params' of https://github.com/LiviaMedeiros/util-linux:
zramctl: rename `--params` into `--algorithm-params`
zramctl: add support for `algorithm_params`
Maks Mishin [Tue, 10 Dec 2024 09:26:32 +0000 (12:26 +0300)]
sys-utils: (setpriv): fix potential memory leak
Dynamic memory, referenced by 'my_caps' is allocated by calling function 'xstrdup'
add then changed by calling of strsep function.
The free(my_caps) call is incorrect if my_caps != NULL, and points to some
place inside or outside the source string.
Zhaoming Luo [Mon, 9 Dec 2024 11:16:11 +0000 (19:16 +0800)]
hwclock: Support GNU Hurd
* configure.ac: add HURD so it can be used in conditional in am files
* sys-utils/Makemodule.am: compile hwclock for GNU Hurd
* sys-utils/hwclock-rtc.c: compile for GNU Hurd
* sys-utils/hwclock.c: compile for GNU Hurd
* sys-utils/hwclock.h: compile for GNU Hurd
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
```
Karel Zak [Fri, 6 Dec 2024 09:05:25 +0000 (10:05 +0100)]
Merge branch 'posix-argument-order' of https://github.com/nilfsuser5678/util-linux
* 'posix-argument-order' of https://github.com/nilfsuser5678/util-linux:
libmount: exec mount helpers with posixly correct argument order
libmount/context_mount: fix argument number comments
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.
mount: fix expected argument order for mount helpers in tests
Reads of ext superblocks can race with updates. If libblkid observes a
checksum mismatch, re-read the superblock with O_DIRECT in order to get
a consistent view of its contents. Only if the O_DIRECT read fails the
checksum should it be reported to have failed.
This fixes a problem where devices that were named by filesystem label
failed to be found when systemd attempted to mount them on boot. The
problem was caused by systemd-udevd using libblkid. If a read of a
superblock resulted in a checksum mismatch, udev will remove the
by-label links which result in the mount call failing to find the
device. The checksum mismatch that was triggering the problem was
spurious, and when we use O_DIRECT, or even perform a subsequent retry,
the superblock is correctly read. This resulted in a failure to mount
/boot in one out of every 2,000 or so attempts in our environment.
e2fsprogs fixed[1] an identical version of this bug that afflicted
resize2fs during online grow operations when run from cloud-init. The
fix there was also to use O_DIRECT in order to read the superblock.
This patch uses a similar approach: read the superblock with O_DIRECT in
the case where a bad checksum is detected.
Karel Zak [Mon, 25 Nov 2024 11:38:00 +0000 (12:38 +0100)]
Merge branch 'su-runuser-improvements' of https://github.com/calestyo/util-linux
* 'su-runuser-improvements' of https://github.com/calestyo/util-linux:
man pages: document `--user` option for `runuser`
man pages: use `user` rather than `username`
bash-completion: add `--pty` and `--no-pty` options for `su` and `runuser`
bash-completion: complete `--user` only for `runuser`, not for `su`
Karel Zak [Mon, 25 Nov 2024 11:10:37 +0000 (12:10 +0100)]
zramctl: add COMP-RATIO column
* Improve get_mm_stat() to return both numbers and strings.
* Add get_mm_stat_number() and get_mm_stat_string() functions.
* Add a new COL_COMPRATIO column.
Based on https://github.com/util-linux/util-linux/pull/3293
Co-Author: davidemanini Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Thu, 21 Nov 2024 09:24:07 +0000 (10:24 +0100)]
login,libblkid: use econf_readConfig rather than deprecated econf_readDirs
Fixes:
lib/logindefs.c: In function ‘load_defaults’:
lib/logindefs.c:257:9: warning: ‘econf_readDirs’ is deprecated: Use the econf_readConfig/econf_readConfigWithCallback instead [-Wdeprecated-declarations]
257 | error = econf_readDirs(&file,
| ^~~~~
libblkid/src/config.c: In function 'blkid_read_config':
libblkid/src/config.c:164:17: error: 'econf_readDirs' is deprecated: Use the econf_readConfig/econf_readConfigWithCallback instead [-Werror=deprecated-declarations]
164 | error = econf_readDirs(&file,
| ^~~~~
* check for econf_readConfig() by ./configure and moson
* add UL_VENDORDIR_PATH into pathnames.h to avoid #ifdef in code
* use #ifdef HAVE_ECONF_READCONFIG to switch between econf_readDirs()
and the econf_readConfig()
Bitfields have their uses, but the uses here didn't make any sense.
Code generated to read or write bitfields is more complicated (and
slower) because, well, the bits need to be manipulated with special
instructions. So bitfields should be used when we have a structure
that is repeated hundreds or thousands of times in memory and those
saving are higher than the cost of having more complicated code. This
can happen for example in the kernel code. But the code here has
structures that are instantiated once or or at most few times.
In addition, a bitfield often does not save any memory because of
alignment requirements. In the majority of cases modified here, the
bitfield was the last field in a structure, so no memory savings were
made.
(To be clear: those small savings are not particularly important. The
motivation for this patch is to eradicate the antipattern of making
things more complicated without any benefit.)
Currently, additional locations (such as /run or /usr/lib) are only
read if /etc/issue does not exist. This behavior makes it difficult to use
local settings (/etc) together with generated (/run) and distribution-specific
(/usr/lib) files. Let's read all the locations.
If the output of issue files is unwanted, the option --noissue can be
used, or the default locations can be ignored by using --issue-file
<list>.
Fixes: https://github.com/util-linux/util-linux/issues/3279
Addresses: https://github.com/systemd/systemd/issues/35071 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 19 Nov 2024 10:54:00 +0000 (11:54 +0100)]
libmount: support X-mount.noloop
libmount automatically creates a loop device and mounts it if the
source of the mount is a regular file that contains a well-known
filesystem. However, in some cases, this feature may be unwanted. The
new mount option "X-mount.noloop" forces libmount to use the file
directly as the mount source.
Addresses: https://github.com/util-linux/util-linux/pull/3288 Signed-off-by: Karel Zak <kzak@redhat.com>
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.
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 [Fri, 15 Nov 2024 10:53:37 +0000 (11:53 +0100)]
mesg: remove ability to compile with fchmod(S_IWOTH)
The default is to use mesg(1) to modify write access for the "tty"
group, but there is an obscure legacy. If mesg(1) is compiled with the
option "--disable-use-tty-group", then it defaults to using
fchmod(S_IWGRP | S_IWOTH). This means that your tty is then writable
for everyone. Let's get rid of this ugly feature.
Reported-by: Chris Hofstaedtler <zeha@debian.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Fri, 15 Nov 2024 10:32:34 +0000 (11:32 +0100)]
meson: add -D tty-setgid=[false|true]
If your distribution does not define permissions for installed
binaries and follows the upstream guidelines, disabling the tty
group's setgid could be a beneficial decision in certain situations.
Karel Zak [Fri, 15 Nov 2024 10:30:17 +0000 (11:30 +0100)]
autotools: add --disable-makeinstall-tty-setgid
If your distribution does not define permissions for installed
binaries and follows the upstream guidelines, disabling the tty
group's setgid could be a beneficial decision in certain situations.
Ameer Hamza [Fri, 4 Oct 2024 16:57:44 +0000 (21:57 +0500)]
libblkid: zfs: Use nvlist for detection instead of Uber blocks
Currently, blkid relies on the presence of Uber blocks to detect ZFS
partition types. However, Uber blocks are not consistently dumped for
cache and spare vdevs, particularly in pools created prior to
https://github.com/openzfs/zfs/commit/d9885b3. Additionally, indirect
vdevs are incorrectly detected by blkid due to the presence of Uber
blocks in the label. ZFS itself does not depend on Uber blocks either
when reading ZFS labels; instead, it parses the nvlist.
This commit aligns blkid's approach with ZFS by parsing the nvlist in
the label to detect ZFS partition types, requiring at least one valid
label for successful detection. This change also ensures compatibility
with wipefs, as it now uses nvlist headers for offsets instead of the
Uber Magic offset. Consequently, running wipefs -a will zero out the
nvlist header in each label, fully removing the ZFS partition type and
making the pool unimportable. Previously, wipefs -a did not clear all
the Uber blocks or delete all nvlist headers, allowing pools to remain
importable even after wiping.