diff options
Diffstat (limited to 'debian/openssh-server.preinst')
-rw-r--r-- | debian/openssh-server.preinst | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/debian/openssh-server.preinst b/debian/openssh-server.preinst index a5c507bd4..2c2e2687c 100644 --- a/debian/openssh-server.preinst +++ b/debian/openssh-server.preinst | |||
@@ -1,17 +1,36 @@ | |||
1 | #!/bin/sh -e | 1 | #!/bin/sh -e |
2 | 2 | ||
3 | ETC_DEFAULT_SSH=@ETC_DEFAULT_SSH@ | ||
4 | |||
5 | ETC_INIT_D_SSH=@ETC_INIT_D_SSH@ | ||
6 | |||
7 | ETC_PAM_D_SSH=@ETC_PAM_D_SSH@ | ||
8 | |||
3 | action=$1 | 9 | action=$1 |
4 | version=$2 | 10 | version=$2 |
5 | 11 | ||
6 | prepare_transfer_conffile () { | 12 | prepare_transfer_conffile () { |
7 | CONFFILE="$1" | 13 | CONFFILE="$1" |
14 | TEXT="$2" | ||
15 | MODE="$3" | ||
8 | [ -e "$CONFFILE" ] || return 0 | 16 | [ -e "$CONFFILE" ] || return 0 |
9 | 17 | ||
10 | md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')" | 18 | md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')" |
11 | old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)" | 19 | old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)" |
12 | if [ "$md5sum" = "$old_md5sum" ]; then | 20 | if [ "$md5sum" = "$old_md5sum" ]; then |
13 | echo >&2 "Transferring ownership of conffile $CONFFILE ..." | 21 | echo >&2 "Transferring ownership of conffile $CONFFILE ..." |
22 | # We have to write out the desired new text of the conffile, | ||
23 | # which is tricky in the preinst, hence the nasty way we | ||
24 | # have to hardcode the text here. Fortunately, this is only | ||
25 | # necessary with sarge's dpkg and older. | ||
26 | if echo "$TEXT" | head -n1 | grep -q '^@.*@$'; then | ||
27 | echo >&2 'Unsubstituted conffile text! Please report this bug.' | ||
28 | exit 1 | ||
29 | fi | ||
30 | printf '%s' "$TEXT" >"$CONFFILE.dpkg-new" | ||
31 | chmod "$MODE" "$CONFFILE.dpkg-new" | ||
14 | mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst" | 32 | mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst" |
33 | mv -f "$CONFFILE.dpkg-new" "$CONFFILE" | ||
15 | return 0 | 34 | return 0 |
16 | fi | 35 | fi |
17 | } | 36 | } |
@@ -92,9 +111,9 @@ EOF | |||
92 | fi | 111 | fi |
93 | 112 | ||
94 | if dpkg --compare-versions "$version" lt 0; then | 113 | if dpkg --compare-versions "$version" lt 0; then |
95 | prepare_transfer_conffile /etc/default/ssh | 114 | prepare_transfer_conffile /etc/default/ssh "$ETC_DEFAULT_SSH" 0644 |
96 | prepare_transfer_conffile /etc/init.d/ssh | 115 | prepare_transfer_conffile /etc/init.d/ssh "$ETC_INIT_D_SSH" 0755 |
97 | prepare_transfer_conffile /etc/pam.d/ssh | 116 | prepare_transfer_conffile /etc/pam.d/ssh "$ETC_PAM_D_SSH" 0644 |
98 | fi | 117 | fi |
99 | fi | 118 | fi |
100 | 119 | ||