summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2012-11-08 13:41:13 +0000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-07-11 07:39:03 +1000
commit59a6d3f1eb03010ab831b32b03706a1d6143c732 (patch)
tree1cb63ec25a26448c71c7e7b4d3cd18594ef2cf0b /os
parent8eeaa74bc241acb41f1d3ed64971e0b01e794776 (diff)
os: Remove any old logfile before trying to write to it
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 change is useful when: - The DDX doesn't use the logfile backup mechanism (i.e. not Xorg) - The DDX is run by a non-root user, and then by a different non-root user - The logfile directory doesn't have the restricted-deletion flag set Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Acked-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> Reviewed-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'os')
-rw-r--r--os/log.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/os/log.c b/os/log.c
index f19faf5ee..53b358629 100644
--- a/os/log.c
+++ b/os/log.c
@@ -216,6 +216,9 @@ 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);
setvbuf(logFile, NULL, _IONBF, 0);