From 1e50498a5a28af7428d63e498e0f3d2718a990b4 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 5 Jan 2024 17:46:21 +0100 Subject: [PATCH] create /etc/shadow with pwconv if not existing in %post [release 4.5-4mamba;Wed Nov 15 2017] --- shadow.spec | 58 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/shadow.spec b/shadow.spec index 4a27ccb..565e77f 100644 --- a/shadow.spec +++ b/shadow.spec @@ -3,7 +3,7 @@ Summary: Utilities for managing shadow password files and user/group accou Name: shadow Version: 4.5 Group: Applications/Security -Release: 3mamba +Release: 4mamba Vendor: openmamba Distribution: openmamba Packager: Silvan Calarco @@ -166,32 +166,41 @@ done %clean [ "%{buildroot}" != / ] && rm -rf %{buildroot} -%post common -/sbin/ldconfig +%post groupadd shadow -g %{shadowgroupid} 2>/dev/null || : -exit 0 - -%preun common -/sbin/ldconfig -exit 0 - -%posttrans common -if [ -e /etc/shadow.rpmsave ]; then - SAVEPWD=`grep "^root:" /etc/shadow.rpmsave | sed "s|root:\([^:]*\):.*|\1|"` - NEWPWD=`grep "^root:" /etc/shadow | sed "s|root:\([^:]*\):.*|\1|"` - if [ "$NEWPWD" == "" -o "$NEWPWD" == "!" -o "$NEWPWD" == "x" ]; then - if [ "$SAVEPWD" != "!" -a "$SAVEPWD" != "" -a "$SAVEPWD" != "x" ]; then - mv /etc/shadow.rpmsave /etc/shadow - else - echo "Unexpected error updating /etc/shadow file: root password was lost, recover needed!" - fi - fi +if [ ! -e /etc/shadow ]; then + # upgrade/create passwords to shadow system + # for a new install or an upgrade + /usr/sbin/pwconv + chmod 0640 /etc/shadow + chgrp shadow /etc/shadow fi -[ -e /etc/shadow ] || touch /etc/shadow -chmod 0640 /etc/shadow -chgrp shadow /etc/shadow exit 0 +#% post common +#/sbin/ldconfig +#exit 0 + +#% preun common +#/sbin/ldconfig +#exit 0 + +#% posttrans common +#if [ -e /etc/shadow.rpmsave ]; then +# SAVEPWD=`grep "^root:" /etc/shadow.rpmsave | sed "s|root:\([^:]*\):.*|\1|"` +# NEWPWD=`grep "^root:" /etc/shadow | sed "s|root:\([^:]*\):.*|\1|"` +# if [ "$NEWPWD" == "" -o "$NEWPWD" == "!" -o "$NEWPWD" == "x" ]; then +# if [ "$SAVEPWD" != "!" -a "$SAVEPWD" != "" -a "$SAVEPWD" != "x" ]; then +# mv /etc/shadow.rpmsave /etc/shadow +# else +# echo "Unexpected error updating /etc/shadow file: root password was lost, recovery needed!" +# fi +# fi +#fi +#chmod 0640 /etc/shadow +#chgrp shadow /etc/shadow +#exit 0 + %files -f shadow-main.man %defattr(-,root,root) %{_bindir}/chage @@ -254,6 +263,9 @@ exit 0 %{_mandir}/man8/nologin.8* %changelog +* Wed Nov 15 2017 Silvan Calarco 4.5-4mamba +- create /etc/shadow with pwconv if not existing in %post + * Thu Nov 09 2017 Silvan Calarco 4.5-3mamba - create /etc/shadow if missing