diff -uNr dovecot-1.0.5/debian/dovecot-imapd.postinst dovecot-1.0.5.update_default/debian/dovecot-imapd.postinst
--- dovecot-1.0.5/debian/dovecot-imapd.postinst	2007-10-18 17:12:11.000000000 -0400
+++ dovecot-1.0.5.update_default/debian/dovecot-imapd.postinst	2007-10-18 17:11:31.000000000 -0400
@@ -2,15 +2,17 @@
 
 set -e
 
-#perl -pi.bak -e 'if (/^\s*protocols =/i) { s/$/ imap imaps/ unless /imap/; };'\
-#   /etc/dovecot/dovecot.conf
-
+if [ "$1" = "configure" -a -z "$2" ]; then
+	# Add the imap and imaps options to the protocols line on first install
+	perl -pi.bak -e 'if (/^\s*protocols =/i) { s/none//; s/$/ imap imaps/ unless /imap/; s/[ \t]+/ /g; };'\
+   /etc/dovecot/dovecot.conf
+fi
 
 if [ -x "/etc/init.d/dovecot" ]; then
 	if [ -x /usr/sbin/invoke-rc.d ]; then
-		invoke-rc.d dovecot start
+		invoke-rc.d dovecot restart
 	else
-		/etc/init.d/dovecot start
+		/etc/init.d/dovecot restart
 	fi
 fi
 
diff -uNr dovecot-1.0.5/debian/dovecot-imapd.postrm dovecot-1.0.5.update_default/debian/dovecot-imapd.postrm
--- dovecot-1.0.5/debian/dovecot-imapd.postrm	1969-12-31 19:00:00.000000000 -0500
+++ dovecot-1.0.5.update_default/debian/dovecot-imapd.postrm	2007-10-18 17:11:31.000000000 -0400
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -e
+
+
+if [ "$1" = "remove" ]; then
+	# Remove the imaps and imap option from the protocols line
+	perl -pi.bak -e 'if (/^\s*protocols =/i) { s/imaps//; s/imap//; s/$/ none/ unless (/pop3/ or /none/); s/[ \t]+/ /g; };'\
+   /etc/dovecot/dovecot.conf
+fi
+
+# Restart dovecot because we've updated the configuration file.
+if [ -x "/etc/init.d/dovecot" ]; then
+	if [ -x /usr/sbin/invoke-rc.d ] ; then
+		invoke-rc.d dovecot start
+	else
+		/etc/init.d/dovecot start
+	fi
+fi
+
+#DEBHELPER#
diff -uNr dovecot-1.0.5/debian/dovecot-pop3d.postinst dovecot-1.0.5.update_default/debian/dovecot-pop3d.postinst
--- dovecot-1.0.5/debian/dovecot-pop3d.postinst	2007-10-18 17:12:11.000000000 -0400
+++ dovecot-1.0.5.update_default/debian/dovecot-pop3d.postinst	2007-10-18 17:11:31.000000000 -0400
@@ -2,13 +2,17 @@
 
 set -e
 
-#perl -pi.bak -e 'if (/^\s*protocols =/i) { s/$/ pop3 pop3s/ unless /pop3/; };'\
-#   /etc/dovecot/dovecot.conf
+if [ "$1" = "configure" -a -z "$2" ]; then
+	# Add the pop3 and pop3s options to the protocols line.
+	perl -pi.bak -e 'if (/^\s*protocols =/i) { s/none//; s/$/ pop3 pop3s/ unless /pop3/;  s/[ \t]+/ /g; };'\
+	/etc/dovecot/dovecot.conf
+fi
+
 if [ -x "/etc/init.d/dovecot" ]; then
 	if [ -x /usr/sbin/invoke-rc.d ]; then
-		invoke-rc.d dovecot start
+		invoke-rc.d dovecot restart
 	else
-		/etc/init.d/dovecot start
+		/etc/init.d/dovecot restart
 	fi
 fi
 
