diff -r 7aeb74df004b -r 08e910e23d9f debian/postinst --- a/debian/postinst Wed Aug 12 19:15:33 2015 +0200 +++ b/debian/postinst Wed Aug 12 20:20:23 2015 +0200 @@ -35,15 +35,39 @@ } update_sshd_config() { - add_sshd_env IUS_USER - add_sshd_env IUS_PROFILE - add_sshd_env HGUSER - add_sshd_env HGRCPATH - add_sshd_env EDITOR - add_sshd_env REMOTE_USER - add_sshd_env INPUTRC + tmp=$(mktemp) + out=$(mktemp) + trap 'rm $tmp $out' EXIT + + need_sshd_env $tmp IUS_USER + need_sshd_env $tmp IUS_PROFILE + need_sshd_env $tmp HGUSER + need_sshd_env $tmp EDITOR + need_sshd_env $tmp REMOTE_USER + need_sshd_env $tmp HGRCPATH + + test -s $tmp || return 0 + + file=$tmp perl >$out <<'_' + open($f, '/etc/ssh/sshd_config') or die "Can't open sshd_config: $!\n"; + my @conf; + while (<$f>) { + /^Match\s/ and last; + push @conf, $_; + } + push @conf, "# autoadded by schlittermann-ssh-keys\n", + do { local @ARGV = $ENV{file}; <> }, + $_, <$f>; + print @conf; +_ + test $(stat -c%s $out) -ge $(stat -c%s /etc/ssh/sshd_config) + cp --backup=numbered -p /etc/ssh/sshd_config /etc/ssh/sshd_config~ + cat $out > /etc/ssh/sshd_config + + invoke-rc.d ssh reload || service ssh reload } + case "$1" in configure) update-schlittermann-ssh-keys