Compare commits

...

No commits in common. "c8" and "c9-beta" have entirely different histories.
c8 ... c9-beta

177 changed files with 7643 additions and 10004 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/util-linux-2.32.1.tar.xz SOURCES/util-linux-2.37.4.tar.xz

View File

@ -1 +1 @@
de9271fb93fb651d21c027e2efb0cf0ac80f2e9a SOURCES/util-linux-2.32.1.tar.xz 6e6c49c1dbb288b90b933e4328bde4786172f021 SOURCES/util-linux-2.37.4.tar.xz

View File

@ -1,7 +1,7 @@
From 2d57cb2d64ba4757dcfd9d0e7ed4873cae8a6fcd Mon Sep 17 00:00:00 2001 From ef8c8e117234f135a22ba7180114f0153b2444d8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com> From: Karel Zak <kzak@redhat.com>
Date: Mon, 20 Jun 2016 11:09:02 +0200 Date: Mon, 20 Jun 2016 11:09:02 +0200
Subject: [PATCH 0/6] login: create /var/log/lastlog Subject: login: create /var/log/lastlog
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=151635 Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=151635
--- ---
@ -9,10 +9,10 @@ Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=151635
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/login-utils/login.c b/login-utils/login.c diff --git a/login-utils/login.c b/login-utils/login.c
index 09ee8f8ea..8c9e43292 100644 index c6cd340b6..3657f04cd 100644
--- a/login-utils/login.c --- a/login-utils/login.c
+++ b/login-utils/login.c +++ b/login-utils/login.c
@@ -506,7 +506,7 @@ static void log_lastlog(struct login_context *cxt) @@ -662,7 +662,7 @@ static void log_lastlog(struct login_context *cxt)
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sigaction(SIGXFSZ, &sa, &oldsa_xfsz); sigaction(SIGXFSZ, &sa, &oldsa_xfsz);
@ -20,7 +20,7 @@ index 09ee8f8ea..8c9e43292 100644
+ fd = open(_PATH_LASTLOG, O_RDWR | O_CREAT, 0); + fd = open(_PATH_LASTLOG, O_RDWR | O_CREAT, 0);
if (fd < 0) if (fd < 0)
goto done; goto done;
offset = cxt->pwd->pw_uid * sizeof(ll);
-- --
2.14.4 2.34.1

View File

@ -1,123 +0,0 @@
From 768b91ef6f68661462494bed800505064eb97bc8 Mon Sep 17 00:00:00 2001
From: Milan Broz <gmazyland@gmail.com>
Date: Wed, 11 Jul 2018 12:34:39 +0200
Subject: [PATCH 1/6] libblkid: Check for a secondary LUKS2 header.
This patch adds search for a secondary LUKS2 header,
if the primary one is corrupted.
This patch is primarily needed for wipefs that should wipe
both signatures (otherwise LUKS2 header recovery can use
secondary header and revert wipefs action).
Signed-off-by: Milan Broz <gmazyland@gmail.com>
Upstream: http://github.com/karelzak/util-linux/commit/8bee1a220db8effbe5a75ba9bc68840e019ea89a
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1595882
---
libblkid/src/superblocks/luks.c | 60 ++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/libblkid/src/superblocks/luks.c b/libblkid/src/superblocks/luks.c
index bc3d7f558..67d7cfcc5 100644
--- a/libblkid/src/superblocks/luks.c
+++ b/libblkid/src/superblocks/luks.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Karel Zak <kzak@redhat.com>
+ * Copyright (C) 2018 Milan Broz <gmazyland@gmail.com>
*
* Inspired by libvolume_id by
* Kay Sievers <kay.sievers@vrfy.org>
@@ -29,6 +30,15 @@
#define LUKS2_CHECKSUM_ALG_L 32
#define LUKS2_CHECKSUM_L 64
+#define LUKS_MAGIC "LUKS\xba\xbe"
+#define LUKS_MAGIC_2 "SKUL\xba\xbe"
+
+/* Offsets for secondary header (for scan if primary header is corrupted). */
+#define LUKS2_HDR2_OFFSETS { 0x04000, 0x008000, 0x010000, 0x020000, \
+ 0x40000, 0x080000, 0x100000, 0x200000, 0x400000 }
+
+static const uint64_t secondary_offsets[] = LUKS2_HDR2_OFFSETS;
+
struct luks_phdr {
uint8_t magic[LUKS_MAGIC_L];
uint16_t version;
@@ -59,18 +69,16 @@ struct luks2_phdr {
/* Padding to 4k, then JSON area */
} __attribute__ ((packed));
-static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag)
+static int luks_attributes(blkid_probe pr, struct luks2_phdr *header, uint64_t offset)
{
- struct luks_phdr *header_v1;
- struct luks2_phdr *header;
int version;
+ struct luks_phdr *header_v1;
- header = blkid_probe_get_sb(pr, mag, struct luks2_phdr);
- if (header == NULL)
- return errno ? -errno : 1;
+ if (blkid_probe_set_magic(pr, offset, LUKS_MAGIC_L, (unsigned char *) &header->magic))
+ return BLKID_PROBE_NONE;
version = be16_to_cpu(header->version);
- blkid_probe_sprintf_version(pr, "%u", be16_to_cpu(header->version));
+ blkid_probe_sprintf_version(pr, "%u", version);
if (version == 1) {
header_v1 = (struct luks_phdr *)header;
@@ -84,7 +92,37 @@ static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag)
blkid_probe_set_id_label(pr, "SUBSYSTEM",
(unsigned char *) header->subsystem, LUKS2_LABEL_L);
}
- return 0;
+
+ return BLKID_PROBE_OK;
+}
+
+static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag __attribute__((__unused__)))
+{
+ struct luks2_phdr *header;
+ size_t i;
+
+ header = (struct luks2_phdr *) blkid_probe_get_buffer(pr, 0, sizeof(struct luks2_phdr));
+ if (!header)
+ return errno ? -errno : BLKID_PROBE_NONE;
+
+ if (!memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L)) {
+ /* LUKS primary header was found. */
+ return luks_attributes(pr, header, 0);
+ } else {
+ /* No primary header, scan for known offsets of LUKS2 secondary header. */
+ for (i = 0; i < ARRAY_SIZE(secondary_offsets); i++) {
+ header = (struct luks2_phdr *) blkid_probe_get_buffer(pr,
+ secondary_offsets[i], sizeof(struct luks2_phdr));
+
+ if (!header)
+ return errno ? -errno : BLKID_PROBE_NONE;
+
+ if (!memcmp(header->magic, LUKS_MAGIC_2, LUKS_MAGIC_L))
+ return luks_attributes(pr, header, secondary_offsets[i]);
+ }
+ }
+
+ return BLKID_PROBE_NONE;
}
const struct blkid_idinfo luks_idinfo =
@@ -92,9 +130,5 @@ const struct blkid_idinfo luks_idinfo =
.name = "crypto_LUKS",
.usage = BLKID_USAGE_CRYPTO,
.probefunc = probe_luks,
- .magics =
- {
- { .magic = "LUKS\xba\xbe", .len = 6 },
- { NULL }
- }
+ .magics = BLKID_NONE_MAGIC
};
--
2.14.4

View File

@ -0,0 +1,28 @@
From c8574869e60a0351551cb281872e08b4d8fc68d8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 24 Aug 2021 13:50:57 +0200
Subject: login: default motd file
Add `/run/motd.d` to the hardcoded MOTD_FILE
Addresses: https://github.com/coreos/console-login-helper-messages/issues/60
---
include/pathnames.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/pathnames.h b/include/pathnames.h
index 9be2baa83..7e7d9053f 100644
--- a/include/pathnames.h
+++ b/include/pathnames.h
@@ -41,7 +41,7 @@
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/var/spool/mail"
#endif
-#define _PATH_MOTDFILE "/usr/share/misc/motd:/run/motd:/etc/motd"
+#define _PATH_MOTDFILE "/usr/share/misc/motd:/run/motd:/run/motd.d:/etc/motd:/etc/motd.d"
#ifndef _PATH_NOLOGIN
# define _PATH_NOLOGIN "/etc/nologin"
#endif
--
2.34.1

View File

@ -1,40 +0,0 @@
From 315960fa9a89248e9d56682c1915567d38fef431 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 7 Jun 2018 12:05:08 +0200
Subject: [PATCH 2/6] losetup: keep -f and <devname> mutually exclusive
losetup tries to blindly use specified device as well as search for
the first free device, the result is:
# losetup /dev/loop1 -f /tmp/tfile_loop1
losetup: /dev/loop1: failed to set up loop device: Invalid argument
fixed version:
# losetup /dev/loop10 -f img
losetup: unexpected arguments
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1614364
Upstream: http://github.com/karelzak/util-linux/commit/c3f5a0f1d47dbc47f6d21da232d4eb1cfb7905db
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/losetup.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 9c479c02d..e80ceacce 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -749,6 +749,9 @@ int main(int argc, char **argv)
*/
act = A_CREATE;
file = argv[optind++];
+
+ if (optind < argc)
+ errx(EXIT_FAILURE, _("unexpected arguments"));
}
if (list && !act && optind == argc)
--
2.14.4

View File

@ -0,0 +1,30 @@
From 38b2b2e49e72638639c997e532a846ee935ce148 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 23 Aug 2021 15:15:38 +0200
Subject: tests: make ./run.sh more robust
Let's make upstream tests more stable to be usable in RHEL
environment where we do not use ASAN and meson.
Upstream: http://github.com/karelzak/util-linux/commit/331c5e0c54d9cb6f67dc3e825eec2d78c67d8ce6
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/run.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/run.sh b/tests/run.sh
index 9d26406c4..d020bfe88 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -165,7 +165,7 @@ OPTS="$OPTS --srcdir=$top_srcdir --builddir=$top_builddir"
if [ -z "$has_asan_opt" ]; then
if [ -e "$top_builddir/Makefile" ]; then
asan=$(awk '/^ASAN_LDFLAGS/ { print $3 }' $top_builddir/Makefile)
- else
+ elif [ -f "$top_builddir/meson.conf" ]; then
. "$top_builddir/meson.conf"
fi
if [ -n "$asan" ]; then
--
2.34.1

View File

@ -1,55 +0,0 @@
From 4859f218a3be0ae90908fc0ddbef498a784e9b24 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 10 Aug 2018 16:27:41 +0200
Subject: [PATCH 3/6] mount: add ext4 to some places to the man page
Upstream: http://github.com/karelzak/util-linux/commit/d901e4275f7c1899518bab3b34424c90af8dc35e
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1614852
---
sys-utils/mount.8 | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sys-utils/mount.8 b/sys-utils/mount.8
index 562ecb187..1cc792979 100644
--- a/sys-utils/mount.8
+++ b/sys-utils/mount.8
@@ -880,7 +880,7 @@ output for extN filesystems).
The following options apply to any filesystem that is being
mounted (but not every filesystem actually honors them \(en e.g.\&, the
.B sync
-option today has an effect only for ext2, ext3, fat, vfat and ufs):
+option today has an effect only for ext2, ext3, ext4, fat, vfat and ufs):
.TP
.B async
@@ -916,7 +916,8 @@ The
.B context=
option is useful when mounting filesystems that do not support
extended attributes, such as a floppy or hard disk formatted with VFAT, or
-systems that are not normally running under SELinux, such as an ext3 formatted
+systems that are not normally running under SELinux, such as an ext3 or ext4 formatted
+
disk from a non-SELinux workstation. You can also use
.B context=
on filesystems you do not trust, such as a floppy. It also helps in compatibility with
@@ -2314,7 +2315,7 @@ not specified or the filesystem is known for libblkid, for example:
.sp
.B "mount /tmp/disk.img /mnt"
.sp
-.B "mount \-t ext3 /tmp/disk.img /mnt"
+.B "mount \-t ext4 /tmp/disk.img /mnt"
.sp
.RE
This type of mount knows about three options, namely
@@ -2462,7 +2463,7 @@ It is possible for a corrupted filesystem to cause a crash.
.PP
Some Linux filesystems don't support
.BR "\-o sync " nor " \-o dirsync"
-(the ext2, ext3, fat and vfat filesystems
+(the ext2, ext3, ext4, fat and vfat filesystems
.I do
support synchronous updates (a la BSD) when mounted with the
.B sync
--
2.14.4

View File

@ -0,0 +1,66 @@
From a4d1feed2803a5c0596877b64487734bcdb781ef Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 23 Aug 2021 16:28:52 +0200
Subject: tests: make mount/fstab-all more robust
Upstream: http://github.com/karelzak/util-linux/commit/85ae61dd6d956e7c9fe2b22b8c46bb1d0bfd13da
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/mount/fstab-all | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/ts/mount/fstab-all b/tests/ts/mount/fstab-all
index acc64e462..6b7018823 100755
--- a/tests/ts/mount/fstab-all
+++ b/tests/ts/mount/fstab-all
@@ -79,6 +79,7 @@ echo "${TS_DEVICE}4 ${MOUNTPOINT}D ext4 rw,defaults 0 0" >> $MY_FSTAB
ts_init_subtest "basic"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -87,6 +88,7 @@ ts_finalize_subtest
ts_init_subtest "filter-type"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t ext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}D
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -95,6 +97,7 @@ ts_finalize_subtest
ts_init_subtest "filter-notype"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -t noext4 >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -103,6 +106,7 @@ ts_finalize_subtest
ts_init_subtest "filter-option"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -O ro >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}C
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -111,6 +115,7 @@ ts_finalize_subtest
ts_init_subtest "override-option"
$TS_CMD_MOUNT --all --fstab $MY_FSTAB -o ro >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT ${MOUNTPOINT}{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
@@ -132,6 +137,7 @@ $TS_CMD_MOUNT --all \
--target-prefix $MY_ROOT \
-o X-mount.mkdir >> $TS_OUTPUT 2>> $TS_ERRLOG
[ $? == 0 ] || ts_log "mount failed"
+udevadm settle
$TS_CMD_UMOUNT $MY_ROOT/foo/{A,B,C,D}
[ $? == 0 ] || ts_log "umount failed"
ts_finalize_subtest
--
2.34.1

View File

@ -1,29 +0,0 @@
From 56b9e31e6b9864bba07a25d2244ca0006eed5bb5 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 10 Aug 2018 16:55:14 +0200
Subject: [PATCH 4/6] logger: add -S to the man page
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1614843
Upstream: http://github.com/karelzak/util-linux/commit/1f6583930b1061c5e79e09a9f2e80caaf9eeb405
Reported-by: Radka Skvarilova <rskvaril@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/logger.1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc-utils/logger.1 b/misc-utils/logger.1
index f121c4dc9..f9655978d 100644
--- a/misc-utils/logger.1
+++ b/misc-utils/logger.1
@@ -224,7 +224,7 @@ produces:
.fi
.IP
.TP
-.BR \-\-size " \fIsize
+.BR \-S , " -\-size " \fIsize
Sets the maximum permitted message size to \fIsize\fR. The default
is 1KiB characters, which is the limit traditionally used and specified
in RFC 3164. With RFC 5424, this limit has become flexible. A good assumption
--
2.14.4

View File

@ -0,0 +1,42 @@
From 54c1c6895ec53929d44153073a862521f6ed869d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 24 Aug 2021 10:49:32 +0200
Subject: tests: make eject umount tests more robust
Upstream: http://github.com/karelzak/util-linux/commit/abe16d0d34413555fbd621f90a0b93c2105116a2
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/eject/umount | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/ts/eject/umount b/tests/ts/eject/umount
index 2be281ee3..04f53ed99 100755
--- a/tests/ts/eject/umount
+++ b/tests/ts/eject/umount
@@ -83,6 +83,7 @@ mkfs.ext2 -q -F $TS_DEVICE
udevadm settle
mkdir -p $TS_MOUNTPOINT
$TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT
+udevadm settle
$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
deinit_device
ts_finalize_subtest
@@ -95,6 +96,7 @@ mkdir -p ${TS_MOUNTPOINT}1
mkdir -p ${TS_MOUNTPOINT}2
$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+udevadm settle
$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
deinit_device
ts_finalize_subtest
@@ -115,6 +117,7 @@ mkdir -p ${TS_MOUNTPOINT}1
mkdir -p ${TS_MOUNTPOINT}2
$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+udevadm settle
$TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
deinit_device
ts_finalize_subtest
--
2.34.1

View File

@ -1,8 +1,7 @@
From 9e7cedda86e5356d1723e6bd0bab5e38c4fe4a34 Mon Sep 17 00:00:00 2001 From 41ae35c39241575c63db204c786cb1423c202815 Mon Sep 17 00:00:00 2001
From: "Andrew G. Morgan" <morgan@kernel.org> From: "Andrew G. Morgan" <morgan@kernel.org>
Date: Sat, 27 Nov 2021 21:00:22 -0800 Date: Sat, 27 Nov 2021 21:00:22 -0800
Subject: [PATCH 74/74] Complete Linux-PAM compliance for forked child in su Subject: Complete Linux-PAM compliance for forked child in su and login.
and login.
As documented here: As documented here:
@ -12,8 +11,7 @@ The child that is about to exec*() the user shell is supposed to pam_end()
with PAM_DATA_SILENT. This gives the modules a last chance to do a minor with PAM_DATA_SILENT. This gives the modules a last chance to do a minor
cleanup of the module state before the user's shell is launched. cleanup of the module state before the user's shell is launched.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1950187 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2037212
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2033566
Upstream: http://github.com/util-linux/util-linux/commit/4660286e9cdff6d95b49295674b96f83af10ea36 Upstream: http://github.com/util-linux/util-linux/commit/4660286e9cdff6d95b49295674b96f83af10ea36
Signed-off-by: Andrew G. Morgan <morgan@kernel.org> Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
--- ---
@ -22,24 +20,24 @@ Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
2 files changed, 6 insertions(+) 2 files changed, 6 insertions(+)
diff --git a/login-utils/login.c b/login-utils/login.c diff --git a/login-utils/login.c b/login-utils/login.c
index 8c9e43292..9f50fe03b 100644 index 3657f04cd..c62e91e94 100644
--- a/login-utils/login.c --- a/login-utils/login.c
+++ b/login-utils/login.c +++ b/login-utils/login.c
@@ -1370,6 +1370,9 @@ int main(int argc, char **argv) @@ -1521,6 +1521,9 @@ int main(int argc, char **argv)
childArgv[childArgc++] = NULL; child_argv[child_argc++] = NULL;
+ /* http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end */ + /* http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_end */
+ (void) pam_end(cxt.pamh, PAM_SUCCESS|PAM_DATA_SILENT); + (void) pam_end(cxt.pamh, PAM_SUCCESS|PAM_DATA_SILENT);
+ +
execvp(childArgv[0], childArgv + 1); execvp(child_argv[0], child_argv + 1);
if (!strcmp(childArgv[0], "/bin/sh")) if (!strcmp(child_argv[0], "/bin/sh"))
diff --git a/login-utils/su-common.c b/login-utils/su-common.c diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index c1b1a04e4..825ff1d5a 100644 index afd0ea8ad..7d4826bbc 100644
--- a/login-utils/su-common.c --- a/login-utils/su-common.c
+++ b/login-utils/su-common.c +++ b/login-utils/su-common.c
@@ -1428,6 +1428,9 @@ int su_main(int argc, char **argv, int mode) @@ -1231,6 +1231,9 @@ int su_main(int argc, char **argv, int mode)
if (su->simulate_login && chdir(su->pwd->pw_dir) != 0) if (su->simulate_login && chdir(su->pwd->pw_dir) != 0)
warn(_("warning: cannot change directory to %s"), su->pwd->pw_dir); warn(_("warning: cannot change directory to %s"), su->pwd->pw_dir);
@ -50,5 +48,5 @@ index c1b1a04e4..825ff1d5a 100644
run_shell(su, shell, command, argv + optind, max(0, argc - optind)); run_shell(su, shell, command, argv + optind, max(0, argc - optind));
-- --
2.31.1 2.34.1

View File

@ -1,76 +0,0 @@
From e73085fe74356df96b0e694c906f22f9c71a56c7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Aug 2018 13:49:26 +0200
Subject: [PATCH 5/6] lslogins: add info about single-user output mode
The supported command line synopsis is also
lslogins foo
and it provides different output than
lslogins -l foo
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1614967
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.1 | 11 ++++++++++-
login-utils/lslogins.c | 2 +-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/login-utils/lslogins.1 b/login-utils/lslogins.1
index bd6955f82..effd42790 100644
--- a/login-utils/lslogins.1
+++ b/login-utils/lslogins.1
@@ -9,10 +9,17 @@ lslogins \- display information about known users in the system
.RB [ \-s | \-u [ =\fIUID ]]
.RB [ \-g " \fIgroups\fR]"
.RB [ \-l " \fIlogins\fR]"
+.RB [\fIusername\fR]
.SH DESCRIPTION
.PP
Examine the wtmp and btmp logs, /etc/shadow (if necessary) and /etc/passwd
and output the desired data.
+
+The optional argument \fIusername\fR forces
+.BR lslogins
+to print all available details about the specified user only. In this case the
+output format is different than in case of \fB\-l\fR or \fB\-g\fR.
+
.PP
The default action is to list info about all the users in the system.
.SH OPTIONS
@@ -39,7 +46,8 @@ Show information about supplementary groups.
.TP
\fB\-g\fR, \fB\-\-groups\fR=\fIgroups\fR
Only show data of users belonging to \fIgroups\fR. More than one group
-may be specified; the list has to be comma-separated.
+may be specified; the list has to be comma-separated. The unknown group
+names are ignored.
Note that relation between user and group may be invisible for primary group if
the user is not explicitly specify as group member (e.g. in /etc/group). If the
@@ -55,6 +63,7 @@ Display data containing information about the users' last login sessions.
\fB\-l\fR, \fB\-\-logins\fR=\fIlogins\fR
Only show data of users with a login specified in \fIlogins\fR (user names or user
IDS). More than one login may be specified; the list has to be comma-separated.
+The unknown login names are ignored.
.TP
\fB\-n\fR, \fB\-\-newline\fR
Display each piece of information on a separate line.
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 169962b72..501778e54 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -1293,7 +1293,7 @@ static void __attribute__((__noreturn__)) usage(void)
size_t i;
fputs(USAGE_HEADER, out);
- fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
+ fprintf(out, _(" %s [options] [<username>]\n"), program_invocation_short_name);
fputs(USAGE_SEPARATOR, out);
fputs(_("Display information about known users in the system.\n"), out);
--
2.14.4

View File

@ -1,105 +0,0 @@
From 0aa9097f9ecee3688b8659d7f7414f5fb26e147a Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Aug 2018 14:16:28 +0200
Subject: [PATCH 6/6] lslogins: return 1 on "lslogins nonexisting"
The default behavior for -l and -g is to silently ignore unknown login
names, but this is very confusing when you explicitly specify just one
login name.
Note that the current implementation also prints empty "Last log" for
nonexisting user. It seems ugly.
# lslogins nonexisting
Last logs:
new version:
# lslogins nonexisting
lt-lslogins: cannot found 'nonexisting'
# echo $?
1
The -l and -g behaviour has not been changed.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1614967
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.1 | 3 ++-
login-utils/lslogins.c | 16 +++++++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/login-utils/lslogins.1 b/login-utils/lslogins.1
index effd42790..c831739d9 100644
--- a/login-utils/lslogins.1
+++ b/login-utils/lslogins.1
@@ -18,7 +18,8 @@ and output the desired data.
The optional argument \fIusername\fR forces
.BR lslogins
to print all available details about the specified user only. In this case the
-output format is different than in case of \fB\-l\fR or \fB\-g\fR.
+output format is different than in case of \fB\-l\fR or \fB\-g\fR and unknown
+is \fIusername\fR reported as an error.
.PP
The default action is to list info about all the users in the system.
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 501778e54..6f804aa35 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -266,6 +266,7 @@ struct lslogins_control {
const char *journal_path;
unsigned int selinux_enabled : 1,
+ fail_on_unknown : 1, /* fail if user does not exist */
ulist_on : 1,
noheadings : 1,
notrunc : 1;
@@ -653,6 +654,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
uid_t uid;
errno = 0;
+ errno = 0;
pwd = username ? getpwnam(username) : getpwent();
if (!pwd)
return NULL;
@@ -675,6 +677,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
return NULL;
}
+ errno = 0;
grp = getgrgid(pwd->pw_gid);
if (!grp)
return NULL;
@@ -965,10 +968,16 @@ static int create_usertree(struct lslogins_control *ctl)
if (ctl->ulist_on) {
for (n = 0; n < ctl->ulsiz; n++) {
- if (get_user(ctl, &user, ctl->ulist[n]))
+ int rc = get_user(ctl, &user, ctl->ulist[n]);
+
+ if (ctl->fail_on_unknown && !user) {
+ warnx(_("cannot found '%s'"), ctl->ulist[n]);
+ return -1;
+ }
+ if (rc || !user)
continue;
- if (user) /* otherwise an invalid user name has probably been given */
- tsearch(user, &ctl->usertree, cmp_uid);
+
+ tsearch(user, &ctl->usertree, cmp_uid);
}
} else {
while ((user = get_next_user(ctl)))
@@ -1518,6 +1527,7 @@ int main(int argc, char *argv[])
errx(EXIT_FAILURE, _("Only one user may be specified. Use -l for multiple users."));
logins = argv[optind];
outmode = OUT_PRETTY;
+ ctl->fail_on_unknown = 1;
} else if (argc != optind)
errx(EXIT_FAILURE, _("Only one user may be specified. Use -l for multiple users."));
--
2.14.4

View File

@ -0,0 +1,70 @@
From a80ba745cc54d5ba726e48065aebe6dac50dedd2 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 24 Jan 2022 14:08:08 +0100
Subject: uuidd: fix open/lock state issue
* warn on open/lock state issue
* enable access to /var/lib/libuuid/, because ProtectSystem=strict make it read-only
openat(AT_FDCWD, "/var/lib/libuuid/clock.txt",
O_RDWR|O_CREAT|O_CLOEXEC, 0660) = -1 EROFS (Read-only file system)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2040366
Upstream: http://github.com/util-linux/util-linux/commit/f27876f9c1056bf41fd940d5c4990b4277e0024f
Upstream: http://github.com/util-linux/util-linux/commit/417982d0236a12756923d88e627f5e4facf8951c
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.c | 9 ++++++---
misc-utils/uuidd.service.in | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index fa8db173b..78a37d2e8 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -494,7 +494,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_TIME_UUID:
num = 1;
- __uuid_generate_time(uu, &num);
+ if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, _("Generated time UUID: %s\n"), str);
@@ -504,7 +505,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_RANDOM_UUID:
num = 1;
- __uuid_generate_random(uu, &num);
+ if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, _("Generated random UUID: %s\n"), str);
@@ -513,7 +515,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
reply_len = sizeof(uu);
break;
case UUIDD_OP_BULK_TIME_UUID:
- __uuid_generate_time(uu, &num);
+ if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, P_("Generated time UUID %s "
diff --git a/misc-utils/uuidd.service.in b/misc-utils/uuidd.service.in
index b4c9c4635..e64ca59b5 100644
--- a/misc-utils/uuidd.service.in
+++ b/misc-utils/uuidd.service.in
@@ -18,6 +18,7 @@ ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_UNIX
MemoryDenyWriteExecute=yes
+ReadWritePaths=/var/lib/libuuid/
SystemCallFilter=@default @file-system @basic-io @system-service @signal @io-event @network-io
[Install]
--
2.34.1

View File

@ -1,115 +0,0 @@
From f942ba2c4c14b6bf7720e8316afe1971231553bc Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 31 Aug 2018 12:27:32 +0200
Subject: [PATCH 7/8] libuuid: fix name-based UUIDs
The current version is not fully compatible with RFC4122. It
incorrectly encodes UUID variant
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
where M is UUID version and N is UUID variant.
$ python -c "import uuid ; print(uuid.uuid5(uuid.UUID(int=0), 'foo'))"
aa752cea-8222-5bc8-acd9-555b090c0ccb
^^
Old version:
$ uuidgen --namespace 00000000-0000-0000-0000-000000000000 --name 'foo' --sha1
aa752cea-8222-5bc8-8cd9-555b090c0ccb
^^
Fixed version:
./uuidgen --namespace 00000000-0000-0000-0000-000000000000 --name 'foo' --sha1;
aa752cea-8222-5bc8-acd9-555b090c0ccb
^^
The patch uses uuid_unpack and uuid_pack. It makes code more readable
and allow to access proper octens. The same way we already use for
time and random based UUIDs.
Upstream: http://github.com/karelzak/util-linux/commit/d6ddf07d31dfdc894eb8e7e6842aa856342c526e
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1624877
Addresses: https://github.com/karelzak/util-linux/issues/683
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libuuid/src/gen_uuid.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index a374e75c9..27c135db5 100644
--- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c
@@ -96,9 +96,6 @@
#define THREAD_LOCAL static
#endif
-/* index with UUID_VARIANT_xxx and shift 5 bits */
-static unsigned char variant_bits[] = { 0x00, 0x04, 0x06, 0x07 };
-
#ifdef _WIN32
static void gettimeofday (struct timeval *tv, void *dummy)
{
@@ -566,21 +563,22 @@ void uuid_generate_md5(uuid_t out, const uuid_t ns, const char *name, size_t len
{
UL_MD5_CTX ctx;
char hash[UL_MD5LENGTH];
+ uuid_t buf;
+ struct uuid uu;
ul_MD5Init(&ctx);
- /* hash concatenation of well-known UUID with name */
ul_MD5Update(&ctx, ns, sizeof(uuid_t));
ul_MD5Update(&ctx, (const unsigned char *)name, len);
-
ul_MD5Final((unsigned char *)hash, &ctx);
- memcpy(out, hash, sizeof(uuid_t));
+ assert(sizeof(buf) <= sizeof(hash));
- out[6] &= ~(UUID_TYPE_MASK << UUID_TYPE_SHIFT);
- out[6] |= (UUID_TYPE_DCE_MD5 << UUID_TYPE_SHIFT);
+ memcpy(buf, hash, sizeof(buf));
+ uuid_unpack(buf, &uu);
- out[8] &= ~(UUID_VARIANT_MASK << UUID_VARIANT_SHIFT);
- out[8] |= (variant_bits[UUID_VARIANT_DCE] << UUID_VARIANT_SHIFT);
+ uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000;
+ uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x3000;
+ uuid_pack(&uu, out);
}
/*
@@ -591,20 +589,20 @@ void uuid_generate_sha1(uuid_t out, const uuid_t ns, const char *name, size_t le
{
UL_SHA1_CTX ctx;
char hash[UL_SHA1LENGTH];
+ uuid_t buf;
+ struct uuid uu;
ul_SHA1Init(&ctx);
- /* hash concatenation of well-known UUID with name */
ul_SHA1Update(&ctx, ns, sizeof(uuid_t));
ul_SHA1Update(&ctx, (const unsigned char *)name, len);
-
ul_SHA1Final((unsigned char *)hash, &ctx);
- memcpy(out, hash, sizeof(uuid_t));
+ assert(sizeof(buf) <= sizeof(hash));
- out[6] &= ~(UUID_TYPE_MASK << UUID_TYPE_SHIFT);
- out[6] |= (UUID_TYPE_DCE_SHA1 << UUID_TYPE_SHIFT);
+ memcpy(buf, hash, sizeof(buf));
+ uuid_unpack(buf, &uu);
- out[8] &= ~(UUID_VARIANT_MASK << UUID_VARIANT_SHIFT);
- out[8] |= (variant_bits[UUID_VARIANT_DCE] << UUID_VARIANT_SHIFT);
+ uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000;
+ uu.time_hi_and_version = (uu.time_hi_and_version & 0x0FFF) | 0x5000;
+ uuid_pack(&uu, out);
}
-
--
2.14.4

View File

@ -0,0 +1,51 @@
From 9c45c4bf1a1a02ebaf9e24fd7d81d62c676eda7c Mon Sep 17 00:00:00 2001
From: Portisch <hugo.portisch@yahoo.de>
Date: Mon, 8 Nov 2021 12:31:39 +0100
Subject: sysfs: fallback for partitions not including parent name
Upstream: http://github.com/util-linux/util-linux/commit/9b59641bcec3df9c451eea4c7057751a153a3fcb
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2021462
Signed-off-by: Karel Zak <kzak@redhat.com>
---
lib/sysfs.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/sysfs.c b/lib/sysfs.c
index bb7183319..191d870f6 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -210,9 +210,10 @@ int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *par
d->d_type != DT_UNKNOWN)
return 0;
#endif
+ size_t len = 0;
+
if (parent_name) {
const char *p = parent_name;
- size_t len;
/* /dev/sda --> "sda" */
if (*parent_name == '/') {
@@ -223,14 +224,15 @@ int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *par
}
len = strlen(p);
- if (strlen(d->d_name) <= len)
- return 0;
+ if ((strlen(d->d_name) <= len) || (strncmp(p, d->d_name, len) != 0))
+ len = 0;
+ }
+ if (len > 0) {
/* partitions subdir name is
* "<parent>[:digit:]" or "<parent>p[:digit:]"
*/
- return strncmp(p, d->d_name, len) == 0 &&
- ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1)))
+ return ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1)))
|| isdigit(*(d->d_name + len)));
}
--
2.34.1

View File

