[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

runaway .xsession-errors vs. temp races: a compromise?

I noticed that my ~/.xsession-errors file had grown to over a
megabyte, even though I'd restarted X earlier today.  Checking the
changelog, I found this:

 "* Modify Xsession to always append to the error file, closing a temporary
    file race condition window if it has to fall back to using tempfile(1) to
    create an X session error file.  Because it always appends now, log the
    fact that the session has started, the username, and the date to the X
    session error file once it is successfully opened.  Document this change
    in behavior in Xsession(5)."

Ok, that makes perfect sense if the error file is created by
tempfile(1), and lives in /tmp.  But by default, it's not and it
doesn't.  And people are used to the error file getting truncated.
The new always-append behavior is going to surprise a lot of people,
and upset a few.  So, I'd like to toss out the suggestion that we go
back to truncating the file in the default case (not in /tmp).

I even made a patch for your consideration.  (It can be modified to
use "echo -n > $ERRFILE" or "cat /dev/null > $ERRFILE" if my idiom of
": > $ERRFILE" seems too obscure.)  I don't have a patch for
Xsession(5), but I could probably be persuaded to come up with one if

*** Xsession.orig	2004-07-06 00:58:17.000000000 -0700
--- Xsession	2004-07-06 01:02:03.000000000 -0700
*** 81,86 ****
--- 81,88 ----
  if touch "$ERRFILE" 2> /dev/null && [ -w "$ERRFILE" ] &&
    [ ! -L "$ERRFILE" ]; then
    chmod 600 "$ERRFILE"
+   # we can safely truncate a regular file in the user's home dir
+   [ -f $ERRFILE ] && : > $ERRFILE
  elif ERRFILE=$(tempfile 2> /dev/null); then
    if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
      message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \

Chris Waters           |  Pneumonoultra-        osis is too long
xtifr@debian.org       |  microscopicsilico-    to fit into a single
or xtifr@speakeasy.net |  volcaniconi-          standalone haiku

Reply to: