Bug 684670

Summary: Impossible %postun for package erasure
Product: [Fedora] Fedora Reporter: Panu Matilainen <pmatilai>
Component: bashAssignee: Roman Rakus <rrakus>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: rawhideCC: maxamillion, rrakus, tsmetana
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-03-14 16:28:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Panu Matilainen 2011-03-14 08:17:16 UTC
Description of problem:

%postun
if [ "$1" = 0 ]; then
    /bin/grep -v '^/bin/bash$' < /etc/shells | \
      /bin/grep -v '^/bin/sh$' > /etc/shells.new
    /bin/mv /etc/shells.new /etc/shells
fi

This scriptlet tries to handle the case when bash is removed, but consider the circumstances where the if is ever true: the scriptlet is a shell script using /bin/sh as the interpreter, and gets executed /after/ bash has already been removed. So there's no /bin/sh anymore (because bash is what provides it), and the script can never be executed. 

Version-Release number of selected component (if applicable):
All versions that I can remember up to and including bash-4.2.7-1.fc16.

How reproducible:
Always

Steps to Reproduce:
1. yum --disablerepo="*" --enablerepo="rawhide" --installroot=/home/test/ -y install bash
2. rpm -e --root /home/test/ bash glibc-common glibc ncurses-libs nss-softokn-freebl

(step 2 uses rpm because yum blows up there but that's another bug...)
  
Actual results:
warning: %postun(bash-4.2.7-1.fc16.x86_64) scriptlet failed, exit status 127

Expected results:
Package is removed without scriptlet errors.

Additional info:
This is quite obviously a low-priority item, bash being removed is pretty much a never happens situation, just filing this for "correctness' sake" since it actually tries to handle this case. Couple of easy options:
1) use %preun instead of %postun for removing bash from /etc/shells
2) rewrite the scriptlet to use -p <lua> like %post does

There's also an rpm bug here: rpm should realize the %postun dependencies cannot be satisfied on removal and issue an error, but that's my headache...

Comment 1 Roman Rakus 2011-03-14 12:44:35 UTC
(In reply to comment #0)
> Description of problem:
> 
> %postun
> if [ "$1" = 0 ]; then
>     /bin/grep -v '^/bin/bash$' < /etc/shells | \
>       /bin/grep -v '^/bin/sh$' > /etc/shells.new
>     /bin/mv /etc/shells.new /etc/shells
> fi
> 
> This scriptlet tries to handle the case when bash is removed, but consider the
> circumstances where the if is ever true: the scriptlet is a shell script using
> /bin/sh as the interpreter, and gets executed /after/ bash has already been
> removed. So there's no /bin/sh anymore (because bash is what provides it), and
> the script can never be executed. 
Thanks for the report.
> 
> Version-Release number of selected component (if applicable):
> All versions that I can remember up to and including bash-4.2.7-1.fc16.
> 
> How reproducible:
> Always
> 
> Steps to Reproduce:
> 1. yum --disablerepo="*" --enablerepo="rawhide" --installroot=/home/test/ -y
> install bash
> 2. rpm -e --root /home/test/ bash glibc-common glibc ncurses-libs
> nss-softokn-freebl
> 
> (step 2 uses rpm because yum blows up there but that's another bug...)
> 
> Actual results:
> warning: %postun(bash-4.2.7-1.fc16.x86_64) scriptlet failed, exit status 127
> 
> Expected results:
> Package is removed without scriptlet errors.
> 
> Additional info:
> This is quite obviously a low-priority item, bash being removed is pretty much
> a never happens situation, just filing this for "correctness' sake" since it
> actually tries to handle this case. Couple of easy options:
> 1) use %preun instead of %postun for removing bash from /etc/shells
Does not work.
# rpm -e --root /home/test/ bash glibc-common glibc ncurses-libs nss-softokn-freebl/bin/sh: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
error: %preun(bash-4.2.7-2.fc16.x86_64) scriptlet failed, exit status 127
warning: %postun(glibc-2.13.90-6.x86_64) scriptlet failed, exit status 127

> 2) rewrite the scriptlet to use -p <lua> like %post does
I have to go this way.
> 
> There's also an rpm bug here: rpm should realize the %postun dependencies
> cannot be satisfied on removal and issue an error, but that's my headache...

Comment 2 Panu Matilainen 2011-03-14 13:29:30 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > 1) use %preun instead of %postun for removing bash from /etc/shells
> Does not work.
> # rpm -e --root /home/test/ bash glibc-common glibc ncurses-libs
> nss-softokn-freebl/bin/sh: error while loading shared libraries: libtinfo.so.5:
> cannot open shared object file: No such file or directory
> error: %preun(bash-4.2.7-2.fc16.x86_64) scriptlet failed, exit status 127
> warning: %postun(glibc-2.13.90-6.x86_64) scriptlet failed, exit status 127

Hmm, technically it /should/ to work... but then the bash - glibc - ncurses etc loop is a tricky one, quite possibly even more problematic on erase. I'll try to have a look at it.

> > 2) rewrite the scriptlet to use -p <lua> like %post does
> I have to go this way.

Nod, using lua largely frees it from dependency loop issues.

Comment 3 Roman Rakus 2011-03-14 16:28:01 UTC
Should be fixed in bash-4.2.7-2.fc16. Rewritten in lua. Feel free to reopen if it doesn't work.