Bug#596634: x11-common: /etc/X11/Xsession always appends to .xsession-errors
Julien Cristau <jcristau@debian.org> writes:
> That seems to duplicate the last 512kB rather than remove the rest?
> Perhaps your '>>' ought to be '>'?
Whoops, yes indeed. I had some debugging prints like "starting session
on $(date)" there and forgot >>.
Fixed version is attached.
>From d1df83712f29dc7ffe2203f38efdd290fbac6535 Mon Sep 17 00:00:00 2001
From: Timo Juhani Lindfors <timo.lindfors@iki.fi>
Date: Mon, 13 Sep 2010 14:25:54 +0300
Subject: [PATCH] Keep only last 512 KiB of .xsession-errors
---
debian/x11-common/etc/X11/Xsession | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/debian/x11-common/etc/X11/Xsession b/debian/x11-common/etc/X11/Xsession
index 6ad7d6e..6145389 100755
--- a/debian/x11-common/etc/X11/Xsession
+++ b/debian/x11-common/etc/X11/Xsession
@@ -74,6 +74,13 @@ else
errormsg "unable to create X session log/error file; aborting."
fi
+if ERRFILETMP=$(tempfile 2> /dev/null); then
+ # Keep only last 512 KiB of $ERRFILE
+ tail --bytes 524288 "$ERRFILE" > "$ERRFILETMP"
+ cat "$ERRFILETMP" > "$ERRFILE"
+ rm -f "$ERRFILETMP"
+fi
+
exec >>"$ERRFILE" 2>&1
echo "$PROGNAME: X session started for $LOGNAME at $(date)"
--
1.7.1
Reply to: