From e7be6ae5f5d5bdb28d802d616b596304b6b3280e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 14 Jul 2021 17:40:22 +0200 Subject: [PATCH] 2.37-4: fix #1981729 (close_range(), remove raw(8) and PCRE2 use) --- hardlink-remove-pcre2posix.h-support.patch | 49 +++++++++++++++++ login-fix-close_range-use.patch | 62 ++++++++++++++++++++++ util-linux.spec | 41 +++++++------- 3 files changed, 131 insertions(+), 21 deletions(-) create mode 100644 hardlink-remove-pcre2posix.h-support.patch create mode 100644 login-fix-close_range-use.patch diff --git a/hardlink-remove-pcre2posix.h-support.patch b/hardlink-remove-pcre2posix.h-support.patch new file mode 100644 index 0000000..5c2368b --- /dev/null +++ b/hardlink-remove-pcre2posix.h-support.patch @@ -0,0 +1,49 @@ +diff -up util-linux-2.37/configure.ac.kzak util-linux-2.37/configure.ac +--- util-linux-2.37/configure.ac.kzak 2021-06-01 09:50:39.898388178 +0200 ++++ util-linux-2.37/configure.ac 2021-07-14 17:57:45.927112572 +0200 +@@ -1452,14 +1452,6 @@ UL_REQUIRES_HAVE([setpriv], [linux_capab + UL_REQUIRES_HAVE([setpriv], [cap_ng], [libcap-ng library]) + AM_CONDITIONAL([BUILD_SETPRIV], [test "x$build_setpriv" = xyes]) + +-PKG_CHECK_MODULES([PCRE2_POSIX], [libpcre2-posix], +- [have_pcre2_posix=yes], +- [have_pcre2_posix=no]) +-AS_IF([test "x$have_pcre2_posix" = xyes ], [ +- AC_DEFINE([HAVE_PCRE2_POSIX], [1], [Define if libpcre2-posix is available]) +-]) +-AM_CONDITIONAL([HAVE_PCRE2_POSIX], [test "x$have_pcre2_posix" = xyes]) +- + AC_ARG_ENABLE([hardlink], + AS_HELP_STRING([--disable-hardlink], [do not build hardlink]), + [], [UL_DEFAULT_ENABLE([hardlink], [check])] +diff -up util-linux-2.37/misc-utils/hardlink.c.kzak util-linux-2.37/misc-utils/hardlink.c +--- util-linux-2.37/misc-utils/hardlink.c.kzak 2021-05-24 13:39:52.714045529 +0200 ++++ util-linux-2.37/misc-utils/hardlink.c 2021-07-14 17:57:51.910085213 +0200 +@@ -44,14 +44,7 @@ + #include "monotonic.h" + #include "optutils.h" + +-/* Use libpcre2posix if it's available */ +-#ifdef HAVE_PCRE2_POSIX +-# include +-# undef REG_NOSUB +-# define REG_NOSUB 0 /* we do want backreferences in PCRE mode */ +-#else +-# include /* regcomp(), regsearch() */ +-#endif ++#include /* regcomp(), regsearch() */ + + #ifdef HAVE_SYS_XATTR_H + # include /* listxattr, getxattr */ +diff -up util-linux-2.37/misc-utils/Makemodule.am.kzak util-linux-2.37/misc-utils/Makemodule.am +--- util-linux-2.37/misc-utils/Makemodule.am.kzak 2021-05-24 13:39:52.714045529 +0200 ++++ util-linux-2.37/misc-utils/Makemodule.am 2021-07-14 17:57:51.910085213 +0200 +@@ -244,8 +244,4 @@ dist_noinst_DATA += misc-utils/hardlink. + hardlink_SOURCES = misc-utils/hardlink.c lib/monotonic.c + hardlink_LDADD = $(LDADD) libcommon.la $(REALTIME_LIBS) + hardlink_CFLAGS = $(AM_CFLAGS) +-if HAVE_PCRE2_POSIX +-hardlink_LDADD += $(PCRE2_POSIX_LIBS) +-hardlink_CFLAGS += $(PCRE2_POSIX_CFLAGS) +-endif + endif diff --git a/login-fix-close_range-use.patch b/login-fix-close_range-use.patch new file mode 100644 index 0000000..6972c61 --- /dev/null +++ b/login-fix-close_range-use.patch @@ -0,0 +1,62 @@ +From b8d99a618baffb4fc03cda4c40e29778b6d77ad4 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 14 Jul 2021 17:25:57 +0200 +Subject: [PATCH] login: fix close_range() use + +This new syscall comes with three arguments (see kernel commit +278a5fbaed89dacd04e9d052f4594ffd0e0585de). Not sure why util-linux +assume only two. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1981729 +Signed-off-by: Karel Zak +--- + include/fileutils.h | 4 ++-- + lib/fileutils.c | 2 +- + login-utils/login.c | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/include/fileutils.h b/include/fileutils.h +index ad54b952c..f86426b96 100644 +--- a/include/fileutils.h ++++ b/include/fileutils.h +@@ -82,9 +82,9 @@ static inline struct dirent *xreaddir(DIR *dp) + # if defined(SYS_close_range) + # include + # ifndef HAVE_CLOSE_RANGE +-static inline int close_range(unsigned int first, unsigned int last) ++static inline int close_range(unsigned int first, unsigned int last, int flags) + { +- return syscall(SYS_close_range, first, last); ++ return syscall(SYS_close_range, first, last, flags); + } + # endif + # define HAVE_CLOSE_RANGE 1 +diff --git a/lib/fileutils.c b/lib/fileutils.c +index 846b718c9..a979b03ac 100644 +--- a/lib/fileutils.c ++++ b/lib/fileutils.c +@@ -189,7 +189,7 @@ int main(int argc, char *argv[]) + ignore_result( dup(STDIN_FILENO) ); + + # ifdef HAVE_CLOSE_RANGE +- close_range(STDERR_FILENO + 1, ~0U); ++ close_range(STDERR_FILENO + 1, ~0U, 0); + # else + ul_close_all_fds(STDERR_FILENO + 1, ~0U); + # endif +diff --git a/login-utils/login.c b/login-utils/login.c +index 48e3fa2e2..d926466d3 100644 +--- a/login-utils/login.c ++++ b/login-utils/login.c +@@ -1357,7 +1357,7 @@ static void initialize(int argc, char **argv, struct login_context *cxt) + #endif + } + #ifdef HAVE_CLOSE_RANGE +- close_range(STDERR_FILENO + 1, ~0U); ++ close_range(STDERR_FILENO + 1, ~0U, 0); + #else + ul_close_all_fds(STDERR_FILENO + 1, ~0U); + #endif +-- +2.31.1 + diff --git a/util-linux.spec b/util-linux.spec index a1f80f5..b35590d 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -2,7 +2,7 @@ Summary: Collection of basic system utilities Name: util-linux Version: 2.37 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain URL: https://en.wikipedia.org/wiki/Util-linux @@ -31,11 +31,11 @@ BuildRequires: systemd Buildrequires: libuser-devel BuildRequires: libcap-ng-devel BuildRequires: %{pypkg}-devel -BuildRequires: pcre2-devel BuildRequires: gcc BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool +BuildRequires: bison BuildRequires: rubygem-asciidoctor %ifarch ppc64le BuildRequires: librtas-devel @@ -98,6 +98,14 @@ Patch0: login-lastlog-create.patch # https://github.com/coreos/console-login-helper-messages/issues/60 Patch1: login-default-motd-file.patch +### Upstream patches (remove ./autogen.sh call from build section when remove +### these patches) +### +# 1981729 - close_range() +Patch2: login-fix-close_range-use.patch +# Remove dependence on POSIX PCRE2 +Patch3: hardlink-remove-pcre2posix.h-support.patch + %description The util-linux package contains a large variety of low-level system utilities that are necessary for a Linux system to function. Among @@ -292,6 +300,10 @@ chfn and chsh utilities with dependence on libuser %build unset LINGUAS || : +# unfortunately, we did changes to build-system +./autogen.sh + + 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" @@ -305,7 +317,7 @@ export DAEMON_LDFLAGS="$SUID_LDFLAGS" --enable-chfn-chsh \ --enable-usrdir-path \ --enable-write \ - --enable-raw \ + --disable-raw \ --enable-hardlink \ --enable-fdformat \ --enable-asciidoc \ @@ -343,19 +355,6 @@ chmod 0644 ${RPM_BUILD_ROOT}/var/log/lastlog # install util-linux %make_install -# raw -echo '.so man8/raw.8' > $RPM_BUILD_ROOT%{_mandir}/man8/rawdevices.8 -{ - # see RH bugzilla #216664 - mkdir -p ${RPM_BUILD_ROOT}%{_prefix}/lib/udev/rules.d - pushd ${RPM_BUILD_ROOT}%{_prefix}/lib/udev/rules.d - install -m 644 %{SOURCE4} ./60-raw.rules - popd -} - -# sbin -> bin -mv ${RPM_BUILD_ROOT}%{_sbindir}/raw ${RPM_BUILD_ROOT}%{_bindir}/raw - # And a dirs uuidd needs that the makefiles don't create install -d ${RPM_BUILD_ROOT}/run/uuidd install -d ${RPM_BUILD_ROOT}/var/lib/libuuid @@ -520,7 +519,6 @@ fi %config(noreplace) %{_sysconfdir}/pam.d/su-l %config(noreplace) %{_sysconfdir}/pam.d/runuser %config(noreplace) %{_sysconfdir}/pam.d/runuser-l -%config(noreplace) %{_prefix}/lib/udev/rules.d/60-raw.rules %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/adjtime @@ -561,7 +559,6 @@ fi %{_bindir}/mesg %{_bindir}/namei %{_bindir}/prlimit -%{_bindir}/raw %{_bindir}/rename %{_bindir}/rev %{_bindir}/script @@ -645,8 +642,6 @@ fi %{_mandir}/man8/mkfs.minix.8* %{_mandir}/man8/nologin.8* %{_mandir}/man8/pivot_root.8* -%{_mandir}/man8/raw.8* -%{_mandir}/man8/rawdevices.8* %{_mandir}/man8/readprofile.8* %{_mandir}/man8/resizepart.8* %{_mandir}/man8/rfkill.8* @@ -729,7 +724,6 @@ fi %{compldir}/namei %{compldir}/pivot_root %{compldir}/prlimit -%{compldir}/raw %{compldir}/readprofile %{compldir}/rename %{compldir}/resizepart @@ -960,6 +954,11 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog +* Wed Jul 14 2021 Karel Zak - 2.37-4 +- disable raw(8) - no more supported since Linux v5.14 (commit 03e4922f1c81fc2ed3a87b4f91a8d3aafc7e093) +- remove dependence on deprecated pcre2posix.h +- fix #1981729 - close_range() 3rd argument + * Wed Jun 16 2021 Richard W.M. Jones - 2.37-3 - Rebuild for updated pcre2