@ -1,7 +1,7 @@
From 7cc5bcfcb2340266a6b42370c9c4c02d8a325d5f Mon Sep 17 00:00:00 2001 From 199c328686aac174b0535619e5cea8450016e827 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com> From: Karel Zak <kzak@redhat.com>
Date: Thu, 21 Oct 2021 18:47:40 +0200 Date: Thu, 21 Oct 2021 18:47:40 +0200
Subject: [PATCH 67/74] logger: fix --size use for stdin Subject: logger: fix --size use for stdin
MIME-Version: 1.0 MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
@ -16,22 +16,19 @@ itself.
$ echo "abcd" | logger --stderr --size 3 $ echo "abcd" | logger --stderr --size 3
logger: cannot allocate 18446744073709551597 bytes: Cannot allocate memory logger: cannot allocate 18446744073709551597 bytes: Cannot allocate memory
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2011602
Upstream: http://github.com/util-linux/util-linux/commit/58e4ee082bca100034791a4a74481f263bb30a25 Upstream: http://github.com/util-linux/util-linux/commit/58e4ee082bca100034791a4a74481f263bb30a25
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2033622
Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
--- ---
misc-utils/logger.c | 16 ++++------------ misc-utils/logger.c | 9 +++------
1 file changed, 4 insertions(+), 12 deletions(-) 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/misc-utils/logger.c b/misc-utils/logger.c diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index ebdc56ec2..c20ef05f1 100644 index 5b122de79..43284caeb 100644
--- a/misc-utils/logger.c --- a/misc-utils/logger.c
+++ b/misc-utils/logger.c +++ b/misc-utils/logger.c
@@ -957,11 +957,9 @@ static void logger_stdin(struct logger_ctl *ctl) @@ -976,8 +976,7 @@ static void logger_stdin(struct logger_ctl *ctl)
* update header timestamps and to reflect possible priority changes. int has_header = 1;
* The initial header is generated by logger_open().
*/
- int has_header = 1;
int default_priority = ctl->pri; int default_priority = ctl->pri;
int last_pri = default_priority; int last_pri = default_priority;
- size_t max_usrmsg_size = ctl->max_message_size - strlen(ctl->hdr); - size_t max_usrmsg_size = ctl->max_message_size - strlen(ctl->hdr);
@ -40,7 +37,7 @@ index ebdc56ec2..c20ef05f1 100644
int pri; int pri;
int c; int c;
size_t i; size_t i;
@@ -988,27 +986,21 @@ static void logger_stdin(struct logger_ctl *ctl) @@ -1004,16 +1003,14 @@ static void logger_stdin(struct logger_ctl *ctl)
ctl->pri = default_priority; ctl->pri = default_priority;
if (ctl->pri != last_pri) { if (ctl->pri != last_pri) {
@ -59,18 +56,6 @@ index ebdc56ec2..c20ef05f1 100644
buf[i++] = c; buf[i++] = c;
c = getchar(); c = getchar();
} }
buf[i] = '\0';
- if (i > 0 || !ctl->skip_empty_lines) {
- if (!has_header)
- generate_syslog_header(ctl);
+ if (i > 0 || !ctl->skip_empty_lines)
write_output(ctl, buf);
- has_header = 0;
- }
if (c == '\n') /* discard line terminator */
c = getchar();
-- --
2.31.1 2.34.1

View File

@ -1,25 +0,0 @@
From 2f75c4cdf6992af034bf02de55ad2ea90608e1c0 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 31 Aug 2018 12:48:46 +0200
Subject: [PATCH 8/8] test: update UUID v5 tests
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1624877
Upstream: http://github.com/karelzak/util-linux/commit/7edaf221d610309874e866670dceb4e2f3a04070
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/expected/uuid/oids | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/expected/uuid/oids b/tests/expected/uuid/oids
index 4644848e8..c121cbeee 100644
--- a/tests/expected/uuid/oids
+++ b/tests/expected/uuid/oids
@@ -1,4 +1,4 @@
3d813cbb-47fb-32ba-91df-831e1593ac29
5df41881-3aed-3515-88a7-2f4a814cf09e
2ed6657d-e927-568b-95e1-2665a8aea6a2
-fcdc2122-78d2-59f7-91ed-041a561ef652
+fcdc2122-78d2-59f7-b1ed-041a561ef652
--
2.14.4

View File

@ -1,30 +0,0 @@
From a0753a5452e293da56e1e8579d17b4eb19a7d6a2 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 30 Nov 2018 12:22:48 +0100
Subject: [PATCH 09/14] tests: enlarge backing file for fstab-btrfs
It seems the new limit for Btrfs is 47MiB.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1656437
Upstream: http://github.com/karelzak/util-linux/commit/7174b93dfda08f87228bb7aec6274fe60af581bd
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/mount/fstab-btrfs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/ts/mount/fstab-btrfs b/tests/ts/mount/fstab-btrfs
index 090f52304..54c6bb8ba 100755
--- a/tests/ts/mount/fstab-btrfs
+++ b/tests/ts/mount/fstab-btrfs
@@ -42,7 +42,7 @@ TS_MOUNTPOINT_SUBVOL="$TS_MOUNTPOINT-subvol"
TS_MOUNTPOINT_SUBVOLID="$TS_MOUNTPOINT-subvolid"
TS_MOUNTPOINT_BIND="$TS_MOUNTPOINT-bind"
-ts_device_init 42
+ts_device_init 50
DEVICE=$TS_LODEV
[ -d "$TS_MOUNTPOINT_CREATE" ] || mkdir -p "$TS_MOUNTPOINT_CREATE"
[ -d "$TS_MOUNTPOINT_DEFAULT" ] || mkdir -p "$TS_MOUNTPOINT_DEFAULT"
--
2.17.2

View File

@ -0,0 +1,54 @@
From 006aca565d4c8565baf05296b8e65ca4d5f203d3 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 30 Jul 2021 13:22:54 +0200
Subject: wdctl: Workaround reported boot-status bits not being present in
wd->ident.options
Some watchdog drivers are capable of reporting WDIOF_CARDRESET in their
bootstatus, but they do not advertise this in the options field
returned by the WDIOC_GETSUPPORT ioctl.
This causes wdctl to not print the CARDRESET flag on these devices,
even when the reset was caused by the watchdog and this is being
reported in the WDIOC_GETBOOTSTATUS return.
Add a workaround by or-ing any bits which are set in the status and
bstatus returns into wd->ident.options so that reported flags will
get printend independent of them being advertised as supported in
wd->ident.options.
This will make wdctl print a CARDRESET line when the system was
actually reset by the watchdog while omitting it when it was not
reset by the watchdog. At least on drivers which have the
CARDRESET is missing from info.options problem. On other drivers
the CARDRESET line will always be printend, but the actual reported
value will change.
Upstream: http://github.com/util-linux/util-linux/commit/b1b0259fe42aad1bf0997ce1c03a020ce59e38ab
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2057046
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
sys-utils/wdctl.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c
index 8de5d5a2d..6b9affa0a 100644
--- a/sys-utils/wdctl.c
+++ b/sys-utils/wdctl.c
@@ -419,6 +419,13 @@ static int read_watchdog_from_device(struct wd_device *wd)
ioctl(fd, WDIOC_GETSTATUS, &wd->status);
ioctl(fd, WDIOC_GETBOOTSTATUS, &wd->bstatus);
+ /*
+ * Sometimes supported options like WDIOF_CARDRESET are missing from
+ * ident.options, add anything set in status/bstatus to ident.options.
+ */
+ wd->ident.options |= wd->status;
+ wd->ident.options |= wd->bstatus;
+
if (ioctl(fd, WDIOC_GETTIMEOUT, &wd->timeout) >= 0)
wd->has_timeout = 1;
if (ioctl(fd, WDIOC_GETPRETIMEOUT, &wd->pretimeout) >= 0)
--
2.34.1

View File

@ -0,0 +1,28 @@
From 097fc3427d3221d763f0b1c41923758af2f471a3 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 21 Jul 2022 10:57:36 +0200
Subject: lslogins: remove unexpected debug message
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 9431a50bb..c37df9096 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -562,9 +562,6 @@ static int get_sgroups(gid_t **list, size_t *len, struct passwd *pwd)
*list = xcalloc(1, ngroups * sizeof(gid_t));
-fprintf(stderr, "KZAK>>> alloc '%p' for %s\n", *list, pwd->pw_name);
-
-
/* now for the actual list of GIDs */
if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
return -1;
--
2.36.1

View File

@ -1,81 +0,0 @@
From b48e972b3aa32710ed0495c35b2184f5d3ec9eb0 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 30 Nov 2018 12:24:15 +0100
Subject: [PATCH 10/14] tests: make lsns-netnsid portable
It seems ip(8) link-show command does not provide link-netnsid in all
cases (versions ?). Let's try to use "ip netns list-id" as fallback.
This commit also add possibility to debug the script by $LOG variable.
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1656437
Upstream: http://github.com/karelzak/util-linux/commit/0d79f5805ff2d7651ec70b06753e908cc782857a
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/lsns/netnsid | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/tests/ts/lsns/netnsid b/tests/ts/lsns/netnsid
index 72c14de6c..9d04f28f0 100755
--- a/tests/ts/lsns/netnsid
+++ b/tests/ts/lsns/netnsid
@@ -36,6 +36,7 @@ vethb=lsns-vethb
NS=LSNS-TEST-NETNSID-NS
FIFO=$TS_OUTDIR/FIFO-NETNSID
NULL=/dev/null
+LOG=/dev/null #/root/foo.log
function cleanup {
ip link delete $vetha 2> $NULL || :
@@ -43,24 +44,47 @@ function cleanup {
rm -f $FIFO
}
+echo "==Cleanup" >> $LOG
cleanup
+
+echo "==Create FIFO" >> $LOG
mkfifo $FIFO
+echo "==Netns ADD" >> $LOG
if ip netns add $NS &&
ip link add name $vetha type veth peer name $vethb &&
ip link set $vethb netns $NS; then
+ echo "===Netns EXEC" >> $LOG
ip netns exec $NS dd if=$FIFO bs=1 count=2 of=$NULL 2> $NULL &
PID=$!
+ echo "====PID=$PID" >> $LOG
else
cleanup
ts_skip "failed to initialize"
fi
{
+ echo "==Write to FIFO" >> $LOG
dd if=/dev/zero bs=1 count=1 2> $NULL
{
- ip -o link show dev $vetha > $NULL
+ echo "===IP output" >> $LOG
+ ip -o link show dev $vetha >> $LOG
+
IP_ID=$(ip -o link show dev $vetha | sed -ne 's/.* *link-netnsid *\([0-9]*\)/\1/p')
+ echo "====ip show: IP_ID=$IP_ID" >> $LOG
+
+ if [ "x$IP_ID" = "x" ]; then
+ echo "===IP output list id" >> $LOG
+ ip netns list-id >> $LOG
+
+ IP_ID=$(ip netns list-id | awk "/name: $NS/ { print \$2 }")
+ echo "====ip list-id: IP_ID=$IP_ID" >> $LOG
+ fi
+
+ echo "===LSNS output" >> $LOG
+ $TS_CMD_LSNS -o+NETNSID,NSFS --type net >> $LOG
+
LSNS_ID=$($TS_CMD_LSNS -n -o NETNSID --type net --task $PID | { read VAL; echo $VAL; } )
+ echo "===LSNS_ID=$LSNS_ID" >> $LOG
}
dd if=/dev/zero bs=1 count=1 2> $NULL
} > $FIFO
--
2.17.2

View File

@ -1,4 +1,4 @@
From 818cd2018ca66e804ea30066c44572ca128a24a7 Mon Sep 17 00:00:00 2001 From 53339f53ab71c138578d4102a4e4011344d33b2d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com> From: Karel Zak <kzak@redhat.com>
Date: Tue, 7 Jun 2022 09:11:56 +0200 Date: Tue, 7 Jun 2022 09:11:56 +0200
Subject: lslogins: improve prefixes interpretation Subject: lslogins: improve prefixes interpretation
@ -11,17 +11,17 @@ The patch also makes description of the PWD-EMPTY output field more
explicit. explicit.
Upstream: http://github.com/util-linux/util-linux/commit/c51cba1e838ae7e36a843ec785543492bb8737cd Upstream: http://github.com/util-linux/util-linux/commit/c51cba1e838ae7e36a843ec785543492bb8737cd
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2093166 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
--- ---
login-utils/lslogins.c | 31 +++++++++++++++++++++++++------ login-utils/lslogins.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 6 deletions(-) 1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 6f804aa35..b81afc6c7 100644 index c37df9096..1332a9925 100644
--- a/login-utils/lslogins.c --- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c +++ b/login-utils/lslogins.c
@@ -216,7 +216,7 @@ static const struct lslogins_coldesc coldescs[] = @@ -225,7 +225,7 @@ static const struct lslogins_coldesc coldescs[] =
{ {
[COL_USER] = { "USER", N_("user name"), N_("Username"), 0.1, SCOLS_FL_NOEXTREMES }, [COL_USER] = { "USER", N_("user name"), N_("Username"), 0.1, SCOLS_FL_NOEXTREMES },
[COL_UID] = { "UID", N_("user ID"), "UID", 1, SCOLS_FL_RIGHT}, [COL_UID] = { "UID", N_("user ID"), "UID", 1, SCOLS_FL_RIGHT},
@ -29,8 +29,8 @@ index 6f804aa35..b81afc6c7 100644
+ [COL_PWDEMPTY] = { "PWD-EMPTY", N_("password not defined"), N_("Password not required (empty)"), 1, SCOLS_FL_RIGHT }, + [COL_PWDEMPTY] = { "PWD-EMPTY", N_("password not defined"), N_("Password not required (empty)"), 1, SCOLS_FL_RIGHT },
[COL_PWDDENY] = { "PWD-DENY", N_("login by password disabled"), N_("Login by password disabled"), 1, SCOLS_FL_RIGHT }, [COL_PWDDENY] = { "PWD-DENY", N_("login by password disabled"), N_("Login by password disabled"), 1, SCOLS_FL_RIGHT },
[COL_PWDLOCK] = { "PWD-LOCK", N_("password defined, but locked"), N_("Password is locked"), 1, SCOLS_FL_RIGHT }, [COL_PWDLOCK] = { "PWD-LOCK", N_("password defined, but locked"), N_("Password is locked"), 1, SCOLS_FL_RIGHT },
[COL_NOLOGIN] = { "NOLOGIN", N_("log in disabled by nologin(8) or pam_nologin(8)"), N_("No login"), 1, SCOLS_FL_RIGHT }, [COL_PWDMETHOD] = { "PWD-METHOD", N_("password encryption method"), N_("Password encryption method"), 0.1 },
@@ -755,16 +755,24 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c @@ -817,23 +817,42 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
break; break;
case COL_PWDEMPTY: case COL_PWDEMPTY:
if (shadow) { if (shadow) {
@ -59,8 +59,7 @@ index 6f804aa35..b81afc6c7 100644
user->pwd_deny = STATUS_TRUE; user->pwd_deny = STATUS_TRUE;
} else } else
user->pwd_deny = STATUS_UNKNOWN; user->pwd_deny = STATUS_UNKNOWN;
@@ -772,7 +780,18 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c break;
case COL_PWDLOCK: case COL_PWDLOCK:
if (shadow) { if (shadow) {
- if (*shadow->sp_pwdp == '!' && valid_pwd(shadow->sp_pwdp + 1)) - if (*shadow->sp_pwdp == '!' && valid_pwd(shadow->sp_pwdp + 1))
@ -79,6 +78,15 @@ index 6f804aa35..b81afc6c7 100644
user->pwd_lock = STATUS_TRUE; user->pwd_lock = STATUS_TRUE;
} else } else
user->pwd_lock = STATUS_UNKNOWN; user->pwd_lock = STATUS_UNKNOWN;
@@ -842,7 +861,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
if (shadow) {
const char *p = shadow->sp_pwdp;
- if (*p == '!' || *p == '*')
+ while (p && (*p == '!' || *p == '*'))
p++;
user->pwd_method = get_pwd_method(p, NULL, NULL);
} else
-- --
2.36.1 2.36.1

View File

@ -1,111 +0,0 @@
From c2b650ebe33a001b3bf19912b136dbbff5495600 Mon Sep 17 00:00:00 2001
From: Frank Schaefer <kelledin@gmail.com>
Date: Tue, 10 Jul 2018 20:21:02 -0500
Subject: [PATCH 11/14] tests: break up large strings for PySys_WriteStdout()
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1656437
Upstream: http://github.com/karelzak/util-linux/commit/8a12ab57755afc36546834f175ef0b9e9376ba59
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/python/fs.c | 56 ++++++++++++++++++++++++++++++++++----------
1 file changed, 43 insertions(+), 13 deletions(-)
diff --git a/libmount/python/fs.c b/libmount/python/fs.c
index d6490d248..634a914ef 100644
--- a/libmount/python/fs.c
+++ b/libmount/python/fs.c
@@ -63,32 +63,62 @@ static PyObject *Fs_get_devno(FsObject *self)
return PyObjectResultInt(mnt_fs_get_devno(self->fs));
}
+static void _dump_debug_string(const char *lead, const char *s, char quote)
+{
+ /* PySys_WriteStdout() will automatically truncate any '%s' token
+ * longer than a certain length (documented as 1000 bytes, but we
+ * give ourselves some margin here just in case). The only way I
+ * know to get around this is to print such strings in bite-sized
+ * chunks.
+ */
+ static const unsigned int _PY_MAX_LEN = 900;
+ static const char *_PY_MAX_LEN_FMT = "%.900s";
+ unsigned int len;
+
+ if (lead != NULL)
+ PySys_WriteStdout("%s", lead);
+
+ if (quote != 0)
+ PySys_WriteStdout("%c", quote);
+
+ for (len = strlen(s); len > _PY_MAX_LEN; len -= _PY_MAX_LEN, s += _PY_MAX_LEN)
+ PySys_WriteStdout(_PY_MAX_LEN_FMT, s);
+
+ if (len > 0)
+ PySys_WriteStdout(_PY_MAX_LEN_FMT, s);
+
+ if (quote != 0)
+ PySys_WriteStdout("%c\n", quote);
+ else
+ PySys_WriteStdout("\n");
+}
+
#define Fs_print_debug_HELP "print_debug()\n\n"
static PyObject *Fs_print_debug(FsObject *self)
{
PySys_WriteStdout("------ fs: %p\n", self->fs);
- PySys_WriteStdout("source: %s\n", mnt_fs_get_source(self->fs));
- PySys_WriteStdout("target: %s\n", mnt_fs_get_target(self->fs));
- PySys_WriteStdout("fstype: %s\n", mnt_fs_get_fstype(self->fs));
+ _dump_debug_string("source: ", mnt_fs_get_source(self->fs), 0);
+ _dump_debug_string("target: ", mnt_fs_get_target(self->fs), 0);
+ _dump_debug_string("fstype: ", mnt_fs_get_fstype(self->fs), 0);
if (mnt_fs_get_options(self->fs))
- PySys_WriteStdout("optstr: %s\n", mnt_fs_get_options(self->fs));
+ _dump_debug_string("optstr: ", mnt_fs_get_options(self->fs), 0);
if (mnt_fs_get_vfs_options(self->fs))
- PySys_WriteStdout("VFS-optstr: %s\n", mnt_fs_get_vfs_options(self->fs));
+ _dump_debug_string("VFS-optstr: ", mnt_fs_get_vfs_options(self->fs), 0);
if (mnt_fs_get_fs_options(self->fs))
- PySys_WriteStdout("FS-opstr: %s\n", mnt_fs_get_fs_options(self->fs));
+ _dump_debug_string("FS-opstr: ", mnt_fs_get_fs_options(self->fs), 0);
if (mnt_fs_get_user_options(self->fs))
- PySys_WriteStdout("user-optstr: %s\n", mnt_fs_get_user_options(self->fs));
+ _dump_debug_string("user-optstr: ", mnt_fs_get_user_options(self->fs), 0);
if (mnt_fs_get_optional_fields(self->fs))
- PySys_WriteStdout("optional-fields: '%s'\n", mnt_fs_get_optional_fields(self->fs));
+ _dump_debug_string("optional-fields: ", mnt_fs_get_optional_fields(self->fs), '\'');
if (mnt_fs_get_attributes(self->fs))
- PySys_WriteStdout("attributes: %s\n", mnt_fs_get_attributes(self->fs));
+ _dump_debug_string("attributes: ", mnt_fs_get_attributes(self->fs), 0);
if (mnt_fs_get_root(self->fs))
- PySys_WriteStdout("root: %s\n", mnt_fs_get_root(self->fs));
+ _dump_debug_string("root: ", mnt_fs_get_root(self->fs), 0);
if (mnt_fs_get_swaptype(self->fs))
- PySys_WriteStdout("swaptype: %s\n", mnt_fs_get_swaptype(self->fs));
+ _dump_debug_string("swaptype: ", mnt_fs_get_swaptype(self->fs), 0);
if (mnt_fs_get_size(self->fs))
PySys_WriteStdout("size: %jd\n", mnt_fs_get_size(self->fs));
if (mnt_fs_get_usedsize(self->fs))
@@ -97,7 +127,7 @@ static PyObject *Fs_print_debug(FsObject *self)
PySys_WriteStdout("priority: %d\n", mnt_fs_get_priority(self->fs));
if (mnt_fs_get_bindsrc(self->fs))
- PySys_WriteStdout("bindsrc: %s\n", mnt_fs_get_bindsrc(self->fs));
+ _dump_debug_string("bindsrc: ", mnt_fs_get_bindsrc(self->fs), 0);
if (mnt_fs_get_freq(self->fs))
PySys_WriteStdout("freq: %d\n", mnt_fs_get_freq(self->fs));
if (mnt_fs_get_passno(self->fs))
@@ -112,7 +142,7 @@ static PyObject *Fs_print_debug(FsObject *self)
if (mnt_fs_get_tid(self->fs))
PySys_WriteStdout("tid: %d\n", mnt_fs_get_tid(self->fs));
if (mnt_fs_get_comment(self->fs))
- PySys_WriteStdout("comment: '%s'\n", mnt_fs_get_comment(self->fs));
+ _dump_debug_string("comment: ", mnt_fs_get_comment(self->fs), '\'');
return UL_IncRef(self);
}
/*
--
2.17.2

View File

@ -1,33 +0,0 @@
From 0afd0613fc738659fb0ff490e4e069366dee4a94 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 10 Dec 2018 16:25:08 +0100
Subject: [PATCH 12/14] libmount: (umount) make mnt_stat_mountpoin() usable for
relative paths
# mount -o loop devicefile /mnt/test
# umount devicefile
umount: devicefile: not mounted.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653781
Upstream: http://github.com/karelzak/util-linux/commit/2859592ecb7b48d47d2e34d589ea35f76e329416
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index fd98d0529..c36187c07 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -121,7 +121,7 @@ static int fstype_cmp(const void *v1, const void *v2)
int mnt_stat_mountpoint(const char *target, struct stat *st)
{
#ifdef AT_NO_AUTOMOUNT
- return fstatat(-1, target, st, AT_NO_AUTOMOUNT);
+ return fstatat(AT_FDCWD, target, st, AT_NO_AUTOMOUNT);
#else
return stat(target, st);
#endif
--
2.17.2

View File

@ -0,0 +1,38 @@
From c269e116ea4d9e96a5f5801aecf1f624199fa6ec Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 7 Jun 2022 09:46:54 +0200
Subject: lslogins: fix free(): invalid pointer
Upstream: http://github.com/util-linux/util-linux/commit/890d4d3f236e2d28db35ea9bc9dc3e5e35db975c
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 1332a9925..ff4386d1b 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -488,7 +488,7 @@ static int parse_utmpx(const char *path, size_t *nrecords, struct utmpx **record
/* optimize allocation according to file size, the realloc() below is
* just fallback only */
- if (stat(path, &st) == 0 && (size_t) st.st_size > sizeof(struct utmpx)) {
+ if (stat(path, &st) == 0 && (size_t) st.st_size >= sizeof(struct utmpx)) {
imax = st.st_size / sizeof(struct utmpx);
ary = xmalloc(imax * sizeof(struct utmpx));
}
@@ -1007,6 +1007,9 @@ static void free_ctl(struct lslogins_control *ctl)
{
size_t n = 0;
+ if (!ctl)
+ return;
+
free(ctl->wtmp);
free(ctl->btmp);
--
2.36.1

View File

@ -1,65 +0,0 @@
From 5aea6937edf77a753e0d504bb637214e116aaed2 Mon Sep 17 00:00:00 2001
From: KyleMahlkuch <Kyle.Mahlkuch@ibm.com>
Date: Mon, 25 Jun 2018 14:52:01 -0500
Subject: [PATCH 13/14] libfdisk: Fix multipath partition seperators for
user-friendly names
The current code assumes "-part" is the only partition sepereator
but this is not true for some distros.
For example in Ubuntu 18.04 fdisk does not print the correct names for
mpatha:
~# ls -l /dev/mapper/mpatha*
lrwxrwxrwx 1 root root 7 Feb 1 04:39 /dev/mapper/mpatha -> ../dm-0
lrwxrwxrwx 1 root root 7 Feb 1 04:38 /dev/mapper/mpatha1 -> ../dm-4
lrwxrwxrwx 1 root root 7 Feb 1 04:38 /dev/mapper/mpatha2 -> ../dm-5
lrwxrwxrwx 1 root root 7 Feb 1 04:38 /dev/mapper/mpatha3 -> ../dm-6
~# fdisk -l /dev/mapper/mpatha
Device Boot Start End Sectors Size Id Type
/dev/mapper/mpatha-part1 2048 419432447 419430400 200G 83 Linux
/dev/mapper/mpatha-part2 419432448 838862847 419430400 200G 83 Linux
/dev/mapper/mpatha-part3 838862848 1258291199 419428352 200G 83 Linux
Instead of assuming a partition seperator of "-part" this patch uses
access to check the file system for a partition seperator of "p" or
the absense of a partition seperator. If neither of these work the patch
defaults to "-part" like we had before this patch.
Upstream: http://github.com/karelzak/util-linux/commit/73775189767195f1d9f5b6b6f6a54e51f61c4356
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1655650
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libfdisk/src/utils.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/libfdisk/src/utils.c b/libfdisk/src/utils.c
index 5ba9e0466..54e28b2fa 100644
--- a/libfdisk/src/utils.c
+++ b/libfdisk/src/utils.c
@@ -153,7 +153,20 @@ char *fdisk_partname(const char *dev, size_t partno)
if ((strncmp(dev, _PATH_DEV_BYID, sizeof(_PATH_DEV_BYID) - 1) == 0) ||
strncmp(dev, _PATH_DEV_BYPATH, sizeof(_PATH_DEV_BYPATH) - 1) == 0 ||
strncmp(dev, "/dev/mapper", sizeof("/dev/mapper") - 1) == 0) {
- p = "-part";
+ asprintf(&res, "%.*s%zu", w, dev, partno);
+ if (access(res, F_OK) == 0){
+ p = "";
+ } else {
+ /* check for partition seperator "p" */
+ p = "p";
+ free(res);
+ asprintf(&res, "%.*s%s%zu", w, dev, p, partno);
+ if (access(res, F_OK) != 0){
+ /* otherwise, default to "-path" */
+ p = "-part";
+ }
+ }
+ free(res);
}
if (asprintf(&res, "%.*s%s%zu", w, dev, p, partno) <= 0)
--
2.17.2

View File

@ -0,0 +1,30 @@
From 1c4ee8348e220b633d676214fd585ee2b3945cf6 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 6 Jun 2022 16:14:14 +0200
Subject: login-utils/logindefs: fix compiler warning
[-Werror=format-truncation=]
Upstream: http://github.com/util-linux/util-linux/commit/977f98ee34ca002cb5301c2d3a5953c754f813ec
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/logindefs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/login-utils/logindefs.c b/login-utils/logindefs.c
index 97150dc28..95631223a 100644
--- a/login-utils/logindefs.c
+++ b/login-utils/logindefs.c
@@ -521,7 +521,8 @@ int get_hushlogin_status(struct passwd *pwd, int force_check)
if (strlen(pwd->pw_dir) + strlen(file) + 2 > sizeof(buf))
continue;
- sprintf(buf, "%s/%s", pwd->pw_dir, file);
+ if (snprintf(buf, sizeof(buf), "%s/%s", pwd->pw_dir, file) < 0)
+ continue;
if (force_check) {
uid_t ruid = getuid();
--
2.36.1

View File

@ -1,136 +0,0 @@
From 64473a830dc93e7fcd246a64bb8389d66f0034b8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 29 Nov 2018 13:21:36 +0100
Subject: [PATCH 14/14] blkid: make PART_ENTRY_* tags optional (add
--no-part-details)
blkid(8) returns information from partition table also for empty
partitions. This is necessary for example for udev, but it could be
confusing if you care about on-device content only.
Default:
# blkid -p /dev/md0p1; echo $?
/dev/md0p1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="6d8796b1-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="204800" PART_ENTRY_DISK="9:0"
0
With --no-part-details:
# blkid -p /dev/md0p1 --no-part-details; echo $?
2
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653413
Upstream: http://github.com/karelzak/util-linux/commit/5e91d5dd716ebc6144bcb0cabb0ec847a678be9e
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/blkid.8 | 6 +++++-
misc-utils/blkid.c | 15 +++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/misc-utils/blkid.8 b/misc-utils/blkid.8
index 13b5edb4d..d1cec1dea 100644
--- a/misc-utils/blkid.8
+++ b/misc-utils/blkid.8
@@ -35,6 +35,7 @@ blkid \- locate/print block device attributes
.IR list ]
.RB [ \-\-usages
.IR list ]
+.RB [ \-\-no\-part\-details ]
.IR device " ..."
.IP \fBblkid\fR
@@ -114,6 +115,9 @@ Don't encode non-printing characters. The non-printing characters are encoded
by ^ and M- notation by default. Note that the \fB\-\-output udev\fR output format uses
a different encoding which cannot be disabled.
.TP
+\fB\-D\fR, \fB\-\-no\-part\-details\fR
+Don't print information (PART_ENTRY_* tags) from partition table in low-level probing mode.
+.TP
\fB\-g\fR, \fB\-\-garbage\-collect\fR
Perform a garbage collection pass on the blkid cache to remove
devices which no longer exist.
@@ -224,7 +228,7 @@ Note that low-level probing also returns information about partition table type
(PTTYPE tag) and partitions (PART_ENTRY_* tags). The tag names produced by
low-level probing are based on names used internally by libblkid and it may be
different than when executed without \fB\-\-probe\fR (for example PART_ENTRY_UUID= vs
-PARTUUID=).
+PARTUUID=). See also \fB\-\-no\-part\-details\fR.
.TP
\fB\-s\fR, \fB\-\-match\-tag\fR \fItag\fR
For each (specified) device, show only the tags that match
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index 4cd85317f..61a6994c2 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -58,6 +58,7 @@ struct blkid_control {
lowprobe:1,
lowprobe_superblocks:1,
lowprobe_topology:1,
+ no_part_details:1,
raw_chars:1;
};
@@ -101,6 +102,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_( " -O, --offset <offset> probe at the given offset\n"), out);
fputs(_( " -u, --usages <list> filter by \"usage\" (e.g. -u filesystem,raid)\n"), out);
fputs(_( " -n, --match-types <list> filter by filesystem type (e.g. -n vfat,ext3)\n"), out);
+ fputs(_( " -D, --no-part-details don't print info from partition table\n"), out);
fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(28));
@@ -444,7 +446,7 @@ done:
return rc;
}
-static int lowprobe_superblocks(blkid_probe pr)
+static int lowprobe_superblocks(blkid_probe pr, struct blkid_control *ctl)
{
struct stat st;
int rc, fd = blkid_probe_get_fd(pr);
@@ -470,7 +472,8 @@ static int lowprobe_superblocks(blkid_probe pr)
return 0; /* partition table detected */
}
- blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
+ if (!ctl->no_part_details)
+ blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
blkid_probe_enable_superblocks(pr, 1);
return blkid_do_safeprobe(pr);
@@ -509,7 +512,7 @@ static int lowprobe_device(blkid_probe pr, const char *devname,
if (ctl->lowprobe_topology)
rc = lowprobe_topology(pr);
if (rc >= 0 && ctl->lowprobe_superblocks)
- rc = lowprobe_superblocks(pr);
+ rc = lowprobe_superblocks(pr, ctl);
if (rc < 0)
goto done;
@@ -661,6 +664,7 @@ int main(int argc, char **argv)
static const struct option longopts[] = {
{ "cache-file", required_argument, NULL, 'c' },
{ "no-encoding", no_argument, NULL, 'd' },
+ { "no-part-details", no_argument, NULL, 'D' },
{ "garbage-collect", no_argument, NULL, 'g' },
{ "output", required_argument, NULL, 'o' },
{ "list-filesystems", no_argument, NULL, 'k' },
@@ -694,7 +698,7 @@ int main(int argc, char **argv)
strutils_set_exitcode(BLKID_EXIT_OTHER);
while ((c = getopt_long (argc, argv,
- "c:dghilL:n:ko:O:ps:S:t:u:U:w:Vv", longopts, NULL)) != -1) {
+ "c:DdghilL:n:ko:O:ps:S:t:u:U:w:Vv", longopts, NULL)) != -1) {
err_exclusive_options(c, NULL, excl, excl_st);
@@ -705,6 +709,9 @@ int main(int argc, char **argv)
case 'd':
ctl.raw_chars = 1;
break;
+ case 'D':
+ ctl.no_part_details = 1;
+ break;
case 'L':
ctl.eval = 1;
search_value = xstrdup(optarg);
--
2.17.2

View File

@ -0,0 +1,38 @@
From 3ceddbb1238e13a51efbe23119c885568e820e69 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 2 Jun 2022 16:55:49 +0200
Subject: uuidd: allow AF_INET in systemd service
libuuid uses
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)
to get MAC address for time based UUIDs, but there is
RestrictAddressFamilies=AF_UNIX
in uuidd service file ...
Fixes: https://github.com/util-linux/util-linux/issues/1704
Upstream: http://github.com/util-linux/util-linux/commit/304b4dc4936b115ca33af5325c3b04d0997c1353
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2092943
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.service.in | 1 -
1 file changed, 1 deletion(-)
diff --git a/misc-utils/uuidd.service.in b/misc-utils/uuidd.service.in
index e64ca59b5..64580287f 100644
--- a/misc-utils/uuidd.service.in
+++ b/misc-utils/uuidd.service.in
@@ -16,7 +16,6 @@ PrivateUsers=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
-RestrictAddressFamilies=AF_UNIX
MemoryDenyWriteExecute=yes
ReadWritePaths=/var/lib/libuuid/
SystemCallFilter=@default @file-system @basic-io @system-service @signal @io-event @network-io
--
2.36.1

View File

