[PATCH] Remove any old logfile before trying to write to it

Jon TURNEY jon.turney at dronecode.org.uk
Tue Jan 11 09:18:24 PST 2011


If we are not backing up logfiles, remove the old logfile before
trying to write a new logfile, as otherwise the operation may fail
if the previous logfile was created by a different user.

This looks like a generic problem, but will only be seen with DDX
which don't use the logfile backup mechanism (unlike the Xfree86 DDX)
and can be run as different non-root users.

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
Acked-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
---
 os/log.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/os/log.c b/os/log.c
index 65195ba..741fb3f 100644
--- a/os/log.c
+++ b/os/log.c
@@ -197,6 +197,8 @@ LogInit(const char *fname, const char *backup)
 		}
 		free(oldLog);
 	    }
+	} else {
+	    unlink(logFileName);
 	}
 	if ((logFile = fopen(logFileName, "w")) == NULL)
 	    FatalError("Cannot open log file \"%s\"\n", logFileName);
-- 
1.7.3.3



More information about the xorg-devel mailing list