]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Allow trace output files (-tf option) to be overwritten, rather than
authorEvan Hunt <each@isc.org>
Fri, 27 Apr 2007 22:38:03 +0000 (22:38 +0000)
committerEvan Hunt <each@isc.org>
Fri, 27 Apr 2007 22:38:03 +0000 (22:38 +0000)
crashing dhcpd if the file already exists [rt16459]

RELNOTES
omapip/trace.c

index 65ca834890686cf7ea3f06f8a16717cf0a549836..25000f802f90f6ffdb65afabcff320b370a59455 100644 (file)
--- 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.
 
index 8d3ce62349892b9db9f5ff19bf09159d023e94e8..9957891806b84824ad3575c5699564d340e80a87 100644 (file)
@@ -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 <omapip/omapip_p.h>
@@ -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);