@ -1,132 +0,0 @@
From 9bccbbf06a91f4e7bf5c0cddadf18265dc2e9e4b Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 4 Mar 2019 16:42:30 +0100
Subject: [PATCH 15/19] tests: add missing ts_check_test_command calls
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
Upstream: http://github.com/karelzak/util-linux/commit/19e00ec9e9e9c36305cf2dd163d0333e2d72c671
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/fsck/ismounted | 2 ++
tests/ts/hexdump/format-strings | 1 +
tests/ts/hexdump/highlighting | 1 +
tests/ts/ipcs/limits | 1 +
tests/ts/ipcs/limits2 | 1 +
tests/ts/ipcs/mk-rm-msg | 1 +
tests/ts/ipcs/mk-rm-sem | 1 +
tests/ts/ipcs/mk-rm-shm | 1 +
tests/ts/misc/swaplabel | 1 +
9 files changed, 10 insertions(+)
diff --git a/tests/ts/fsck/ismounted b/tests/ts/fsck/ismounted
index 2a55907a7..7d1fe6273 100755
--- a/tests/ts/fsck/ismounted
+++ b/tests/ts/fsck/ismounted
@@ -22,6 +22,8 @@ ts_init "$*"
ts_check_test_command "$TS_CMD_FDISK"
ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_HELPER_ISMOUNTED"
ts_skip_nonroot
ts_check_losetup
diff --git a/tests/ts/hexdump/format-strings b/tests/ts/hexdump/format-strings
index e6f9229a5..f2dc6a89b 100755
--- a/tests/ts/hexdump/format-strings
+++ b/tests/ts/hexdump/format-strings
@@ -23,6 +23,7 @@ FILES="$TS_TOPDIR/ts/hexdump/files"
ts_init "$*"
ts_check_test_command "$TS_CMD_HEXDUMP"
+ts_check_test_command "$TS_HELPER_SYSINFO"
# on big endian systems some of the subtests have different expected output
BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order)
diff --git a/tests/ts/hexdump/highlighting b/tests/ts/hexdump/highlighting
index cf78f7b96..e57757978 100755
--- a/tests/ts/hexdump/highlighting
+++ b/tests/ts/hexdump/highlighting
@@ -25,6 +25,7 @@ ADDRFMT='-e "%07.7_Ax\n"'
ts_init "$*"
ts_check_test_command "$TS_CMD_HEXDUMP"
+ts_check_test_command "$TS_HELPER_SYSINFO"
# on big endian systems some of the subtests have different expected output
BYTE_ORDER=$($TS_HELPER_SYSINFO byte-order)
diff --git a/tests/ts/ipcs/limits b/tests/ts/ipcs/limits
index 7b64b3c17..671f23c77 100755
--- a/tests/ts/ipcs/limits
+++ b/tests/ts/ipcs/limits
@@ -23,6 +23,7 @@ TS_DESC="limits overflow"
ts_init "$*"
ts_check_test_command "$TS_CMD_IPCS"
+ts_check_test_command "$TS_HELPER_SYSINFO"
ts_skip_nonroot
ts_check_prog "bc"
diff --git a/tests/ts/ipcs/limits2 b/tests/ts/ipcs/limits2
index d23c41a35..77ad70f9b 100755
--- a/tests/ts/ipcs/limits2
+++ b/tests/ts/ipcs/limits2
@@ -23,6 +23,7 @@ TS_DESC="basic limits"
ts_init "$*"
ts_check_test_command "$TS_CMD_IPCS"
+ts_check_test_command "$TS_HELPER_SYSINFO"
ts_check_prog "bc"
. $TS_SELF/functions.sh
diff --git a/tests/ts/ipcs/mk-rm-msg b/tests/ts/ipcs/mk-rm-msg
index 25460e25d..de3682e87 100755
--- a/tests/ts/ipcs/mk-rm-msg
+++ b/tests/ts/ipcs/mk-rm-msg
@@ -21,6 +21,7 @@ ts_init "$*"
ts_check_test_command "$TS_CMD_IPCS"
ts_check_test_command "$TS_CMD_IPCMK"
ts_check_test_command "$TS_CMD_IPCRM"
+ts_check_test_command "$TS_HELPER_SYSINFO"
. $TS_SELF/functions.sh
diff --git a/tests/ts/ipcs/mk-rm-sem b/tests/ts/ipcs/mk-rm-sem
index 61e0cfdef..d7b505f7c 100755
--- a/tests/ts/ipcs/mk-rm-sem
+++ b/tests/ts/ipcs/mk-rm-sem
@@ -21,6 +21,7 @@ ts_init "$*"
ts_check_test_command "$TS_CMD_IPCS"
ts_check_test_command "$TS_CMD_IPCMK"
ts_check_test_command "$TS_CMD_IPCRM"
+ts_check_test_command "$TS_HELPER_SYSINFO"
. $TS_SELF/functions.sh
diff --git a/tests/ts/ipcs/mk-rm-shm b/tests/ts/ipcs/mk-rm-shm
index 838fb3f21..c21547b82 100755
--- a/tests/ts/ipcs/mk-rm-shm
+++ b/tests/ts/ipcs/mk-rm-shm
@@ -21,6 +21,7 @@ ts_init "$*"
ts_check_test_command "$TS_CMD_IPCS"
ts_check_test_command "$TS_CMD_IPCMK"
ts_check_test_command "$TS_CMD_IPCRM"
+ts_check_test_command "$TS_HELPER_SYSINFO"
. $TS_SELF/functions.sh
diff --git a/tests/ts/misc/swaplabel b/tests/ts/misc/swaplabel
index 646304508..22858b0ac 100755
--- a/tests/ts/misc/swaplabel
+++ b/tests/ts/misc/swaplabel
@@ -20,6 +20,7 @@ ts_init "$*"
ts_check_test_command "$TS_CMD_MKSWAP"
ts_check_test_command "$TS_CMD_SWAPLABEL"
+ts_check_test_command "$TS_HELPER_SYSINFO"
# fallocate does not work on most file systems
function fallocate_or_skip()
--
2.20.1

View File

@ -0,0 +1,28 @@
From bf0cd2995c5e34338703105c62e49a785c6c9dcc Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 3 Jun 2022 09:07:09 +0200
Subject: uuidd: remove also PrivateNetwork=yes from systemd service
Fixes: https://github.com/util-linux/util-linux/issues/1704
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2092943
Upstream: http://github.com/util-linux/util-linux/commit/c9671a3cf7738bb81e1cbef2f56485a36c6e7623
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.service.in | 1 -
1 file changed, 1 deletion(-)
diff --git a/misc-utils/uuidd.service.in b/misc-utils/uuidd.service.in
index 64580287f..4ad6d97c9 100644
--- a/misc-utils/uuidd.service.in
+++ b/misc-utils/uuidd.service.in
@@ -11,7 +11,6 @@ Group=uuidd
ProtectSystem=strict
ProtectHome=yes
PrivateDevices=yes
-PrivateNetwork=yes
PrivateUsers=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
--
2.36.1

View File

@ -0,0 +1,31 @@
From 338d5f2876c54e5d811100ba816d3a6dec00ab11 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 29 Apr 2022 10:11:49 +0200
Subject: lsirq: improve --sort IRQ
IRQ column mixes numbers and text, it seems better to use strverscmp()
rather than classic strcmp().
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2078787
Upstream: http://github.com/util-linux/util-linux/commit/d382861c0815ff241fb2844a2a896f0fb1c7b73e
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/irq-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c
index 350675394..22080b96d 100644
--- a/sys-utils/irq-common.c
+++ b/sys-utils/irq-common.c
@@ -371,7 +371,7 @@ static inline int cmp_delta(const struct irq_info *a,
static inline int cmp_interrupts(const struct irq_info *a,
const struct irq_info *b)
{
- return (strcmp(a->irq, b->irq) > 0) ? 1 : 0;
+ return (strverscmp(a->irq, b->irq) > 0) ? 1 : 0;
}
static void sort_result(struct irq_output *out,
--
2.36.1

View File

@ -1,357 +0,0 @@
From 748fbfa9b1bb3b64b3fbc6b1e51d260d8376c791 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 4 Mar 2019 17:10:04 +0100
Subject: [PATCH 16/19] tests: add --use-system-commands
This change allows to use commands from $PATH rather than from
$top_builddir. There two basic use cases:
* check differences between installed and git version
run.sh --use-system-command --show-diff
* check system binaries by upstream tests (for example tests from
src.rpm package)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
Upstream: http://github.com/karelzak/util-linux/commit/43b4a4d3c720a4e65fe9de884cd73e0b1b94fbe
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/commands.sh | 194 ++++++++++++++++++++++-----------------------
tests/functions.sh | 34 ++++++--
tests/run.sh | 33 +++++---
3 files changed, 146 insertions(+), 115 deletions(-)
diff --git a/tests/commands.sh b/tests/commands.sh
index 1be2d25b4..93100caf6 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -2,105 +2,105 @@
TS_TESTUSER=${TS_TESTUSER:-"nobody"}
# helpers
-TS_HELPER_BYTESWAP="$top_builddir/test_byteswap"
-TS_HELPER_CPUSET="$top_builddir/test_cpuset"
-TS_HELPER_DMESG="$top_builddir/test_dmesg"
-TS_HELPER_ISLOCAL="$top_builddir/test_islocal"
-TS_HELPER_ISMOUNTED="$top_builddir/test_ismounted"
-TS_HELPER_LIBFDISK_GPT="$top_builddir/test_fdisk_gpt"
-TS_HELPER_LIBFDISK_MKPART="$top_builddir/sample-fdisk-mkpart"
-TS_HELPER_LIBMOUNT_CONTEXT="$top_builddir/test_mount_context"
-TS_HELPER_LIBFDISK_MKPART_FULLSPEC="$top_builddir/sample-fdisk-mkpart-fullspec"
-TS_HELPER_LIBMOUNT_LOCK="$top_builddir/test_mount_lock"
-TS_HELPER_LIBMOUNT_OPTSTR="$top_builddir/test_mount_optstr"
-TS_HELPER_LIBMOUNT_TABDIFF="$top_builddir/test_mount_tab_diff"
-TS_HELPER_LIBMOUNT_TAB="$top_builddir/test_mount_tab"
-TS_HELPER_LIBMOUNT_UPDATE="$top_builddir/test_mount_tab_update"
-TS_HELPER_LIBMOUNT_UTILS="$top_builddir/test_mount_utils"
-TS_HELPER_LIBMOUNT_DEBUG="$top_builddir/test_mount_debug"
-TS_HELPER_LIBSMARTCOLS_FROMFILE="$top_builddir/sample-scols-fromfile"
-TS_HELPER_LIBSMARTCOLS_TITLE="$top_builddir/sample-scols-title"
+TS_HELPER_BYTESWAP="${ts_helpersdir}test_byteswap"
+TS_HELPER_CPUSET="${ts_helpersdir}test_cpuset"
+TS_HELPER_DMESG="${ts_helpersdir}test_dmesg"
+TS_HELPER_ISLOCAL="${ts_helpersdir}test_islocal"
+TS_HELPER_ISMOUNTED="${ts_helpersdir}test_ismounted"
+TS_HELPER_LIBFDISK_GPT="${ts_helpersdir}test_fdisk_gpt"
+TS_HELPER_LIBFDISK_MKPART="${ts_helpersdir}sample-fdisk-mkpart"
+TS_HELPER_LIBMOUNT_CONTEXT="${ts_helpersdir}test_mount_context"
+TS_HELPER_LIBFDISK_MKPART_FULLSPEC="${ts_helpersdir}sample-fdisk-mkpart-fullspec"
+TS_HELPER_LIBMOUNT_LOCK="${ts_helpersdir}test_mount_lock"
+TS_HELPER_LIBMOUNT_OPTSTR="${ts_helpersdir}test_mount_optstr"
+TS_HELPER_LIBMOUNT_TABDIFF="${ts_helpersdir}test_mount_tab_diff"
+TS_HELPER_LIBMOUNT_TAB="${ts_helpersdir}test_mount_tab"
+TS_HELPER_LIBMOUNT_UPDATE="${ts_helpersdir}test_mount_tab_update"
+TS_HELPER_LIBMOUNT_UTILS="${ts_helpersdir}test_mount_utils"
+TS_HELPER_LIBMOUNT_DEBUG="${ts_helpersdir}test_mount_debug"
+TS_HELPER_LIBSMARTCOLS_FROMFILE="${ts_helpersdir}sample-scols-fromfile"
+TS_HELPER_LIBSMARTCOLS_TITLE="${ts_helpersdir}sample-scols-title"
TS_HELPER_PYLIBMOUNT_CONTEXT="$top_srcdir/libmount/python/test_mount_context.py"
TS_HELPER_PYLIBMOUNT_TAB="$top_srcdir/libmount/python/test_mount_tab.py"
TS_HELPER_PYLIBMOUNT_UPDATE="$top_srcdir/libmount/python/test_mount_tab_update.py"
-TS_HELPER_LOGGER="$top_builddir/test_logger"
-TS_HELPER_LOGINDEFS="$top_builddir/test_logindefs"
-TS_HELPER_MD5="$top_builddir/test_md5"
-TS_HELPER_SHA1="$top_builddir/test_sha1"
-TS_HELPER_MKFS_MINIX="$top_builddir/test_mkfs_minix"
-TS_HELPER_MORE=${TS_HELPER_MORE-"$top_builddir/test_more"}
-TS_HELPER_PARTITIONS="$top_builddir/sample-partitions"
-TS_HELPER_PATHS="$top_builddir/test_pathnames"
-TS_HELPER_SCRIPT="$top_builddir/test_script"
-TS_HELPER_SIGRECEIVE="$top_builddir/test_sigreceive"
-TS_HELPER_STRUTILS="$top_builddir/test_strutils"
-TS_HELPER_SYSINFO="$top_builddir/test_sysinfo"
-TS_HELPER_TIOCSTI="$top_builddir/test_tiocsti"
-TS_HELPER_UUID_PARSER="$top_builddir/test_uuid_parser"
-TS_HELPER_UUID_NAMESPACE="$top_builddir/test_uuid_namespace"
-TS_HELPER_MBSENCODE="$top_builddir/test_mbsencode"
-TS_HELPER_CAL="$top_builddir/test_cal"
+TS_HELPER_LOGGER="${ts_helpersdir}test_logger"
+TS_HELPER_LOGINDEFS="${ts_helpersdir}test_logindefs"
+TS_HELPER_MD5="${ts_helpersdir}test_md5"
+TS_HELPER_SHA1="${ts_helpersdir}test_sha1"
+TS_HELPER_MKFS_MINIX="${ts_helpersdir}test_mkfs_minix"
+TS_HELPER_MORE=${TS_HELPER_MORE-"${ts_helpersdir}test_more"}
+TS_HELPER_PARTITIONS="${ts_helpersdir}sample-partitions"
+TS_HELPER_PATHS="${ts_helpersdir}test_pathnames"
+TS_HELPER_SCRIPT="${ts_helpersdir}test_script"
+TS_HELPER_SIGRECEIVE="${ts_helpersdir}test_sigreceive"
+TS_HELPER_STRUTILS="${ts_helpersdir}test_strutils"
+TS_HELPER_SYSINFO="${ts_helpersdir}test_sysinfo"
+TS_HELPER_TIOCSTI="${ts_helpersdir}test_tiocsti"
+TS_HELPER_UUID_PARSER="${ts_helpersdir}test_uuid_parser"
+TS_HELPER_UUID_NAMESPACE="${ts_helpersdir}test_uuid_namespace"
+TS_HELPER_MBSENCODE="${ts_helpersdir}test_mbsencode"
+TS_HELPER_CAL="${ts_helpersdir}test_cal"
# paths to commands
-TS_CMD_ADDPART=${TS_CMD_ADDPART:-"$top_builddir/addpart"}
-TS_CMD_DELPART=${TS_CMD_DELPART:-"$top_builddir/delpart"}
-TS_CMD_BLKDISCARD=${TS_CMD_BLKID-"$top_builddir/blkdiscard"}
-TS_CMD_BLKID=${TS_CMD_BLKID-"$top_builddir/blkid"}
-TS_CMD_CAL=${TS_CMD_CAL-"$top_builddir/cal"}
-TS_CMD_COLCRT=${TS_CMD_COLCRT:-"$top_builddir/colcrt"}
-TS_CMD_COLRM=${TS_CMD_COLRM:-"$top_builddir/colrm"}
-TS_CMD_COL=${TS_CMD_COL:-"$top_builddir/col"}
-TS_CMD_COLUMN=${TS_CMD_COLUMN:-"$top_builddir/column"}
-TS_CMD_EJECT=${TS_CMD_EJECT-"$top_builddir/eject"}
-TS_CMD_FALLOCATE=${TS_CMD_FALLOCATE-"$top_builddir/fallocate"}
-TS_CMD_FDISK=${TS_CMD_FDISK-"$top_builddir/fdisk"}
-TS_CMD_FLOCK=${TS_CMD_FLOCK-"$top_builddir/flock"}
-TS_CMD_SFDISK=${TS_CMD_SFDISK-"$top_builddir/sfdisk"}
-TS_CMD_FINCORE=${TS_CMD_FINCORE-"$top_builddir/fincore"}
-TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"$top_builddir/findmnt"}
-TS_CMD_FSCKCRAMFS=${TS_CMD_FSCKCRAMFS:-"$top_builddir/fsck.cramfs"}
-TS_CMD_FSCKMINIX=${TS_CMD_FSCKMINIX:-"$top_builddir/fsck.minix"}
-TS_CMD_GETOPT=${TS_CMD_GETOPT-"$top_builddir/getopt"}
-TS_CMD_HEXDUMP=${TS_CMD_HEXDUMP-"$top_builddir/hexdump"}
-TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"$top_builddir/hwclock"}
-TS_CMD_IONICE=${TS_CMD_IONICE-"$top_builddir/ionice"}
-TS_CMD_IPCMK=${TS_CMD_IPCMK-"$top_builddir/ipcmk"}
-TS_CMD_IPCRM=${TS_CMD_IPCRM-"$top_builddir/ipcrm"}
-TS_CMD_IPCS=${TS_CMD_IPCS:-"$top_builddir/ipcs"}
-TS_CMD_ISOSIZE=${TS_CMD_ISOSIZE-"$top_builddir/isosize"}
-TS_CMD_KILL=${TS_CMD_KILL-"$top_builddir/kill"}
-TS_CMD_LAST=${TS_CMD_LAST-"$top_builddir/last"}
-TS_CMD_LINE=${TS_CMD_LINE-"$top_builddir/line"}
-TS_CMD_LOOK=${TS_CMD_LOOK-"$top_builddir/look"}
-TS_CMD_LOSETUP=${TS_CMD_LOSETUP:-"$top_builddir/losetup"}
-TS_CMD_LSBLK=${TS_CMD_LSBLK-"$top_builddir/lsblk"}
-TS_CMD_LSCPU=${TS_CMD_LSCPU-"$top_builddir/lscpu"}
-TS_CMD_LSMEM=${TS_CMD_LSMEM-"$top_builddir/lsmem"}
-TS_CMD_LSNS=${TS_CMD_LSNS-"$top_builddir/lsns"}
-TS_CMD_MCOOKIE=${TS_CMD_MCOOKIE-"$top_builddir/mcookie"}
-TS_CMD_MKCRAMFS=${TS_CMD_MKCRAMFS:-"$top_builddir/mkfs.cramfs"}
-TS_CMD_MKMINIX=${TS_CMD_MKMINIX:-"$top_builddir/mkfs.minix"}
-TS_CMD_MKSWAP=${TS_CMD_MKSWAP:-"$top_builddir/mkswap"}
-TS_CMD_MOUNT=${TS_CMD_MOUNT:-"$top_builddir/mount"}
-TS_CMD_MOUNTPOINT=${TS_CMD_MOUNTPOINT:-"$top_builddir/mountpoint"}
-TS_CMD_NAMEI=${TS_CMD_NAMEI-"$top_builddir/namei"}
-TS_CMD_PARTX=${TS_CMD_PARTX-"$top_builddir/partx"}
-TS_CMD_RENAME=${TS_CMD_RENAME-"$top_builddir/rename"}
-TS_CMD_RUNUSER=${TS_CMD_RUNUSER-"$top_builddir/runuser"}
-TS_CMD_REV=${TS_CMD_REV:-"$top_builddir/rev"}
-TS_CMD_SCRIPT=${TS_CMD_SCRIPT-"$top_builddir/script"}
-TS_CMD_SCRIPTREPLAY=${TS_CMD_SCRIPTREPLAY-"$top_builddir/scriptreplay"}
-TS_CMD_SETARCH=${TS_CMD_SETARCH-"$top_builddir/setarch"}
-TS_CMD_SETSID=${TS_CMD_SETSID-"$top_builddir/setsid"}
-TS_CMD_SWAPLABEL=${TS_CMD_SWAPLABEL:-"$top_builddir/swaplabel"}
-TS_CMD_SWAPOFF=${TS_CMD_SWAPOFF:-"$top_builddir/swapoff"}
-TS_CMD_SWAPON=${TS_CMD_SWAPON:-"$top_builddir/swapon"}
-TS_CMD_UL=${TS_CMD_UL-"$top_builddir/ul"}
-TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"$top_builddir/umount"}
-TS_CMD_UTMPDUMP=${TS_CMD_UTMPDUMP-"$top_builddir/utmpdump"}
-TS_CMD_UUIDD=${TS_CMD_UUIDD-"$top_builddir/uuidd"}
-TS_CMD_UUIDGEN=${TS_CMD_UUIDGEN-"$top_builddir/uuidgen"}
-TS_CMD_UUIDPARSE=${TS_CMD_UUIDPARSE-"$top_builddir/uuidparse"}
-TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"$top_builddir/whereis"}
-TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"$top_builddir/wipefs"}
-TS_CMD_CHRT=${TS_CMD_CHRT-"$top_builddir/chrt"}
+TS_CMD_ADDPART=${TS_CMD_ADDPART:-"${ts_commandsdir}addpart"}
+TS_CMD_DELPART=${TS_CMD_DELPART:-"${ts_commandsdir}delpart"}
+TS_CMD_BLKDISCARD=${TS_CMD_BLKID-"${ts_commandsdir}blkdiscard"}
+TS_CMD_BLKID=${TS_CMD_BLKID-"${ts_commandsdir}blkid"}
+TS_CMD_CAL=${TS_CMD_CAL-"${ts_commandsdir}cal"}
+TS_CMD_COLCRT=${TS_CMD_COLCRT:-"${ts_commandsdir}colcrt"}
+TS_CMD_COLRM=${TS_CMD_COLRM:-"${ts_commandsdir}colrm"}
+TS_CMD_COL=${TS_CMD_COL:-"${ts_commandsdir}col"}
+TS_CMD_COLUMN=${TS_CMD_COLUMN:-"${ts_commandsdir}column"}
+TS_CMD_EJECT=${TS_CMD_EJECT-"${ts_commandsdir}eject"}
+TS_CMD_FALLOCATE=${TS_CMD_FALLOCATE-"${ts_commandsdir}fallocate"}
+TS_CMD_FDISK=${TS_CMD_FDISK-"${ts_commandsdir}fdisk"}
+TS_CMD_FLOCK=${TS_CMD_FLOCK-"${ts_commandsdir}flock"}
+TS_CMD_SFDISK=${TS_CMD_SFDISK-"${ts_commandsdir}sfdisk"}
+TS_CMD_FINCORE=${TS_CMD_FINCORE-"${ts_commandsdir}fincore"}
+TS_CMD_FINDMNT=${TS_CMD_FINDMNT-"${ts_commandsdir}findmnt"}
+TS_CMD_FSCKCRAMFS=${TS_CMD_FSCKCRAMFS:-"${ts_commandsdir}fsck.cramfs"}
+TS_CMD_FSCKMINIX=${TS_CMD_FSCKMINIX:-"${ts_commandsdir}fsck.minix"}
+TS_CMD_GETOPT=${TS_CMD_GETOPT-"${ts_commandsdir}getopt"}
+TS_CMD_HEXDUMP=${TS_CMD_HEXDUMP-"${ts_commandsdir}hexdump"}
+TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"${ts_commandsdir}hwclock"}
+TS_CMD_IONICE=${TS_CMD_IONICE-"${ts_commandsdir}ionice"}
+TS_CMD_IPCMK=${TS_CMD_IPCMK-"${ts_commandsdir}ipcmk"}
+TS_CMD_IPCRM=${TS_CMD_IPCRM-"${ts_commandsdir}ipcrm"}
+TS_CMD_IPCS=${TS_CMD_IPCS:-"${ts_commandsdir}ipcs"}
+TS_CMD_ISOSIZE=${TS_CMD_ISOSIZE-"${ts_commandsdir}isosize"}
+TS_CMD_KILL=${TS_CMD_KILL-"${ts_commandsdir}kill"}
+TS_CMD_LAST=${TS_CMD_LAST-"${ts_commandsdir}last"}
+TS_CMD_LINE=${TS_CMD_LINE-"${ts_commandsdir}line"}
+TS_CMD_LOOK=${TS_CMD_LOOK-"${ts_commandsdir}look"}
+TS_CMD_LOSETUP=${TS_CMD_LOSETUP:-"${ts_commandsdir}losetup"}
+TS_CMD_LSBLK=${TS_CMD_LSBLK-"${ts_commandsdir}lsblk"}
+TS_CMD_LSCPU=${TS_CMD_LSCPU-"${ts_commandsdir}lscpu"}
+TS_CMD_LSMEM=${TS_CMD_LSMEM-"${ts_commandsdir}lsmem"}
+TS_CMD_LSNS=${TS_CMD_LSNS-"${ts_commandsdir}lsns"}
+TS_CMD_MCOOKIE=${TS_CMD_MCOOKIE-"${ts_commandsdir}mcookie"}
+TS_CMD_MKCRAMFS=${TS_CMD_MKCRAMFS:-"${ts_commandsdir}mkfs.cramfs"}
+TS_CMD_MKMINIX=${TS_CMD_MKMINIX:-"${ts_commandsdir}mkfs.minix"}
+TS_CMD_MKSWAP=${TS_CMD_MKSWAP:-"${ts_commandsdir}mkswap"}
+TS_CMD_MOUNT=${TS_CMD_MOUNT:-"${ts_commandsdir}mount"}
+TS_CMD_MOUNTPOINT=${TS_CMD_MOUNTPOINT:-"${ts_commandsdir}mountpoint"}
+TS_CMD_NAMEI=${TS_CMD_NAMEI-"${ts_commandsdir}namei"}
+TS_CMD_PARTX=${TS_CMD_PARTX-"${ts_commandsdir}partx"}
+TS_CMD_RENAME=${TS_CMD_RENAME-"${ts_commandsdir}rename"}
+TS_CMD_RUNUSER=${TS_CMD_RUNUSER-"${ts_commandsdir}runuser"}
+TS_CMD_REV=${TS_CMD_REV:-"${ts_commandsdir}rev"}
+TS_CMD_SCRIPT=${TS_CMD_SCRIPT-"${ts_commandsdir}script"}
+TS_CMD_SCRIPTREPLAY=${TS_CMD_SCRIPTREPLAY-"${ts_commandsdir}scriptreplay"}
+TS_CMD_SETARCH=${TS_CMD_SETARCH-"${ts_commandsdir}setarch"}
+TS_CMD_SETSID=${TS_CMD_SETSID-"${ts_commandsdir}setsid"}
+TS_CMD_SWAPLABEL=${TS_CMD_SWAPLABEL:-"${ts_commandsdir}swaplabel"}
+TS_CMD_SWAPOFF=${TS_CMD_SWAPOFF:-"${ts_commandsdir}swapoff"}
+TS_CMD_SWAPON=${TS_CMD_SWAPON:-"${ts_commandsdir}swapon"}
+TS_CMD_UL=${TS_CMD_UL-"${ts_commandsdir}ul"}
+TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"${ts_commandsdir}umount"}
+TS_CMD_UTMPDUMP=${TS_CMD_UTMPDUMP-"${ts_commandsdir}utmpdump"}
+TS_CMD_UUIDD=${TS_CMD_UUIDD-"${ts_commandsdir}uuidd"}
+TS_CMD_UUIDGEN=${TS_CMD_UUIDGEN-"${ts_commandsdir}uuidgen"}
+TS_CMD_UUIDPARSE=${TS_CMD_UUIDPARSE-"${ts_commandsdir}uuidparse"}
+TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"${ts_commandsdir}whereis"}
+TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"${ts_commandsdir}wipefs"}
+TS_CMD_CHRT=${TS_CMD_CHRT-"${ts_commandsdir}chrt"}
diff --git a/tests/functions.sh b/tests/functions.sh
index 2fb0ddb5f..ab607c4ce 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -75,9 +75,19 @@ function ts_report {
}
function ts_check_test_command {
- if [ ! -x "$1" ]; then
- ts_skip "${1##*/} not found"
- fi
+ case "$1" in
+ */*)
+ # paths
+ if [ ! -x "$1" ]; then
+ ts_skip "${1##*/} not found"
+ fi
+ ;;
+ *)
+ # just command names (e.g. --use-system-commands)
+ local cmd=$1
+ type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd"
+ ;;
+ esac
}
function ts_check_prog {
@@ -254,8 +264,20 @@ function ts_init_env {
top_srcdir=$(ts_abspath $top_srcdir)
top_builddir=$(ts_abspath $top_builddir)
- # some ul commands search other ul commands in $PATH
- export PATH="$top_builddir:$PATH"
+ # We use helpser always from build tree
+ ts_helpersdir="${top_builddir}/"
+
+ TS_USE_SYSTEM_COMMANDS=$(ts_has_option "use-system-commands" "$*")
+ if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
+ # Don't define anything, just follow current PATH
+ ts_commandsdir=""
+ else
+ # The default is to use commands from build tree
+ ts_commandsdir="${top_builddir}/"
+
+ # some ul commands search other ul commands in $PATH
+ export PATH="$ts_commandsdir:$PATH"
+ fi
TS_SCRIPT="$mydir/$(basename $0)"
TS_SUBDIR=$(dirname $TS_SCRIPT)
@@ -319,6 +341,8 @@ function ts_init_env {
if [ "$TS_VERBOSE" == "yes" ]; then
echo
echo " script: $TS_SCRIPT"
+ echo " commands: $ts_commandsdir"
+ echo " helpers: $ts_helpersdir"
echo " sub dir: $TS_SUBDIR"
echo " top dir: $TS_TOPDIR"
echo " self: $TS_SELF"
diff --git a/tests/run.sh b/tests/run.sh
index f40c9f801..28f8ee25a 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -20,6 +20,7 @@ TS_TOPDIR=$(cd ${0%/*} && pwd)
SUBTESTS=
EXCLUDETESTS=
OPTS=
+SYSCOMMANDS=
top_srcdir=
top_builddir=
@@ -68,6 +69,11 @@ while [ -n "$1" ]; do
# these options are simply forwarded to the test scripts
OPTS="$OPTS $1"
;;
+ --use-system-commands)
+ OPTS="$OPTS $1"
+ SYSCOMMANDS="yes"
+ ;;
+
--nonroot)
if [ $(id -ru) -eq 0 ]; then
echo "Ignore util-linux test suite [non-root UID expected]."
@@ -98,18 +104,19 @@ while [ -n "$1" ]; do
echo "Usage: "
echo " $(basename $0) [options] [<component> ...]"
echo "Options:"
- echo " --force execute demanding tests"
- echo " --fake do not run, setup tests only"
- echo " --memcheck-valgrind run with valgrind"
- echo " --memcheck-asan enable ASAN (requires ./configure --enable-asan)"
- echo " --nolocks don't use flock to lock resources"
- echo " --verbose verbose mode"
- echo " --show-diff show diff from failed tests"
- echo " --nonroot ignore test suite if user is root"
- echo " --srcdir=<path> autotools top source directory"
- echo " --builddir=<path> autotools top build directory"
- echo " --parallel=<num> number of parallel test jobs, default: num cpus"
- echo " --exclude=<list> exclude tests by list '<utilname>/<testname> ..'"
+ echo " --force execute demanding tests"
+ echo " --fake do not run, setup tests only"
+ echo " --memcheck-valgrind run with valgrind"
+ echo " --memcheck-asan enable ASAN (requires ./configure --enable-asan)"
+ echo " --nolocks don't use flock to lock resources"
+ echo " --verbose verbose mode"
+ echo " --show-diff show diff from failed tests"
+ echo " --nonroot ignore test suite if user is root"
+ echo " --use-system-commands use PATH rather than builddir"
+ echo " --srcdir=<path> autotools top source directory"
+ echo " --builddir=<path> autotools top build directory"
+ echo " --parallel=<num> number of parallel test jobs, default: num cpus"
+ echo " --exclude=<list> exclude tests by list '<utilname>/<testname> ..'"
echo
exit 1
;;
@@ -148,7 +155,7 @@ if [ -n "$SUBTESTS" ]; then
fi
done
else
- if [ ! -f "$top_builddir/test_ttyutils" ]; then
+ if [ -z "$SYSCOMMANDS" -a ! -f "$top_builddir/test_ttyutils" ]; then
echo "Tests not compiled! Run 'make check' to fix the problem."
exit 1
fi
--
2.20.1

View File

@ -0,0 +1,28 @@
From de0402358f6d363a57e6fef98c92a9eef5690cdd Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 6 Jun 2022 16:14:30 +0200
Subject: irqtop: fix compiler warning [-Werror=format-truncation=]
Upstream: http://github.com/util-linux/util-linux/commit/b7865ae165bb43b1626c6928250843cc2c96be57
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2078787
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/irq-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c
index 22080b96d..e39ef823c 100644
--- a/sys-utils/irq-common.c
+++ b/sys-utils/irq-common.c
@@ -426,7 +426,7 @@ struct libscols_table *get_scols_cpus_table(struct irq_output *out,
struct libscols_table *table;
struct libscols_column *cl;
struct libscols_line *ln;
- char colname[sizeof(stringify_value(LONG_MAX))];
+ char colname[sizeof("cpu") + sizeof(stringify_value(LONG_MAX))];
size_t i;
if (prev) {
--
2.36.1

View File

@ -1,99 +0,0 @@
From 47b0f3480a88be94ef73973e73ad9f7fb8258cad Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 4 Mar 2019 17:28:15 +0100
Subject: [PATCH 17/19] tests: (kill) do not use shell build-in
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
Upstream: http://github.com/karelzak/util-linux/commit/2fadcded53add5b5b0ca7071f310a0f37c711c51
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/kill/all_processes | 5 +++++
tests/ts/kill/name_to_number | 5 +++++
tests/ts/kill/options | 5 +++++
tests/ts/kill/print_pid | 5 +++++
tests/ts/kill/queue | 5 +++++
5 files changed, 25 insertions(+)
diff --git a/tests/ts/kill/all_processes b/tests/ts/kill/all_processes
index 2596ef02b..7a0c95931 100755
--- a/tests/ts/kill/all_processes
+++ b/tests/ts/kill/all_processes
@@ -20,6 +20,11 @@ ts_init "$*"
ts_skip_nonroot
+# make sure we do not use shell built-in command
+if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
+ TS_CMD_KILL="/bin/kill"
+fi
+
ts_check_test_command "$TS_CMD_KILL"
ts_check_test_command "$TS_HELPER_SIGRECEIVE"
diff --git a/tests/ts/kill/name_to_number b/tests/ts/kill/name_to_number
index cde55c9ed..fd2aaafe0 100755
--- a/tests/ts/kill/name_to_number
+++ b/tests/ts/kill/name_to_number
@@ -18,6 +18,11 @@ TS_DESC="name_to_number"
. "$TS_TOPDIR/functions.sh"
ts_init "$*"
+# make sure we do not use shell built-in command
+if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
+ TS_CMD_KILL="/bin/kill"
+fi
+
ts_check_test_command "$TS_CMD_KILL"
ts_check_test_command "$TS_HELPER_SIGRECEIVE"
diff --git a/tests/ts/kill/options b/tests/ts/kill/options
index 2c82bbccc..ee9e52f47 100755
--- a/tests/ts/kill/options
+++ b/tests/ts/kill/options
@@ -18,6 +18,11 @@ TS_DESC="options"
. "$TS_TOPDIR/functions.sh"
ts_init "$*"
+# make sure we do not use shell built-in command
+if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
+ TS_CMD_KILL="/bin/kill"
+fi
+
ts_check_test_command "$TS_CMD_KILL"
ts_check_test_command "$TS_HELPER_SIGRECEIVE"
diff --git a/tests/ts/kill/print_pid b/tests/ts/kill/print_pid
index c6187f192..2a2a838ee 100755
--- a/tests/ts/kill/print_pid
+++ b/tests/ts/kill/print_pid
@@ -18,6 +18,11 @@ TS_DESC="print_pid"
. "$TS_TOPDIR/functions.sh"
ts_init "$*"
+# make sure we do not use shell built-in command
+if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
+ TS_CMD_KILL="/bin/kill"
+fi
+
ts_check_test_command "$TS_CMD_KILL"
ts_check_test_command "$TS_HELPER_SIGRECEIVE"
diff --git a/tests/ts/kill/queue b/tests/ts/kill/queue
index 992acf7a6..4727cbfc4 100755
--- a/tests/ts/kill/queue
+++ b/tests/ts/kill/queue
@@ -18,6 +18,11 @@ TS_DESC="queue"
. "$TS_TOPDIR/functions.sh"
ts_init "$*"
+# make sure we do not use shell built-in command
+if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then
+ TS_CMD_KILL="/bin/kill"
+fi
+
ts_check_test_command "$TS_CMD_KILL"
ts_check_test_command "$TS_HELPER_SIGRECEIVE"
--
2.20.1

View File

@ -0,0 +1,34 @@
From f45fe0768ac09cb5e05b095afa47a0a71e931f84 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 20 Apr 2022 14:42:32 +0200
Subject: dmesg: fix --since and --until
Now --since and --until requires any time field in the output (e.g.
--ctime,-T), it means "dmesg --since '1 day ago'" doesn't work, but
"dmesg -T --since '1 day ago'" works as expected.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2076829
Upstream: http://github.com/util-linux/util-linux/commit/c9667633f1f6b7a84116f2af067d1d15c72e6382
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/dmesg.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index d301951bb..5c580107a 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1539,7 +1539,9 @@ int main(int argc, char *argv[])
if ((is_timefmt(&ctl, RELTIME) ||
is_timefmt(&ctl, CTIME) ||
- is_timefmt(&ctl, ISO8601))) {
+ is_timefmt(&ctl, ISO8601)) ||
+ ctl.since ||
+ ctl.until) {
if (dmesg_get_boot_time(&ctl.boot_time) != 0)
ctl.time_fmt = DMESG_TIMEFTM_NONE;
else
--
2.36.1

View File

@ -1,27 +0,0 @@
From aa983f0eea49638f04de0fbafcd156c1472726ee Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 4 Mar 2019 17:32:03 +0100
Subject: [PATCH 18/19] tests: add missing TS_CMD_UMOUNT check
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
Upstream: http://github.com/karelzak/util-linux/commit/bb872a239ce9faae7ac672a9137945dd8e4ee964
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/libmount/loop | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop
index b52b7476a..090b79fa4 100755
--- a/tests/ts/libmount/loop
+++ b/tests/ts/libmount/loop
@@ -23,6 +23,7 @@ TS_DESC="losetup-loop"
ts_init "$*"
ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
ts_check_test_command "$TS_CMD_FINDMNT"
ts_check_test_command "$TS_CMD_LOSETUP"
--
2.20.1

View File

@ -0,0 +1,62 @@
From f02e9004303df5ab3d9b868f6f60af44663cce69 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 19 Apr 2022 09:44:07 +0200
Subject: libblkid: check fsync() return code
Since 39f5af25982d8b0244000e92a9d0e0e6557d0e17 libblkid uses
O_NONBLOCK. Now it's more obvious that check fsync() (and close())
return value after write() is always a good idea ...
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2074486
Upstream: http://github.com/util-linux/util-linux/commit/133a0d70f637b4f4e4337811e452153b04f2bdcf
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/probe.c | 5 ++++-
misc-utils/wipefs.c | 8 ++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 5f01bc3b3..d317dc19a 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -1298,7 +1298,10 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
/* wipen on device */
if (write_all(fd, buf, len))
return -1;
- fsync(fd);
+
+ if (fsync(fd) != 0)
+ return -1;
+
pr->flags &= ~BLKID_FL_MODIF_BUFF; /* be paranoid */
return blkid_probe_step_back(pr);
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
index 78dc63ee7..f08a9ba4f 100644
--- a/misc-utils/wipefs.c
+++ b/misc-utils/wipefs.c
@@ -615,7 +615,9 @@ static int do_wipe(struct wipe_control *ctl)
if (need_force)
warnx(_("Use the --force option to force erase."));
- fsync(blkid_probe_get_fd(pr));
+ if (fsync(blkid_probe_get_fd(pr)) != 0)
+ err(EXIT_FAILURE, _("%s: cannot flush modified buffers"),
+ ctl->devname);
#ifdef BLKRRPART
if (reread && (mode & O_EXCL)) {
@@ -635,7 +637,9 @@ static int do_wipe(struct wipe_control *ctl)
}
#endif
- close(blkid_probe_get_fd(pr));
+ if (close(blkid_probe_get_fd(pr)) != 0)
+ err(EXIT_FAILURE, _("%s: close device failed"), ctl->devname);
+
blkid_free_probe(pr);
free(backup);
return 0;
--
2.36.1

View File

@ -1,66 +0,0 @@
From 9e92f2ff939a885b70d3a5d20e8c94f6e41e821b Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 5 Mar 2019 11:06:41 +0100
Subject: [PATCH 19/19] tests: add --noskip-commands
The default is SKIP missing commands on --use-system-commands, but
with --noskip-commands the test will FAIL.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
Upstream: http://github.com/karelzak/util-linux/commit/7c90efa384cbb2ace873e2b90e8cc396a1719535
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/functions.sh | 9 ++++++++-
tests/run.sh | 2 ++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/tests/functions.sh b/tests/functions.sh
index ab607c4ce..0605a1320 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -85,7 +85,13 @@ function ts_check_test_command {
*)
# just command names (e.g. --use-system-commands)
local cmd=$1
- type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd"
+ type "$cmd" >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ if [ "$TS_NOSKIP_COMMANDS" = "yes" ]; then
+ ts_failed "missing in PATH: $cmd"
+ fi
+ ts_skip "missing in PATH: $cmd"
+ fi
;;
esac
}
@@ -301,6 +307,7 @@ function ts_init_env {
ts_init_core_env
+ TS_NOSKIP_COMMANDS=$(ts_has_option "noskip-commands" "$*")
TS_VERBOSE=$(ts_has_option "verbose" "$*")
TS_SHOWDIFF=$(ts_has_option "show-diff" "$*")
TS_PARALLEL=$(ts_has_option "parallel" "$*")
diff --git a/tests/run.sh b/tests/run.sh
index 28f8ee25a..e8328cc5d 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -65,6 +65,7 @@ while [ -n "$1" ]; do
--show-diff |\
--verbose |\
--skip-loopdevs |\
+ --noskip-commands |\
--parsable)
# these options are simply forwarded to the test scripts
OPTS="$OPTS $1"
@@ -113,6 +114,7 @@ while [ -n "$1" ]; do
echo " --show-diff show diff from failed tests"
echo " --nonroot ignore test suite if user is root"
echo " --use-system-commands use PATH rather than builddir"
+ echo " --noskip-commands fail on missing commands"
echo " --srcdir=<path> autotools top source directory"
echo " --builddir=<path> autotools top build directory"
echo " --parallel=<num> number of parallel test jobs, default: num cpus"
--
2.20.1

View File

@ -0,0 +1,87 @@
From 863ecca27cfc937bc6fb2131e0d0e35947e38ce6 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Mon, 25 Apr 2022 17:08:37 +0200
Subject: libblkid: add interface for FSSIZE field
Add interface to let filesystem probe calculate and set FSSIZE.
Enable that field in the 'superblocks' sample.
Upstream: http://github.com/util-linux/util-linux/commit/ad08ae0aa
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/samples/superblocks.c | 2 +-
libblkid/src/blkid.h.in | 1 +
libblkid/src/superblocks/superblocks.c | 11 +++++++++++
libblkid/src/superblocks/superblocks.h | 1 +
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/libblkid/samples/superblocks.c b/libblkid/samples/superblocks.c
index 7d9555771..38903ecee 100644
--- a/libblkid/samples/superblocks.c
+++ b/libblkid/samples/superblocks.c
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_MAGIC);
+ BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE);
rc = blkid_do_safeprobe(pr);
if (rc == -1)
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index 3cd4116d9..ad4becf0a 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -281,6 +281,7 @@ extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
+#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index f21365538..9adc2cfa3 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -7,6 +7,7 @@
* GNU Lesser General Public License.
*/
+#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -584,6 +585,16 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage)
return blkid_probe_set_value(pr, "USAGE", (unsigned char *) u, strlen(u) + 1);
}
+int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
+{
+ struct blkid_chain *chn = blkid_probe_get_chain(pr);
+
+ if (!(chn->flags & BLKID_SUBLKS_FSSIZE))
+ return 0;
+
+ return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
+}
+
int blkid_probe_set_id_label(blkid_probe pr, const char *name,
const unsigned char *data, size_t len)
{
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
index 9c489c438..67803679f 100644
--- a/libblkid/src/superblocks/superblocks.h
+++ b/libblkid/src/superblocks/superblocks.h
@@ -111,6 +111,7 @@ extern int blkid_probe_set_utf8_id_label(blkid_probe pr, const char *name,
const unsigned char *data, size_t len, int enc);
int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size);
+int blkid_probe_set_fssize(blkid_probe pr, uint64_t size);
extern int blkid_probe_is_bitlocker(blkid_probe pr);
extern int blkid_probe_is_ntfs(blkid_probe pr);
--
2.36.1

View File

@ -1,83 +0,0 @@
From 68ab6d9691e667f89f72bc7eb39a5300b2f6cbaf Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 5 Mar 2019 13:56:45 +0100
Subject: [PATCH] tests: add missing program checks
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/cal/bigyear | 2 +-
tests/ts/cal/month | 2 +-
tests/ts/cal/sep1752 | 2 +-
tests/ts/misc/mbsencode | 2 ++
tests/ts/misc/strtosize | 2 ++
5 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/tests/ts/cal/bigyear b/tests/ts/cal/bigyear
index d205c3afd..34139fd27 100755
--- a/tests/ts/cal/bigyear
+++ b/tests/ts/cal/bigyear
@@ -18,7 +18,7 @@ TS_DESC="Year 2147483646"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_CAL"
+ts_check_test_command "$TS_HELPER_CAL"
export TERM=linux
diff --git a/tests/ts/cal/month b/tests/ts/cal/month
index 9794e90c0..37996acae 100755
--- a/tests/ts/cal/month
+++ b/tests/ts/cal/month
@@ -22,7 +22,7 @@ TS_DESC="month"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_CAL"
+ts_check_test_command "$TS_HELPER_CAL"
export TERM=linux
diff --git a/tests/ts/cal/sep1752 b/tests/ts/cal/sep1752
index 3128261cd..41c30d40e 100755
--- a/tests/ts/cal/sep1752
+++ b/tests/ts/cal/sep1752
@@ -18,7 +18,7 @@ TS_DESC="September 1752"
. $TS_TOPDIR/functions.sh
ts_init "$*"
-ts_check_test_command "$TS_CMD_CAL"
+ts_check_test_command "$TS_HELPER_CAL"
export TERM=linux
diff --git a/tests/ts/misc/mbsencode b/tests/ts/misc/mbsencode
index 405d34c56..139148259 100755
--- a/tests/ts/misc/mbsencode
+++ b/tests/ts/misc/mbsencode
@@ -22,6 +22,8 @@ TS_DESC="mbsencode"
. $TS_TOPDIR/functions.sh
ts_init "$*"
+ts_check_test_command "$TS_HELPER_MBSENCODE"
+
# These test may fail on some machines (locales, other libc...)
TS_KNOWN_FAIL="yes"
diff --git a/tests/ts/misc/strtosize b/tests/ts/misc/strtosize
index 68b3b8bab..a5914a939 100755
--- a/tests/ts/misc/strtosize
+++ b/tests/ts/misc/strtosize
@@ -21,6 +21,8 @@ TS_DESC="strtosize"
. $TS_TOPDIR/functions.sh
ts_init "$*"
+ts_check_test_command "$TS_HELPER_STRUTILS"
+
$TS_HELPER_STRUTILS --size -1 >> $TS_OUTPUT 2>&1
$TS_HELPER_STRUTILS --size 0 >> $TS_OUTPUT 2>&1
$TS_HELPER_STRUTILS --size 1 >> $TS_OUTPUT 2>&1
--
2.20.1

View File

@ -0,0 +1,45 @@
From e81cc68312e91ab7086188542f3377605bf144a8 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Mon, 25 Apr 2022 17:08:38 +0200
Subject: libblkid: implement FSSIZE calculation for XFS
The implementation is similar to one provided by statfs(2) + lsblk.
Upstream: http://github.com/util-linux/util-linux/commit/d7ec8fe8e
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/src/superblocks/xfs.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libblkid/src/superblocks/xfs.c b/libblkid/src/superblocks/xfs.c
index d8c6fb6d4..444050f55 100644
--- a/libblkid/src/superblocks/xfs.c
+++ b/libblkid/src/superblocks/xfs.c
@@ -158,6 +158,15 @@ static int xfs_verify_sb(struct xfs_super_block *ondisk)
return 1;
}
+static uint64_t xfs_fssize(struct xfs_super_block *xs)
+{
+ uint32_t lsize = xs->sb_logstart ? xs->sb_logblocks : 0;
+ uint64_t avail_blocks = be64_to_cpu(xs->sb_dblocks) - be32_to_cpu(lsize);
+ uint64_t fssize = avail_blocks*be32_to_cpu(xs->sb_blocksize);
+
+ return fssize;
+}
+
static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
{
struct xfs_super_block *xs;
@@ -173,6 +182,7 @@ static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
blkid_probe_set_label(pr, (unsigned char *) xs->sb_fname,
sizeof(xs->sb_fname));
blkid_probe_set_uuid(pr, xs->sb_uuid);
+ blkid_probe_set_fssize(pr, xfs_fssize(xs));
blkid_probe_set_block_size(pr, be16_to_cpu(xs->sb_sectsize));
return 0;
}
--
2.36.1

