[PATCH 1/7] os: Remove any old logfile before trying to write to it

Jon TURNEY jon.turney at dronecode.org.uk
Tue Jul 9 04:59:26 PDT 2013


On 08/11/2012 13:41, Jon TURNEY wrote:
> 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-GrJqePx9RPPAJUdA+FbntA at public.gmane.org>
> Acked-by: Yaakov Selkowitz <yselkowitz-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f at public.gmane.org>
> Reviewed-by: Yaakov Selkowitz <yselkowitz-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f at public.gmane.org>
> ---
>  os/log.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/os/log.c b/os/log.c
> index 4820e9a..15271eb 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);
> 

Ping?

Patch still applies to master


More information about the xorg-devel mailing list