summaryrefslogtreecommitdiff
path: root/debian/openssh-server.postrm
diff options
context:
space:
mode:
Diffstat (limited to 'debian/openssh-server.postrm')
-rw-r--r--debian/openssh-server.postrm66
1 files changed, 66 insertions, 0 deletions
diff --git a/debian/openssh-server.postrm b/debian/openssh-server.postrm
new file mode 100644
index 000000000..655c1ae17
--- /dev/null
+++ b/debian/openssh-server.postrm
@@ -0,0 +1,66 @@
1#!/bin/sh -e
2
3#DEBHELPER#
4
5abort_mv_conffile () {
6 CONFFILE="$1"
7
8 if [ ! -e "$CONFFILE" ]; then
9 if [ -e "$CONFFILE.dpkg-old" ]; then
10 mv -f "$CONFFILE.dpkg-old" "$CONFFILE"
11 elif [ -e "$CONFFILE.moving" ]; then
12 mv -f "$CONFFILE.moving" "$CONFFILE"
13 fi
14 fi
15}
16
17finish_mv_conffile () {
18 CONFFILE="$1"
19
20 if [ -e "$CONFFILE.dpkg-old" ]; then
21 rm -f "$CONFFILE.dpkg-old"
22 fi
23}
24
25abort_transfer_conffile () {
26 CONFFILE="$1"
27 if [ -e "$CONFFILE.moved-by-preinst" ]; then
28 echo >&2 "Aborting ownership transfer of conffile $CONFFILE ..."
29 mv -f "$CONFFILE.moved-by-preinst" "$CONFFILE"
30 return 0
31 fi
32}
33
34case $1 in
35 abort-install|abort-upgrade)
36 if dpkg --compare-versions "$2" lt 1:4.7p1-4; then
37 abort_mv_conffile /etc/pam.d/ssh
38 fi
39 abort_transfer_conffile /etc/default/ssh
40 abort_transfer_conffile /etc/init.d/ssh
41 abort_transfer_conffile /etc/pam.d/ssh
42 ;;
43 purge)
44 # Remove all non-conffiles that ssh might create, so that we
45 # can smoothly remove /etc/ssh if and only if the user
46 # hasn't dropped some other files in there. Conffiles have
47 # already been removed at this point.
48 rm -f /etc/ssh/ssh_host_key /etc/ssh/ssh_host_key.pub
49 rm -f /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key.pub
50 rm -f /etc/ssh/ssh_host_dsa_key /etc/ssh/ssh_host_dsa_key.pub
51 rm -f /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key.pub
52 rm -f /etc/ssh/sshd_config
53 rm -f /etc/ssh/sshd_not_to_be_run
54 rmdir --ignore-fail-on-non-empty /etc/ssh
55
56 update-rc.d ssh remove >/dev/null
57
58 if which deluser >/dev/null 2>&1; then
59 deluser --quiet sshd > /dev/null || true
60 fi
61
62 finish_mv_conffile /etc/pam.d/ssh
63 ;;
64esac
65
66exit 0