This is complicated by the fact that the postrm script currently runs
remove-shell even during an upgrade.  So we cannot tell during an
upgrade whether bash was removed from /etc/shells by the user or by the
old postrm script.

The following patch should improve later upgrades, however.  It changes
postrm to run remove-shell only on purge (or disappear), and postinst to
run add-shell on initial installation or upgrade from a version that
runs remove-shell when being upgraded.

This would mean that bash would still be left in /etc/shells if it is
removed but not purged, though this is a non-issue so long as bash is
essential.

Ben.

diff -u bash-3.2/debian/bash.postrm bash-3.2/debian/bash.postrm
--- bash-3.2/debian/bash.postrm
+++ bash-3.2/debian/bash.postrm
@@ -3,7 +3,14 @@
 set -e
 
 case "$1" in
-    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    remove|upgrade|failed-upgrade|abort-install|abort-upgrade)
+       ;;
+
+    purge|disappear)
+       if [ -x /usr/sbin/remove-shell ] && [ -f /etc/shells ]; then
+           /usr/sbin/remove-shell /bin/bash
+           /usr/sbin/remove-shell /bin/rbash
+       fi
        ;;
 
     *)
@@ -12,11 +19,6 @@
        ;;
 esac
 
-if [ -x /usr/sbin/remove-shell ] && [ -f /etc/shells ]; then
-    /usr/sbin/remove-shell /bin/bash
-    /usr/sbin/remove-shell /bin/rbash
-fi
-
 #DEBHELPER#
 
 exit 0
diff -u bash-3.2/debian/bash.postinst bash-3.2/debian/bash.postinst
--- bash-3.2/debian/bash.postinst
+++ bash-3.2/debian/bash.postinst
@@ -14,7 +14,8 @@
     10 \
   || true
 
-if [ -x /usr/sbin/add-shell ]; then
+if [ "$1" = configure ] && dpkg --compare-versions "$2" le 3.2-2 \
+    && [ -x /usr/sbin/add-shell ]; then
     /usr/sbin/add-shell /bin/bash
     /usr/sbin/add-shell /bin/rbash
 fi
--- END ---

-- 
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
                                                              - Albert Camus

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to