diff -uNr dovecot-1.0.5/debian/dovecot-pop3d.postrm dovecot-1.0.5.update_default/debian/dovecot-pop3d.postrm
--- dovecot-1.0.5/debian/dovecot-pop3d.postrm	1969-12-31 19:00:00.000000000 -0500
+++ dovecot-1.0.5.update_default/debian/dovecot-pop3d.postrm	2007-10-18 17:11:31.000000000 -0400
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -e
+
+
+if [ "$1" = "remove" ]; then
+	# Remove the imaps and imap option from the protocols line
+	perl -pi.bak -e 'if (/^\s*protocols =/i) { s/pop3s//; s/pop3//; s/$/ none/ unless (/imap/ or /none/); s/[ \t]+/ /g; };'\
+   /etc/dovecot/dovecot.conf
+fi
+
+# Restart dovecot because we've updated the configuration file.
+if [ -x "/etc/init.d/dovecot" ]; then
+	if [ -x /usr/sbin/invoke-rc.d ] ; then
+		invoke-rc.d dovecot start
+	else
+		/etc/init.d/dovecot start
+	fi
+fi
+
+#DEBHELPER#
diff -uNr dovecot-1.0.5/debian/patches/00list dovecot-1.0.5.update_default/debian/patches/00list
--- dovecot-1.0.5/debian/patches/00list	2007-10-18 17:12:11.000000000 -0400
+++ dovecot-1.0.5.update_default/debian/patches/00list	2007-10-18 17:11:42.000000000 -0400
@@ -4,3 +4,5 @@
 postgres_configure
 quota_mountpoint
 quota_v2
+exec_check_for_none
+protocols_none_by_default
diff -uNr dovecot-1.0.5/debian/patches/exec_check_for_none.dpatch dovecot-1.0.5.update_default/debian/patches/exec_check_for_none.dpatch
--- dovecot-1.0.5/debian/patches/exec_check_for_none.dpatch	1969-12-31 19:00:00.000000000 -0500
+++ dovecot-1.0.5.update_default/debian/patches/exec_check_for_none.dpatch	2007-10-18 17:11:31.000000000 -0400
@@ -0,0 +1,28 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## debug_protocols.dpatch by  <soren@ubuntu.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Inhibit access(.., X_OK) check for disabled protocols.
+
+@DPATCH@
+diff -urNad dovecot-1.0.3~/src/master/master-settings.c dovecot-1.0.3/src/master/master-settings.c
+--- dovecot-1.0.3~/src/master/master-settings.c	2007-10-08 11:53:00.767163713 +0200
++++ dovecot-1.0.3/src/master/master-settings.c	2007-10-08 11:53:16.187360629 +0200
+@@ -637,7 +637,7 @@
+ 		return FALSE;
+ 	}
+ 
+-	if (access(t_strcut(set->mail_executable, ' '), X_OK) < 0) {
++	if (strcmp(set->protocols, "none") && access(t_strcut(set->mail_executable, ' '), X_OK) < 0) {
+ 		i_error("Can't use mail executable %s: %m",
+ 			t_strcut(set->mail_executable, ' '));
+ 		return FALSE;
+@@ -714,7 +714,7 @@
+ 		return FALSE;
+ 	}
+ 
+-	if (access(t_strcut(set->login_executable, ' '), X_OK) < 0) {
++	if (strcmp(set->protocols, "none") && access(t_strcut(set->login_executable, ' '), X_OK) < 0) {
+ 		i_error("Can't use login executable %s: %m",
+ 			t_strcut(set->login_executable, ' '));
+ 		return FALSE;
diff -uNr dovecot-1.0.5/debian/patches/protocols_none_by_default.dpatch dovecot-1.0.5.update_default/debian/patches/protocols_none_by_default.dpatch
--- dovecot-1.0.5/debian/patches/protocols_none_by_default.dpatch	1969-12-31 19:00:00.000000000 -0500
+++ dovecot-1.0.5.update_default/debian/patches/protocols_none_by_default.dpatch	2007-10-18 17:11:31.000000000 -0400
@@ -0,0 +1,19 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## no_protocols_by_default.dpatch by  <soren@ubuntu.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Set protocols to "none" by default
+
+@DPATCH@
+diff -urNad dovecot-1.0.5~/dovecot-example.conf dovecot-1.0.5/dovecot-example.conf
+--- dovecot-1.0.5~/dovecot-example.conf	2007-10-08 13:38:23.111439900 +0200
++++ dovecot-1.0.5/dovecot-example.conf	2007-10-08 13:38:41.479672553 +0200
+@@ -21,7 +21,7 @@
+ # Protocols we want to be serving: imap imaps pop3 pop3s
+ # If you only want to use dovecot-auth, you can set this to "none".
+ #protocols = imap imaps
+-protocols =
++protocols = none
+ 
+ # IP or host address where to listen in for connections. It's not currently
+ # possible to specify multiple addresses. "*" listens in all IPv4 interfaces.