View File

@ -1,42 +0,0 @@
From 0c57e5fedce0e627debda3258e2203842b427572 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 11 Dec 2018 11:44:48 +0100
Subject: [PATCH] tests: check for tar and {b,g}zip
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1681062
Upstream: http://github.com/karelzak/util-linux/commit/9e07672bb9989c88f6a7d8b8ab23158701fb4eec
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/lscpu/lscpu | 2 ++
tests/ts/lsmem/lsmem | 2 ++
2 files changed, 4 insertions(+)
diff --git a/tests/ts/lscpu/lscpu b/tests/ts/lscpu/lscpu
index 70fbce9f3..ccf271149 100755
--- a/tests/ts/lscpu/lscpu
+++ b/tests/ts/lscpu/lscpu
@@ -22,6 +22,8 @@ TS_TOPDIR="${0%/*}/../.."
ts_init "$*"
+ts_check_prog "tar"
+ts_check_prog "gzip"
ts_check_test_command "$TS_CMD_LSCPU"
for dump in $(ls $TS_SELF/dumps/*.tar.gz | sort); do
diff --git a/tests/ts/lsmem/lsmem b/tests/ts/lsmem/lsmem
index f1a643f85..bedf4143f 100755
--- a/tests/ts/lsmem/lsmem
+++ b/tests/ts/lsmem/lsmem
@@ -21,6 +21,8 @@ TS_TOPDIR="${0%/*}/../.."
ts_init "$*"
ts_check_test_command "$TS_CMD_LSMEM"
+ts_check_prog "tar"
+ts_check_prog "bzip2"
LSCOLUMNS="RANGE,SIZE,STATE,REMOVABLE,BLOCK,NODE"
--
2.20.1

View File

@ -0,0 +1,54 @@
From d3d0e6dc70889e5fe9d9dfeab67e9ba1f0491a28 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Mon, 25 Apr 2022 17:08:39 +0200
Subject: blkid: add FSSIZE tag with tests for XFS
The FSSIZE tag was added to the libblkid. Enable this tag in blkid
and update tests golden output for XFS test cases.
Upstream: http://github.com/util-linux/util-linux/commit/60cedc921
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
misc-utils/blkid.c | 3 ++-
tests/expected/blkid/low-probe-xfs | 1 +
tests/expected/blkid/low-probe-xfs-v5 | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index cccd8af87..4f456be52 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -892,7 +892,8 @@ int main(int argc, char **argv)
blkid_probe_set_superblocks_flags(pr,
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
- BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION);
+ BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
+ BLKID_SUBLKS_FSSIZE);
if (fltr_usage &&
diff --git a/tests/expected/blkid/low-probe-xfs b/tests/expected/blkid/low-probe-xfs
index 6eb1b4600..a91e92bcc 100644
--- a/tests/expected/blkid/low-probe-xfs
+++ b/tests/expected/blkid/low-probe-xfs
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=512
+ID_FS_FSSIZE=11862016
ID_FS_LABEL=test-xfs
ID_FS_LABEL_ENC=test-xfs
ID_FS_TYPE=xfs
diff --git a/tests/expected/blkid/low-probe-xfs-v5 b/tests/expected/blkid/low-probe-xfs-v5
index 513a3818f..129b41f26 100644
--- a/tests/expected/blkid/low-probe-xfs-v5
+++ b/tests/expected/blkid/low-probe-xfs-v5
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=512
+ID_FS_FSSIZE=17469440
ID_FS_LABEL=test-xfs-v5
ID_FS_LABEL_ENC=test-xfs-v5
ID_FS_TYPE=xfs
--
2.36.1

View File

@ -1,93 +0,0 @@
From 8822103e30121d95fa58b5e8b7ce8ce91d4e778e Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 3 Jun 2019 22:29:51 +0200
Subject: [PATCH] tests: make mount -oloop use more robust
The command creates loop device, so udevd is in the game and it seems
better to wait for him.
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1681062
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/libmount/loop | 4 ++++
tests/ts/libmount/loop-overlay | 11 +++++++++++
2 files changed, 15 insertions(+)
diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop
index 090b79fa4..50764781c 100755
--- a/tests/ts/libmount/loop
+++ b/tests/ts/libmount/loop
@@ -65,6 +65,7 @@ ts_finalize_subtest
ts_init_subtest "file-o-loop"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
$TS_CMD_MOUNT -oloop "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
+udevadm settle
$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
udevadm settle
ts_log "Success"
@@ -89,6 +90,7 @@ else
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT )
$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
+ udevadm settle
verify_mount_dev "$LODEV" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
$TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>&1
udevadm settle
@@ -122,6 +124,7 @@ ts_init_subtest "o-loop-val-initialized"
LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE" 2>>$TS_OUTPUT)
$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1
udevadm settle
ts_log "Success"
@@ -133,6 +136,7 @@ cp "$BACKFILE" "$BACKFILE"-2
LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE"-2 2>> $TS_OUTPUT)
$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1
rm "$BACKFILE"-2
udevadm settle
diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay
index fffb823c0..1ba6eb06e 100755
--- a/tests/ts/libmount/loop-overlay
+++ b/tests/ts/libmount/loop-overlay
@@ -43,23 +43,34 @@ dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null
echo "second should fail" >>$TS_OUTPUT
$TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
+udevadm settle
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
+udevadm settle
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
+udevadm settle
echo "should succeed" >>$TS_OUTPUT
$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
+udevadm settle
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1
+udevadm settle
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
+udevadm settle
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1
+udevadm settle
echo "both should fail" >>$TS_OUTPUT
LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG")
+udevadm settle
$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
+udevadm settle
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP --detach $LOOPDEV
+udevadm settle
ts_log "Success"
ts_finalize
--
2.21.0

View File

@ -0,0 +1,28 @@
From 8ae64e23bc34fd939586705f64a93676bae8c2b2 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 26 Apr 2022 10:32:05 +0200
Subject: libblkid: fix FSSIZE docs
Upstream: http://github.com/util-linux/util-linux/commit/9c01f798f
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/superblocks/superblocks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 9adc2cfa3..adf4ee025 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -66,7 +66,7 @@
*
* @SBMAGIC_OFFSET: offset of SBMAGIC
*
- * @FSSIZE: size of filesystem [not-implemented yet]
+ * @FSSIZE: size of filesystem (implemented for XFS only)
*
* @SYSTEM_ID: ISO9660 system identifier
*
--
2.36.1

View File

@ -1,87 +0,0 @@
From e431bfeca0f3e7be2eba30be83260f20976f871d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 31 Jul 2019 16:18:27 +0200
Subject: [PATCH 23/24] libblkid: fix file descriptor leak in blkid_verify()
The function blkid_verify() uses private device file descriptor and
uses blkid_probe_set_device() to assign the descriptor to low-level
probing code. Unfortunately, close() in this case is not enough as the
prober can internally open whole-disk device too.
The library API has been extended so blkid_probe_set_device()
deallocates and close previously used prober for whole-disk. This new
functionality is used in blkid_verify() now.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1734553
Upstream: http://github.com/karelzak/util-linux/commit/c4d6d1c54dcd0eff701236d396d88b1fc6251768
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/probe.c | 19 ++++++++++++++++---
libblkid/src/verify.c | 4 +++-
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 647ae416a..a6dc8416a 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -848,10 +848,15 @@ failed:
* @off: begin of probing area
* @size: size of probing area (zero means whole device/file)
*
- * Assigns the device to probe control struct, resets internal buffers and
- * resets the current probing.
+ * Assigns the device to probe control struct, resets internal buffers, resets
+ * the current probing, and close previously associated device (if open by
+ * libblkid).
*
- * Returns: -1 in case of failure, or 0 on success.
+ * If @fd is < 0 than only resets the prober and returns 1. Note that
+ * blkid_reset_probe() keeps the device associated with the prober, but
+ * blkid_probe_set_device() does complete reset.
+ *
+ * Returns: -1 in case of failure, 0 on success and 1 on reset.
*/
int blkid_probe_set_device(blkid_probe pr, int fd,
blkid_loff_t off, blkid_loff_t size)
@@ -866,6 +871,11 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
if ((pr->flags & BLKID_FL_PRIVATE_FD) && pr->fd >= 0)
close(pr->fd);
+ if (pr->disk_probe) {
+ blkid_free_probe(pr->disk_probe);
+ pr->disk_probe = NULL;
+ }
+
pr->flags &= ~BLKID_FL_PRIVATE_FD;
pr->flags &= ~BLKID_FL_TINY_DEV;
pr->flags &= ~BLKID_FL_CDROM_DEV;
@@ -881,6 +891,9 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
pr->wipe_size = 0;
pr->wipe_chain = NULL;
+ if (fd < 0)
+ return 1;
+
#if defined(POSIX_FADV_RANDOM) && defined(HAVE_POSIX_FADVISE)
/* Disable read-ahead */
posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM);
diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c
index 7f44f5497..750378f8c 100644
--- a/libblkid/src/verify.c
+++ b/libblkid/src/verify.c
@@ -184,9 +184,11 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
dev->bid_name, (long long)st.st_rdev, dev->bid_type));
}
- blkid_reset_probe(cache->probe);
+ /* reset prober */
blkid_probe_reset_superblocks_filter(cache->probe);
+ blkid_probe_set_device(cache->probe, -1, 0, 0);
close(fd);
+
return dev;
}
--
2.21.0

View File

@ -1,73 +0,0 @@
From 3f6de92999cf63e234265f51d6ee02134bc75ac3 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 12 Jun 2019 11:02:51 +0200
Subject: [PATCH 24/24] findmnt: (verify) ignore passno for XFS
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1719069
Upstream: http://github.com/karelzak/util-linux/commit/f5b7bf155b9881de5b99cc0a23b4dccf9a2d4af3
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/findmnt-verify.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/misc-utils/findmnt-verify.c b/misc-utils/findmnt-verify.c
index 1cc62def9..73e44a418 100644
--- a/misc-utils/findmnt-verify.c
+++ b/misc-utils/findmnt-verify.c
@@ -28,7 +28,8 @@ struct verify_context {
int nwarnings;
int nerrors;
- unsigned int target_printed : 1;
+ unsigned int target_printed : 1,
+ no_fsck : 1;
};
static void verify_mesg(struct verify_context *vfy, char type, const char *fmt, va_list ap)
@@ -408,6 +409,8 @@ static int verify_fstype(struct verify_context *vfy)
isauto = 1;
else if (strcmp(type, "swap") == 0)
isswap = 1;
+ else if (strcmp(type, "xfs") == 0)
+ vfy->no_fsck = 1;
if (!isswap && !isauto && !none && !is_supported_filesystem(vfy, type))
verify_warn(vfy, _("%s seems unsupported by the current kernel"), type);
@@ -422,6 +425,7 @@ static int verify_fstype(struct verify_context *vfy)
if (realtype) {
isswap = strcmp(realtype, "swap") == 0;
+ vfy->no_fsck = strcmp(realtype, "xfs") == 0;
if (type && !isauto && strcmp(type, realtype) != 0)
return verify_err(vfy, _("%s does not match with on-disk %s"), type, realtype);
@@ -440,7 +444,7 @@ static int verify_passno(struct verify_context *vfy)
int passno = mnt_fs_get_passno(vfy->fs);
const char *tgt = mnt_fs_get_target(vfy->fs);
- if (tgt && strcmp("/", tgt) == 0 && passno != 1)
+ if (tgt && strcmp("/", tgt) == 0 && passno != 1 && !vfy->no_fsck)
return verify_warn(vfy, _("recommended root FS passno is 1 (current is %d)"), passno);
return 0;
@@ -463,7 +467,7 @@ static int verify_filesystem(struct verify_context *vfy)
if (!rc)
rc = verify_fstype(vfy);
if (!rc)
- rc = verify_passno(vfy);
+ rc = verify_passno(vfy); /* depends on verify_fstype() */
return rc;
}
@@ -492,6 +496,8 @@ int verify_table(struct libmnt_table *tb)
while (rc == 0 && (vfy.fs = get_next_fs(tb, itr))) {
vfy.target_printed = 0;
+ vfy.no_fsck = 0;
+
if (check_order)
rc = verify_order(&vfy);
if (!rc)
--
2.21.0

View File

@ -0,0 +1,113 @@
From fb9ea75a8a69b06eb6a4039b841ce3ccabb76775 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Wed, 27 Apr 2022 13:24:56 +0200
Subject: libblkid: add FSLASTBLOCK field interface showing area occupied by fs
Add interface to let filesystem set FSLASTBLOCK which is basically
total number of fsblocks (area occupied by fs). Enable that field in
the 'superblocks' sample.
Upstream: http://github.com/util-linux/util-linux/commit/b7cb26ec3
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/samples/superblocks.c | 3 ++-
libblkid/src/blkid.h.in | 23 ++++++++++++-----------
libblkid/src/superblocks/superblocks.c | 13 +++++++++++++
libblkid/src/superblocks/superblocks.h | 1 +
4 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/libblkid/samples/superblocks.c b/libblkid/samples/superblocks.c
index 38903ecee..b7f94ec14 100644
--- a/libblkid/samples/superblocks.c
+++ b/libblkid/samples/superblocks.c
@@ -44,7 +44,8 @@ int main(int argc, char *argv[])
BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE);
+ BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE |
+ BLKID_SUBLKS_FSLASTBLOCK);
rc = blkid_do_safeprobe(pr);
if (rc == -1)
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index ad4becf0a..56e64f9ab 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -271,17 +271,18 @@ extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage)
extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
-#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
-#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
-#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
-#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
-#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
-#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
-#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
-#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
-#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
-#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
-#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
+#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
+#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
+#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
+#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
+#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
+#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
+#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
+#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
+#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
+#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
+#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
+#define BLKID_SUBLKS_FSLASTBLOCK (1 << 12) /* read and define FSLASTBLOCK from superblock */
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index adf4ee025..5b899a830 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -68,6 +68,8 @@
*
* @FSSIZE: size of filesystem (implemented for XFS only)
*
+ * @FSLASTBLOCK: last fsblock/total number of fsblocks
+ *
* @SYSTEM_ID: ISO9660 system identifier
*
* @PUBLISHER_ID: ISO9660 publisher identifier
@@ -595,6 +597,17 @@ int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
}
+int blkid_probe_set_fslastblock(blkid_probe pr, uint64_t lastblock)
+{
+ struct blkid_chain *chn = blkid_probe_get_chain(pr);
+
+ if (!(chn->flags & BLKID_SUBLKS_FSLASTBLOCK))
+ return 0;
+
+ return blkid_probe_sprintf_value(pr, "FSLASTBLOCK", "%" PRIu64,
+ lastblock);
+}
+
int blkid_probe_set_id_label(blkid_probe pr, const char *name,
const unsigned char *data, size_t len)
{
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
index 67803679f..251e2e386 100644
--- a/libblkid/src/superblocks/superblocks.h
+++ b/libblkid/src/superblocks/superblocks.h
@@ -112,6 +112,7 @@ extern int blkid_probe_set_utf8_id_label(blkid_probe pr, const char *name,
int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size);
int blkid_probe_set_fssize(blkid_probe pr, uint64_t size);
+int blkid_probe_set_fslastblock(blkid_probe pr, uint64_t lastblock);
extern int blkid_probe_is_bitlocker(blkid_probe pr);
extern int blkid_probe_is_ntfs(blkid_probe pr);
--
2.36.1

View File

@ -0,0 +1,86 @@
From 9c7f3317fc66fe971a331dd71e76aff7ae091ab2 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Wed, 27 Apr 2022 14:46:33 +0200
Subject: libblkid: add FSLASTBLOCK implementation for xfs, ext and btrfs
Implementation of FSLASTBLOCK for most common filesystems. Most of
the fs store total number of reserved blocks in superblock.
Upstream: http://github.com/util-linux/util-linux/commit/5f995b3f1
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/src/superblocks/btrfs.c | 5 +++++
libblkid/src/superblocks/ext.c | 10 ++++++++--
libblkid/src/superblocks/xfs.c | 1 +
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/libblkid/src/superblocks/btrfs.c b/libblkid/src/superblocks/btrfs.c
index f0fde700d..9708f2e28 100644
--- a/libblkid/src/superblocks/btrfs.c
+++ b/libblkid/src/superblocks/btrfs.c
@@ -76,6 +76,11 @@ static int probe_btrfs(blkid_probe pr, const struct blkid_idmag *mag)
blkid_probe_set_uuid_as(pr, bfs->dev_item.uuid, "UUID_SUB");
blkid_probe_set_block_size(pr, le32_to_cpu(bfs->sectorsize));
+ uint32_t sectorsize_log = 31 -
+ __builtin_clz(le32_to_cpu(bfs->sectorsize));
+ blkid_probe_set_fslastblock(pr,
+ le64_to_cpu(bfs->total_bytes) >> sectorsize_log);
+
return 0;
}
diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c
index 3870522fa..0b9023734 100644
--- a/libblkid/src/superblocks/ext.c
+++ b/libblkid/src/superblocks/ext.c
@@ -164,10 +164,11 @@ static struct ext2_super_block *ext_get_super(
static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
+ uint32_t s_feature_incompat = le32_to_cpu(es->s_feature_incompat);
DBG(PROBE, ul_debug("ext2_sb.compat = %08X:%08X:%08X",
le32_to_cpu(es->s_feature_compat),
- le32_to_cpu(es->s_feature_incompat),
+ s_feature_incompat,
le32_to_cpu(es->s_feature_ro_compat)));
if (*es->s_volume_name != '\0')
@@ -179,7 +180,7 @@ static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es)
blkid_probe_set_uuid_as(pr, es->s_journal_uuid, "EXT_JOURNAL");
if (ver != 2 && (chn->flags & BLKID_SUBLKS_SECTYPE) &&
- ((le32_to_cpu(es->s_feature_incompat) & EXT2_FEATURE_INCOMPAT_UNSUPPORTED) == 0))
+ ((s_feature_incompat & EXT2_FEATURE_INCOMPAT_UNSUPPORTED) == 0))
blkid_probe_set_value(pr, "SEC_TYPE",
(unsigned char *) "ext2",
sizeof("ext2"));
@@ -190,6 +191,11 @@ static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es)
if (le32_to_cpu(es->s_log_block_size) < 32)
blkid_probe_set_block_size(pr, 1024U << le32_to_cpu(es->s_log_block_size));
+
+ uint64_t fslastblock = le32_to_cpu(es->s_blocks_count) |
+ ((s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) ?
+ (uint64_t) le32_to_cpu(es->s_blocks_count_hi) << 32 : 0);
+ blkid_probe_set_fslastblock(pr, fslastblock);
}
diff --git a/libblkid/src/superblocks/xfs.c b/libblkid/src/superblocks/xfs.c
index 444050f55..1f2e92cac 100644
--- a/libblkid/src/superblocks/xfs.c
+++ b/libblkid/src/superblocks/xfs.c
@@ -183,6 +183,7 @@ static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
sizeof(xs->sb_fname));
blkid_probe_set_uuid(pr, xs->sb_uuid);
blkid_probe_set_fssize(pr, xfs_fssize(xs));
+ blkid_probe_set_fslastblock(pr, be64_to_cpu(xs->sb_dblocks));
blkid_probe_set_block_size(pr, be16_to_cpu(xs->sb_sectsize));
return 0;
}
--
2.36.1

View File

