--- imap/imapd-ssl.dist.in.orig	2008-02-03 12:12:36.000000000 +0100
+++ imap/imapd-ssl.dist.in	2008-02-03 12:19:41.000000000 +0100
@@ -254,7 +254,7 @@
 #
 # This is an experimental feature.
 
-TLS_CERTFILE=@mydatadir@/imapd.pem
+TLS_CERTFILE=@sysconfig@/courier-imap/imapd.pem
 
 ##NAME: TLS_TRUSTCERTS:0
 #
--- imap/pop3d-ssl.dist.in.orig	2008-02-03 12:12:36.000000000 +0100
+++ imap/pop3d-ssl.dist.in	2008-02-03 12:18:59.000000000 +0100
@@ -241,7 +241,7 @@
 #
 # This is an experimental feature.
 
-TLS_CERTFILE=@mydatadir@/pop3d.pem
+TLS_CERTFILE=@sysconfig@/courier-imap/pop3d.pem
 
 ##NAME: TLS_TRUSTCERTS:0
 #
--- imap/mkimapdcert.in.orig	2007-11-04 21:50:15.000000000 +0100
+++ imap/mkimapdcert.in	2008-02-03 12:20:45.000000000 +0100
@@ -18,41 +18,41 @@
 
 prefix="@prefix@"
 
-if test -f @mydatadir@/imapd.pem
+if test -f @sysconfig@/courier-imap/imapd.pem
 then
-	echo "@mydatadir@/imapd.pem already exists."
+	echo "@sysconfig@/courier-imap/imapd.pem already exists."
 	exit 1
 fi
 
 umask 077
 
 cleanup() {
-	rm -f @mydatadir@/imapd.pem
-	rm -f @mydatadir@/imapd.rand
-	rm -f @mydatadir@/imapd.key
-	rm -f @mydatadir@/imapd.cert
+	rm -f @sysconfig@/courier-imap/imapd.pem
+	rm -f @sysconfig@/courier-imap/imapd.rand
+	rm -f @sysconfig@/courier-imap/imapd.key
+	rm -f @sysconfig@/courier-imap/imapd.cert
 	exit 1
 }
 
-cd @mydatadir@
+cd @sysconfig@/courier-imap
 
 if test "@ssllib@" = "openssl"
 then
-	cp /dev/null @mydatadir@/imapd.pem
-	chmod 600 @mydatadir@/imapd.pem
-	chown @mailuser@ @mydatadir@/imapd.pem
+	cp /dev/null @sysconfig@/courier-imap/imapd.pem
+	chmod 600 @sysconfig@/courier-imap/imapd.pem
+	chown @mailuser@ @sysconfig@/courier-imap/imapd.pem
 
-	dd if=@RANDOMV@ of=@mydatadir@/imapd.rand count=1 2>/dev/null
+	dd if=@RANDOMV@ of=@sysconfig@/courier-imap/imapd.rand count=1 2>/dev/null
 	@OPENSSL@ req -new -x509 -days 365 -nodes \
-		  -config @sysconfdir@/imapd.cnf -out @mydatadir@/imapd.pem -keyout @mydatadir@/imapd.pem || cleanup
-	@OPENSSL@ gendh -rand @mydatadir@/imapd.rand 512 >>@mydatadir@/imapd.pem || cleanup
-	@OPENSSL@ x509 -subject -dates -fingerprint -noout -in @mydatadir@/imapd.pem || cleanup
-	rm -f @mydatadir@/imapd.rand
+		  -config @sysconfdir@/imapd.cnf -out @sysconfig@/courier-imap/imapd.pem -keyout @sysconfig@/courier-imap/imapd.pem || cleanup
+	@OPENSSL@ gendh -rand @sysconfig@/courier-imap/imapd.rand 512 >>@sysconfig@/courier-imap/imapd.pem || cleanup
+	@OPENSSL@ x509 -subject -dates -fingerprint -noout -in @sysconfig@/courier-imap/imapd.pem || cleanup
+	rm -f @sysconfig@/courier-imap/imapd.rand
 else
