#!/bin/sh -e action=$1 version=$2 prepare_transfer_conffile () { CONFFILE="$1" [ -e "$CONFFILE" ] || return 0 md5sum="$(md5sum "$CONFFILE" |sed -e 's/ .*//')" old_md5sum="$(sed -n -e "/^Conffiles:/,/^[^ ]/{\\' $CONFFILE'{s/^ [^ ]* //;s/ .*//;p}}" /var/lib/dpkg/status)" if [ "$md5sum" = "$old_md5sum" ]; then echo >&2 "Transferring ownership of conffile $CONFFILE ..." mv -f "$CONFFILE" "$CONFFILE.moved-by-preinst" return 0 fi } if [ -d /etc/ssh-nonfree ] && [ ! -d /etc/ssh ]; then version=1.2.27 fi if [ "$action" = upgrade ] || [ "$action" = install ] then # check if debconf is missing if ! test -f /usr/share/debconf/confmodule then cat </dev/null || exit 1 # work around for missing debconf db_get() { : ; } RET=true if [ -d /etc/ssh-nonfree ] && [ ! -d /etc/ssh ]; then cp -a /etc/ssh-nonfree /etc/ssh fi else # Source debconf library. . /usr/share/debconf/confmodule db_version 2.0 fi db_get ssh/use_old_init_script if [ "$RET" = "false" ]; then echo "ssh config: Aborting because ssh/use_old_init_script = false" >&2 exit 1 fi # deal with upgrading from pre-OpenSSH versions key=/etc/ssh/ssh_host_key export key if [ -n "$version" ] && [ -x /usr/bin/ssh-keygen ] && [ -f $key ] && dpkg --compare-versions "$version" lt 1.2.28 then # make sure that keys get updated to get rid of IDEA # # N.B. this only works because we've still got the old # nonfree ssh-keygen at this point # # First, check if we need to bother echo -en '\0\0' | 3<&0 sh -c \ 'dd if=$key bs=1 skip=32 count=2 2>/dev/null | cmp -s - /dev/fd/3' || { # this means that bytes 32&33 of the key were not both zero, in which # case the key is encrypted, which we need to fix chmod 600 $key ssh-keygen -u -f $key >/dev/null if type restorecon >/dev/null 2>&1; then restorecon "$key.pub" fi } fi if dpkg --compare-versions "$version" lt 0; then prepare_transfer_conffile /etc/default/ssh prepare_transfer_conffile /etc/init.d/ssh prepare_transfer_conffile /etc/pam.d/ssh fi fi #DEBHELPER#