Subject: Collected Debian patches for postsrsd
Author: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>

The postsrsd package is maintained in Git rather than maintaining
patches as separate files, and separating the patches isn't worth
the effort.  They are therefore all included in this single Debian
patch.

For full commit history and separated commits, see the packaging Git
repository. The location of the repository can be found in the Vcs-Git
field in debian/control.
--- postsrsd-1.2.orig/init/postsrsd.apparmor.in
+++ postsrsd-1.2/init/postsrsd.apparmor.in
@@ -7,6 +7,6 @@
   capability setuid,
   capability sys_chroot,
   /etc/postsrsd.secret r,
-  @CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ mr,
+  @CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ r,
 }
 
--- postsrsd-1.2.orig/init/postsrsd.systemd.in
+++ postsrsd-1.2/init/postsrsd.systemd.in
@@ -4,12 +4,11 @@ After=network.target
 
 [Service]
 Type=simple
-Environment SRS_DOMAIN=localhost.localdomain
-Environment SRS_EXCLUDE_DOMAINS=
-EnvironmentFile=@CONFIG_DIR@/@PROJECT_NAME@
+Environment=SRS_DOMAIN=localhost.localdomain SRS_FORWARD_PORT=10001 SRS_REVERSE_PORT=10002 SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
+Environment=SRS_EXCLUDE_DOMAINS= RUN_AS=nobody CHROOT=@CHROOT_DIR@
+EnvironmentFile=-@CONFIG_DIR@/@PROJECT_NAME@
 ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ -f${SRS_FORWARD_PORT} -r${SRS_REVERSE_PORT} -d${SRS_DOMAIN} -s${SRS_SECRET} -u${RUN_AS} -c${CHROOT} -X${SRS_EXCLUDE_DOMAINS}
 Restart=always
 
 [Install]
 WantedBy=multi-user.target
-
--- postsrsd-1.2.orig/init/postsrsd.sysv-lsb.in
+++ postsrsd-1.2/init/postsrsd.sysv-lsb.in
@@ -5,11 +5,12 @@
 #
 ### BEGIN INIT INFO
 # Provides:          @PROJECT_NAME@
-# Required-Start:    $syslog $network $local_fs
-# Required-Stop:     $syslog $network $local_fs
+# Required-Start:    $syslog $network $remote_fs
+# Required-Stop:     $syslog $network $remote_fs
 # Default-Start:     2 3 4 5
 # Default-Stop:      0 1 6
 # Short-Description: Start/stop the @PROJECT_NAME@ daemon
+# Description:       postsrsd offers Sender Rewriting Scheme support for Postfix
 ### END INIT INFO
 
 set -e
@@ -29,10 +30,17 @@ test -x $DAEMON || exit 0
 
 # Default configuration
 SRS_DOMAIN=`postconf -h mydomain || true`
-SRS_EXCLUDE_DOMAINS=
-
-# Read config file
-. @CONFIG_DIR@/$NAME
+SRS_FORWARD_PORT=10001
+SRS_REVERSE_PORT=10002
+SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
+RUN_AS=nobody
+CHROOT=@CHROOT_DIR@
+
+# Read config file if it is present.
+if [ -r @CONFIG_DIR@/$NAME ]
+then
+    . @CONFIG_DIR@/$NAME
+fi
 
 test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
 
--- postsrsd-1.2.orig/init/postsrsd.sysv-redhat.in
+++ postsrsd-1.2/init/postsrsd.sysv-redhat.in
@@ -25,10 +25,17 @@ test -x $DAEMON || exit 0
 
 # Default configuration
 SRS_DOMAIN=`postconf -h mydomain || true`
-SRS_EXCLUDE_DOMAINS=
+SRS_FORWARD_PORT=10001
+SRS_REVERSE_PORT=10002
+SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
+RUN_AS=nobody
+CHROOT=@CHROOT_DIR@
 
-# Read config file
-. @CONFIG_DIR@/$NAME
+# Read config file if it is present.
+if [ -r @CONFIG_DIR@/$NAME ]
+then
+    . @CONFIG_DIR@/$NAME
+fi
 
 test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
 
--- postsrsd-1.2.orig/init/postsrsd.upstart.in
+++ postsrsd-1.2/init/postsrsd.upstart.in
@@ -5,10 +5,19 @@ start on (filesystem and net-device-up)
 stop on runlevel [!2345]
 respawn
 
+env DEFAULTFILE=@CONFIG_DIR@/@PROJECT_NAME@
+
 script
 	SRS_DOMAIN=`postconf -h mydomain || true`
+	SRS_FORWARD_PORT=10001
+	SRS_REVERSE_PORT=10002
+	SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
 	SRS_EXCLUDE_DOMAINS=
-	. "@CONFIG_DIR@/@PROJECT_NAME@"
+	RUN_AS=nobody
+	CHROOT=@CHROOT_DIR@
+	if [ -r "$DEFAULTFILE" ]; then
+		. "$DEFAULTFILE"
+	fi
 	exec @CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" -u"$RUN_AS" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS"
 end script
 
