Xauthority file getting deleted while system is running

I’m having the exact same issue here and can’t find the cause.

Edit1:

I looked into systemd-tmpfiles-clean.service and suspect the tmp.conf configuration file to be the culprit. It also maches your observation of 10 days. As this file is owned by systemd, I wonder how other distributions are overriding the value or avoid the issue altogether.

> rg /tmp /usr/lib/tmpfiles.d/
/usr/lib/tmpfiles.d/systemd-pstore.conf
28:#  systemd-tmpfiles --create path/to/tmpfiles.d/systemd-pstore.conf

/usr/lib/tmpfiles.d/x11.conf
12:D! /tmp/.X11-unix 1777 root root 10d
13:D! /tmp/.ICE-unix 1777 root root 10d
14:D! /tmp/.XIM-unix 1777 root root 10d
15:D! /tmp/.font-unix 1777 root root 10d
18:r! /tmp/.X[0-9]*-lock

/usr/lib/tmpfiles.d/sddm.conf
6:r!    /tmp/sddm-auth*
8:r!    /tmp/xauth_*

/usr/lib/tmpfiles.d/systemd-tmp.conf
11:x /tmp/systemd-private-%b-*
12:X /tmp/systemd-private-%b-*/tmp
13:x /var/tmp/systemd-private-%b-*
14:X /var/tmp/systemd-private-%b-*/tmp
17:R! /tmp/systemd-private-*
18:R! /var/tmp/systemd-private-*

/usr/lib/tmpfiles.d/flatpak.conf
2:R! /var/tmp/flatpak-cache-*

/usr/lib/tmpfiles.d/tmp.conf
11:q /tmp 1777 root root 10d
12:q /var/tmp 1777 root root 30d

/usr/lib/tmpfiles.d/ostree-tmpfiles.conf
19:R! /var/tmp/ostree-unlock-ovl.*
> pacman -Qo /usr/lib/tmpfiles.d/tmp.conf
/usr/lib/tmpfiles.d/tmp.conf is owned by systemd 254.7-1

Looking forward to suggestions

Edit2:
This has been handled upstream but not released yet:

  @@ -6,3 +6,9 @@ d	${RUNTIME_DIR}	0711	root	root
  r!	/tmp/sddm-auth*
  # xauth files passed to user sessions
  r!	/tmp/xauth_*
+ # "r!" above means to remove the files if existent (r), but only at boot (!).
+ # tmpfiles.d/tmp.conf declares a periodic cleanup of old /tmp/ files, which
+ # would ordinarily result in the deletion of our xauth files. To prevent that
+ # from happening, explicitly tag these as X (ignore).
+ X	/tmp/sddm-auth*
+ X	/tmp/xauth_*

@lewax00:
Transitionally I created a file /etc/tmpfiles.d/tmp-xauth.conf with the following contents

X	/tmp/sddm-auth*
X	/tmp/xauth_*

Please let me know if it works for you

5 Likes