#596634 x11-common: /etc/X11/Xsession always appends to .xsession-errors

#596634#5
Date:
2010-09-12 23:41:49 UTC
From:
To:
Is there any reason why /etc/X11/Xsession appends to the logfile
instead of creating it:

exec >>"$ERRFILE" 2>&1

If the argument is that you want to be able to see what errors
happened in the last session, so you don't want to clear them out
before the user gets to review them, they can always log into the
console and review the errors before they restart X.

Meanwhile, the non-priveleged user has no opportunity to make sure
their .xsession-errors file is emptied when their session starts,
because if they empty it unconditionally in their own ~/.xsession
file, then they'll lose any error message output before ~/.xsession
executes.

This is particularly insidious when the disk is full because something
was writing lots of crap to ~/.xsession-errors.  That crap is not
cleared out when the user's session restarts, and so that user can't
log in because their Xauthority file can't be modified, should they
opt for Xauthority to be created in their home directory (or their
desktop manager will get stuck when it tries to read-write-modify
its dotfiles).

All of this talk for the past 5 years that maybe we should have a
mechanism for limiting the size of logfiles is just skirting around
the issue.  The logfile never shrinks if it is never truncated at X
startup!  Fix that one line, and the whole issue goes away!  Disk full
because of too much crap emitted to ~/.xsession-errors?  Well, just
let the unsophisticated user log out and log back in again.

#596634#10
Date:
2010-09-13 04:24:05 UTC
From:
To:
[I'm not a maintainer, just happened be following X bugs...]

Tim Connors <reportbug@rather.puzzling.org> writes:

Always might be too strong word. On my PDA I don't have a physical
keyboard, the only way to read .xsession-errors is via X or by
connecting a laptop. And on my laptop switching virtual consoles
sometimes fails if I have used suspend...

I think this is the real problem and applications should be fixed to
limit their error output.

How about a compromise? Could we truncate all but the last 1000 lines
in /etc/X11/Xsession?

#596634#15
Date:
2010-09-13 07:48:26 UTC
From:
To:
Yep.  But sometimes wmbattery goes haywire trying to connect to HAL, or a
homegrown app might output too much.  In the absense of a library to do
this (and I *really* hate it when gnome by default limits output and just
discards the rest - its limit is arbitrarily small, and I have no way of
retrieving that lost information after a certain point in a desktop
session once it starts discarding data.  Fortunately, I do not use gnome
often).

Sure.  Or perhaps 1000*80 characters (never encountered super long lines
as output to .xsession-errors, but could happen).

#596634#24
Date:
2010-09-13 11:28:37 UTC
From:
To:
package x11-common
tag 596634 patch
thanks

Tim Connors <reportbug@rather.puzzling.org> writes:

Can you locate where this limit is in gnome? Is it a per-app limit or
global to all gnome applications?

Good point. I recall seeing binaries in ~/.xsession-errors.

The attached patch keeps only the last 512 KiB of ~/.xsession-errors
on login. Can you test if this works for you?

#596634#29
Date:
2010-09-13 13:05:01 UTC
From:
To:
It used to be in gdm, was removed in 2.20.11-2.

That seems to duplicate the last 512kB rather than remove the rest?
Perhaps your '>>' ought to be '>'?

Cheers,
Julien

#596634#34
Date:
2010-09-13 13:57:03 UTC
From:
To:
Julien Cristau <jcristau@debian.org> writes:

Whoops, yes indeed. I had some debugging prints like "starting session
on $(date)" there and forgot >>.

Fixed version is attached.

#596634#39
Date:
2010-10-02 11:56:47 UTC
From:
To:
Seems to work thanks.