summaryrefslogtreecommitdiff
path: root/debian/patches/10_daemon_close_fds.dpatch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/10_daemon_close_fds.dpatch')
-rw-r--r--debian/patches/10_daemon_close_fds.dpatch47
1 files changed, 47 insertions, 0 deletions
diff --git a/debian/patches/10_daemon_close_fds.dpatch b/debian/patches/10_daemon_close_fds.dpatch
new file mode 100644
index 0000000..3da77b6
--- /dev/null
+++ b/debian/patches/10_daemon_close_fds.dpatch
@@ -0,0 +1,47 @@
+#! /bin/sh -e
+## 10_daemon_close_fds.dpatch by Steve Haslam <araqnid@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Close FDs 0-254 when going into background
+
+if [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch -f --no-backup-if-mismatch --dry-run -p0 < $0 && patch -f --no-backup-if-mismatch -p0 < $0;;
+ -unpatch) patch -f --no-backup-if-mismatch -R -p0 < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1;;
+esac
+exit 0
+
+@DPATCH@
+--- ../old/src/daemon.c 2002-12-18 10:28:01.000000000 +0000
++++ src/daemon.c 2003-01-19 06:24:18.000000000 +0000
+@@ -42,6 +42,13 @@
+ static smtp_slot *smtp_slots;
+
+
++static void close_fds(void)
++{
++ int fd;
++ for (fd = 0; fd < 255; fd++) {
++ close(fd);
++ }
++}
+
+ /*************************************************
+ * SIGALRM Handler *
+@@ -662,9 +669,7 @@
+ {
+ log_close_all(); /* Just in case anything was logged earlier */
+ search_tidyup(); /* Just in case any were used in reading the config. */
+- close(0); /* Get rid of stdin/stdout/stderr */
+- close(1);
+- close(2);
++ close_fds();
+ log_stderr = NULL; /* So no attempt to copy paniclog output */
+
+ /* If the parent process of this one has pid == 1, we are re-initializing the