-	cp /dev/null @mydatadir@/imapd.key
-	chmod 600 @mydatadir@/imapd.key
-	cp /dev/null @mydatadir@/imapd.cert
-	chmod 600 @mydatadir@/imapd.cert
+	cp /dev/null @sysconfig@/courier-imap/imapd.key
+	chmod 600 @sysconfig@/courier-imap/imapd.key
+	cp /dev/null @sysconfig@/courier-imap/imapd.cert
+	chmod 600 @sysconfig@/courier-imap/imapd.cert
 
 	@CERTTOOL@ --generate-privkey --outfile imapd.key
 	@CERTTOOL@ --generate-self-signed --load-privkey imapd.key --outfile imapd.cert --template @sysconfdir@/imapd.cnf
--- imap/mkpop3dcert.in.orig	2007-11-04 21:50:15.000000000 +0100
+++ imap/mkpop3dcert.in	2008-02-03 12:22:08.000000000 +0100
@@ -18,41 +18,41 @@
 
 prefix="@prefix@"
 
-if test -f @mydatadir@/pop3d.pem
+if test -f @sysconfig@/courier-imap/pop3d.pem
 then
-	echo "@mydatadir@/pop3d.pem already exists."
+	echo "@sysconfig@/courier-imap/pop3d.pem already exists."
 	exit 1
 fi
 
 umask 077
 
 cleanup() {
-	rm -f @mydatadir@/pop3d.pem
-	rm -f @mydatadir@/pop3d.rand
-	rm -f @mydatadir@/pop3d.key
-	rm -f @mydatadir@/pop3d.cert
+	rm -f @sysconfig@/courier-imap/pop3d.pem
+	rm -f @sysconfig@/courier-imap/pop3d.rand
+	rm -f @sysconfig@/courier-imap/pop3d.key
+	rm -f @sysconfig@/courier-imap/pop3d.cert
 	exit 1
 }
 
-cd @mydatadir@
+cd @sysconfig@/courier-imap
 
 if test "@ssllib@" = "openssl"
 then
-	cp /dev/null @mydatadir@/pop3d.pem
-	chmod 600 @mydatadir@/pop3d.pem
-	chown @mailuser@ @mydatadir@/pop3d.pem
+	cp /dev/null @sysconfig@/courier-imap/pop3d.pem
+	chmod 600 @sysconfig@/courier-imap/pop3d.pem
+	chown @mailuser@ @sysconfig@/courier-imap/pop3d.pem
 
-	dd if=@RANDOMV@ of=@mydatadir@/pop3d.rand count=1 2>/dev/null
+	dd if=@RANDOMV@ of=@sysconfig@/courier-imap/pop3d.rand count=1 2>/dev/null
 	@OPENSSL@ req -new -x509 -days 365 -nodes \
-		  -config @sysconfdir@/pop3d.cnf -out @mydatadir@/pop3d.pem -keyout @mydatadir@/pop3d.pem || cleanup
-	@OPENSSL@ gendh -rand @mydatadir@/pop3d.rand 512 >>@mydatadir@/pop3d.pem || cleanup
-	@OPENSSL@ x509 -subject -dates -fingerprint -noout -in @mydatadir@/pop3d.pem || cleanup
-	rm -f @mydatadir@/pop3d.rand
+		  -config @sysconfdir@/pop3d.cnf -out @sysconfig@/courier-imap/pop3d.pem -keyout @sysconfig@/courier-imap/pop3d.pem || cleanup
+	@OPENSSL@ gendh -rand @sysconfig@/courier-imap/pop3d.rand 512 >>@sysconfig@/courier-imap/pop3d.pem || cleanup
+	@OPENSSL@ x509 -subject -dates -fingerprint -noout -in @sysconfig@/courier-imap/pop3d.pem || cleanup
+	rm -f @sysconfig@/courier-imap/pop3d.rand
 else
-	cp /dev/null @mydatadir@/pop3d.key
-	chmod 600 @mydatadir@/pop3d.key
-	cp /dev/null @mydatadir@/pop3d.cert
-	chmod 600 @mydatadir@/pop3d.cert
+	cp /dev/null @sysconfig@/courier-imap/pop3d.key
+	chmod 600 @sysconfig@/courier-imap/pop3d.key
+	cp /dev/null @sysconfig@/courier-imap/pop3d.cert
+	chmod 600 @sysconfig@/courier-imap/pop3d.cert
 
 	@CERTTOOL@ --generate-privkey --outfile pop3d.key
 	@CERTTOOL@ --generate-self-signed --load-privkey pop3d.key --outfile pop3d.cert --template @sysconfdir@/pop3d.cnf
