diff --git a/libmount-Fix-regression-when-mounting-with-atime.patch b/libmount-Fix-regression-when-mounting-with-atime.patch new file mode 100644 index 0000000000000000000000000000000000000000..c149eab5cea3cde3afec8e0d10bffad04c7a825c --- /dev/null +++ b/libmount-Fix-regression-when-mounting-with-atime.patch @@ -0,0 +1,132 @@ +From 2b99ee2526ae61be761b0e31c50e106dbec5e9e4 Mon Sep 17 00:00:00 2001 +From: Filipe Manana +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_ 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 +--- + 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 diff --git a/login-default-motd-file.patch b/login-default-motd-file.patch new file mode 100644 index 0000000000000000000000000000000000000000..3670848498094fae83dfa7452b09e13e0d79e759 --- /dev/null +++ b/login-default-motd-file.patch @@ -0,0 +1,13 @@ +diff --git a/include/pathnames.h b/include/pathnames.h +index 3845d4c33..fac3a0783 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 diff --git a/login-lastlog-create.patch b/login-lastlog-create.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2523d3aaadd1d9cb4a527db65491ac04a3566f5 --- /dev/null +++ b/login-lastlog-create.patch @@ -0,0 +1,12 @@ +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); diff --git a/util-linux.spec b/util-linux.spec index 470ce0ced76af3b16194b78c50d0b13e6ef6d2e9..82a581a286dcc9d753f218a723e817929c5fae19 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 %global upstream_version 2.39.2 %global major_version v2.39 %global compldir %{_datadir}/bash-completion/completions/ @@ -24,6 +24,9 @@ Source15: util-linux-runuser-l.pamd Patch0: https://patch-diff.githubusercontent.com/raw/util-linux/util-linux/pull/2251.patch # Disable conflicts man pages with shadow-utils Patch1: util-linux-disable-conflict-man-pages.patch +Patch2: login-lastlog-create.patch +Patch3: login-default-motd-file.patch +Patch4: libmount-Fix-regression-when-mounting-with-atime.patch BuildRequires: make BuildRequires: audit-libs-devel @@ -37,7 +40,6 @@ BuildRequires: popt-devel BuildRequires: libutempter-devel Buildrequires: systemd-devel BuildRequires: systemd -Buildrequires: libuser-devel BuildRequires: libcap-ng-devel BuildRequires: python3-devel BuildRequires: gcc @@ -49,6 +51,8 @@ Provides: /sbin/findfs Provides: eject = 2.1.6 Provides: rfkill = 0.5 Provides: util-linux-ng = %{version}-%{release} +Provides: util-linux-user = %{version}-%{release} +Obsoletes: util-linux-user < %{version}-%{release} Requires(post): coreutils Requires: pam >= 1.1.3-7, /etc/pam.d/system-auth @@ -233,19 +237,21 @@ written in the Python programming language to use the interface supplied by the libmount library to work with mount tables (fstab, mountinfo, etc) and mount filesystems. - -%package -n util-linux-user -Summary: libuser based util-linux utilities +%package -n util-linux-i18n +Summary: Internationalization pack for util-linux Requires: util-linux = %{version}-%{release} License: GPLv2 - -%description -n util-linux-user -chfn and chsh utilities with dependence on libuser + +%description -n util-linux-i18n +Internationalization pack with translated messages and manual pages for +util-linux commands. %prep %autosetup -n %{name}-%{upstream_version} -p1 %build +unset LINGUAS || : + export CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $RPM_OPT_FLAGS" export SUID_CFLAGS="-fpie" export SUID_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now" @@ -254,6 +260,7 @@ export DAEMON_LDFLAGS="$SUID_LDFLAGS" %configure \ --with-systemdsystemunitdir=%{_unitdir} \ + --without-user \ --disable-silent-rules \ --disable-bfs \ --disable-pg \ @@ -318,7 +325,7 @@ rm -f $RPM_BUILD_ROOT%{compldir}/{mount,umount} %find_lang %name --all-name --with-man -mv %{name}.lang %{name}.files +touch %{name}.files find $RPM_BUILD_ROOT%{_bindir}/ -regextype posix-egrep -type l \ -regex ".*(linux32|linux64|i386|x86_64|uname26)$" \ @@ -368,12 +375,16 @@ fi %config(noreplace) %{_sysconfdir}/pam.d/su-l %config(noreplace) %{_sysconfdir}/pam.d/runuser %config(noreplace) %{_sysconfdir}/pam.d/runuser-l +%config(noreplace) %{_sysconfdir}/pam.d/chfn +%config(noreplace) %{_sysconfdir}/pam.d/chsh %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/adjtime %attr(4755,root,root) %{_bindir}/su %attr(755,root,root) %{_bindir}/login %attr(2755,root,tty) %{_bindir}/write +%attr(4711,root,root) %{_bindir}/chfn +%attr(4711,root,root) %{_bindir}/chsh %{_unitdir}/fstrim.* %{_bindir}/cal @@ -426,7 +437,9 @@ fi %{_bindir}/wdctl %{_bindir}/whereis %{_mandir}/man1/cal.1* +%{_mandir}/man1/chfn.1* %{_mandir}/man1/choom.1* +%{_mandir}/man1/chsh.1* %{_mandir}/man1/col.1* %{_mandir}/man1/colcrt.1* %{_mandir}/man1/colrm.1* @@ -541,7 +554,9 @@ fi %{compldir}/blkzone %{compldir}/cal %{compldir}/chcpu +%{compldir}/chfn %{compldir}/chmem +%{compldir}/chsh %{compldir}/col %{compldir}/colcrt %{compldir}/colrm @@ -629,7 +644,6 @@ fi %{compldir}/sfdisk %files -n util-linux-core -%ghost %verify(not md5 size mtime) %config(noreplace,missingok) /etc/mtab %attr(4755,root,root) %{_bindir}/mount %attr(4755,root,root) %{_bindir}/umount %{_bindir}/chrt @@ -715,17 +729,7 @@ fi %{_sbindir}/swapoff %{_sbindir}/swapon %{_sbindir}/switch_root - - -%files -n util-linux-user -%config(noreplace) %{_sysconfdir}/pam.d/chfn -%config(noreplace) %{_sysconfdir}/pam.d/chsh -%attr(4711,root,root) %{_bindir}/chfn -%attr(4711,root,root) %{_bindir}/chsh -%{_mandir}/man1/chfn.1* -%{_mandir}/man1/chsh.1* -%{compldir}/chfn -%{compldir}/chsh +/etc/mtab %files -n uuidd @@ -806,7 +810,12 @@ fi %license Documentation/licenses/COPYING.LGPL-2.1-or-later libmount/COPYING %{python3_sitearch}/libmount +%files -n util-linux-i18n -f %{name}.lang + %changelog +* Mon Oct 09 2023 happy_orange - 2.39.2-2 +- fix mount error and move user package to main package and add util-linux-i18n package + * Thu Aug 17 2023 Funda Wang - 2.39.2-1 - New version 2.39.2