summaryrefslogtreecommitdiff
path: root/debian/openssh-client.preinst
diff options
context:
space:
mode:
Diffstat (limited to 'debian/openssh-client.preinst')
-rw-r--r--debian/openssh-client.preinst21
1 files changed, 19 insertions, 2 deletions
diff --git a/debian/openssh-client.preinst b/debian/openssh-client.preinst
index 0e200712e..9cf29dfba 100644
--- a/debian/openssh-client.preinst
+++ b/debian/openssh-client.preinst
@@ -1,17 +1,34 @@
1#! /bin/sh -e 1#! /bin/sh -e
2 2
3ETC_SSH_MODULI=@ETC_SSH_MODULI@
4
5ETC_SSH_SSH_CONFIG=@ETC_SSH_SSH_CONFIG@
6
3action="$1" 7action="$1"
4version="$2" 8version="$2"
5 9
6prepare_transfer_conffile () { 10prepare_transfer_conffile () {
7 CONFFILE="$1" 11 CONFFILE="$1"
12 TEXT="$2"
13 MODE="$3"
8 [ -e "$CONFFILE" ] || return 0 14 [ -e "$CONFFILE" ] || return 0
9 15
10 md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')" 16 md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')"
11 old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)" 17 old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)"
12 if [ "$md5sum" = "$old_md5sum" ]; then 18 if [ "$md5sum" = "$old_md5sum" ]; then
13 echo >&2 "Transferring ownership of conffile $CONFFILE ..." 19 echo >&2 "Transferring ownership of conffile $CONFFILE ..."
20 # We have to write out the desired new text of the conffile,
21 # which is tricky in the preinst, hence the nasty way we
22 # have to hardcode the text here. Fortunately, this is only
23 # necessary with sarge's dpkg and older.
24 if echo "$TEXT" | head -n1 | grep -q '^@.*@$'; then
25 echo >&2 'Unsubstituted conffile text! Please report this bug.'
26 exit 1
27 fi
28 printf '%s' "$TEXT" >"$CONFFILE.dpkg-new"
29 chmod "$MODE" "$CONFFILE.dpkg-new"
14 mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst" 30 mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst"
31 mv -f "$CONFFILE.dpkg-new" "$CONFFILE"
15 return 0 32 return 0
16 fi 33 fi
17} 34}
@@ -19,8 +36,8 @@ prepare_transfer_conffile () {
19case $action in 36case $action in
20 install|upgrade) 37 install|upgrade)
21 if dpkg --compare-versions "$version" lt 0; then 38 if dpkg --compare-versions "$version" lt 0; then
22 prepare_transfer_conffile /etc/ssh/moduli 39 prepare_transfer_conffile /etc/ssh/moduli "$ETC_SSH_MODULI" 0644
23 prepare_transfer_conffile /etc/ssh/ssh_config 40 prepare_transfer_conffile /etc/ssh/ssh_config "$ETC_SSH_SSH_CONFIG" 0644
24 fi 41 fi
25 ;; 42 ;;
26esac 43esac