@ -1,41 +0,0 @@
From be5e6b14db3cdd09dab711572116d7ee39344875 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 21 Aug 2019 10:51:18 +0200
Subject: [PATCH 25/26] partx: don't report ENXIO as error on -d
The errno ENXIO should be ignored, unfortunately the current code uses
variable 'rc' for ioctl return code as well as for final del_parts()
return value. So, failed ioctl (which should be ignored) affects all
del_parts() status.
# modprobe scsi_debug dev_size_mb=100
# partx -d --nr 1-1024 /dev/sdc; echo $?
1
The device dos not contains any partitions, so 0 return code is
expected in this case.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179
Upstream: http://github.com/karelzak/util-linux/commit/53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555
Signed-off-by: Karel Zak <kzak@redhat.com>
---
disk-utils/partx.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/disk-utils/partx.c b/disk-utils/partx.c
index e3443ea80..f3dcc9007 100644
--- a/disk-utils/partx.c
+++ b/disk-utils/partx.c
@@ -327,8 +327,7 @@ static int del_parts(int fd, const char *device, dev_t devno,
}
for (i = lower; i <= upper; i++) {
- rc = partx_del_partition(fd, i);
- if (rc == 0) {
+ if (partx_del_partition(fd, i) == 0) {
if (verbose)
printf(_("%s: partition #%d removed\n"), device, i);
continue;
--
2.21.0

View File

@ -0,0 +1,146 @@
From ab34732c0aaf7814393acbffa59cb82a79583e3d Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Wed, 27 Apr 2022 17:29:27 +0200
Subject: blkid: add image for btrfs testing
The btrfs is one of the popular filesystem which is supported by
blkid. However, the image for 'low-probe' tests was missing. Add
115M BTRFS default image (mkfs.btrfs btrfs.img).
Upstream: http://github.com/util-linux/util-linux/commit/bf64c83ec
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
tests/expected/blkid/low-probe-btrfs | 7 +++++++
tests/ts/blkid/images-fs/btrfs.img.xz | Bin 0 -> 21696 bytes
2 files changed, 7 insertions(+)
create mode 100644 tests/expected/blkid/low-probe-btrfs
create mode 100644 tests/ts/blkid/images-fs/btrfs.img.xz
diff --git a/tests/expected/blkid/low-probe-btrfs b/tests/expected/blkid/low-probe-btrfs
new file mode 100644
index 000000000..509fac378
--- /dev/null
+++ b/tests/expected/blkid/low-probe-btrfs
@@ -0,0 +1,7 @@
+ID_FS_BLOCK_SIZE=4096
+ID_FS_TYPE=btrfs
+ID_FS_USAGE=filesystem
+ID_FS_UUID=d4a78b72-55e4-4811-86a6-09af936d43f9
+ID_FS_UUID_ENC=d4a78b72-55e4-4811-86a6-09af936d43f9
+ID_FS_UUID_SUB=1e7603cb-d0be-4d8f-8972-9dddf7d5543c
+ID_FS_UUID_SUB_ENC=1e7603cb-d0be-4d8f-8972-9dddf7d5543c
diff --git a/tests/ts/blkid/images-fs/btrfs.img.xz b/tests/ts/blkid/images-fs/btrfs.img.xz
new file mode 100644
index 0000000000000000000000000000000000000000..418833d42078492f0266d73b22170d5626b80cc0
GIT binary patch
literal 21696
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
literal 0
HcmV?d00001
--
2.36.1

View File

@ -1,59 +0,0 @@
From 5a9269c019f9cb0b2d54444501beb74663670693 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 21 Aug 2019 13:42:22 +0200
Subject: [PATCH 26/26] partx: document -d vs. --nr and fix test
The commit ab025087f91b66ee8e23a16bc49eb0d9bd421d65 has disabled error
message, but unfortunately it keeps wrong return code. This has been fixed
by commit 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555.
This commit add hit about it to docs and fix regression test too.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179
Upstream: http://github.com/karelzak/util-linux/commit/5200aa99d27e084b514e8b035db32f39b49562a3
Signed-off-by: Karel Zak <kzak@redhat.com>
---
disk-utils/partx.8 | 5 ++++-
tests/ts/partx/partx | 9 +++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/disk-utils/partx.8 b/disk-utils/partx.8
index af7313cb9..c6bbbae42 100644
--- a/disk-utils/partx.8
+++ b/disk-utils/partx.8
@@ -53,7 +53,10 @@ Add the specified partitions, or read the disk and add all partitions.
Print the SIZE column in bytes rather than in human-readable format.
.TP
.BR \-d , " \-\-delete"
-Delete the specified partitions or all partitions.
+Delete the specified partitions or all partitions. It is not error to
+remove non-existing partitions, so this option is possible to use together with
+large \fB\-\-nr\fR ranges without care about the current partitions set on
+the device.
.TP
.BR \-g , " \-\-noheadings"
Do not print a header line with \fB\-\-show\fR or \fB\-\-raw\fR.
diff --git a/tests/ts/partx/partx b/tests/ts/partx/partx
index b21dc44ef..84c286a94 100755
--- a/tests/ts/partx/partx
+++ b/tests/ts/partx/partx
@@ -137,9 +137,14 @@ udevadm settle
ts_init_subtest "delete-non-existent"
#attempt to remove it again
{
+ # remove non-existing partitions (ENXIO) is not error
+ #
+ # see ab025087f91b66ee8e23a16bc49eb0d9bd421d65 and
+ # 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555
+ #
$TS_CMD_PARTX -d --nr $PARTS $TS_DEVICE &&
- echo "partx failed: removed non-existing partition" ||
- echo "partx: OK"
+ echo "partx: OK" ||
+ echo "partx failed: removed non-existing partition"
} >$TS_OUTPUT 2>&1
ts_finalize_subtest
--
2.21.0

View File

@ -0,0 +1,94 @@
From 96a699563b65b6a9204f2c3184faf1366155a614 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Wed, 27 Apr 2022 17:33:33 +0200
Subject: blkid: add tests for FSLASTBLOCK tag
Upstream: http://github.com/util-linux/util-linux/commit/800ed56f4
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
misc-utils/blkid.c | 2 +-
tests/expected/blkid/low-probe-btrfs | 1 +
tests/expected/blkid/low-probe-ext2 | 1 +
tests/expected/blkid/low-probe-ext3 | 1 +
tests/expected/blkid/low-probe-jbd | 1 +
tests/expected/blkid/low-probe-xfs | 1 +
tests/expected/blkid/low-probe-xfs-v5 | 1 +
7 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index 4f456be52..f2b190ce3 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -893,7 +893,7 @@ int main(int argc, char **argv)
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_FSSIZE);
+ BLKID_SUBLKS_FSSIZE | BLKID_SUBLKS_FSLASTBLOCK);
if (fltr_usage &&
diff --git a/tests/expected/blkid/low-probe-btrfs b/tests/expected/blkid/low-probe-btrfs
index 509fac378..48649389a 100644
--- a/tests/expected/blkid/low-probe-btrfs
+++ b/tests/expected/blkid/low-probe-btrfs
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=4096
+ID_FS_FSLASTBLOCK=29440
ID_FS_TYPE=btrfs
ID_FS_USAGE=filesystem
ID_FS_UUID=d4a78b72-55e4-4811-86a6-09af936d43f9
diff --git a/tests/expected/blkid/low-probe-ext2 b/tests/expected/blkid/low-probe-ext2
index 087da97a4..e236c6e8a 100644
--- a/tests/expected/blkid/low-probe-ext2
+++ b/tests/expected/blkid/low-probe-ext2
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=1024
+ID_FS_FSLASTBLOCK=100
ID_FS_LABEL=test-ext2
ID_FS_LABEL_ENC=test-ext2
ID_FS_TYPE=ext2
diff --git a/tests/expected/blkid/low-probe-ext3 b/tests/expected/blkid/low-probe-ext3
index 8684884c1..164fefb7b 100644
--- a/tests/expected/blkid/low-probe-ext3
+++ b/tests/expected/blkid/low-probe-ext3
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=1024
+ID_FS_FSLASTBLOCK=2048
ID_FS_LABEL=test-ext3
ID_FS_LABEL_ENC=test-ext3
ID_FS_SEC_TYPE=ext2
diff --git a/tests/expected/blkid/low-probe-jbd b/tests/expected/blkid/low-probe-jbd
index c9f9f6b79..f5462a2a3 100644
--- a/tests/expected/blkid/low-probe-jbd
+++ b/tests/expected/blkid/low-probe-jbd
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=1024
+ID_FS_FSLASTBLOCK=1024
ID_FS_LOGUUID=0d7a07df-7b06-4829-bce7-3b9c3ece570c
ID_FS_TYPE=jbd
ID_FS_USAGE=other
diff --git a/tests/expected/blkid/low-probe-xfs b/tests/expected/blkid/low-probe-xfs
index a91e92bcc..be9c4194a 100644
--- a/tests/expected/blkid/low-probe-xfs
+++ b/tests/expected/blkid/low-probe-xfs
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=512
+ID_FS_FSLASTBLOCK=4096
ID_FS_FSSIZE=11862016
ID_FS_LABEL=test-xfs
ID_FS_LABEL_ENC=test-xfs
diff --git a/tests/expected/blkid/low-probe-xfs-v5 b/tests/expected/blkid/low-probe-xfs-v5
index 129b41f26..fd2cba933 100644
--- a/tests/expected/blkid/low-probe-xfs-v5
+++ b/tests/expected/blkid/low-probe-xfs-v5
@@ -1,4 +1,5 @@
ID_FS_BLOCK_SIZE=512
+ID_FS_FSLASTBLOCK=5120
ID_FS_FSSIZE=17469440
ID_FS_LABEL=test-xfs-v5
ID_FS_LABEL_ENC=test-xfs-v5
--
2.36.1

View File

@ -1,396 +0,0 @@
From 32fe4f1dd8fbc104bd848e24de613122947f095a Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 28 Aug 2019 15:47:16 +0200
Subject: [PATCH] libmount: improve mountinfo reliability
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The standard way how we read mount table is not reliable because
during the read() syscalls the table may be modified by some another
process. The changes in the table is possible to detect by poll()
event, and in this case it seems better to lseek to the begin of the file
and read it again. It's expensive, but better than races...
This patch does not modify mountinfo parser, but it reads all file to
memory (by read()+poll()) and than it creates memory stream
from the buffer and use it rather than a regular file stream.
It means the parser is still possible to use for normal files
(e.g. fstab) as well as for mountinfo and it's also portable to
systems where for some reason is no fmemopen().
Addresses: https://github.com/systemd/systemd/issues/10872
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1751447
Upstream: http://github.com/karelzak/util-linux/commit/e4925f591c1bfb83719418b56b952830d15b77eb
Upstream: http://github.com/karelzak/util-linux/commit/ee551c909f95437fd9fcd162f398c069d0ce9720
Reported-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
configure.ac | 1 +
libmount/src/mountP.h | 2 +
libmount/src/tab_parse.c | 87 +++++++++++++++++----
libmount/src/utils.c | 158 +++++++++++++++++++++++++++++++++++++++
4 files changed, 233 insertions(+), 15 deletions(-)
diff --git a/configure.ac b/configure.ac
index a05a294ad..245004890 100644
--- a/configure.ac
+++ b/configure.ac
@@ -456,6 +456,7 @@ AC_CHECK_FUNCS([ \
err \
errx \
explicit_bzero \
+ fmemopen \
fsync \
utimensat \
getdomainname \
diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h
index d47d26442..52a238ef3 100644
--- a/libmount/src/mountP.h
+++ b/libmount/src/mountP.h
@@ -93,6 +93,7 @@ extern int mnt_valid_tagname(const char *tagname);
extern int append_string(char **a, const char *b);
extern const char *mnt_statfs_get_fstype(struct statfs *vfs);
+extern int is_procfs_fd(int fd);
extern int is_file_empty(const char *name);
extern int mnt_is_readonly(const char *path)
@@ -118,6 +119,7 @@ extern void mnt_free_filesystems(char **filesystems);
extern char *mnt_get_kernel_cmdline_option(const char *name);
extern int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path);
extern int mnt_stat_mountpoint(const char *target, struct stat *st);
+extern FILE *mnt_get_procfs_memstream(int fd, char **membuf);
/* tab.c */
extern int is_mountinfo(struct libmnt_table *tb);
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index 3ed84ebc2..10fc68279 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -603,15 +603,7 @@ static int kernel_fs_postparse(struct libmnt_table *tb,
return rc;
}
-/**
- * mnt_table_parse_stream:
- * @tb: tab pointer
- * @f: file stream
- * @filename: filename used for debug and error messages
- *
- * Returns: 0 on success, negative number in case of error.
- */
-int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename)
+static int __table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename)
{
int rc = -1;
int flags = 0;
@@ -685,6 +677,40 @@ err:
return rc;
}
+/**
+ * mnt_table_parse_stream:
+ * @tb: tab pointer
+ * @f: file stream
+ * @filename: filename used for debug and error messages
+ *
+ * Returns: 0 on success, negative number in case of error.
+ */
+int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename)
+{
+ int fd, rc;
+ FILE *memf = NULL;
+ char *membuf = NULL;
+
+ /*
+ * For /proc/#/{mountinfo,mount} we read all file to memory and use it
+ * as memory stream. For more details see mnt_read_procfs_file().
+ */
+ if ((fd = fileno(f)) >= 0
+ && (tb->fmt == MNT_FMT_GUESS ||
+ tb->fmt == MNT_FMT_MOUNTINFO ||
+ tb->fmt == MNT_FMT_MTAB)
+ && is_procfs_fd(fd)
+ && (memf = mnt_get_procfs_memstream(fd, &membuf))) {
+
+ rc = __table_parse_stream(tb, memf, filename);
+ fclose(memf);
+ free(membuf);
+ } else
+ rc = __table_parse_stream(tb, f, filename);
+
+ return rc;
+}
+
/**
* mnt_table_parse_file:
* @tb: tab pointer
@@ -700,18 +726,49 @@ err:
int mnt_table_parse_file(struct libmnt_table *tb, const char *filename)
{
FILE *f;
- int rc;
+ int rc, fd = -1;
if (!filename || !tb)
return -EINVAL;
- f = fopen(filename, "r" UL_CLOEXECSTR);
+ /*
+ * Try to use read()+poll() to realiably read all
+ * /proc/#/{mount,mountinfo} file to memory
+ */
+ if (tb->fmt != MNT_FMT_SWAPS
+ && strncmp(filename, "/proc/", 6) == 0) {
+
+ FILE *memf;
+ char *membuf = NULL;
+
+ fd = open(filename, O_RDONLY|O_CLOEXEC);
+ if (fd < 0) {
+ rc = -errno;
+ goto done;
+ }
+ memf = mnt_get_procfs_memstream(fd, &membuf);
+ if (memf) {
+ rc = __table_parse_stream(tb, memf, filename);
+
+ fclose(memf);
+ free(membuf);
+ close(fd);
+ goto done;
+ }
+ /* else fallback to fopen/fdopen() */
+ }
+
+ if (fd >= 0)
+ f = fdopen(fd, "r" UL_CLOEXECSTR);
+ else
+ f = fopen(filename, "r" UL_CLOEXECSTR);
+
if (f) {
- rc = mnt_table_parse_stream(tb, f, filename);
+ rc = __table_parse_stream(tb, f, filename);
fclose(f);
} else
rc = -errno;
-
+done:
DBG(TAB, ul_debugobj(tb, "parsing done [filename=%s, rc=%d]", filename, rc));
return rc;
}
@@ -768,7 +825,7 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname)
f = fopen_at(dd, d->d_name, O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR);
if (f) {
- mnt_table_parse_stream(tb, f, d->d_name);
+ __table_parse_stream(tb, f, d->d_name);
fclose(f);
}
}
@@ -809,7 +866,7 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname)
f = fopen_at(dirfd(dir), d->d_name,
O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR);
if (f) {
- mnt_table_parse_stream(tb, f, d->d_name);
+ __table_parse_stream(tb, f, d->d_name);
fclose(f);
}
}
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index c36187c07..f7d85d124 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -14,6 +14,7 @@
#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
+#include <poll.h>
#include <blkid.h>
#include "strutils.h"
@@ -408,6 +409,12 @@ const char *mnt_statfs_get_fstype(struct statfs *vfs)
return NULL;
}
+int is_procfs_fd(int fd)
+{
+ struct statfs sfs;
+
+ return fstatfs(fd, &sfs) == 0 && sfs.f_type == STATFS_PROC_MAGIC;
+}
/**
* mnt_match_fstype:
@@ -1117,8 +1124,158 @@ done:
return 1;
}
+#if defined(HAVE_FMEMOPEN) || defined(TEST_PROGRAM)
+
+/*
+ * This function tries to minimize possible races when we read
+ * /proc/#/{mountinfo,mount} files.
+ *
+ * The idea is to minimize number of read()s and check by poll() that during
+ * the read the mount table has not been modified. If yes, than re-read it
+ * (with some limitations to avoid never ending loop).
+ *
+ * Returns: <0 error, 0 success, 1 too many attempts
+ */
+static int read_procfs_file(int fd, char **buf, size_t *bufsiz)
+{
+ size_t bufmax = 0;
+ int rc = 0, tries = 0, ninters = 0;
+ char *bufptr = NULL;;
+
+ assert(buf);
+ assert(bufsiz);
+
+ *bufsiz = 0;
+ *buf = NULL;
+
+ do {
+ ssize_t ret;
+
+ if (!bufptr || bufmax == *bufsiz) {
+ char *tmp;
+
+ bufmax = bufmax ? bufmax * 2 : (16 * 1024);
+ tmp = realloc(*buf, bufmax);
+ if (!tmp)
+ break;
+ *buf = tmp;
+ bufptr = tmp + *bufsiz;
+ }
+
+ errno = 0;
+ ret = read(fd, bufptr, bufmax - *bufsiz);
+
+ if (ret < 0) {
+ /* error */
+ if ((errno == EAGAIN || errno == EINTR) && (ninters++ < 5)) {
+ xusleep(200000);
+ continue;
+ }
+ break;
+
+ } else if (ret > 0) {
+ /* success -- verify no event during read */
+ struct pollfd fds[] = {
+ { .fd = fd, .events = POLLPRI }
+ };
+
+ rc = poll(fds, 1, 0);
+ if (rc < 0)
+ break; /* poll() error */
+ if (rc > 0) {
+ /* event -- read all again */
+ if (lseek(fd, 0, SEEK_SET) != 0)
+ break;
+ *bufsiz = 0;
+ bufptr = *buf;
+ tries++;
+
+ if (tries > 10)
+ /* busy system? -- wait */
+ xusleep(10000);
+ continue;
+ }
+
+ /* successful read() without active poll() */
+ (*bufsiz) += (size_t) ret;
+ bufptr += ret;
+ tries = ninters = 0;
+ } else {
+ /* end-of-file */
+ goto success;
+ }
+ } while (tries <= 100);
+
+ rc = errno ? -errno : 1;
+ free(*buf);
+ return rc;
+
+success:
+ return 0;
+}
+
+/*
+ * Create FILE stream for data from read_procfs_file()
+ */
+FILE *mnt_get_procfs_memstream(int fd, char **membuf)
+{
+ FILE *memf;
+ size_t sz = 0;
+ off_t cur;
+
+ /* in case of error, rewind to the original position */
+ cur = lseek(fd, 0, SEEK_CUR);
+
+ if (read_procfs_file(fd, membuf, &sz) == 0
+ && sz > 0
+ && (memf = fmemopen(*membuf, sz, "r")))
+ return memf;
+
+ /* error */
+ lseek(fd, cur, SEEK_SET);
+ return NULL;
+}
+#else
+FILE *mnt_get_procfs_memstream(int fd __attribute((__unused__)),
+ char **membuf __attribute((__unused__)))
+{
+ return NULL;
+}
+#endif /* HAVE_FMEMOPEN */
+
#ifdef TEST_PROGRAM
+static int test_proc_read(struct libmnt_test *ts, int argc, char *argv[])
+{
+ char *buf = NULL;
+ char *filename = argv[1];
+ size_t bufsiz = 0;
+ int rc = 0, fd = open(filename, O_RDONLY);
+
+ if (fd <= 0) {
+ warn("%s: cannot open", filename);
+ return -errno;
+ }
+
+ rc = read_procfs_file(fd, &buf, &bufsiz);
+ close(fd);
+
+ switch (rc) {
+ case 0:
+ fwrite(buf, 1, bufsiz, stdout);
+ free(buf);
+ break;
+ case 1:
+ warnx("too many attempts");
+ break;
+ default:
+ warn("%s: cannot read", filename);
+ break;
+ }
+
+ return rc;
+}
+
static int test_match_fstype(struct libmnt_test *ts, int argc, char *argv[])
{
char *type = argv[1];
@@ -1300,6 +1457,7 @@ int main(int argc, char *argv[])
{ "--guess-root", test_guess_root, "[<maj:min>]" },
{ "--mkdir", test_mkdir, "<path>" },
{ "--statfs-type", test_statfs_type, "<path>" },
+ { "--read-procfs", test_proc_read, "<path>" },
{ NULL }
};
--
2.21.0

View File

@ -0,0 +1,120 @@
From f58a63a3d88cccd5fdf53ead425c5e8186f32cc1 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Mon, 2 May 2022 17:08:33 +0200
Subject: libblkid: merge FS* flags into one FSINFO
Put BLOCK_SIZE, FSSIZE and FSLASTBLOCK tags under one FSINFO flag.
These, and probably future ones, are read directly from the
superblock (with minor post-processing). These properties are
combined under one flag to escape adding a flag per superblock
member.
Upstream: http://github.com/util-linux/util-linux/commit/c9b2297eb
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/samples/superblocks.c | 3 +--
libblkid/src/blkid.h.in | 23 +++++++++++------------
libblkid/src/superblocks/superblocks.c | 9 +++++++--
misc-utils/blkid.c | 3 +--
4 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/libblkid/samples/superblocks.c b/libblkid/samples/superblocks.c
index b7f94ec14..5253f9cc4 100644
--- a/libblkid/samples/superblocks.c
+++ b/libblkid/samples/superblocks.c
@@ -44,8 +44,7 @@ int main(int argc, char *argv[])
BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE |
- BLKID_SUBLKS_FSLASTBLOCK);
+ BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSINFO);
rc = blkid_do_safeprobe(pr);
if (rc == -1)
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
index 56e64f9ab..ae4e555e3 100644
--- a/libblkid/src/blkid.h.in
+++ b/libblkid/src/blkid.h.in
@@ -271,18 +271,17 @@ extern int blkid_superblocks_get_name(size_t idx, const char **name, int *usage)
extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
__ul_attribute__((nonnull));
-#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
-#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
-#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
-#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
-#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
-#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
-#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
-#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
-#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
-#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
-#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
-#define BLKID_SUBLKS_FSLASTBLOCK (1 << 12) /* read and define FSLASTBLOCK from superblock */
+#define BLKID_SUBLKS_LABEL (1 << 1) /* read LABEL from superblock */
+#define BLKID_SUBLKS_LABELRAW (1 << 2) /* read and define LABEL_RAW result value*/
+#define BLKID_SUBLKS_UUID (1 << 3) /* read UUID from superblock */
+#define BLKID_SUBLKS_UUIDRAW (1 << 4) /* read and define UUID_RAW result value */
+#define BLKID_SUBLKS_TYPE (1 << 5) /* define TYPE result value */
+#define BLKID_SUBLKS_SECTYPE (1 << 6) /* define compatible fs type (second type) */
+#define BLKID_SUBLKS_USAGE (1 << 7) /* define USAGE result value */
+#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
+#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
+#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
+#define BLKID_SUBLKS_FSINFO (1 << 11) /* read and define fs properties from superblock */
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 5b899a830..a1f42c611 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -562,6 +562,11 @@ int blkid_probe_sprintf_version(blkid_probe pr, const char *fmt, ...)
int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size)
{
+ struct blkid_chain *chn = blkid_probe_get_chain(pr);
+
+ if (!(chn->flags & BLKID_SUBLKS_FSINFO))
+ return 0;
+
return blkid_probe_sprintf_value(pr, "BLOCK_SIZE", "%u", block_size);
}
@@ -591,7 +596,7 @@ int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
- if (!(chn->flags & BLKID_SUBLKS_FSSIZE))
+ if (!(chn->flags & BLKID_SUBLKS_FSINFO))
return 0;
return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
@@ -601,7 +606,7 @@ int blkid_probe_set_fslastblock(blkid_probe pr, uint64_t lastblock)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
- if (!(chn->flags & BLKID_SUBLKS_FSLASTBLOCK))
+ if (!(chn->flags & BLKID_SUBLKS_FSINFO))
return 0;
return blkid_probe_sprintf_value(pr, "FSLASTBLOCK", "%" PRIu64,
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index f2b190ce3..744151616 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -893,8 +893,7 @@ int main(int argc, char **argv)
BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
- BLKID_SUBLKS_FSSIZE | BLKID_SUBLKS_FSLASTBLOCK);
-
+ BLKID_SUBLKS_FSINFO);
if (fltr_usage &&
blkid_probe_filter_superblocks_usage(pr, fltr_flag, fltr_usage))
--
2.36.1

View File

@ -1,53 +0,0 @@
From d9fe56d8da9015694fcba5f3dd850becff677ab5 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 20 Sep 2019 13:00:19 +0200
Subject: [PATCH] libmount: use fmemopen() in more robust way [coverity scan]
Upstream: http://github.com/karelzak/util-linux/commit/026f7d302066a4e6f5a69dc9818ec3180939f4a3
Upstream: http://github.com/karelzak/util-linux/commit/bc747dfccf511419312ec872cefa90e25d83136a
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1751447
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/utils.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index f7d85d124..04e79f53f 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -1219,20 +1219,26 @@ success:
*/
FILE *mnt_get_procfs_memstream(int fd, char **membuf)
{
- FILE *memf;
size_t sz = 0;
off_t cur;
+ *membuf = NULL;
+
/* in case of error, rewind to the original position */
cur = lseek(fd, 0, SEEK_CUR);
- if (read_procfs_file(fd, membuf, &sz) == 0
- && sz > 0
- && (memf = fmemopen(*membuf, sz, "r")))
- return memf;
+ if (read_procfs_file(fd, membuf, &sz) == 0 && sz > 0) {
+ FILE *memf = fmemopen(*membuf, sz, "r");
+ if (memf)
+ return memf; /* success */
+
+ free(*membuf);
+ *membuf = NULL;
+ }
/* error */
- lseek(fd, cur, SEEK_SET);
+ if (cur != (off_t) -1)
+ lseek(fd, cur, SEEK_SET);
return NULL;
}
#else
--
2.21.0

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
From 6f16035b81cd7feca02d6df8eff1bb954ed7e58d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 4 Sep 2018 14:30:37 +0200
Subject: [PATCH 29/32] lscpu: use the first VM from /proc/sysinfo
Addresses: https://github.com/karelzak/util-linux/issues/685
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739443
Upstream: http://github.com/karelzak/util-linux/commit/350f5c8df2cb6edbfb5bae95f00a9fff446d236c
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/lscpu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index fd6d63bbf..1aa7bff4d 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -866,6 +866,7 @@ read_hypervisor(struct lscpu_desc *desc, struct lscpu_modifier *mod)
*(str--) = '\0';
while ((str = strstr(desc->hypervisor, " ")))
memmove(str, str + 1, strlen(str));
+ break;
}
fclose(fd);
}
--
2.21.0

View File

@ -0,0 +1,32 @@
From 5300d69be2919d0a50968377d23807831fdf3f71 Mon Sep 17 00:00:00 2001
From: Andrey Albershteyn <aalbersh@redhat.com>
Date: Fri, 27 May 2022 12:56:27 +0200
Subject: libblkid: update documentation of BLOCK_SIZE tag
The name BLOCK_SIZE is unfortunate. This tag doesn't represent
commonly used file system block size but minimal block size
accessible by file system (sector size).
Upstream: http://github.com/util-linux/util-linux/commit/895f0b609
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/src/superblocks/superblocks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 9cfa991fc..9c32bc9d5 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -80,7 +80,7 @@
*
* @BOOT_SYSTEM_ID: ISO9660 boot system identifier
*
- * @BLOCK_SIZE: block size
+ * @BLOCK_SIZE: minimal block size accessible by file system
*/
static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn);
--
2.36.1

View File

@ -1,206 +0,0 @@
From e10bdfc6cd623f02740cf2bcfd9867c56534c5e5 Mon Sep 17 00:00:00 2001
From: Radka Skvarilova <rskvaril@redhat.com>
Date: Sun, 22 Sep 2019 13:49:45 +0200
Subject: [PATCH 30/32] tests: lscpu s390 nested virtualization
Signed-off-by: Radka Skvarilova <rskvaril@redhat.com>
Addresses:https://bugzilla.redhat.com/show_bug.cgi?id=1739443
Upstream: http://github.com/karelzak/util-linux/commit/2062164894fffa314ecb7ac99dc6c98062484389
---
tests/expected/lscpu/lscpu-s390-nested-virt | 45 +++++++++++++++++++
tests/ts/lscpu/dumps/s390-nested-virt.tar.gz | Bin 0 -> 7199 bytes
2 files changed, 45 insertions(+)
create mode 100644 tests/expected/lscpu/lscpu-s390-nested-virt
create mode 100644 tests/ts/lscpu/dumps/s390-nested-virt.tar.gz
diff --git a/tests/expected/lscpu/lscpu-s390-nested-virt b/tests/expected/lscpu/lscpu-s390-nested-virt
new file mode 100644
index 000000000..2665fd8dc
--- /dev/null
+++ b/tests/expected/lscpu/lscpu-s390-nested-virt
@@ -0,0 +1,45 @@
+CPU op-mode(s): 32-bit, 64-bit
+CPU(s): 2
+On-line CPU(s) list: 0,1
+Thread(s) per core: 1
+Core(s) per socket: 1
+Socket(s) per book: 1
+Book(s) per drawer: 1
+Drawer(s): 2
+NUMA node(s): 1
+Vendor ID: IBM/S390
+Machine type: 2964
+CPU dynamic MHz: 5000
+CPU static MHz: 5000
+BogoMIPS: 3033.00
+Hypervisor: KVM/Linux
+Hypervisor vendor: KVM
+Virtualization type: full
+Dispatching mode: horizontal
+L1d cache: 256 KiB
+L1i cache: 192 KiB
+L2d cache: 4 MiB
+L2i cache: 4 MiB
+L3 cache: 64 MiB
+L4 cache: 480 MiB
+NUMA node0 CPU(s): 0,1
+Vulnerability L1tf: Not affected
+Vulnerability Meltdown: Not affected
+Vulnerability Spec store bypass: Not affected
+Vulnerability Spectre v1: Mitigation; __user pointer sanitization
+Vulnerability Spectre v2: Mitigation; execute trampolines
+Flags: esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx
+
+# The following is the parsable format, which can be fed to other
+# programs. Each different item in every column has an unique ID
+# starting from zero.
+# CPU,Core,Socket,Node,,L1d,L1i,L2d,L2i
+0,0,0,0,,0,0,0,0
+1,1,1,0,,1,1,1,1
+
+# The following is the parsable format, which can be fed to other
+# programs. Each different item in every column has an unique ID
+# starting from zero.
+# CPU,Core,Socket,Node,,L1d,L1i,L2d,L2i
+0,0,0,0,,0,0,0,0
+1,1,1,0,,1,1,1,1
diff --git a/tests/ts/lscpu/dumps/s390-nested-virt.tar.gz b/tests/ts/lscpu/dumps/s390-nested-virt.tar.gz
new file mode 100644
index 0000000000000000000000000000000000000000..7992699925395ed8d33b1e1466b74fc1aa235268
GIT binary patch
literal 7199
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
L#Syu9MY;b1+Xr6l
literal 0
HcmV?d00001
--
2.21.0

View File

@ -0,0 +1,28 @@
From da3add097b70160cd2c6bab0a4acb699df07ebe8 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 17 Mar 2022 10:48:33 +0100
Subject: cfdisk: don't use NULL in printf [coverity scan]
Upstream: http://github.com/util-linux/util-linux/commit/30cc5f5751698cccb625193f715f1a606a7f91b4
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2109459
Signed-off-by: Karel Zak <kzak@redhat.com>
---
disk-utils/cfdisk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c
index c1b28889f..36eb3f8c6 100644
--- a/disk-utils/cfdisk.c
+++ b/disk-utils/cfdisk.c
@@ -2080,7 +2080,7 @@ done:
}
free(cm);
DBG(UI, ul_debug("get parrtype done [type=%s] ", t ?
- fdisk_parttype_get_name(t) : NULL));
+ fdisk_parttype_get_name(t) : ""));
return t;
}
--
2.36.1

View File

