Re: [PATCH 1/7] os: Remove any old logfile before trying to write to it
On Tue, Jul 09, 2013 at 12:59:26PM +0100, Jon TURNEY wrote: > 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 > > > > Acked-by: Yaakov Selkowitz > > > > Reviewed-by: Yaakov Selkowitz > > > > --- > > 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 > merged, thanks. Cheers, Peter ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 1/7] os: Remove any old logfile before trying to write to it
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 > Acked-by: Yaakov Selkowitz > > Reviewed-by: Yaakov Selkowitz > > --- > 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 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 1/7] os: Remove any old logfile before trying to write to it
On 08/11/12 18:21, walter harms wrote: > Am 08.11.2012 14:41, schrieb Jon TURNEY: >> 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. >> > > what are the permissions of that file ? > normally you can not remove any file that is not worn by your. > I would print an advive to use rm /logfile if the creation failed. > > just my 2 cents > > re, > wh It's not the permissions of the file what matters, but those of the folder where it lives. If you can write in that folder, and it doesn't have the sticky bit set, you can also delete files. Extended attributes and security modules could change that, obviously. I find the commit message quite clear in what it expects and its limitations. I tried to make up a use case where the logfile was being used by a user and removing it actually made it fail because it couldn't be recreated, but then, the it's unlikely that unlink() would have worked. It would have to be a setup with multiple users on a sticky folder. ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH 1/7] os: Remove any old logfile before trying to write to it
Am 08.11.2012 14:41, schrieb Jon TURNEY: > 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. > what are the permissions of that file ? normally you can not remove any file that is not worn by your. I would print an advive to use rm /logfile if the creation failed. just my 2 cents re, wh > 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 > Acked-by: Yaakov Selkowitz > Reviewed-by: Yaakov Selkowitz > --- > 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); ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH 1/7] 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 Acked-by: Yaakov Selkowitz Reviewed-by: Yaakov Selkowitz --- 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); -- 1.7.9 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel