From a58da042f5492ed0260b77f82cf40235f9e5e035 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 27 Apr 2007 22:38:03 +0000 Subject: [PATCH] Allow trace output files (-tf option) to be overwritten, rather than crashing dhcpd if the file already exists [rt16459] --- RELNOTES | 3 +++ omapip/trace.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RELNOTES b/RELNOTES index 65ca83489..25000f802 100644 --- a/RELNOTES +++ b/RELNOTES @@ -27,6 +27,9 @@ the README file. Changes since 3.1.0b1 +- Allow trace output files (-tf option) to be overwritten, rather than + crashing dhcpd if the file already exists + - A bug was fixed that caused dhcpd to segfault if a pool was declared outside the scope of a subnet in dhcpd.conf. diff --git a/omapip/trace.c b/omapip/trace.c index 8d3ce6234..995789180 100644 --- a/omapip/trace.c +++ b/omapip/trace.c @@ -34,7 +34,7 @@ #ifndef lint static char ocopyright[] = -"$Id: trace.c,v 1.12 2006/02/24 23:16:30 dhankins Exp $ Copyright 2004-2006 Internet Systems Consortium."; +"$Id: trace.c,v 1.13 2007/04/27 22:38:03 each Exp $ Copyright 2004-2006 Internet Systems Consortium."; #endif #include @@ -57,6 +57,8 @@ trace_type_t trace_time_marker; extern omapi_array_t *trace_listeners; extern omapi_array_t *omapi_connections; +extern int errno; + void trace_free_all () { trace_type_t *tp; @@ -142,6 +144,11 @@ isc_result_t trace_begin (const char *filename, } traceoutfile = open (filename, O_CREAT | O_WRONLY | O_EXCL, 0600); + if (traceoutfile < 0 && errno == EEXIST) { + log_error ("WARNING: Overwriting trace file \"%s\"", filename); + traceoutfile = open (filename, O_WRONLY | O_EXCL, 0600); + } + if (traceoutfile < 0) { log_error ("%s(%d): trace_begin: %s: %m", file, line, filename); -- 2.39.5