summaryrefslogtreecommitdiff
path: root/debian/preinst
diff options
context:
space:
mode:
Diffstat (limited to 'debian/preinst')
-rw-r--r--debian/preinst79
1 files changed, 79 insertions, 0 deletions
diff --git a/debian/preinst b/debian/preinst
new file mode 100644
index 000000000..320d4df2a
--- /dev/null
+++ b/debian/preinst
@@ -0,0 +1,79 @@
1#!/bin/sh -e
2
3action=$1
4version=$2
5
6if [ -d /etc/ssh-nonfree -a ! -d /etc/ssh ]; then
7 version=1.2.27
8fi
9
10if [ "$action" = upgrade -o "$action" = install ]
11then
12 # check if debconf is missing
13 if ! test -f /usr/share/debconf/confmodule
14 then
15 cat <<EOF
16
17WARNING: ssh's pre-configuration script relies on debconf to tell you
18about some problems that might prevent you from logging in if you are
19upgrading from the old, Non-free version of ssh.
20
21If this is a new installation, you don't need to worry about this.
22Just go ahead and install ssh (make sure to read .../ssh/README.Debian).
23
24If you are upgrading, but you have alternative ways of logging into
25the machine (i.e. you're sitting in front of it, or you have telnetd
26running), then you also don't need to worry too much, because you can
27fix it up afterwards if there's a problem.
28
29If you're upgrading from an older (non-free) version of ssh, and ssh
30is the only way you have to access this machine, then you should
31probably abort the installation of ssh, install debconf, and then
32retry the installation of ssh.
33
34EOF
35 echo -n "Do you want to install SSH anyway [yN]: "
36 read input
37 expr "$input" : '[Yy]' >/dev/null || exit 1
38
39 # work around for missing debconf
40 db_get() { : ; }
41 RET=true
42 if [ -d /etc/ssh-nonfree -a ! -d /etc/ssh ]; then
43 cp -a /etc/ssh-nonfree /etc/ssh
44 fi
45 else
46 # Source debconf library.
47 . /usr/share/debconf/confmodule
48 db_version 2.0
49 fi
50
51 db_get ssh/use_old_init_script
52 if [ "$RET" = "false" ]; then
53 echo "ssh config: Aborting because ssh/use_old_init_script = false" >&2
54 exit 1
55 fi
56
57 # deal with upgrading from pre-OpenSSH versions
58 key=/etc/ssh/ssh_host_key
59 export key
60 if [ -n "$version" ] && [ -x /usr/bin/ssh-keygen ] && [ -f $key ] &&
61 dpkg --compare-versions "$version" lt 1.2.28
62 then
63 # make sure that keys get updated to get rid of IDEA
64 #
65 # N.B. this only works because we've still got the old
66 # nonfree ssh-keygen at this point
67 #
68 # First, check if we need to bother
69 echo -en '\0\0' | 3<&0 sh -c \
70 'dd if=$key bs=1 skip=32 count=2 2>/dev/null | cmp -s - /dev/fd/3' || {
71 # this means that bytes 32&33 of the key were not both zero, in which
72 # case the key is encrypted, which we need to fix
73 chmod 600 $key
74 ssh-keygen -u -f $key >/dev/null
75 }
76 fi
77fi
78
79#DEBHELPER#