#!/usr/bin/make -f

DEB_DIVERT_EXTENSION = .invirt
DEB_DIVERT_FILES_invirt-ssh-config += \
	/etc/ssh/sshd_config.invirt

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/config-package.mk

debian/sshd_config.invirt-orig: /var/lib/dpkg/info/openssh-server.postinst
	perl -0pe 's/^.*<<EOF[^\n]*\n(.*\n)EOF\n.*$$/$$1/s or die;' $< > $@

common-build-indep:: debian/sshd_config.invirt

debian/sshd_config.invirt: debian/sshd_config.invirt-orig
	perl -0pe ' \
	    s/^#?GSSAPIAuthentication .*$$/GSSAPIAuthentication yes\nGSSAPIKeyExchange yes\nGSSAPIStrictAcceptorCheck no/m and \
	    s/^#?GSSAPICleanupCredentials .*$$/GSSAPICleanupCredentials yes/m and \
	    s/^#?ChallengeResponseAuthentication .*$$/ChallengeResponseAuthentication yes/m and \
	    s/^#?UsePrivilegeSeparation .*$$/UsePrivilegeSeparation yes/m and \
	    s/^#?PasswordAuthentication .*$$/PasswordAuthentication no/m or die;' $< > $@

clean::
	rm -f debian/sshd_config.invirt debian/sshd_config.invirt-orig