@ -1,43 +0,0 @@
From 90d4faece26c328c40336a0e02b875515c503e30 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 19 Aug 2019 14:03:07 +0200
Subject: [PATCH 31/32] chfn: don't append extra tailing commas
# grep kzak /etc/passwd
kzak:x:1000:1000::/home/kzak:/bin/bash
# chfn kzak
...
grep kzak /etc/passwd
old version:
kzak:x:1000:1000:Karel Zak,,,,:/home/kzak:/bin/bash
fixed version:
kzak:x:1000:1000:Karel Zak:/home/kzak:/bin/bash
Reported-by: Filip Dvorak <fdvorak@redhat.com>
References: f723cbf544a7eac2927634f2cb6d802437a2d519
Upstream: http://github.com/karelzak/util-linux/commit/9210c0d225fd808da451d86055bf243a8b47a525
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1743555
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/chfn.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
index c5312fa0c..4f32604c5 100644
--- a/login-utils/chfn.c
+++ b/login-utils/chfn.c
@@ -377,7 +377,7 @@ static int save_new_data(struct chfn_control *ctl)
ctl->newf.other);
/* remove trailing empty fields (but not subfields of ctl->newf.other) */
- if (!ctl->newf.other) {
+ if (!ctl->newf.other || !*ctl->newf.other) {
while (len > 0 && gecos[len - 1] == ',')
len--;
gecos[len] = 0;
--
2.21.0

View File

@ -1,83 +0,0 @@
From 447b7d7222bf8cb3591d611aa51917bd4453f8d6 Mon Sep 17 00:00:00 2001
From: Radka Skvarilova <rskvaril@redhat.com>
Date: Mon, 16 Dec 2019 10:57:32 +0100
Subject: [PATCH 32/32] tests: add new test for chfn gecos
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1743555
Upstream: http://github.com/karelzak/util-linux/commit/02238bff663ce5fe823980d8119f3871cc348764
Upstream: http://github.com/karelzak/util-linux/commit/b2ef43864f24b1a9c0c67fe2a7177a5110da1b6e
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/commands.sh | 1 +
tests/expected/chfn/gecos | 6 ++++++
tests/ts/chfn/gecos | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
create mode 100644 tests/expected/chfn/gecos
create mode 100755 tests/ts/chfn/gecos
diff --git a/tests/commands.sh b/tests/commands.sh
index 93100caf6..b56381c9e 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -104,3 +104,4 @@ TS_CMD_UUIDPARSE=${TS_CMD_UUIDPARSE-"${ts_commandsdir}uuidparse"}
TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"${ts_commandsdir}whereis"}
TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"${ts_commandsdir}wipefs"}
TS_CMD_CHRT=${TS_CMD_CHRT-"${ts_commandsdir}chrt"}
+TS_CMD_CHFN=${TS_CMD_CHFN-"${ts_commandsdir}chfn"}
diff --git a/tests/expected/chfn/gecos b/tests/expected/chfn/gecos
new file mode 100644
index 000000000..af7b81b6c
--- /dev/null
+++ b/tests/expected/chfn/gecos
@@ -0,0 +1,6 @@
+Initialize user
+testuser_chfn_test:x:9899:9899::/home/testuser_chfn_test:/bin/bash
+Changing finger information for testuser_chfn_test.
+
+Finger information changed.
+testuser_chfn_test:x:9899:9899:test_gecos:/home/testuser_chfn_test:/bin/bash
diff --git a/tests/ts/chfn/gecos b/tests/ts/chfn/gecos
new file mode 100755
index 000000000..aad27d40a
--- /dev/null
+++ b/tests/ts/chfn/gecos
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2019 Radka Skvarilova <rskvaril@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="gecos"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_skip_nonroot
+ts_check_test_command "$TS_CMD_CHFN"
+ts_check_prog "useradd"
+ts_check_prog "userdel"
+
+ts_log "Initialize user"
+useradd -u 9899 --shell /bin/bash testuser_chfn_test
+grep testuser /etc/passwd >> $TS_OUTPUT
+$TS_CMD_CHFN -f test_gecos testuser_chfn_test >>$TS_OUTPUT
+grep testuser /etc/passwd >> $TS_OUTPUT
+userdel --remove testuser_chfn_test &> /dev/null
+ts_finalize
--
2.21.0

View File

@ -0,0 +1,28 @@
From cee4a7f69d853fcc574241d394edc5bcb91469a5 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 6 Jun 2022 16:19:16 +0200
Subject: zramctl: fix compiler warning [-Werror=maybe-uninitialized]
Upstream: http://github.com/util-linux/util-linux/commit/8883f037466a5534554d7d9114aceb740295ef20
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2109459
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/zramctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index 003349fad..64d5fcd81 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -291,7 +291,7 @@ static struct path_cxt *zram_get_control(void)
static int zram_control_add(struct zram *z)
{
- int n;
+ int n = 0;
struct path_cxt *ctl;
if (!zram_has_control(z) || !(ctl = zram_get_control()))
--
2.36.1

View File

@ -0,0 +1,46 @@
From f6fffc1a89e57b7d5dd4adf1ee6b2146e58ec411 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 17 Mar 2022 12:18:03 +0100
Subject: lib/path: make ul_path_read_buffer() more robust [coverity scan]
Make sure we never call buf[rc - 1] for rc=0.
Upstream: http://github.com/util-linux/util-linux/commit/ea459dcf95d0bb04c816b71d2b85fbcd8cfc5ee4
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2109459
Signed-off-by: Karel Zak <kzak@redhat.com>
---
lib/path.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/lib/path.c b/lib/path.c
index 21f9bd1c4..ab034e110 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -666,14 +666,17 @@ int ul_path_readf_string(struct path_cxt *pc, char **str, const char *path, ...)
int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path)
{
int rc = ul_path_read(pc, buf, bufsz - 1, path);
- if (rc < 0)
- return rc;
- /* Remove tailing newline (usual in sysfs) */
- if (rc > 0 && *(buf + rc - 1) == '\n')
- buf[--rc] = '\0';
- else
- buf[rc - 1] = '\0';
+ if (rc == 0)
+ buf[0] = '\0';
+
+ else if (rc > 0) {
+ /* Remove tailing newline (usual in sysfs) */
+ if (*(buf + rc - 1) == '\n')
+ buf[--rc] = '\0';
+ else
+ buf[rc - 1] = '\0';
+ }
return rc;
}
--
2.36.1

View File

@ -1,83 +0,0 @@
From b30f84e240bd60a23508797e33a4777cbaa50949 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 17 Dec 2019 10:53:47 +0100
Subject: [PATCH] tests: update lscpu test for RHEL8
The test is originally from upstream (~v2.35), but RHEL-8 uses older
version with a little different output -- RHEL-8 has no vulnerability
fields and it counts cache sizes in different way.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739443
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/expected/lscpu/lscpu-s390-nested-virt | 57 ++++++++++-----------
1 file changed, 26 insertions(+), 31 deletions(-)
diff --git a/tests/expected/lscpu/lscpu-s390-nested-virt b/tests/expected/lscpu/lscpu-s390-nested-virt
index 2665fd8dc..a6ab04f0b 100644
--- a/tests/expected/lscpu/lscpu-s390-nested-virt
+++ b/tests/expected/lscpu/lscpu-s390-nested-virt
@@ -1,34 +1,29 @@
-CPU op-mode(s): 32-bit, 64-bit
-CPU(s): 2
-On-line CPU(s) list: 0,1
-Thread(s) per core: 1
-Core(s) per socket: 1
-Socket(s) per book: 1
-Book(s) per drawer: 1
-Drawer(s): 2
-NUMA node(s): 1
-Vendor ID: IBM/S390
-Machine type: 2964
-CPU dynamic MHz: 5000
-CPU static MHz: 5000
-BogoMIPS: 3033.00
-Hypervisor: KVM/Linux
-Hypervisor vendor: KVM
-Virtualization type: full
-Dispatching mode: horizontal
-L1d cache: 256 KiB
-L1i cache: 192 KiB
-L2d cache: 4 MiB
-L2i cache: 4 MiB
-L3 cache: 64 MiB
-L4 cache: 480 MiB
-NUMA node0 CPU(s): 0,1
-Vulnerability L1tf: Not affected
-Vulnerability Meltdown: Not affected
-Vulnerability Spec store bypass: Not affected
-Vulnerability Spectre v1: Mitigation; __user pointer sanitization
-Vulnerability Spectre v2: Mitigation; execute trampolines
-Flags: esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx
+CPU op-mode(s): 32-bit, 64-bit
+CPU(s): 2
+On-line CPU(s) list: 0,1
+Thread(s) per core: 1
+Core(s) per socket: 1
+Socket(s) per book: 1
+Book(s) per drawer: 1
+Drawer(s): 2
+NUMA node(s): 1
+Vendor ID: IBM/S390
+Machine type: 2964
+CPU dynamic MHz: 5000
+CPU static MHz: 5000
+BogoMIPS: 3033.00
+Hypervisor: KVM/Linux
+Hypervisor vendor: KVM
+Virtualization type: full
+Dispatching mode: horizontal
+L1d cache: 128K
+L1i cache: 96K
+L2d cache: 2048K
+L2i cache: 2048K
+L3 cache: 65536K
+L4 cache: 491520K
+NUMA node0 CPU(s): 0,1
+Flags: esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx
# The following is the parsable format, which can be fed to other
# programs. Each different item in every column has an unique ID
--
2.21.0

View File

@ -0,0 +1,27 @@
From 53af90a8edf2e60342b477d28e0d802dc26f18b7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 9 Aug 2022 12:35:05 +0200
Subject: lslogins: improve for static analyzer
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index ff4386d1b..56431212d 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -852,7 +852,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
while (p && *p == '!')
p++, i++;
- if (i != 0 && (!*p || valid_pwd(p)))
+ if (i != 0 && p && (!*p || valid_pwd(p)))
user->pwd_lock = STATUS_TRUE;
} else
user->pwd_lock = STATUS_UNKNOWN;
--
2.37.1

View File

@ -1,91 +0,0 @@
From 60f97394878d8b540ee6a4fb9c9edaae2f90d0d0 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 17 Dec 2019 18:10:31 +0100
Subject: [PATCH] tests: (fdisk) make sure we use the same sizes for MD devices
It seems on some kernels MD can return error if the devices in RAID
have different size
# mdadm -q --create /dev/md8 --chunk=64 --level=0 --raid-devices=2 /dev/sda1 /dev/sda2
mdadm: RUN_ARRAY failed: Unknown error 524
# dmesg
...
[ 1485.148435] md/raid0:md8: cannot assemble multi-zone RAID0 with default_layout setting
[ 1485.152306] md/raid0: please set raid.default_layout to 1 or 2
[ 1485.154050] md: pers->run() failed ...
[ 1485.154104] md: md8 stopped.
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1784534
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/expected/fdisk/align-512-4K-md | 12 ++++++------
tests/ts/fdisk/align-512-4K-md | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/tests/expected/fdisk/align-512-4K-md b/tests/expected/fdisk/align-512-4K-md
index caca03154..3690c04c2 100644
--- a/tests/expected/fdisk/align-512-4K-md
+++ b/tests/expected/fdisk/align-512-4K-md
@@ -16,7 +16,7 @@ Created a new <removed>.
Command (m for help): Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
-Select (default p): Partition number (2-4, default 2): First sector (43008-102399, default 43008): Last sector, +sectors or +size{K,M,G,T,P} (43008-102399, default 102399):
+Select (default p): Partition number (2-4, default 2): First sector (51199-102399, default 51200): Last sector, +sectors or +size{K,M,G,T,P} (51200-102399, default 102399):
Created a new <removed>.
Command (m for help): Disk <removed>: 50 MiB, 52428800 bytes, 102400 sectors
@@ -27,8 +27,8 @@ Disklabel type: dos
Disk identifier: <removed>
Device Boot Start End Sectors Size Id Type
-<removed>1 2048 43007 40960 20M 83 Linux
-<removed>2 43008 102399 59392 29M 83 Linux
+<removed>1 2048 51198 49151 24M 83 Linux
+<removed>2 51200 100350 49151 24M 83 Linux
Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
@@ -49,16 +49,16 @@ Created a new <removed>.
Command (m for help): Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
-Select (default p): Partition number (1-4, default 1): First sector (2048-100095, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-100095, default 100095):
+Select (default p): Partition number (1-4, default 1): First sector (2048-97791, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-97791, default 97791):
Created a new <removed>.
Command (m for help): Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
-Select (default p): Partition number (2-4, default 2): First sector (22528-100095, default 22528): Last sector, +sectors or +size{K,M,G,T,P} (22528-100095, default 100095):
+Select (default p): Partition number (2-4, default 2): First sector (22528-97791, default 22528): Last sector, +sectors or +size{K,M,G,T,P} (22528-97791, default 97791):
Created a new <removed>.
-Command (m for help): Disk <removed>: 48.9 MiB, 51249152 bytes, 100096 sectors
+Command (m for help): Disk <removed>: 47.8 MiB, 50069504 bytes, 97792 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 65536 bytes / <removed> bytes
diff --git a/tests/ts/fdisk/align-512-4K-md b/tests/ts/fdisk/align-512-4K-md
index 7f60a654f..68aaff0b7 100755
--- a/tests/ts/fdisk/align-512-4K-md
+++ b/tests/ts/fdisk/align-512-4K-md
@@ -41,12 +41,12 @@ n
p
1
-+20M
++49150
n
p
2
-
++49150
p
w
q
--
2.21.0

View File

@ -0,0 +1,48 @@
From 723438ad02928d9614439def99b36e0758f62d26 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 12 Aug 2022 08:30:49 +0200
Subject: tests: add udevadm settle to loop overlap test
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/libmount/loop-overlay | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay
index 62874a182..c27f60d0f 100755
--- a/tests/ts/libmount/loop-overlay
+++ b/tests/ts/libmount/loop-overlay
@@ -43,22 +43,29 @@ dd if="$IMG" of="$IMG" oflag=append bs=1024k count=5 conv=notrunc &>/dev/null
echo "second should fail" >>$TS_OUTPUT
$TS_CMD_MOUNT -oloop "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
echo "should succeed" >>$TS_OUTPUT
$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>> $TS_ERRLOG
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>> $TS_ERRLOG
+udevadm settle
echo "both should fail" >>$TS_OUTPUT
LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG")
+udevadm settle
$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP --detach $LOOPDEV
ts_log "Success"
--
2.37.2

View File

@ -1,80 +0,0 @@
From 3fd5c8e78a9758a6fc9310485d2428e300ad3b63 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 11 Jun 2020 10:55:25 +0200
Subject: [PATCH 35/40] tests: mark MD tests with metadata v0.90 as KNOWN-FAIL
metadata v0.90 is deprecated thing and unsupported to create by some new
mdadm versions. It's possible to assemble this array (with
default_layout=1 on modprobe raid0), but impossible to create a new
one.
Upstream: http://github.com/karelzak/util-linux/commit/4ae96cf77b36660255d5870a4209480bbec47902
Upstream: http://github.com/karelzak/util-linux/commit/7519c3edab120b14623931d5ddb16fdc6e7cad5d
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1826251
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/blkid/md-raid0-whole | 3 +++
tests/ts/blkid/md-raid1-part | 3 +++
tests/ts/blkid/md-raid1-whole | 3 +++
tests/ts/fdisk/align-512-4K-md | 3 +++
4 files changed, 12 insertions(+)
diff --git a/tests/ts/blkid/md-raid0-whole b/tests/ts/blkid/md-raid0-whole
index 45c6ee55b..1f3fc2634 100755
--- a/tests/ts/blkid/md-raid0-whole
+++ b/tests/ts/blkid/md-raid0-whole
@@ -29,6 +29,9 @@ ts_skip_nonroot
ts_check_losetup
ts_check_prog "mdadm"
+# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1-12.
+TS_KNOWN_FAIL="yes"
+
ts_log "Initialize devices"
IMGNAME="${TS_OUTDIR}/${TS_TESTNAME}"
diff --git a/tests/ts/blkid/md-raid1-part b/tests/ts/blkid/md-raid1-part
index 3fa6395b0..3d42aadb8 100755
--- a/tests/ts/blkid/md-raid1-part
+++ b/tests/ts/blkid/md-raid1-part
@@ -28,6 +28,9 @@ ts_check_test_command "$TS_CMD_BLKID"
ts_skip_nonroot
ts_check_prog "mdadm"
+# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1-12.
+TS_KNOWN_FAIL="yes"
+
# set global variable TS_DEVICE
ts_scsi_debug_init dev_size_mb=51 sector_size=512
diff --git a/tests/ts/blkid/md-raid1-whole b/tests/ts/blkid/md-raid1-whole
index ddf4a6934..6eba9cc8e 100755
--- a/tests/ts/blkid/md-raid1-whole
+++ b/tests/ts/blkid/md-raid1-whole
@@ -29,6 +29,9 @@ ts_skip_nonroot
ts_check_losetup
ts_check_prog "mdadm"
+# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1-12.
+TS_KNOWN_FAIL="yes"
+
ts_log "Initialize devices"
IMGNAME="${TS_OUTDIR}/${TS_TESTNAME}"
diff --git a/tests/ts/fdisk/align-512-4K-md b/tests/ts/fdisk/align-512-4K-md
index 68aaff0b7..0a8e09bc1 100755
--- a/tests/ts/fdisk/align-512-4K-md
+++ b/tests/ts/fdisk/align-512-4K-md
@@ -31,6 +31,9 @@ ts_check_test_command "$TS_CMD_FDISK"
ts_skip_nonroot
ts_check_prog "mdadm"
+# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1-12.
+TS_KNOWN_FAIL="yes"
+
# set global variable TS_DEVICE
ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3
DEVNAME=$(basename $TS_DEVICE)
--
2.25.4

View File

@ -1,284 +0,0 @@
From ae7b79ff8a7fb576c018bc9a7eaf9e135b7b553e Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 24 Apr 2018 10:57:48 +0200
Subject: [PATCH 36/40] libblkid: add BitLocker detection
Supported:
* WinVista version
* Win7 and later versions (based on NTFS)
* BitLockerToGo (for removable media; based on FAT32)
Unfortunately, it's without LABEL and UUID. It seems BitLocker does
not use volume_label and volume_serial stuff from NTFS header.
Upstream: http://github.com/karelzak/util-linux/commit/136f89ce5ed8cd159a1c56b5a775dada2363ecd3
Upstream: http://github.com/karelzak/util-linux/commit/47afae0caaa2b3440d6ac812079e3ada5f2aa0bd (bitlocker.c part)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1812576
Addresses: https://github.com/karelzak/util-linux/issues/617
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/Makemodule.am | 1 +
libblkid/src/superblocks/bitlocker.c | 191 +++++++++++++++++++++++++
libblkid/src/superblocks/superblocks.c | 1 +
libblkid/src/superblocks/superblocks.h | 3 +
libblkid/src/superblocks/vfat.c | 3 +
5 files changed, 199 insertions(+)
create mode 100644 libblkid/src/superblocks/bitlocker.c
diff --git a/libblkid/src/Makemodule.am b/libblkid/src/Makemodule.am
index 0e1c765fb..ea0230702 100644
--- a/libblkid/src/Makemodule.am
+++ b/libblkid/src/Makemodule.am
@@ -47,6 +47,7 @@ libblkid_la_SOURCES = \
libblkid/src/superblocks/bcache.c \
libblkid/src/superblocks/befs.c \
libblkid/src/superblocks/bfs.c \
+ libblkid/src/superblocks/bitlocker.c \
libblkid/src/superblocks/btrfs.c \
libblkid/src/superblocks/cramfs.c \
libblkid/src/superblocks/ddf_raid.c \
diff --git a/libblkid/src/superblocks/bitlocker.c b/libblkid/src/superblocks/bitlocker.c
new file mode 100644
index 000000000..111edf39b
--- /dev/null
+++ b/libblkid/src/superblocks/bitlocker.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2018 Karel Zak <kzak@redhat.com>
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <stdint.h>
+
+#include "superblocks.h"
+
+#define BDE_HDR_SIZE 512
+#define BDE_HDR_OFFSET 0
+
+struct bde_header_win7 {
+/* 0 */ unsigned char boot_entry_point[3];
+/* 3 */ unsigned char fs_signature[8];
+/* 11 */ unsigned char __dummy1[67 - 11];
+/* 67 */ uint32_t volume_serial; /* NTFS uses 64bit serial number */
+/* 71 */ unsigned char volume_label[11]; /* "NO NAME\x20\x20\x20\x20" only */
+/* 82 */ unsigned char __dummy2[160 - 82];
+/* 160 */ unsigned char guid[16]; /* BitLocker specific GUID */
+/* 176 */ uint64_t fve_metadata_offset;
+} __attribute__((packed));
+
+
+struct bde_header_togo {
+/* 0 */ unsigned char boot_entry_point[3];
+/* 3 */ unsigned char fs_signature[8];
+/* 11 */ unsigned char __dummy[424 - 11];
+/* 424 */ unsigned char guid[16];
+/* 440 */ uint64_t fve_metadata_offset;
+} __attribute__((packed));
+
+
+struct bde_fve_metadata {
+/* 0 */ unsigned char signature[8];
+/* 8 */ uint16_t size;
+/* 10 */ uint16_t version;
+};
+
+enum {
+ BDE_VERSION_VISTA = 0,
+ BDE_VERSION_WIN7,
+ BDE_VERSION_TOGO
+};
+
+#define BDE_MAGIC_VISTA "\xeb\x52\x90-FVE-FS-"
+#define BDE_MAGIC_WIN7 "\xeb\x58\x90-FVE-FS-"
+#define BDE_MAGIC_TOGO "\xeb\x58\x90MSWIN4.1"
+
+#define BDE_MAGIC_FVE "-FVE-FS-"
+
+static int get_bitlocker_type(const unsigned char *buf)
+{
+ size_t i;
+ static const char *map[] = {
+ [BDE_VERSION_VISTA] = BDE_MAGIC_VISTA,
+ [BDE_VERSION_WIN7] = BDE_MAGIC_WIN7,
+ [BDE_VERSION_TOGO] = BDE_MAGIC_TOGO
+ };
+
+ for (i = 0; i < ARRAY_SIZE(map); i++) {
+ if (memcmp(buf, map[i], 11) == 0)
+ return (int) i;
+ }
+
+ return -1;
+}
+
+/* Returns: < 0 error, 1 nothing, 0 success
+ */
+static int get_bitlocker_headers(blkid_probe pr,
+ int *type,
+ const unsigned char **buf_hdr,
+ const unsigned char **buf_fve)
+{
+
+ const unsigned char *buf;
+ const struct bde_fve_metadata *fve;
+ uint64_t off = 0;
+ int kind;
+
+ if (buf_hdr)
+ *buf_hdr = NULL;
+ if (buf_fve)
+ *buf_fve = NULL;
+ if (type)
+ *type = -1;
+
+ buf = blkid_probe_get_buffer(pr, BDE_HDR_OFFSET, BDE_HDR_SIZE);
+ if (!buf)
+ return errno ? -errno : 1;
+
+ kind = get_bitlocker_type(buf);
+
+ /* Check BitLocker header */
+ switch (kind) {
+ case BDE_VERSION_WIN7:
+ off = le64_to_cpu(((const struct bde_header_win7 *) buf)->fve_metadata_offset);
+ break;
+ case BDE_VERSION_TOGO:
+ off = le64_to_cpu(((const struct bde_header_togo *) buf)->fve_metadata_offset);
+ break;
+ case BDE_VERSION_VISTA:
+ goto done;
+ default:
+ goto nothing;
+ }
+
+ if (!off)
+ goto nothing;
+ if (buf_hdr)
+ *buf_hdr = buf;
+
+ /* Check Bitlocker FVE metadata header */
+ buf = blkid_probe_get_buffer(pr, off, sizeof(struct bde_fve_metadata));
+ if (!buf)
+ return errno ? -errno : 1;
+
+ fve = (const struct bde_fve_metadata *) buf;
+ if (memcmp(fve->signature, BDE_MAGIC_FVE, sizeof(fve->signature)) != 0)
+ goto nothing;
+ if (buf_fve)
+ *buf_fve = buf;
+done:
+ if (type)
+ *type = kind;
+ return 0;
+nothing:
+ return 1;
+}
+
+/*
+ * This is used by vFAT and NTFS prober to avoid collisions with bitlocker.
+ */
+int blkid_probe_is_bitlocker(blkid_probe pr)
+{
+ return get_bitlocker_headers(pr, NULL, NULL, NULL) == 0;
+}
+
+static int probe_bitlocker(blkid_probe pr,
+ const struct blkid_idmag *mag __attribute__((__unused__)))
+{
+ const unsigned char *buf_fve = NULL;
+ const unsigned char *buf_hdr = NULL;
+ int rc, kind;
+
+ rc = get_bitlocker_headers(pr, &kind, &buf_hdr, &buf_fve);
+ if (rc)
+ return rc;
+
+ if (kind == BDE_VERSION_WIN7) {
+ const struct bde_header_win7 *hdr = (const struct bde_header_win7 *) buf_hdr;
+
+ /* Unfortunately, it seems volume_serial is always zero */
+ blkid_probe_sprintf_uuid(pr,
+ (const unsigned char *) &hdr->volume_serial,
+ sizeof(hdr->volume_serial),
+ "%016d", le32_to_cpu(hdr->volume_serial));
+ }
+
+ if (buf_fve) {
+ const struct bde_fve_metadata *fve = (const struct bde_fve_metadata *) buf_fve;
+
+ blkid_probe_sprintf_version(pr, "%d", fve->version);
+ }
+ return 0;
+}
+
+/* See header details:
+ * https://github.com/libyal/libbde/blob/master/documentation/BitLocker%20Drive%20Encryption%20(BDE)%20format.asciidoc
+ */
+const struct blkid_idinfo bitlocker_idinfo =
+{
+ .name = "BitLocker",
+ .usage = BLKID_USAGE_CRYPTO,
+ .probefunc = probe_bitlocker,
+ .magics =
+ {
+ { .magic = BDE_MAGIC_VISTA, .len = 11 },
+ { .magic = BDE_MAGIC_WIN7, .len = 11 },
+ { .magic = BDE_MAGIC_TOGO, .len = 11 },
+ { NULL }
+ }
+};
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 076541d1a..6dfd2be64 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -115,6 +115,7 @@ static const struct blkid_idinfo *idinfos[] =
&ubi_idinfo,
&vdo_idinfo,
&stratis_idinfo,
+ &bitlocker_idinfo,
/* Filesystems */
&vfat_idinfo,
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
index 2723fb1d5..d677f85bc 100644
--- a/libblkid/src/superblocks/superblocks.h
+++ b/libblkid/src/superblocks/superblocks.h
@@ -81,6 +81,7 @@ extern const struct blkid_idinfo bcache_idinfo;
extern const struct blkid_idinfo mpool_idinfo;
extern const struct blkid_idinfo vdo_idinfo;
extern const struct blkid_idinfo stratis_idinfo;
+extern const struct blkid_idinfo bitlocker_idinfo;
/*
* superblock functions
@@ -105,4 +106,6 @@ extern int blkid_probe_set_id_label(blkid_probe pr, const char *name,
extern int blkid_probe_set_utf8_id_label(blkid_probe pr, const char *name,
unsigned char *data, size_t len, int enc);
+extern int blkid_probe_is_bitlocker(blkid_probe pr);
+
#endif /* _BLKID_SUPERBLOCKS_H */
diff --git a/libblkid/src/superblocks/vfat.c b/libblkid/src/superblocks/vfat.c
index 3aeba018a..29b3c501c 100644
--- a/libblkid/src/superblocks/vfat.c
+++ b/libblkid/src/superblocks/vfat.c
@@ -268,6 +268,9 @@ static int fat_valid_superblock(blkid_probe pr,
}
}
+ if (blkid_probe_is_bitlocker(pr))
+ return 0;
+
return 1; /* valid */
}
--
2.25.4

View File

