[Reproducible-commits] [dpkg] 13/25: libdpkg: Set close-on-exec for the debug output
Holger Levsen
holger at layer-acht.org
Tue May 3 08:43:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to annotated tag 1.16.16
in repository dpkg.
commit 380cc715cf0ae083225b0bc545cd753ffc2a953b
Author: Guillem Jover <guillem at debian.org>
Date: Wed Aug 13 09:34:41 2014 +0200
libdpkg: Set close-on-exec for the debug output
Cherry picked from commit d3d2ba1dd39ae02c92efafd4d4541d33665e48fb.
This fixes a file descriptor leak on dselect subprocesses.
---
debian/changelog | 1 +
dselect/main.cc | 2 +-
lib/dpkg/debug.c | 6 +++++-
lib/dpkg/debug.h | 2 +-
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 3416d43..62487a4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,7 @@ dpkg (1.16.15+nmu1) UNRELEASED; urgency=low
* Fix file triggers/Unincorp descriptor leak on subprocesses. Regression
introduced with the initial triggers implementation in dpkg 1.14.17.
Closes: #751021
+ * Fix a descriptor leak on dselect subprocesses when --debug is used.
[ Updated scripts translations ]
* Fix typos in German (Helge Kreutzmann)
diff --git a/dselect/main.cc b/dselect/main.cc
index c0f2195..2a23442 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -231,7 +231,7 @@ extern "C" {
ohshite(_("couldn't open debug file `%.255s'\n"), v);
setvbuf(fp, 0, _IONBF, 0);
- debug_set_output(fp);
+ debug_set_output(fp, v);
debug_set_mask(dbg_general | dbg_depcon);
}
diff --git a/lib/dpkg/debug.c b/lib/dpkg/debug.c
index 7ff12b3..64af3c9 100644
--- a/lib/dpkg/debug.c
+++ b/lib/dpkg/debug.c
@@ -25,6 +25,7 @@
#include <stdarg.h>
#include <stdio.h>
+#include <dpkg/dpkg.h>
#include <dpkg/debug.h>
static int debug_mask = 0;
@@ -32,10 +33,13 @@ static FILE *debug_output = NULL;
/**
* Set the debugging output file.
+ *
+ * Marks the file descriptor as close-on-exec.
*/
void
-debug_set_output(FILE *output)
+debug_set_output(FILE *output, const char *filename)
{
+ setcloexec(fileno(output), filename);
debug_output = output;
}
diff --git a/lib/dpkg/debug.h b/lib/dpkg/debug.h
index c49f2a7..f44b620 100644
--- a/lib/dpkg/debug.h
+++ b/lib/dpkg/debug.h
@@ -54,7 +54,7 @@ enum debugflags {
dbg_triggersstupid = 040000,
};
-void debug_set_output(FILE *output);
+void debug_set_output(FILE *output, const char *filename);
void debug_set_mask(int mask);
bool debug_has_flag(int flag);
void debug(int flag, const char *fmt, ...) DPKG_ATTR_PRINTF(2);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list