revert recent uuidd mode changes

- rebase rhel specific patches
- fix uuidd-tmpfiles.conf (upstream patch)
- remove unused patches
This commit is contained in:
Karel Zak 2024-07-10 10:40:29 +02:00
parent c57bc4bec0
commit 134b553b83
7 changed files with 88 additions and 151 deletions

View File

@ -0,0 +1,28 @@
From a9d027ee07f56b67054ec8ef02481a1e60429f6d Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 10 Jul 2024 10:29:20 +0200
Subject: login: lastlog create
This is port of the old RHEL patch to RHEL-10.
Signed-off-by: Karel Zak <kzak@redhat.com>
---
login-utils/login.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/login-utils/login.c b/login-utils/login.c
index c8544f6a1..3de0398e9 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -681,7 +681,7 @@ static void log_lastlog(struct login_context *cxt)
sa.sa_handler = SIG_IGN;
sigaction(SIGXFSZ, &sa, &oldsa_xfsz);
- fd = open(_PATH_LASTLOG, O_RDWR, 0);
+ fd = open(_PATH_LASTLOG, O_RDWR | O_CREAT, 0);
if (fd < 0)
goto done;
offset = cxt->pwd->pw_uid * sizeof(ll);
--
2.45.2

View File

@ -1,5 +1,17 @@
From c4354ccde565c742a75816ef46c2f7265415f1f7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 10 Jul 2024 10:30:42 +0200
Subject: login: default motd file
This is port of the old RHEL patch to RHEL-10.
Signed-off-by: Karel Zak <kzak@redhat.com>
---
include/pathnames.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/pathnames.h b/include/pathnames.h diff --git a/include/pathnames.h b/include/pathnames.h
index 3845d4c33..fac3a0783 100644 index de456c53e..ac28a9a50 100644
--- a/include/pathnames.h --- a/include/pathnames.h
+++ b/include/pathnames.h +++ b/include/pathnames.h
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
@ -11,3 +23,6 @@ index 3845d4c33..fac3a0783 100644
#ifndef _PATH_NOLOGIN #ifndef _PATH_NOLOGIN
# define _PATH_NOLOGIN "/etc/nologin" # define _PATH_NOLOGIN "/etc/nologin"
#endif #endif
--
2.45.2

View File

@ -0,0 +1,34 @@
From 151dbf45503032839c02d07d8a5c89e2d064cb34 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 9 Jul 2024 17:04:09 +0200
Subject: uuidd: fix /var/lib/libuuid mode uuidd-tmpfiles.conf
The directory can be directly used by libuuid, for example, by running
"uuidgen --time" as root, even if the uuidd daemon is not installed.
In this case, we must create a clock.txt file with the uuidd group to
prevent any potential ownership mismatch if the uuidd daemon is
installed later. The 2xxx mode (setgid) forces open(O_CREAT) in
libuuid to create the file with the uuidd group.
Please note that mode 2755 is the standard used for years in RHEL.
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit e0c41735aa13a7a62e42c0428823537d3edc02a8)
(cherry picked from commit 555152c36b1026ea97eb06a9a57fac154fa36ed0)
---
misc-utils/uuidd-tmpfiles.conf.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc-utils/uuidd-tmpfiles.conf.in b/misc-utils/uuidd-tmpfiles.conf.in
index b362930d8..90b8a8537 100644
--- a/misc-utils/uuidd-tmpfiles.conf.in
+++ b/misc-utils/uuidd-tmpfiles.conf.in
@@ -3,4 +3,4 @@
# See tmpfiles.d(5) for details
#
d @runstatedir@/uuidd 2775 uuidd uuidd -
-d @localstatedir@/lib/libuuid 0755 uuidd uuidd -
+d @localstatedir@/lib/libuuid 2755 uuidd uuidd -
--
2.45.2

View File