@ -0,0 +1,161 @@
From a1dfd3c737f7dad832b0f6ec975bcc5c9cc80ffe Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 24 Aug 2022 12:20:25 +0200
Subject: lslogins: support more password methods
* detect more hashing methods
* don't care about hash size
* follow crypt(5) when check for valid chars
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2094216
Upstream: http://github.com/util-linux/util-linux/commit/2b9373e06243d5adf93d627916a5421b34a7e63f
Reported-by: Radka Skvarilova <rskvaril@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/lslogins.c | 66 +++++++++++++++++++++++++++---------------
1 file changed, 42 insertions(+), 24 deletions(-)
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 56431212d..22e3cd23e 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -598,7 +598,7 @@ static int get_nprocs(const uid_t uid)
}
#endif
-static const char *get_pwd_method(const char *str, const char **next, unsigned int *sz)
+static const char *get_pwd_method(const char *str, const char **next)
{
const char *p = str;
const char *res = NULL;
@@ -606,32 +606,50 @@ static const char *get_pwd_method(const char *str, const char **next, unsigned i
if (!p || *p++ != '$')
return NULL;
- if (sz)
- *sz = 0;
-
switch (*p) {
case '1':
res = "MD5";
- if (sz)
- *sz = 22;
break;
case '2':
- p++;
- if (*p == 'a' || *p == 'y')
+ switch(*(p+1)) {
+ case 'a':
+ case 'y':
+ p++;
res = "Blowfish";
+ break;
+ case 'b':
+ p++;
+ res = "bcrypt";
+ break;
+ }
+ break;
+ case '3':
+ res = "NT";
break;
case '5':
res = "SHA-256";
- if (sz)
- *sz = 43;
break;
case '6':
res = "SHA-512";
- if (sz)
- *sz = 86;
+ break;
+ case '7':
+ res = "scrypt";
+ break;
+ case 'y':
+ res = "yescrypt";
+ break;
+ case 'g':
+ if (*(p + 1) == 'y') {
+ p++;
+ res = "gost-yescrypt";
+ }
+ break;
+ case '_':
+ res = "bsdicrypt";
break;
default:
- return NULL;
+ res = "unknown";
+ break;
}
p++;
@@ -642,7 +660,10 @@ static const char *get_pwd_method(const char *str, const char **next, unsigned i
return res;
}
-#define is_valid_pwd_char(x) (isalnum((unsigned char) (x)) || (x) == '.' || (x) == '/')
+#define is_invalid_pwd_char(x) (isspace((unsigned char) (x)) || \
+ (x) == ':' || (x) == ';' || (x) == '*' || \
+ (x) == '!' || (x) == '\\')
+#define is_valid_pwd_char(x) (isascii((unsigned char) (x)) && !is_invalid_pwd_char(x))
/*
* This function do not accept empty passwords or locked accouns.
@@ -650,17 +671,16 @@ static const char *get_pwd_method(const char *str, const char **next, unsigned i
static int valid_pwd(const char *str)
{
const char *p = str;
- unsigned int sz = 0, n;
if (!str || !*str)
return 0;
/* $id$ */
- if (get_pwd_method(str, &p, &sz) == NULL)
+ if (get_pwd_method(str, &p) == NULL)
return 0;
+
if (!p || !*p)
return 0;
-
/* salt$ */
for (; *p; p++) {
if (*p == '$') {
@@ -670,17 +690,15 @@ static int valid_pwd(const char *str)
if (!is_valid_pwd_char(*p))
return 0;
}
+
if (!*p)
return 0;
-
/* encrypted */
- for (n = 0; *p; p++, n++) {
- if (!is_valid_pwd_char(*p))
+ for (; *p; p++) {
+ if (!is_valid_pwd_char(*p)) {
return 0;
+ }
}
-
- if (sz && n != sz)
- return 0;
return 1;
}
@@ -863,7 +881,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
while (p && (*p == '!' || *p == '*'))
p++;
- user->pwd_method = get_pwd_method(p, NULL, NULL);
+ user->pwd_method = get_pwd_method(p, NULL);
} else
user->pwd_method = NULL;
break;
--
2.37.2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
From 07ed253a49cbe80c15d43ed3800206f99d15b43e Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 4 Oct 2021 11:14:01 +0200
Subject: fstrim: don't trigger autofs
- ignore read-only entries
- ignore autofs entries (for example from /proc/self/mountinfo)
- ignore autofs mountpoints where automounter has not been triggered yet
Fixes: https://github.com/karelzak/util-linux/issues/1463
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2165981
---
sys-utils/fstrim.8.adoc | 2 +-
sys-utils/fstrim.c | 28 +++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/sys-utils/fstrim.8.adoc b/sys-utils/fstrim.8.adoc
index 66671c293..d2f3b05be 100644
--- a/sys-utils/fstrim.8.adoc
+++ b/sys-utils/fstrim.8.adoc
@@ -29,7 +29,7 @@ Running *fstrim* frequently, or even using *mount -o discard*, might negatively
The _offset_, _length_, and _minimum-size_ arguments may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB") or the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB.
*-A, --fstab*::
-Trim all mounted filesystems mentioned in _/etc/fstab_ on devices that support the discard operation. The root filesystem is determined from kernel command line if missing in the file. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices and read-only filesystems are silently ignored.
+Trim all mounted filesystems mentioned in _/etc/fstab_ on devices that support the discard operation. The root filesystem is determined from kernel command line if missing in the file. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices, autofs and read-only filesystems are silently ignored.
*-a, --all*::
Trim all mounted filesystems on devices that support the discard operation. The other supplied options, like *--offset*, *--length* and *--minimum*, are applied to all these devices. Errors from filesystems that do not support the discard operation, read-only devices and read-only filesystems are silently ignored.
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index d2aec4f71..ea787f42c 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -35,6 +35,7 @@
#include <sys/ioctl.h>
#include <sys/stat.h>
+#include <sys/vfs.h>
#include <linux/fs.h>
#include "nls.h"
@@ -45,6 +46,7 @@
#include "pathnames.h"
#include "sysfs.h"
#include "optutils.h"
+#include "statfs_magic.h"
#include <libmount.h>
@@ -207,6 +209,30 @@ fail:
return 1;
}
+static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt)
+{
+ struct statfs vfs;
+ int fd, rc;
+
+ if (mnt_fs_is_pseudofs(fs))
+ return 1;
+ if (mnt_fs_is_netfs(fs))
+ return 1;
+ if (mnt_fs_is_swaparea(fs))
+ return 1;
+ if (mnt_fs_match_fstype(fs, "autofs"))
+ return 1;
+ if (mnt_fs_match_options(fs, "ro"))
+ return 1;
+
+ fd = open(tgt, O_PATH);
+ if (!fd)
+ return 1;
+ rc = fstatfs(fd, &vfs) != 0 || vfs.f_type == STATFS_AUTOFS_MAGIC;
+ close(fd);
+
+ return rc;
+}
static int uniq_fs_target_cmp(
struct libmnt_table *tb __attribute__((__unused__)),
@@ -292,7 +318,7 @@ static int fstrim_all_from_file(struct fstrim_control *ctl, const char *filename
const char *src = mnt_fs_get_srcpath(fs),
*tgt = mnt_fs_get_target(fs);
- if (!tgt || mnt_fs_is_pseudofs(fs) || mnt_fs_is_netfs(fs)) {
+ if (!tgt || is_unwanted_fs(fs, tgt)) {
mnt_table_remove_fs(tab, fs);
continue;
}
--
2.39.1

View File

@ -0,0 +1,28 @@
From 825f9a8eb7800c572d4ded17dd202249312e3240 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 4 Oct 2021 11:14:01 +0200
Subject: fstrim: fix typo
Addresses: https://github.com/karelzak/util-linux/issues/1463
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2165981
---
sys-utils/fstrim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index ea787f42c..88397f0ec 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -226,7 +226,7 @@ static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt)
return 1;
fd = open(tgt, O_PATH);
- if (!fd)
+ if (fd < 0)
return 1;
rc = fstatfs(fd, &vfs) != 0 || vfs.f_type == STATFS_AUTOFS_MAGIC;
close(fd);
--
2.39.1

View File

@ -1,29 +0,0 @@
From 28b89361bf574af24c2f9c857d0e5f7c84e2787c Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 3 Sep 2019 15:10:35 +0200
Subject: [PATCH 38/40] libblkid: (xfs) fix sector size calculation
Reported-by: Anatoly Pugachev <matorola@gmail.com>
Upstream: http://github.com/karelzak/util-linux/commit/2771d40b88660a11306aa5d4e200fc0ebebfe315
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1817726
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libblkid/src/superblocks/xfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libblkid/src/superblocks/xfs.c b/libblkid/src/superblocks/xfs.c
index eb513ac3e..98e59ff7c 100644
--- a/libblkid/src/superblocks/xfs.c
+++ b/libblkid/src/superblocks/xfs.c
@@ -173,7 +173,7 @@ static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
blkid_probe_set_label(pr, (unsigned char *) xs->sb_fname,
sizeof(xs->sb_fname));
blkid_probe_set_uuid(pr, xs->sb_uuid);
- blkid_probe_set_block_size(pr, xs->sb_sectsize * 256);
+ blkid_probe_set_block_size(pr, be16_to_cpu(xs->sb_sectsize));
return 0;
}
--
2.25.4

View File

@ -1,68 +0,0 @@
From 54e3d1414e1a031d6f635f8fcbe273eecfd65560 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 5 Feb 2019 12:06:00 +0100
Subject: [PATCH 39/40] col: make flush_line() a little bit robust
The code is horrible. The core of the problem are signed integers
and no check for the limits.
This patch fixes c->c_column = cur_col; where c_column is "short"
and "cur_col" is int. Let's use "int" for all the variables. It's
really not perfect as for bigger lines it can segfault again...
The patch also removes some unnecessary static variables.
Upstream: http://github.com/karelzak/util-linux/commit/004356f05018e3bfcaddd2652846659a4d8481f3
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1803753
Addresses: https://github.com/karelzak/util-linux/issues/749
Signed-off-by: Karel Zak <kzak@redhat.com>
---
text-utils/col.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/text-utils/col.c b/text-utils/col.c
index 3d9e15d26..c2f8db64d 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -88,7 +88,7 @@ typedef char CSET;
typedef struct char_str {
#define CS_NORMAL 1
#define CS_ALTERNATE 2
- short c_column; /* column character is in */
+ int c_column; /* column character is in */
CSET c_set; /* character set (currently only 2) */
wchar_t c_char; /* character in question */
int c_width; /* character width */
@@ -476,8 +476,9 @@ void flush_line(LINE *l)
nchars = l->l_line_len;
if (l->l_needs_sort) {
- static CHAR *sorted;
- static int count_size, *count, i, save, sorted_size, tot;
+ static CHAR *sorted = NULL;
+ static int count_size = 0, *count = NULL, sorted_size = 0;
+ int i, tot;
/*
* Do an O(n) sort on l->l_line by column being careful to
@@ -494,7 +495,7 @@ void flush_line(LINE *l)
(unsigned)sizeof(int) * count_size);
}
memset(count, 0, sizeof(int) * l->l_max_col + 1);
- for (i = nchars, c = l->l_line; --i >= 0; c++)
+ for (i = nchars, c = l->l_line; c && --i >= 0; c++)
count[c->c_column]++;
/*
@@ -502,7 +503,7 @@ void flush_line(LINE *l)
* indices into new line.
*/
for (tot = 0, i = 0; i <= l->l_max_col; i++) {
- save = count[i];
+ int save = count[i];
count[i] = tot;
tot += save;
}
--
2.25.4

View File

@ -0,0 +1,114 @@
From c76c1e5d7d3b043549f69c8dc8d6b878b1db0231 Mon Sep 17 00:00:00 2001
From: Scott Shambarger <devel@shambarger.net>
Date: Thu, 12 May 2022 16:27:26 -0700
Subject: fstrim: Remove all skipped entries before de-duplication
When processing fstab entries, de-duplication is performed based on the
source before all tests on the target have been checked, resulting in
some entries being skipped when a removed duplicate with a different
target would not have been.
The fix is to move all the target checks before the source
de-duplication.
Addresses: #1686
Signed-off-by: Scott Shambarger <devel@shambarger.net>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2165981
---
sys-utils/fstrim.c | 53 ++++++++++++++++++++++++++--------------------
1 file changed, 30 insertions(+), 23 deletions(-)
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index 88397f0ec..0b05e590e 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -230,8 +230,17 @@ static int is_unwanted_fs(struct libmnt_fs *fs, const char *tgt)
return 1;
rc = fstatfs(fd, &vfs) != 0 || vfs.f_type == STATFS_AUTOFS_MAGIC;
close(fd);
+ if (rc)
+ return 1;
- return rc;
+ /* FITRIM on read-only filesystem can fail, and it can fail */
+ if (access(tgt, W_OK) != 0) {
+ if (errno == EROFS)
+ return 1;
+ if (errno == EACCES)
+ return 1;
+ }
+ return 0;
}
static int uniq_fs_target_cmp(
@@ -317,6 +326,8 @@ static int fstrim_all_from_file(struct fstrim_control *ctl, const char *filename
while (mnt_table_next_fs(tab, itr, &fs) == 0) {
const char *src = mnt_fs_get_srcpath(fs),
*tgt = mnt_fs_get_target(fs);
+ char *path;
+ int rc = 1;
if (!tgt || is_unwanted_fs(fs, tgt)) {
mnt_table_remove_fs(tab, fs);
@@ -339,19 +350,6 @@ static int fstrim_all_from_file(struct fstrim_control *ctl, const char *filename
mnt_table_remove_fs(tab, fs);
continue;
}
- }
-
- /* de-duplicate by source */
- mnt_table_uniq_fs(tab, MNT_UNIQ_FORWARD, uniq_fs_source_cmp);
-
- mnt_reset_iter(itr, MNT_ITER_BACKWARD);
-
- /* Do FITRIM */
- while (mnt_table_next_fs(tab, itr, &fs) == 0) {
- const char *src = mnt_fs_get_srcpath(fs),
- *tgt = mnt_fs_get_target(fs);
- char *path;
- int rc = 1;
/* Is it really accessible mountpoint? Not all mountpoints are
* accessible (maybe over mounted by another filesystem) */
@@ -359,20 +357,29 @@ static int fstrim_all_from_file(struct fstrim_control *ctl, const char *filename
if (path && streq_paths(path, tgt))
rc = 0;
free(path);
- if (rc)
+ if (rc) {
+ mnt_table_remove_fs(tab, fs);
continue; /* overlaying mount */
-
- /* FITRIM on read-only filesystem can fail, and it can fail */
- if (access(tgt, W_OK) != 0) {
- if (errno == EROFS)
- continue;
- if (errno == EACCES)
- continue;
}
if (!is_directory(tgt, 1) ||
- !has_discard(src, &wholedisk))
+ !has_discard(src, &wholedisk)) {
+ mnt_table_remove_fs(tab, fs);
continue;
+ }
+ }
+
+ /* de-duplicate by source */
+ mnt_table_uniq_fs(tab, MNT_UNIQ_FORWARD, uniq_fs_source_cmp);
+
+ mnt_reset_iter(itr, MNT_ITER_BACKWARD);
+
+ /* Do FITRIM */
+ while (mnt_table_next_fs(tab, itr, &fs) == 0) {
+ const char *src = mnt_fs_get_srcpath(fs),
+ *tgt = mnt_fs_get_target(fs);
+ int rc;
+
cnt++;
/*
--
2.39.1

View File

@ -1,49 +0,0 @@
From 2cd5219da87274db251a7f836efe6ac724b70e53 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 11 Mar 2020 10:38:37 +0100
Subject: [PATCH 40/40] libmount: improve smb{2,3} support
It seems kernel can use smb3 as fstype in mountinfo.
Upstream: http://github.com/karelzak/util-linux/commit/36d80cb6c11b3064ed9fb29c7c8b101e3f266441
Upstream: http://github.com/karelzak/util-linux/commit/b7ff4134beea53688ab3c01484cf59b2ce2d9ce9
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1812118
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/tab.c | 5 ++++-
libmount/src/utils.c | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index eb61dd33e..74d60df3d 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -1644,9 +1644,12 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
if (root) {
const char *fstype = mnt_fs_get_fstype(fs);
- if (fstype && strcmp(fstype, "cifs") == 0) {
+ if (fstype && (strcmp(fstype, "cifs") == 0
+ || strcmp(fstype, "smb3") == 0)) {
+
const char *unc_subdir = get_cifs_unc_subdir_path(src);
const char *path_on_fs = mnt_fs_get_root(fs);
+
if (!unc_subdir || !path_on_fs || !streq_paths(unc_subdir, path_on_fs))
continue;
} else {
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 04e79f53f..e43588831 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -315,6 +315,7 @@ int mnt_fstype_is_pseudofs(const char *type)
int mnt_fstype_is_netfs(const char *type)
{
if (strcmp(type, "cifs") == 0 ||
+ strcmp(type, "smb3") == 0 ||
strcmp(type, "smbfs") == 0 ||
strncmp(type,"nfs", 3) == 0 ||
strcmp(type, "afs") == 0 ||
--
2.25.4

View File

@ -1,4 +1,4 @@
From ccc5db8102728d37e2e28dd50da3370e8c8de33a Mon Sep 17 00:00:00 2001 From a3b3df8d0891ff83b61f62020652798d365299c0 Mon Sep 17 00:00:00 2001
From: Michael Trapp <michael.trapp@sap.com> From: Michael Trapp <michael.trapp@sap.com>
Date: Mon, 20 Jun 2022 17:10:36 +0200 Date: Mon, 20 Jun 2022 17:10:36 +0200
Subject: libuuid: Implement continuous clock handling for time based UUIDs Subject: libuuid: Implement continuous clock handling for time based UUIDs
@ -11,21 +11,19 @@ is extended by a continuous handling of the clock updates - instead of
updating the value to the current timestamp, it is incremented by updating the value to the current timestamp, it is incremented by
the number of requested UUIDs. the number of requested UUIDs.
[kzak@redhat.com: - backport from upstream v2.39 to to RHEL-8]
Upstream: http://github.com/util-linux/util-linux/commit/3cfba7d39b66eff4307218fefd8bb34bb1621f83 Upstream: http://github.com/util-linux/util-linux/commit/3cfba7d39b66eff4307218fefd8bb34bb1621f83
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2141969 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2141970
Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
--- ---
libuuid/src/gen_uuid.c | 91 ++++++++++++++++++++++++++++++++++++++--- libuuid/src/gen_uuid.c | 91 ++++++++++++++++++++++++++++++++++++++---
libuuid/src/libuuid.sym | 1 + libuuid/src/libuuid.sym | 1 +
libuuid/src/uuidd.h | 1 + libuuid/src/uuidd.h | 1 +
misc-utils/uuidd.8.in | 12 ++++++ misc-utils/uuidd.8.adoc | 3 ++
misc-utils/uuidd.c | 86 ++++++++++++++++++++++++++++++++++++-- misc-utils/uuidd.c | 54 +++++++++++++++++++++---
5 files changed, 182 insertions(+), 9 deletions(-) 5 files changed, 140 insertions(+), 10 deletions(-)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index 27c135db5..f557053f7 100644 index d353fa1a0..ac682a1d8 100644
--- a/libuuid/src/gen_uuid.c --- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c +++ b/libuuid/src/gen_uuid.c
@@ -209,6 +209,8 @@ static int get_node_id(unsigned char *node_id) @@ -209,6 +209,8 @@ static int get_node_id(unsigned char *node_id)
@ -41,10 +39,10 @@ index 27c135db5..f557053f7 100644
} }
if ((last.tv_sec == 0) && (last.tv_usec == 0)) { if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
- random_get_bytes(&clock_seq, sizeof(clock_seq)); - ul_random_get_bytes(&clock_seq, sizeof(clock_seq));
- clock_seq &= 0x3FFF; - clock_seq &= 0x3FFF;
+ do { + do {
+ random_get_bytes(&clock_seq, sizeof(clock_seq)); + ul_random_get_bytes(&clock_seq, sizeof(clock_seq));
+ clock_seq &= 0x3FFF; + clock_seq &= 0x3FFF;
+ } while (clock_seq == CLOCK_SEQ_CONT); + } while (clock_seq == CLOCK_SEQ_CONT);
gettimeofday(&last, NULL); gettimeofday(&last, NULL);
@ -169,10 +167,10 @@ index 27c135db5..f557053f7 100644
* Generate time-based UUID and store it to @out * Generate time-based UUID and store it to @out
* *
diff --git a/libuuid/src/libuuid.sym b/libuuid/src/libuuid.sym diff --git a/libuuid/src/libuuid.sym b/libuuid/src/libuuid.sym
index 9e3e80035..0a072b703 100644 index 342453368..96372a857 100644
--- a/libuuid/src/libuuid.sym --- a/libuuid/src/libuuid.sym
+++ b/libuuid/src/libuuid.sym +++ b/libuuid/src/libuuid.sym
@@ -51,6 +51,7 @@ global: @@ -60,6 +60,7 @@ global:
UUIDD_PRIVATE { UUIDD_PRIVATE {
global: global:
__uuid_generate_time; __uuid_generate_time;
@ -181,44 +179,36 @@ index 9e3e80035..0a072b703 100644
local: local:
*; *;
diff --git a/libuuid/src/uuidd.h b/libuuid/src/uuidd.h diff --git a/libuuid/src/uuidd.h b/libuuid/src/uuidd.h
index e55c86f2f..14a01ade2 100644 index fbe821ff3..f76acc8b2 100644
--- a/libuuid/src/uuidd.h --- a/libuuid/src/uuidd.h
+++ b/libuuid/src/uuidd.h +++ b/libuuid/src/uuidd.h
@@ -50,5 +50,6 @@ @@ -49,6 +49,7 @@
#define UUIDD_MAX_OP UUIDD_OP_BULK_RANDOM_UUID
extern int __uuid_generate_time(uuid_t out, int *num); extern int __uuid_generate_time(uuid_t out, int *num);
extern void __uuid_generate_random(uuid_t out, int *num);
+extern int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont); +extern int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont);
extern int __uuid_generate_random(uuid_t out, int *num);
#endif /* _UUID_UUID_H */ #endif /* _UUID_UUID_H */
diff --git a/misc-utils/uuidd.8.in b/misc-utils/uuidd.8.in diff --git a/misc-utils/uuidd.8.adoc b/misc-utils/uuidd.8.adoc
index 0a5cf471b..28bcb48b5 100644 index 77ee2b3e6..c87125901 100644
--- a/misc-utils/uuidd.8.in --- a/misc-utils/uuidd.8.adoc
+++ b/misc-utils/uuidd.8.in +++ b/misc-utils/uuidd.8.adoc
@@ -16,6 +16,18 @@ universally unique identifiers (UUIDs), especially time-based UUIDs, @@ -24,6 +24,9 @@ The *uuidd* daemon is used by the UUID library to generate universally unique id
in a secure and guaranteed-unique fashion, even in the face of large
numbers of threads running on different CPUs trying to grab UUIDs. == OPTIONS
.SH OPTIONS
+*-C*, *--cont-clock* _opt_arg_::
+Activate continuous clock handling for time based UUIDs. *uuidd* could use all possible clock values, beginning with the daemon's start time. The optional argument can be used to set a value for the max_clock_offset. This gurantees, that a clock value of a UUID will always be within the range of the max_clock_offset. '-C' or '--cont-clock' enables the feature with a default max_clock_offset of 2 hours. '-C<NUM>[hd]' or '--cont-clock=<NUM>[hd]' enables the feature with a max_clock_offset of NUM seconds. In case of an appended h or d, the NUM value is read in hours or days. The minimum value is 60 seconds, the maximum value is 365 days.
+ +
+.TP *-d*, *--debug*::
+.BR \-C , " \-\-cont\-clock " [\fInumber\fR]
+Activate continuous clock handling for time based UUIDs. uuidd could use all
+possible clock values, beginning with the daemon's start time. The optional
+argument can be used to set a value for the max_clock_offset. This gurantees,
+that a clock value of a UUID will always be within the range of the
+max_clock_offset. '-C' or '--cont-clock' enables the feature with a default
+max_clock_offset of 2 hours. '-C<NUM>[hd]' or '--cont-clock=<NUM>[hd]' enables
+the feature with a max_clock_offset of NUM seconds. In case of an appended h or
+d, the NUM value is read in hours or days. The minimum value is 60 seconds, the
+maximum value is 365 days.
.TP
.BR \-d , " \-\-debug "
Run uuidd in debugging mode. This prevents uuidd from running as a daemon. Run uuidd in debugging mode. This prevents uuidd from running as a daemon.
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index 8b83d91c0..e3c0abad7 100644 index 78a37d2e8..b859ccb8c 100644
--- a/misc-utils/uuidd.c --- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c +++ b/misc-utils/uuidd.c
@@ -49,6 +49,8 @@ struct uuidd_cxt_t { @@ -72,6 +72,8 @@ struct uuidd_cxt_t {
const char *cleanup_pidfile; const char *cleanup_pidfile;
const char *cleanup_socket; const char *cleanup_socket;
uint32_t timeout; uint32_t timeout;
@ -227,7 +217,7 @@ index 8b83d91c0..e3c0abad7 100644
unsigned int debug: 1, unsigned int debug: 1,
quiet: 1, quiet: 1,
no_fork: 1, no_fork: 1,
@@ -73,6 +75,8 @@ static void __attribute__((__noreturn__)) usage(void) @@ -106,6 +108,8 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -P, --no-pid do not create pid file\n"), out); fputs(_(" -P, --no-pid do not create pid file\n"), out);
fputs(_(" -F, --no-fork do not daemonize using double-fork\n"), out); fputs(_(" -F, --no-fork do not daemonize using double-fork\n"), out);
fputs(_(" -S, --socket-activation do not create listening socket\n"), out); fputs(_(" -S, --socket-activation do not create listening socket\n"), out);
@ -236,7 +226,7 @@ index 8b83d91c0..e3c0abad7 100644
fputs(_(" -d, --debug run in debugging mode\n"), out); fputs(_(" -d, --debug run in debugging mode\n"), out);
fputs(_(" -q, --quiet turn on quiet mode\n"), out); fputs(_(" -q, --quiet turn on quiet mode\n"), out);
fputs(USAGE_SEPARATOR, out); fputs(USAGE_SEPARATOR, out);
@@ -401,6 +405,15 @@ static void server_loop(const char *socket_path, const char *pidfile_path, @@ -438,6 +442,15 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
pfd[POLLFD_SOCKET].fd = s; pfd[POLLFD_SOCKET].fd = s;
pfd[POLLFD_SIGNAL].events = pfd[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP; pfd[POLLFD_SIGNAL].events = pfd[POLLFD_SOCKET].events = POLLIN | POLLERR | POLLHUP;
@ -252,65 +242,40 @@ index 8b83d91c0..e3c0abad7 100644
while (1) { while (1) {
ret = poll(pfd, ARRAY_SIZE(pfd), ret = poll(pfd, ARRAY_SIZE(pfd),
uuidd_cxt->timeout ? uuidd_cxt->timeout ?
@@ -458,7 +471,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path, @@ -494,7 +507,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break; break;
case UUIDD_OP_TIME_UUID: case UUIDD_OP_TIME_UUID:
num = 1; num = 1;
- __uuid_generate_time(uu, &num); - if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset); + ret = __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
+ if (ret < 0 && !uuidd_cxt->quiet)
warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) { if (uuidd_cxt->debug) {
uuid_unparse(uu, str); uuid_unparse(uu, str);
fprintf(stderr, _("Generated time UUID: %s\n"), str); @@ -505,7 +519,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
@@ -477,7 +490,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path, break;
case UUIDD_OP_RANDOM_UUID:
num = 1;
- if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ ret = __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
+ if (ret < 0 && !uuidd_cxt->quiet)
warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
@@ -515,7 +530,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
reply_len = sizeof(uu); reply_len = sizeof(uu);
break; break;
case UUIDD_OP_BULK_TIME_UUID: case UUIDD_OP_BULK_TIME_UUID:
- __uuid_generate_time(uu, &num); - if (__uuid_generate_time(uu, &num) < 0 && !uuidd_cxt->quiet)
+ __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset); + ret = __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
+ if (ret < 0 && !uuidd_cxt->quiet)
warnx(_("failed to open/lock clock counter"));
if (uuidd_cxt->debug) { if (uuidd_cxt->debug) {
uuid_unparse(uu, str); uuid_unparse(uu, str);
fprintf(stderr, P_("Generated time UUID %s " @@ -567,6 +583,27 @@ static void __attribute__ ((__noreturn__)) unexpected_size(int size)
@@ -530,6 +543,64 @@ static void __attribute__ ((__noreturn__)) unexpected_size(int size)
errx(EXIT_FAILURE, _("Unexpected reply length from server %d"), size); errx(EXIT_FAILURE, _("Unexpected reply length from server %d"), size);
} }
+/* Backport from v2.39 lib/strutils.c */
+static int ul_strtos64(const char *str, int64_t *num, int base)
+{
+ char *end = NULL;
+
+ if (str == NULL || *str == '\0')
+ return -(errno = EINVAL);
+
+ errno = 0;
+ *num = (int64_t) strtoimax(str, &end, base);
+
+ if (errno != 0)
+ return -errno;
+ if (str == end || (end && *end))
+ return -(errno = EINVAL);
+ return 0;
+}
+
+/* Backport from v2.39 lib/strutils.c */
+static int64_t str2num_or_err(const char *str, int base, const char *errmesg,
+ int64_t low, int64_t up)
+{
+ int64_t num = 0;
+ int rc;
+
+ rc = ul_strtos64(str, &num, base);
+ if (rc == 0 && ((low && num < low) || (up && num > up)))
+ rc = -(errno = ERANGE);
+
+ if (rc) {
+ if (errno == ERANGE)
+ err(EXIT_FAILURE, "%s: '%s'", errmesg, str);
+ errx(EXIT_FAILURE, "%s: '%s'", errmesg, str);
+ }
+ return num;
+}
+
+static uint32_t parse_cont_clock(char *arg) +static uint32_t parse_cont_clock(char *arg)
+{ +{
+ uint32_t min_val = 60, + uint32_t min_val = 60,
@ -332,19 +297,10 @@ index 8b83d91c0..e3c0abad7 100644
+ min_val, max_val / factor); + min_val, max_val / factor);
+} +}
+ +
int main(int argc, char **argv) static void parse_options(int argc, char **argv, struct uuidd_cxt_t *uuidd_cxt,
struct uuidd_options_t *uuidd_opts)
{ {
const char *socket_path = UUIDD_SOCKET_PATH; @@ -581,6 +618,7 @@ static void parse_options(int argc, char **argv, struct uuidd_cxt_t *uuidd_cxt,
@@ -543,7 +614,7 @@ int main(int argc, char **argv)
int no_pid = 0;
int s_flag = 0;
- struct uuidd_cxt_t uuidd_cxt = { .timeout = 0 };
+ struct uuidd_cxt_t uuidd_cxt = { .timeout = 0, .cont_clock_offset = 0 };
static const struct option longopts[] = {
{"pid", required_argument, NULL, 'p'},
@@ -556,6 +627,7 @@ int main(int argc, char **argv)
{"no-pid", no_argument, NULL, 'P'}, {"no-pid", no_argument, NULL, 'P'},
{"no-fork", no_argument, NULL, 'F'}, {"no-fork", no_argument, NULL, 'F'},
{"socket-activation", no_argument, NULL, 'S'}, {"socket-activation", no_argument, NULL, 'S'},
@ -352,24 +308,32 @@ index 8b83d91c0..e3c0abad7 100644
{"debug", no_argument, NULL, 'd'}, {"debug", no_argument, NULL, 'd'},
{"quiet", no_argument, NULL, 'q'}, {"quiet", no_argument, NULL, 'q'},
{"version", no_argument, NULL, 'V'}, {"version", no_argument, NULL, 'V'},
@@ -576,10 +648,16 @@ int main(int argc, char **argv) @@ -596,9 +634,15 @@ static void parse_options(int argc, char **argv, struct uuidd_cxt_t *uuidd_cxt,
atexit(close_stdout); int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
int c;
while ((c = - while ((c = getopt_long(argc, argv, "p:s:T:krtn:PFSdqVh", longopts, NULL)) != -1) {
- getopt_long(argc, argv, "p:s:T:krtn:PFSdqVh", longopts, + while ((c = getopt_long(argc, argv, "p:s:T:krtn:PFSC::dqVh", longopts, NULL)) != -1) {
+ getopt_long(argc, argv, "p:s:T:krtn:PFSC::dqVh", longopts,
NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st); err_exclusive_options(c, longopts, excl, excl_st);
switch (c) { switch (c) {
+ case 'C': + case 'C':
+ if (optarg != NULL) + if (optarg != NULL)
+ uuidd_cxt.cont_clock_offset = parse_cont_clock(optarg); + uuidd_cxt->cont_clock_offset = parse_cont_clock(optarg);
+ else + else
+ uuidd_cxt.cont_clock_offset = 7200; /* default 2h */ + uuidd_cxt->cont_clock_offset = 7200; /* default 2h */
+ break; + break;
case 'd': case 'd':
uuidd_cxt.debug = 1; uuidd_cxt->debug = 1;
break; break;
-- @@ -673,7 +717,7 @@ int main(int argc, char **argv)
2.38.1 char *cp;
int ret;
- struct uuidd_cxt_t uuidd_cxt = { .timeout = 0 };
+ struct uuidd_cxt_t uuidd_cxt = { .timeout = 0, .cont_clock_offset = 0 };
struct uuidd_options_t uuidd_opts = { .socket_path = UUIDD_SOCKET_PATH };
setlocale(LC_ALL, "");
--
2.39.1

View File

@ -1,65 +0,0 @@
From 618aedc9e892b206492c1720bec261b043c66263 Mon Sep 17 00:00:00 2001
From: Roberto Bergantinos Corpas <rbergant@redhat.com>
Date: Mon, 27 Apr 2020 15:46:02 +0200
Subject: [PATCH] libmount: fix mount -a EBUSY for cifs
fstab:
//rhel73/myshare/sub/path /mnt cifs
after mount in mountinfo:
# grep cifs /proc/self/mountinfo
47 39 0:40 /sub/path /mnt rw,relatime shared:60 - cifs //rhel73/myshare/sub/path ...
^^^^^^^^^
or:
# grep cifs /proc/self/mountinfo
47 39 0:40 / /mnt rw,relatime shared:60 - cifs //rhel73/myshare/sub/path ...
^
That is so since on kernel cifs code, cifs_get_root (which returns the
entry associated with mnt_root) return s_root if
CIFS_MOUNT_USE_PREFIX_PATH is set, no questions asked.
This situation can occurr often on CIFS mounts, as CIFS servers limit
frequently scope of access to the root path.
[kzak@redhat.com: - add more info to the commit message,
- clean up variable names]
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1829245
Upstream: http://github.com/karelzak/util-linux/commit/31b3a523eca2fc7e5876ec5fd89094208fed0899
Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/tab.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index 74d60df3d..cd97a1cb5 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -1644,13 +1644,14 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
if (root) {
const char *fstype = mnt_fs_get_fstype(fs);
- if (fstype && (strcmp(fstype, "cifs") == 0
- || strcmp(fstype, "smb3") == 0)) {
+ if (fstype && (strcmp(fstype, "cifs") == 0 ||
+ strcmp(fstype, "smb3") == 0)) {
- const char *unc_subdir = get_cifs_unc_subdir_path(src);
- const char *path_on_fs = mnt_fs_get_root(fs);
+ const char *sub = get_cifs_unc_subdir_path(src);
+ const char *r = mnt_fs_get_root(fs);
- if (!unc_subdir || !path_on_fs || !streq_paths(unc_subdir, path_on_fs))
+ if (!sub || !r || (!streq_paths(sub, r) &&
+ !streq_paths("/", r)))
continue;
} else {
const char *r = mnt_fs_get_root(fs);
--
2.25.4

View File

@ -1,4 +1,4 @@
From 44cebf3e692053541f362b62f88f327c2c96e70e Mon Sep 17 00:00:00 2001 From cede4c481ba0f8fa4256341a0acca33f826fca4f Mon Sep 17 00:00:00 2001
From: Michael Trapp <michael.trapp@sap.com> From: Michael Trapp <michael.trapp@sap.com>
Date: Tue, 2 Aug 2022 14:16:43 +0200 Date: Tue, 2 Aug 2022 14:16:43 +0200
Subject: libuuid: check clock value from LIBUUID_CLOCK_FILE Subject: libuuid: check clock value from LIBUUID_CLOCK_FILE
@ -7,15 +7,15 @@ The clock value from the LIBUUID_CLOCK_FILE must be checked in
case of an update of libuuid. If clock==CLOCK_SEQ_CONT it must case of an update of libuuid. If clock==CLOCK_SEQ_CONT it must
be set to a new value. be set to a new value.
Signed-off-by: Karel Zak <kzak@redhat.com>
Upstream: http://github.com/util-linux/util-linux/commit/5d1424d85ac9e2a1369ee920038825c154ee5443 Upstream: http://github.com/util-linux/util-linux/commit/5d1424d85ac9e2a1369ee920038825c154ee5443
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2141969 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2141970
Signed-off-by: Karel Zak <kzak@redhat.com>
--- ---
libuuid/src/gen_uuid.c | 5 +++++ libuuid/src/gen_uuid.c | 5 +++++
1 file changed, 5 insertions(+) 1 file changed, 5 insertions(+)
diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
index f557053f7..8dc38559f 100644 index ac682a1d8..f05db467e 100644
--- a/libuuid/src/gen_uuid.c --- a/libuuid/src/gen_uuid.c
+++ b/libuuid/src/gen_uuid.c +++ b/libuuid/src/gen_uuid.c
@@ -274,6 +274,11 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low, @@ -274,6 +274,11 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
@ -31,5 +31,5 @@ index f557053f7..8dc38559f 100644
if ((last.tv_sec == 0) && (last.tv_usec == 0)) { if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
-- --
2.38.1 2.39.1

View File

@ -1,31 +0,0 @@
From 0717177be22588d4e419de280eccd0eeafb15016 Mon Sep 17 00:00:00 2001
From: Rupesh Girase <rgirase@redhat.com>
Date: Thu, 18 Jun 2020 19:17:41 +0530
Subject: [PATCH] Manual pages: losetup.8: Fix "--direct-io" defaults
"--direct-io" option is "off" by default while configuring
loop device but it's mentioned "on" in man page.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1848919
Upstream: http://github.com/karelzak/util-linux/commit/4bee67e2d1a78abc52e89c6eb71f0efc8a278ce9
Signed-off-by: Rupesh Girase <rgirase@redhat.com>
---
sys-utils/losetup.8 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys-utils/losetup.8 b/sys-utils/losetup.8
index cdb9ed052..c87c231b6 100644
--- a/sys-utils/losetup.8
+++ b/sys-utils/losetup.8
@@ -130,7 +130,7 @@ Set up a read-only loop device.
.BR \-\-direct\-io [ =on | off ]
Enable or disable direct I/O for the backing file. The optional argument
can be either \fBon\fR or \fBoff\fR. If the argument is omitted, it defaults
-to \fBon\fR.
+to \fBoff\fR.
.TP
.BR \-v , " \-\-verbose"
Verbose mode.
--
2.25.4

View File

@ -0,0 +1,34 @@
From cae4f3f433e4a308f70103e166c6afad30b59ca7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 10 Oct 2022 09:37:51 +0200
Subject: uuidd: fix random UUIDs
Commit f27876f introduces copy & past bug and replaces
__uuid_generate_random() with __uuid_generate_time().
Fixes: https://github.com/util-linux/util-linux/issues/1837
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2133385
Upstream: http://github.com/util-linux/util-linux/commit/b408a291d39e9b637f6104eb4e1f8e60816421e2
---
misc-utils/uuidd.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index b859ccb8c..489d6b79a 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -519,9 +519,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
break;
case UUIDD_OP_RANDOM_UUID:
num = 1;
- ret = __uuid_generate_time_cont(uu, &num, uuidd_cxt->cont_clock_offset);
- if (ret < 0 && !uuidd_cxt->quiet)
- warnx(_("failed to open/lock clock counter"));
+ __uuid_generate_random(uu, &num);
if (uuidd_cxt->debug) {
uuid_unparse(uu, str);
fprintf(stderr, _("Generated random UUID: %s\n"), str);
--
2.39.1

View File

@ -0,0 +1,106 @@
From b77ac3951932d2ea8bdba2b800380b3e70f8eca2 Mon Sep 17 00:00:00 2001
From: tamz <totemz@protonmail.com>
Date: Thu, 6 Jan 2022 11:56:58 +0100
Subject: agetty: resolve tty name even if stdin is specified
[kzak@redhat.com: - use "const" for options->tty (and friends)
as expected by get_terminal_name()]
Addresses: https://github.com/util-linux/util-linux/issues/1546
Signed-off-by: tamz <totemz@protonmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2156946
Upstream: http://github.com/util-linux/util-linux/commit/47831cc02ac0d71c335caecef1753f4c8861277c
---
term-utils/agetty.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 3b3d5101a..e65cbdeaf 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -186,8 +186,8 @@ struct options {
char *chroot; /* Chroot before the login */
char *login; /* login program */
char *logopt; /* options for login program */
- char *tty; /* name of tty */
- char *vcline; /* line of virtual console */
+ const char *tty; /* name of tty */
+ const char *vcline; /* line of virtual console */
char *term; /* terminal type */
char *initstring; /* modem init string */
char *issue; /* alternative issue file or directory */
@@ -199,6 +199,7 @@ struct options {
int numspeed; /* number of baud rates to try */
int clocal; /* CLOCAL_MODE_* */
int kbmode; /* Keyboard mode if virtual console */
+ int tty_is_stdin; /* is the tty the standard input stream */
speed_t speeds[MAX_SPEED]; /* baud rates to be tried */
};
@@ -315,7 +316,7 @@ static void init_special_char(char* arg, struct options *op);
static void parse_args(int argc, char **argv, struct options *op);
static void parse_speeds(struct options *op, char *arg);
static void update_utmp(struct options *op);
-static void open_tty(char *tty, struct termios *tp, struct options *op);
+static void open_tty(const char *tty, struct termios *tp, struct options *op);
static void termio_init(struct options *op, struct termios *tp);
static void reset_vc(const struct options *op, struct termios *tp, int canon);
static void auto_baud(struct termios *tp);
@@ -918,6 +919,15 @@ static void parse_args(int argc, char **argv, struct options *op)
}
}
+ /* resolve the tty path in case it was provided as stdin */
+ if (strcmp(op->tty, "-") == 0) {
+ op->tty_is_stdin = 1;
+ int fd = get_terminal_name(NULL, &op->tty, NULL);
+ if (fd < 0) {
+ log_warn(_("could not get terminal name: %d"), fd);
+ }
+ }
+
/* On virtual console remember the line which is used for */
if (strncmp(op->tty, "tty", 3) == 0 &&
strspn(op->tty + 3, "0123456789") == strlen(op->tty+3))
@@ -958,8 +968,8 @@ static void update_utmp(struct options *op)
time_t t;
pid_t pid = getpid();
pid_t sid = getsid(0);
- char *vcline = op->vcline;
- char *line = op->tty;
+ const char *vcline = op->vcline;
+ const char *line = op->tty;
struct utmpx *utp;
/*
@@ -998,7 +1008,7 @@ static void update_utmp(struct options *op)
str2memcpy(ut.ut_id, vcline, sizeof(ut.ut_id));
else {
size_t len = strlen(line);
- char * ptr;
+ const char * ptr;
if (len >= sizeof(ut.ut_id))
ptr = line + len - sizeof(ut.ut_id);
else
@@ -1026,7 +1036,7 @@ static void update_utmp(struct options *op)
#endif /* SYSV_STYLE */
/* Set up tty as stdin, stdout & stderr. */
-static void open_tty(char *tty, struct termios *tp, struct options *op)
+static void open_tty(const char *tty, struct termios *tp, struct options *op)
{
const pid_t pid = getpid();
int closed = 0;
@@ -1036,7 +1046,7 @@ static void open_tty(char *tty, struct termios *tp, struct options *op)
/* Set up new standard input, unless we are given an already opened port. */
- if (strcmp(tty, "-") != 0) {
+ if (!op->tty_is_stdin) {
char buf[PATH_MAX+1];
struct group *gr = NULL;
struct stat st;
--
2.39.1

View File

@ -1,46 +0,0 @@
From f575b6e0857087f46d54f494d9a435af715ea19d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 1 Oct 2020 10:40:27 +0200
Subject: [PATCH 43/55] chrt: use SCHED_FLAG_RESET_ON_FORK for sched_setattr()
Reviewed by many people, used for years (but probably nobody uses
SCHED_DEADLINE with reset-on-fork), but we all missed:
- sched_setscheduler() uses SCHED_RESET_ON_FORK (0x40000000)
- sched_setattr() uses SCHED_FLAG_RESET_ON_FORK (0x01)
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1884194
Signed-off-by: Karel Zak <kzak@redhat.com>
---
schedutils/chrt.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index b08c78ed8..15556bbad 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -123,7 +123,7 @@ struct chrt_ctl {
uint64_t period;
unsigned int all_tasks : 1, /* all threads of the PID */
- reset_on_fork : 1, /* SCHED_RESET_ON_FORK */
+ reset_on_fork : 1, /* SCHED_RESET_ON_FORK or SCHED_FLAG_RESET_ON_FORK */
altered : 1, /* sched_set**() used */
verbose : 1; /* verbose output */
};
@@ -376,9 +376,10 @@ static int set_sched_one(struct chrt_ctl *ctl, pid_t pid)
sa.sched_period = ctl->period;
sa.sched_deadline = ctl->deadline;
-# ifdef SCHED_RESET_ON_FORK
+# ifdef SCHED_FLAG_RESET_ON_FORK
+ /* Don't use SCHED_RESET_ON_FORK for sched_setattr()! */
if (ctl->reset_on_fork)
- sa.sched_flags |= SCHED_RESET_ON_FORK;
+ sa.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
# endif
errno = 0;
return sched_setattr(pid, &sa, 0);
--
2.29.2

View File

@ -1,146 +0,0 @@
From c4caa5b973f9cdb4c43edea3c32cda62cdf15b3b Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 1 Oct 2020 11:20:01 +0200
Subject: [PATCH 44/55] chrt: don't restrict --reset-on-fork, add more info to
man page
The flag works (= kernel accepts it) for all scheduling policies
and sched_getattr() returns the flag for all policies.
There is no reason for userspace to be more smart than kernel or hide
the flag when it prints sched_getattr()/sched_getscheduler() results.
# chrt -v --reset-on-fork --batch 0 /bin/true
pid 1315019's new scheduling policy: SCHED_BATCH|SCHED_RESET_ON_FORK
# chrt -v --reset-on-fork --fifo 1 /bin/true
pid 1315055's new scheduling policy: SCHED_FIFO|SCHED_RESET_ON_FORK
# chrt -v --reset-on-fork --deadline --sched-period 10000 0 /bin/true
pid 1315182's new scheduling policy: SCHED_DEADLINE|SCHED_RESET_ON_FORK
# chrt -v --reset-on-fork --idle 0 /bin/true
pid 1315247's new scheduling policy: SCHED_IDLE|SCHED_RESET_ON_FORK
# chrt -v --reset-on-fork --rr 1 /bin/true
pid 1315275's new scheduling policy: SCHED_RR|SCHED_RESET_ON_FORK
# chrt -v --reset-on-fork --other 0 /bin/true
pid 1315311's new scheduling policy: SCHED_OTHER|SCHED_RESET_ON_FORK
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1884194
Signed-off-by: Karel Zak <kzak@redhat.com>
---
schedutils/chrt.1 | 32 ++++++++++++++++++++++++++++----
schedutils/chrt.c | 18 +++++-------------
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/schedutils/chrt.1 b/schedutils/chrt.1
index 4b8b1e9da..a9adfb316 100644
--- a/schedutils/chrt.1
+++ b/schedutils/chrt.1
@@ -92,13 +92,37 @@ Specifies period parameter for SCHED_DEADLINE policy (Linux-specific).
Specifies deadline parameter for SCHED_DEADLINE policy (Linux-specific).
.TP
\fB\-R\fR, \fB\-\-reset-on-fork\fR
-Add
+Use
.B SCHED_RESET_ON_FORK
-flag to the
+or
+.B SCHED_FLAG_RESET_ON_FORK
+flag. Linux-specific, supported since 2.6.31.
+
+Each thread has a reset-on-fork scheduling flag. When this flag is set, children created by
+.BR fork (2)
+do not inherit privileged scheduling policies. After the reset-on-fork flag has been enabled,
+it can be reset only if the thread has the
+.BR CAP_SYS_NICE
+capability. This flag is disabled in child processes created by
+.BR fork (2).
+
+More precisely, if the reset-on-fork flag is set,
+the following rules apply for subsequently created children:
+.RS
+.IP * 3
+If the calling thread has a scheduling policy of
.B SCHED_FIFO
or
-.B SCHED_RR
-scheduling policy (Linux-specific, supported since 2.6.31).
+.BR SCHED_RR ,
+the policy is reset to
+.BR SCHED_OTHER
+in child processes.
+.IP *
+If the calling process has a negative nice value,
+the nice value is reset to zero in child processes.
+.RE
+
+
.SH OPTIONS
.TP
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 15556bbad..2a6f1e151 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -152,7 +152,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(USAGE_SEPARATOR, out);
fputs(_("Scheduling options:\n"), out);
- fputs(_(" -R, --reset-on-fork set SCHED_RESET_ON_FORK for FIFO or RR\n"), out);
+ fputs(_(" -R, --reset-on-fork set reset-on-fork flag\n"), out);
fputs(_(" -T, --sched-runtime <ns> runtime parameter for DEADLINE\n"), out);
fputs(_(" -P, --sched-period <ns> period parameter for DEADLINE\n"), out);
fputs(_(" -D, --sched-deadline <ns> deadline parameter for DEADLINE\n"), out);
@@ -173,22 +173,19 @@ static void __attribute__((__noreturn__)) usage(void)
static const char *get_policy_name(int policy)
{
+#ifdef SCHED_RESET_ON_FORK
+ policy &= ~SCHED_RESET_ON_FORK;
+#endif
switch (policy) {
case SCHED_OTHER:
return "SCHED_OTHER";
case SCHED_FIFO:
-#ifdef SCHED_RESET_ON_FORK
- case SCHED_FIFO | SCHED_RESET_ON_FORK:
-#endif
return "SCHED_FIFO";
#ifdef SCHED_IDLE
case SCHED_IDLE:
return "SCHED_IDLE";
#endif
case SCHED_RR:
-#ifdef SCHED_RESET_ON_FORK
- case SCHED_RR | SCHED_RESET_ON_FORK:
-#endif
return "SCHED_RR";
#ifdef SCHED_BATCH
case SCHED_BATCH:
@@ -257,7 +254,7 @@ fallback:
else
prio = sp.sched_priority;
# ifdef SCHED_RESET_ON_FORK
- if (policy == (SCHED_FIFO|SCHED_RESET_ON_FORK) || policy == (SCHED_BATCH|SCHED_RESET_ON_FORK))
+ if (policy & SCHED_RESET_ON_FORK)
reset_on_fork = 1;
# endif
}
@@ -515,11 +512,6 @@ int main(int argc, char **argv)
errno = 0;
ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
-#ifdef SCHED_RESET_ON_FORK
- if (ctl->reset_on_fork && ctl->policy != SCHED_FIFO && ctl->policy != SCHED_RR)
- errx(EXIT_FAILURE, _("--reset-on-fork option is supported for "
- "SCHED_FIFO and SCHED_RR policies only"));
-#endif
#ifdef SCHED_DEADLINE
if ((ctl->runtime || ctl->deadline || ctl->period) && ctl->policy != SCHED_DEADLINE)
errx(EXIT_FAILURE, _("--sched-{runtime,deadline,period} options "
--
2.29.2

View File

@ -0,0 +1,112 @@
From d4a05cc653c9e251a04afa9bd4f5a75777029445 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 2 Feb 2023 15:46:43 +0100
Subject: last: use snprintf() rather than sprintf()
Signed-off-by: Karel Zak <kzak@redhat.com>
Upstream: http://github.com/util-linux/util-linux/commit/79fb7e18f45e84c6f1a030b5df56cb2bdad26df0
Upstream: http://github.com/util-linux/util-linux/commit/6cd0043221b31a344db8f5dcb82822a2519a2e74
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2166653
---
login-utils/last.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/login-utils/last.c b/login-utils/last.c
index f3272caeb..7f4421c89 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -463,48 +463,48 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t
if (logout_time == currentdate) {
if (ctl->time_fmt > LAST_TIMEFTM_SHORT) {
- sprintf(logouttime, " still running");
+ snprintf(logouttime, sizeof(logouttime), " still running");
length[0] = 0;
} else {
- sprintf(logouttime, " still");
- sprintf(length, "running");
+ snprintf(logouttime, sizeof(logouttime), " still");
+ snprintf(length, sizeof(length), "running");
}
} else if (days) {
- sprintf(length, "(%d+%02d:%02d)", days, abs(hours), abs(mins)); /* hours and mins always shown as positive (w/o minus sign!) even if secs < 0 */
+ snprintf(length, sizeof(length), "(%d+%02d:%02d)", days, abs(hours), abs(mins)); /* hours and mins always shown as positive (w/o minus sign!) even if secs < 0 */
} else if (hours) {
- sprintf(length, " (%02d:%02d)", hours, abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */
+ snprintf(length, sizeof(length), " (%02d:%02d)", hours, abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */
} else if (secs >= 0) {
- sprintf(length, " (%02d:%02d)", hours, mins);
+ snprintf(length, sizeof(length), " (%02d:%02d)", hours, mins);
} else {
- sprintf(length, " (-00:%02d)", abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */
+ snprintf(length, sizeof(length), " (-00:%02d)", abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */
}
switch(what) {
case R_CRASH:
- sprintf(logouttime, "- crash");
+ snprintf(logouttime, sizeof(logouttime), "- crash");
break;
case R_DOWN:
- sprintf(logouttime, "- down ");
+ snprintf(logouttime, sizeof(logouttime), "- down ");
break;
case R_NOW:
if (ctl->time_fmt > LAST_TIMEFTM_SHORT) {
- sprintf(logouttime, " still logged in");
+ snprintf(logouttime, sizeof(logouttime), " still logged in");
length[0] = 0;
} else {
- sprintf(logouttime, " still");
- sprintf(length, "logged in");
+ snprintf(logouttime, sizeof(logouttime), " still");
+ snprintf(length, sizeof(length), "logged in");
}
break;
case R_PHANTOM:
if (ctl->time_fmt > LAST_TIMEFTM_SHORT) {
- sprintf(logouttime, " gone - no logout");
+ snprintf(logouttime, sizeof(logouttime), " gone - no logout");
length[0] = 0;
} else if (ctl->time_fmt == LAST_TIMEFTM_SHORT) {
- sprintf(logouttime, " gone");
- sprintf(length, "- no logout");
+ snprintf(logouttime, sizeof(logouttime), " gone");
+ snprintf(length, sizeof(length), "- no logout");
} else {
logouttime[0] = 0;
- sprintf(length, "no logout");
+ snprintf(length, sizeof(length), "no logout");
}
break;
case R_TIMECHANGE:
@@ -756,7 +756,7 @@ static void process_wtmp_file(const struct last_control *ctl,
else {
if (ut.ut_type != DEAD_PROCESS &&
ut.ut_user[0] && ut.ut_line[0] &&
- strcmp(ut.ut_user, "LOGIN") != 0)
+ strncmp(ut.ut_user, "LOGIN", 5) != 0)
ut.ut_type = USER_PROCESS;
/*
* Even worse, applications that write ghost
@@ -769,7 +769,7 @@ static void process_wtmp_file(const struct last_control *ctl,
/*
* Clock changes.
*/
- if (strcmp(ut.ut_user, "date") == 0) {
+ if (strncmp(ut.ut_user, "date", 4) == 0) {
if (ut.ut_line[0] == '|')
ut.ut_type = OLD_TIME;
if (ut.ut_line[0] == '{')
@@ -804,7 +804,7 @@ static void process_wtmp_file(const struct last_control *ctl,
case RUN_LVL:
x = ut.ut_pid & 255;
if (ctl->extended) {
- sprintf(ut.ut_line, "(to lvl %c)", x);
+ snprintf(ut.ut_line, sizeof(ut.ut_line), "(to lvl %c)", x);
quit = list(ctl, &ut, lastrch, R_NORMAL);
}
if (x == '0' || x == '6') {
--
2.39.1

View File

@ -1,4 +1,4 @@
From 428791718a166ee5ce275b0bcf4a904a97e6af9d Mon Sep 17 00:00:00 2001 From 5285f83b77df9e206f4904eba92c741eb42acc93 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com> From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Dec 2021 13:19:18 +0100 Date: Mon, 13 Dec 2021 13:19:18 +0100
Subject: include/c: add cmp_timespec() and cmp_stat_mtime() Subject: include/c: add cmp_timespec() and cmp_stat_mtime()
@ -6,7 +6,7 @@ Subject: include/c: add cmp_timespec() and cmp_stat_mtime()
It's like timercmp() in libc, but for timespec and for stat.st_mtim It's like timercmp() in libc, but for timespec and for stat.st_mtim
(or stat.st_mtime for old struct stat versions). (or stat.st_mtime for old struct stat versions).
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180413 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180414
Upstream: http://github.com/util-linux/util-linux/commit/0cfb8c5c3205a92ae81def278cdded63ea47094f Upstream: http://github.com/util-linux/util-linux/commit/0cfb8c5c3205a92ae81def278cdded63ea47094f
Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
--- ---
@ -14,10 +14,10 @@ Signed-off-by: Karel Zak <kzak@redhat.com>
1 file changed, 18 insertions(+) 1 file changed, 18 insertions(+)
diff --git a/include/c.h b/include/c.h diff --git a/include/c.h b/include/c.h
index c8bcb375b..e48ac6d7d 100644 index 354b59e29..01f0fa507 100644
--- a/include/c.h --- a/include/c.h
+++ b/include/c.h +++ b/include/c.h
@@ -125,6 +125,24 @@ @@ -167,6 +167,24 @@
_a == _b ? 0 : _a > _b ? 1 : -1; }) _a == _b ? 0 : _a > _b ? 1 : -1; })
#endif #endif

View File

@ -1,41 +0,0 @@
From 8704fa57c3b93152df6c10fd6a35ebdd59e1a5b7 Mon Sep 17 00:00:00 2001
From: Peter Wu <peter@lekensteyn.nl>
Date: Fri, 1 Feb 2019 15:40:53 +0100
Subject: [PATCH 45/55] mount.8: clarify (no)suid behavior on file capabilities
Clarify that the nosuid option also affects file capabilities and that
it only limits execution of programs. (setgid on directories still
inherit the group regardless of the nosuid option.) The new text is
taken from the mount(2) manual page from the man-pages project.
Addresses: https://github.com/karelzak/util-linux/issues/482
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1855759
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
---
sys-utils/mount.8 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sys-utils/mount.8 b/sys-utils/mount.8
index 1cc792979..a4d7de2c0 100644
--- a/sys-utils/mount.8
+++ b/sys-utils/mount.8
@@ -1107,12 +1107,12 @@ or
Do not use the lazytime feature.
.TP
.B suid
-Allow set-user-ID or set-group-ID bits to take
-effect.
+Honor set-user-ID and set-group-ID bits or file capabilities when
+executing programs from this filesystem.
.TP
.B nosuid
-Do not allow set-user-ID or set-group-ID bits to take
-effect.
+Do not honor set-user-ID and set-group-ID bits or file capabilities when
+executing programs from this filesystem.
.TP
.B silent
Turn on the silent flag.
--
2.29.2

View File

@ -1,59 +0,0 @@
From afe6545483a881ccde41dcaa6718c71c74b38d7b Mon Sep 17 00:00:00 2001
From: Sven Wiltink <swiltink@transip.nl>
Date: Fri, 1 May 2020 16:35:40 +0200
Subject: [PATCH 46/55] lsblk: Fall back to ID_SERIAL
In some cases ID_SERIAL_SHORT isn't provided by libudev, but ID_SERIAL
is. An example of this are virtio devices. See the output of udevadm
info:
P: /devices/pci0000:00/0000:00:06.0/virtio2/block/vdb
N: vdb
S: disk/by-id/virtio-08491434ee711d3420e9
S: disk/by-path/pci-0000:00:06.0
S: disk/by-path/virtio-pci-0000:00:06.0
E: DEVLINKS=/dev/disk/by-id/virtio-08491434ee711d3420e9 /dev/disk/by-path/pci-0000:00:06.0 /dev/disk/by-path/virtio-pci-0000:00:06.0
E: DEVNAME=/dev/vdb
E: DEVPATH=/devices/pci0000:00/0000:00:06.0/virtio2/block/vdb
E: DEVTYPE=disk
E: ID_PATH=pci-0000:00:06.0
E: ID_PATH_TAG=pci-0000_00_06_0
E: ID_SERIAL=08491434ee711d3420e9
E: MAJOR=252
E: MINOR=16
E: SUBSYSTEM=block
E: TAGS=:systemd:
E: USEC_INITIALIZED=1403804
[RHEL-8 backport: add ID_SERIAL and also ID_SCSI_SERIAL to be compatible with upstream]
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1861670
Upstream: http://github.com/karelzak/util-linux/commit/e81d0f80068086147434fa947a4f723c00318772
Upstream: http://github.com/karelzak/util-linux/commit/de6c2a4aec140e6086e278688d97f4655ced1a9a
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/lsblk.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index ae97f9f05..d0369d3e7 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -567,8 +567,14 @@ static int get_udev_properties(struct blkdev_cxt *cxt)
if (data)
cxt->wwn = xstrdup(data);
- if ((data = udev_device_get_property_value(dev, "ID_SERIAL_SHORT")))
+ data = udev_device_get_property_value(dev, "ID_SCSI_SERIAL");
+ if (!data)
+ data = udev_device_get_property_value(dev, "ID_SERIAL_SHORT");
+ if (!data)
+ data = udev_device_get_property_value(dev, "ID_SERIAL");
+ if (data)
cxt->serial = xstrdup(data);
+
udev_device_unref(dev);
cxt->probed = 1;
DBG(DEV, ul_debugobj(cxt, "%s: found udev properties", cxt->name));
--
2.29.2

View File

@ -1,4 +1,4 @@
From 7cc9fe69d3f35038b7b3329fef0cccdbe38ffef6 Mon Sep 17 00:00:00 2001 From 5d150964f0b2fbcaa9f9d11809eede9255159a5d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com> From: Karel Zak <kzak@redhat.com>
Date: Mon, 13 Dec 2021 13:22:56 +0100 Date: Mon, 13 Dec 2021 13:22:56 +0100
Subject: mount: add hint about systemctl daemon-reload Subject: mount: add hint about systemctl daemon-reload
@ -12,7 +12,7 @@ The message is printed only on terminal to avoid extra messages in
logs, etc. logs, etc.
Addresses: https://github.com/systemd/systemd/pull/20476 Addresses: https://github.com/systemd/systemd/pull/20476
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180413 Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180414
Upstream: http://github.com/util-linux/util-linux/commit/1db0715169954a8f3898f7ca9d3902cd6c27084d Upstream: http://github.com/util-linux/util-linux/commit/1db0715169954a8f3898f7ca9d3902cd6c27084d
Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
--- ---
@ -21,10 +21,10 @@ Signed-off-by: Karel Zak <kzak@redhat.com>
2 files changed, 25 insertions(+) 2 files changed, 25 insertions(+)
diff --git a/include/pathnames.h b/include/pathnames.h diff --git a/include/pathnames.h b/include/pathnames.h
index 77f8b6e85..19b117cb9 100644 index 7e7d9053f..8c3c36477 100644
--- a/include/pathnames.h --- a/include/pathnames.h
+++ b/include/pathnames.h +++ b/include/pathnames.h
@@ -76,6 +76,8 @@ @@ -82,6 +82,8 @@
#define _PATH_NUMLOCK_ON _PATH_RUNSTATEDIR "/numlock-on" #define _PATH_NUMLOCK_ON _PATH_RUNSTATEDIR "/numlock-on"
#define _PATH_LOGINDEFS "/etc/login.defs" #define _PATH_LOGINDEFS "/etc/login.defs"
@ -34,7 +34,7 @@ index 77f8b6e85..19b117cb9 100644
#define _PATH_WORDS "/usr/share/dict/words" #define _PATH_WORDS "/usr/share/dict/words"
#define _PATH_WORDS_ALT "/usr/share/dict/web2" #define _PATH_WORDS_ALT "/usr/share/dict/web2"
diff --git a/sys-utils/mount.c b/sys-utils/mount.c diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index 83cccf63e..108b55001 100644 index ce1de16dc..90a0331c3 100644
--- a/sys-utils/mount.c --- a/sys-utils/mount.c
+++ b/sys-utils/mount.c +++ b/sys-utils/mount.c
@@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
@ -45,7 +45,7 @@ index 83cccf63e..108b55001 100644
#define XALLOC_EXIT_CODE MNT_EX_SYSERR #define XALLOC_EXIT_CODE MNT_EX_SYSERR
#include "xalloc.h" #include "xalloc.h"
@@ -287,6 +288,25 @@ static void selinux_warning(struct libmnt_context *cxt, const char *tgt) @@ -336,6 +337,25 @@ static void selinux_warning(struct libmnt_context *cxt, const char *tgt)
# define selinux_warning(_x, _y) # define selinux_warning(_x, _y)
#endif #endif
@ -71,7 +71,7 @@ index 83cccf63e..108b55001 100644
/* /*
* Returns exit status (MNT_EX_*) and/or prints error message. * Returns exit status (MNT_EX_*) and/or prints error message.
*/ */
@@ -310,6 +330,9 @@ static int mk_exit_code(struct libmnt_context *cxt, int rc) @@ -359,6 +379,9 @@ static int mk_exit_code(struct libmnt_context *cxt, int rc)
if (rc == MNT_EX_SUCCESS && mnt_context_get_status(cxt) == 1) { if (rc == MNT_EX_SUCCESS && mnt_context_get_status(cxt) == 1) {
selinux_warning(cxt, tgt); selinux_warning(cxt, tgt);
} }

View File

@ -1,32 +0,0 @@
From 4ac8e70822313b0c6b35ebf633c6e8fbca558998 Mon Sep 17 00:00:00 2001
From: Thomas Abraham <tabraham@suse.com>
Date: Thu, 24 Sep 2020 14:52:33 -0400
Subject: [PATCH 47/55] lscpu: avoid segfault on PowerPC systems with valid
hardware configurations
ntypes greater than 1 is valid in some hardware configurations, and an assert()
on the value isn't necessary or very future proof
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1883783
Upstream: http://github.com/karelzak/util-linux/commit/cbe3304bc43b3fceb06fb6e5dd822bb59abf1b84
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/lscpu.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 1aa7bff4d..748d545b6 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -369,8 +369,6 @@ static void read_physical_info_powerpc(struct lscpu_desc *desc)
return;
ntypes = strbe16toh(buf, 2);
-
- assert(ntypes <= 1);
if (!ntypes)
return;
--
2.29.2

View File

@ -0,0 +1,73 @@
From 3dc40e180aaf653bc76fc0097a8bb112f48af5ae Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 2 Mar 2022 11:34:06 +0100
Subject: tests: improve cramfs tests
* make GID and mode use more robust (already used in tests/ts/cramfs/mkfs)
* mark cramfs fsck/mkfs tests as TS_KNOWN_FAIL, the tests are based on
image checksums and it produces a different binary image on s390
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2133396
Addresses: https://github.com/util-linux/util-linux/issues/1613
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/ts/cramfs/doubles | 9 ++++++++-
tests/ts/cramfs/fsck-endianness | 3 +++
tests/ts/cramfs/mkfs-endianness | 3 +++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/tests/ts/cramfs/doubles b/tests/ts/cramfs/doubles
index 8a1b7bb88..eb2c7fa0f 100755
--- a/tests/ts/cramfs/doubles
+++ b/tests/ts/cramfs/doubles
@@ -36,10 +36,17 @@ IMAGE_SRC="$TS_OUTDIR/${TS_TESTNAME}-data"
ts_log "create mountpoint dir"
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
-mkdir -p $IMAGE_SRC
+rm -rf "$IMAGE_SRC"
+mkdir -m 755 -p $IMAGE_SRC
+
+umask 133
+
echo hello > $IMAGE_SRC/a
echo hello > $IMAGE_SRC/b
+# sudo may use whatever group
+chgrp -R 0 "$IMAGE_SRC"
+
ts_log "create cramfs image"
$TS_CMD_MKCRAMFS $IMAGE_SRC $IMAGE_PATH >> $TS_OUTPUT 2>> $TS_ERRLOG
[ -s "$IMAGE_PATH" ] || ts_die "Cannot create $IMAGE_PATH"
diff --git a/tests/ts/cramfs/fsck-endianness b/tests/ts/cramfs/fsck-endianness
index bcfb46c90..222ea3fd3 100755
--- a/tests/ts/cramfs/fsck-endianness
+++ b/tests/ts/cramfs/fsck-endianness
@@ -27,6 +27,9 @@ ts_check_test_command "$TS_HELPER_MD5"
ts_skip_nonroot
+# does not work on s390
+TS_KNOWN_FAIL="yes"
+
IMAGE_LITTLE="$TS_SELF/cramfs-little.img" #Known good little endian image
IMAGE_BIG="$TS_SELF/cramfs-big.img" #Known good big endian image
diff --git a/tests/ts/cramfs/mkfs-endianness b/tests/ts/cramfs/mkfs-endianness
index 91d476579..5f0ff714d 100755
--- a/tests/ts/cramfs/mkfs-endianness
+++ b/tests/ts/cramfs/mkfs-endianness
@@ -26,6 +26,9 @@ ts_check_test_command "$TS_CMD_HEXDUMP"
ts_skip_nonroot
+# does not work on s390
+TS_KNOWN_FAIL="yes"
+
IMAGE_DATA="$TS_OUTDIR/${TS_TESTNAME}-data"
IMAGE_CREATED="$TS_OUTDIR/${TS_TESTNAME}-cramfs.img" #Image created during the test and compared against the known images.
--
2.40.1

View File

@ -1,33 +0,0 @@
From b3c5c1f39db58b057bb581f1d3bebcbeedeee1cb Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 17 Sep 2018 11:58:50 +0200
Subject: [PATCH 48/55] libfdisk: count gaps to possible size when resize
The current code counts only partition sizes when it counts possible
space, but we have gaps between the partitions. It seems better to
count all based on offsets rather than sizes.
Addresses: https://github.com/karelzak/util-linux/issues/693
Upstream: http://github.com/karelzak/util-linux/commit/2f35c1ead621f42f32f7777232568cb03185b473
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1900498
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libfdisk/src/partition.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c
index a790dc9c9..ebcf6bf5c 100644
--- a/libfdisk/src/partition.c
+++ b/libfdisk/src/partition.c
@@ -1113,7 +1113,7 @@ static int resize_get_last_possible(
break;
} else {
last = pa;
- *maxsz += pa->size;
+ *maxsz = pa->size - (start - pa->start);
DBG(TAB, ul_debugobj(tb, " new max=%ju (last updated)", (uintmax_t) *maxsz));
}
}
--
2.29.2

View File

@ -0,0 +1,33 @@
From f0f4fe8901462ca335d89267037ffe99096bac72 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 9 Aug 2023 12:56:42 +0200
Subject: uuidd: improve man page for -cont-clock
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2174748
Signed-off-by: Karel Zak <kzak@redhat.com>
---
misc-utils/uuidd.8.adoc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/misc-utils/uuidd.8.adoc b/misc-utils/uuidd.8.adoc
index c87125901..38ef39598 100644
--- a/misc-utils/uuidd.8.adoc
+++ b/misc-utils/uuidd.8.adoc
@@ -24,8 +24,12 @@ The *uuidd* daemon is used by the UUID library to generate universally unique id
== OPTIONS
-*-C*, *--cont-clock* _opt_arg_::
-Activate continuous clock handling for time based UUIDs. *uuidd* could use all possible clock values, beginning with the daemon's start time. The optional argument can be used to set a value for the max_clock_offset. This gurantees, that a clock value of a UUID will always be within the range of the max_clock_offset. '-C' or '--cont-clock' enables the feature with a default max_clock_offset of 2 hours. '-C<NUM>[hd]' or '--cont-clock=<NUM>[hd]' enables the feature with a max_clock_offset of NUM seconds. In case of an appended h or d, the NUM value is read in hours or days. The minimum value is 60 seconds, the maximum value is 365 days.
+*-C*, *--cont-clock*[=_time_]::
+Activate continuous clock handling for time based UUIDs. *uuidd* could use all possible clock values, beginning with the daemon's start time. The optional argument can be used to set a value for the max_clock_offset. This gurantees, that a clock value of a UUID will always be within the range of the max_clock_offset.
++
+The option '-C' or '--cont-clock' enables the feature with a default max_clock_offset of 2 hours.
++
+The option '-C<NUM>[hd]' or '--cont-clock=<NUM>[hd]' enables the feature with a max_clock_offset of NUM seconds. In case of an appended h or d, the NUM value is read in hours or days. The minimum value is 60 seconds, the maximum value is 365 days.
*-d*, *--debug*::
Run uuidd in debugging mode. This prevents uuidd from running as a daemon.
--
2.40.1

View File

@ -1,116 +0,0 @@
From 780f79420073e0c09cd41afea28ac217a6d4ef29 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Fri, 26 Jun 2020 12:59:32 +0200
Subject: [PATCH 49/55] libmount: (parser) fix memory leak on error before
end-of-file
Let's simplify the loop where we add FS to the table. The optimization
for recoverable errors is a fragile overkill. The new code always
allocates and unrefs FS for each loop.
Addresses: https://github.com/karelzak/util-linux/pull/1068
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1900498
Upstream: http://github.com/karelzak/util-linux/commit/fe0d12d4f82269096f8d0cffc51ca9590814c284
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/fs.c | 2 +-
libmount/src/tab_parse.c | 49 ++++++++++++++++++++++------------------
2 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/libmount/src/fs.c b/libmount/src/fs.c
index def32253c..aae4961c3 100644
--- a/libmount/src/fs.c
+++ b/libmount/src/fs.c
@@ -34,7 +34,7 @@ struct libmnt_fs *mnt_new_fs(void)
fs->refcount = 1;
INIT_LIST_HEAD(&fs->ents);
- /*DBG(FS, ul_debugobj(fs, "alloc"));*/
+ DBG(FS, ul_debugobj(fs, "alloc"));
return fs;
}
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index 10fc68279..719c1abca 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -608,7 +608,6 @@ static int __table_parse_stream(struct libmnt_table *tb, FILE *f, const char *fi
int rc = -1;
int flags = 0;
pid_t tid = -1;
- struct libmnt_fs *fs = NULL;
struct libmnt_parser pa = { .line = 0 };
assert(tb);
@@ -628,19 +627,25 @@ static int __table_parse_stream(struct libmnt_table *tb, FILE *f, const char *fi
if (filename && strcmp(filename, _PATH_PROC_MOUNTS) == 0)
flags = MNT_FS_KERNEL;
- while (!feof(f)) {
- if (!fs) {
- fs = mnt_new_fs();
- if (!fs)
- goto err;
+ do {
+ struct libmnt_fs *fs;
+
+ if (feof(f)) {
+ DBG(TAB, ul_debugobj(tb, "end-of-file"));
+ break;
}
+ fs = mnt_new_fs();
+ if (!fs)
+ goto err;
+ /* parse */
rc = mnt_table_parse_next(&pa, tb, fs);
- if (!rc && tb->fltrcb && tb->fltrcb(fs, tb->fltrcb_data))
- rc = 1; /* filtered out by callback... */
+ if (rc != 0 && tb->fltrcb && tb->fltrcb(fs, tb->fltrcb_data))
+ rc = 1; /* error filtered out by callback... */
- if (!rc) {
+ /* add to the table */
+ if (rc == 0) {
rc = mnt_table_add_fs(tb, fs);
fs->flags |= flags;
@@ -651,21 +656,21 @@ static int __table_parse_stream(struct libmnt_table *tb, FILE *f, const char *fi
}
}
- if (rc) {
- if (rc > 0) {
- mnt_reset_fs(fs);
- assert(fs->refcount == 1);
- continue; /* recoverable error, reuse fs*/
- }
+ /* remove refernece (or deallocate on error) */
+ mnt_unref_fs(fs);
- mnt_unref_fs(fs);
- if (feof(f))
- break;
- goto err; /* fatal error */
+ /* recoverable error */
+ if (rc > 0) {
+ DBG(TAB, ul_debugobj(tb, "recoverable error (continue)"));
+ continue;
}
- mnt_unref_fs(fs);
- fs = NULL;
- }
+
+ /* fatal errors */
+ if (rc < 0 && !feof(f)) {
+ DBG(TAB, ul_debugobj(tb, "fatal error"));
+ goto err;
+ }
+ } while (1);
DBG(TAB, ul_debugobj(tb, "%s: stop parsing (%d entries)",
filename, mnt_table_get_nents(tb)));
--
2.29.2

Some files were not shown because too many files have changed in this diff Show More