diff options
Diffstat (limited to 'debian/openssh-server.postrm')
-rw-r--r-- | debian/openssh-server.postrm | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/debian/openssh-server.postrm b/debian/openssh-server.postrm new file mode 100644 index 000000000..7258d5f99 --- /dev/null +++ b/debian/openssh-server.postrm | |||
@@ -0,0 +1,65 @@ | |||
1 | #!/bin/sh -e | ||
2 | |||
3 | #DEBHELPER# | ||
4 | |||
5 | abort_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 | |||
17 | finish_mv_conffile () { | ||
18 | CONFFILE="$1" | ||
19 | |||
20 | if [ -e "$CONFFILE.dpkg-old" ]; then | ||
21 | rm -f "$CONFFILE.dpkg-old" | ||
22 | fi | ||
23 | } | ||
24 | |||
25 | abort_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 | |||
34 | case $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/sshd_config | ||
52 | rm -f /etc/ssh/sshd_not_to_be_run | ||
53 | rmdir --ignore-fail-on-non-empty /etc/ssh | ||
54 | |||
55 | update-rc.d ssh remove >/dev/null | ||
56 | |||
57 | if which deluser >/dev/null 2>&1; then | ||
58 | deluser --quiet sshd > /dev/null || true | ||
59 | fi | ||
60 | |||
61 | finish_mv_conffile /etc/pam.d/ssh | ||
62 | ;; | ||
63 | esac | ||
64 | |||
65 | exit 0 | ||