@ -1,133 +0,0 @@
From 2b99ee2526ae61be761b0e31c50e106dbec5e9e4 Mon Sep 17 00:00:00 2001
From: Filipe Manana <fdmanana@kernel.org>
Date: Thu, 17 Aug 2023 10:20:13 +0100
Subject: [PATCH] libmount: Fix regression when mounting with atime
A regression was introduced in v2.39 that causes mounting with the atime
option to fail:
$ mkfs.ext4 -F /dev/sdi
$ mount -o atime /dev/sdi /mnt/sdi
mount: /mnt/sdi: not mount point or bad option.
dmesg(1) may have more information after failed mount system call.
The failure comes from the mount_setattr(2) call returning -EINVAL. This
is because we pass an invalid value for the attr_clr argument. From a
strace capture we have:
mount_setattr(4, "", AT_EMPTY_PATH, {attr_set=0, attr_clr=MOUNT_ATTR_NOATIME, propagation=0 /* MS_??? */, userns_fd=0}, 32) = -1 EINVAL (Invalid argument)
We can't pass MOUNT_ATTR_NOATIME to mount_setattr(2) through the attr_clr
argument because all atime options are exclusive, so in order to set atime
one has to pass MOUNT_ATTR__ATIME to attr_clr and leave attr_set as
MOUNT_ATTR_RELATIME (which is defined as a value of 0).
This can be read from the man page for mount_setattr(2) and also from the
kernel source:
$ cat fs/namespace.c
static int build_mount_kattr(const struct mount_attr *attr, size_t usize,
struct mount_kattr *kattr, unsigned int flags)
{
(...)
/*
* Since the MOUNT_ATTR_<atime> values are an enum, not a bitmap,
* users wanting to transition to a different atime setting cannot
* simply specify the atime setting in @attr_set, but must also
* specify MOUNT_ATTR__ATIME in the @attr_clr field.
* So ensure that MOUNT_ATTR__ATIME can't be partially set in
* @attr_clr and that @attr_set can't have any atime bits set if
* MOUNT_ATTR__ATIME isn't set in @attr_clr.
*/
if (attr->attr_clr & MOUNT_ATTR__ATIME) {
if ((attr->attr_clr & MOUNT_ATTR__ATIME) != MOUNT_ATTR__ATIME)
return -EINVAL;
/*
* Clear all previous time settings as they are mutually
* exclusive.
*/
kattr->attr_clr |= MNT_RELATIME | MNT_NOATIME;
switch (attr->attr_set & MOUNT_ATTR__ATIME) {
case MOUNT_ATTR_RELATIME:
kattr->attr_set |= MNT_RELATIME;
break;
case MOUNT_ATTR_NOATIME:
kattr->attr_set |= MNT_NOATIME;
break;
case MOUNT_ATTR_STRICTATIME:
break;
default:
return -EINVAL;
}
(...)
So fix this by setting attr_clr MOUNT_ATTR__ATIME if we want to clear any
atime related option.
Signed-off-by: Filipe Manana <fdmanana@kernel.org>
---
libmount/src/optlist.c | 13 ++++++++++++-
tests/expected/libmount/context-mount-flags | 3 +++
tests/ts/libmount/context | 9 ++++++++-
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c
index e93810b47..d0afc94f7 100644
--- a/libmount/src/optlist.c
+++ b/libmount/src/optlist.c
@@ -875,7 +875,18 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
if (opt->ent->mask & MNT_INVERT) {
DBG(OPTLIST, ul_debugobj(ls, " clr: %s", opt->ent->name));
- *clr |= x;
+ /*
+ * All atime settings are mutually exclusive so *clr must
+ * have MOUNT_ATTR__ATIME set.
+ *
+ * See the function fs/namespace.c:build_mount_kattr()
+ * in the linux kernel source.
+ */
+ if (x == MOUNT_ATTR_RELATIME || x == MOUNT_ATTR_NOATIME ||
+ x == MOUNT_ATTR_STRICTATIME)
+ *clr |= MOUNT_ATTR__ATIME;
+ else
+ *clr |= x;
} else {
DBG(OPTLIST, ul_debugobj(ls, " set: %s", opt->ent->name));
*set |= x;
diff --git a/tests/expected/libmount/context-mount-flags b/tests/expected/libmount/context-mount-flags
index 960641863..eb71323dd 100644
--- a/tests/expected/libmount/context-mount-flags
+++ b/tests/expected/libmount/context-mount-flags
@@ -3,3 +3,6 @@ ro,nosuid,noexec
successfully mounted
rw,nosuid,noexec
successfully umounted
+successfully mounted
+rw,relatime
+successfully umounted
diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context
index f5b47185e..a5d2e81a3 100755
--- a/tests/ts/libmount/context
+++ b/tests/ts/libmount/context
@@ -116,8 +116,15 @@ $TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPU
ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
-ts_finalize_subtest
+# Test that the atime option works after the migration to use the new kernel mount APIs.
+ts_run $TESTPROG --mount -o atime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_finalize_subtest
ts_init_subtest "mount-loopdev"
mkdir -p $MOUNTPOINT &> /dev/null
--
2.40.1

View File

@ -1,12 +0,0 @@
diff -up util-linux-2.36/login-utils/login.c.kzak util-linux-2.36/login-utils/login.c
--- util-linux-2.36/login-utils/login.c.kzak 2020-07-23 14:13:26.777030764 +0200
+++ util-linux-2.36/login-utils/login.c 2020-07-23 14:11:22.793686983 +0200
@@ -585,7 +585,7 @@ static void log_lastlog(struct login_con
sa.sa_handler = SIG_IGN;
sigaction(SIGXFSZ, &sa, &oldsa_xfsz);
- fd = open(_PATH_LASTLOG, O_RDWR, 0);
+ fd = open(_PATH_LASTLOG, O_RDWR | O_CREAT, 0);
if (fd < 0)
goto done;
offset = cxt->pwd->pw_uid * sizeof(ll);

View File

@ -90,13 +90,19 @@ Requires: libsmartcols = %{version}-%{release}
Requires: libfdisk = %{version}-%{release} Requires: libfdisk = %{version}-%{release}
Requires: util-linux-core = %{version}-%{release} Requires: util-linux-core = %{version}-%{release}
### Ready for upstream? ### RHEL-10.0
### ###
# 151635 - makeing /var/log/lastlog # 151635 - makeing /var/log/lastlog
Patch0: login-lastlog-create.patch Patch0: 0000-login-lastlog-create.patch
# Add `/run/motd.d` to the hardcoded MOTD_FILE # Add `/run/motd.d` to the hardcoded MOTD_FILE
# https://github.com/coreos/console-login-helper-messages/issues/60 # https://github.com/coreos/console-login-helper-messages/issues/60
Patch1: login-default-motd-file.patch Patch1: 0001-login-default-motd-file.patch
# upstream
Patch2: 0002-uuidd-fix-var-lib-libuuid-mode-uuidd-tmpfiles.conf.patch
%description %description
The util-linux package contains a large variety of low-level system The util-linux package contains a large variety of low-level system
@ -873,7 +879,7 @@ fi
%{_mandir}/man8/uuidd.8* %{_mandir}/man8/uuidd.8*
%{_sbindir}/uuidd %{_sbindir}/uuidd
%{_unitdir}/uuidd.* %{_unitdir}/uuidd.*
%dir %attr(0775, uuidd, uuidd) /var/lib/libuuid %dir %attr(2775, uuidd, uuidd) /var/lib/libuuid
%dir %attr(2775, uuidd, uuidd) /run/uuidd %dir %attr(2775, uuidd, uuidd) /run/uuidd
%{compldir}/uuidd %{compldir}/uuidd
%{_tmpfilesdir}/uuidd-tmpfiles.conf %{_tmpfilesdir}/uuidd-tmpfiles.conf

View File

@ -1 +0,0 @@
d /run/uuidd 2775 uuidd uuidd