From 34fb9827e7e68b9e35faf2e1568c80176bfcbb05 Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Wed, 26 Feb 2014 17:12:04 +0100 Subject: postinst: check for dangling but possibly correct symlink test -e dereferences symlinks --- debian/openssh-known-hosts.postinst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/debian/openssh-known-hosts.postinst b/debian/openssh-known-hosts.postinst index 7caf740..0d810a9 100644 --- a/debian/openssh-known-hosts.postinst +++ b/debian/openssh-known-hosts.postinst @@ -20,10 +20,12 @@ set -e case "$1" in configure|abort-upgrade|abort-remove|abort-deconfigure) - [ -e /etc/ssh/ssh_known_hosts ] || ln -s /var/lib/openssh-known-hosts/ssh_known_hosts /etc/ssh/ssh_known_hosts - if [ "`readlink /etc/ssh/ssh_known_hosts`" != /var/lib/openssh-known-hosts/ssh_known_hosts ]; then - echo "/etc/ssh/ssh_known_hosts already exists, please set up the link to" - echo "/var/lib/openssh-known-hosts/ssh_known_hosts yourself or point to it" + kh_link=/etc/ssh/ssh_known_hosts + kh_dest=/var/lib/openssh-known-hosts/ssh_known_hosts + [ -L $kh_link ] || [ -e $kh_link ] || ln -s $kh_dest $kh_link + if [ "`readlink $kh_link`" != $kh_dest ]; then + echo "$kh_link already exists, please set up the link to" + echo "$kh_dest yourself or point to it" echo "with GlobalKnownHostsFile in ssh_config(5)." fi ;; -- cgit v1.2.3