From 2a9e12701a1a2e5879cc0d4b3fea64fad4806f61 Mon Sep 17 00:00:00 2001 From: yAn1hCDc Date: Fri, 31 May 2024 07:15:46 +0000 Subject: [PATCH] fix: su to a common user in chroot Solution: Set sssd as the default profile (same with an23 minimal installation). Use lua script to avoid 'rm' or 'touch' command not found when authselect-libs installed before coreutils. Signed-off-by: yAn1hCDc --- authselect.spec | 57 ++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/authselect.spec b/authselect.spec index 9a039cb..06ac486 100644 --- a/authselect.spec +++ b/authselect.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 Name: authselect Version: 1.4.3 @@ -18,6 +18,8 @@ Source10: authselect-lib-filelist %bcond_with user_nsswitch %bcond_without enforce_authselect +%{?anolis:%global default_profile sssd} + BuildRequires: autoconf, automake, gcc, libtool BuildRequires: m4, pkgconfig, pkgconfig(popt) BuildRequires: gettext-devel, po4a, asciidoc, libcmocka-devel, libselinux-devel @@ -210,27 +212,35 @@ if [ $1 == 0 ] ; then fi %if %{with enforce_authselect} -%pre libs -force_file="%{forcefile}" -authselect="%{_bindir}/authselect" -rm -vf $force_file - -# Check if this is a new installation. -if [ $1 -eq 1 ]; then - touch $force_file -fi - -# Check if we are upgrading from older version then authselect-1.3.0 -# The version command is not available on earlier versions -if [ $1 -gt 1 ]; then - comm=$( $authselect check &> /dev/null ) - if [ $? -ne 0 ]; then - comm=$( $authselect version &> /dev/null ) - if [ $? -ne 0 ]; then - touch $force_file - fi - fi -fi +%pre libs -p +force_file = rpm.expand("%{forcefile}") +authselect = rpm.expand("%{_bindir}/authselect") +os.remove(force_file) + +-- Check if this is a new installation. +if tonumber(arg[2]) == 1 +then + f = io.open(force_file, "w") + f:write("") + f:close() +end + +-- Check if we are upgrading from older version then authselect-1.3.0 +-- The version command is not available on earlier versions +if tonumber(arg[2]) > 1 +then + comm = os.execute(authselect .. " check &> /dev/null") + if comm ~= true + then + comm = os.execute(authselect .. " version &> /dev/null") + if comm ~= true + then + f = io.open(force_file, "w") + f:write("") + f:close() + end + end +end %else %pre libs @@ -281,6 +291,9 @@ fi exit 0 %changelog +* Fri May 31 2024 yanyihao - 1.4.3-2 +- fix: su to a common user in chroot + * Tue Feb 27 2024 mgb01105731 - 1.4.3-1 - update to 1.4.3 -- Gitee