Is it possible to change the location for .Xauthority
, to something other than $HOME/.Xauthority
? AFAIU, this file is being created every time I log into LXDE
, by my login manager slim
.
The problem I am having is following:
I want to set my home to "immutable" using extended attributes:
chattr +i /home/martin/
This way, no applications can save their files directly in /home/martin/
, but they can still save files in directories located lower levels of my home, i.e. /home/martin/.config/
.
At the moment, when I set my home to immutable, I cannot login to LXDE
because the login manager (slim
) cannot create /home/martin/.Xauthority
. This happens even if the old .Xauthority
exists. The login manager could just overwrite the old file with new data, but apparently this is not what it does. It creates a new file and deletes the old one. This is not allowed when /home/martin is immutable (overwriting existing file would be allowed).
Therefore, I would like to store .Xauthority
somewhere else, such as .config/.Xauthority
. Is this possible?
I know that xauth
takes the parameter -f
where file path can be specified.
UPDATE:
looking at the source code of slim, I think I might have found the place where .Xauthority
is being deleted and created again:
string xauthority = pw->pw_dir;
xauthority.append("/.Xauthority");
...
/* reinitialize auth file */
authfile = cfg->getOption("authfile");
remove(authfile.c_str());
putenv(StrConcat("XAUTHORITY=", authfile.c_str()));
Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"),
authfile);
How could I change the source code, so that file gets overwritten, rather than deleted/created ?
Best Answer
The location of the X cookie file can be configured with the
XAUTHORITY
environment variable. The default is~/.Xauthority
.Of course, the location that you pass to applications has to match the location where the cookie is stored. SLiM doesn't offer a way to add the cookie to a different file: it has
~/.Xauthority
hard-coded. If you want to use a different file, patch SLiM or use a display manager that happens to have this configuration option. For example, Gdm stores X cookies under/var/run/gdm
.I think you can make
.Xauthority
a symbolic link, if you don't want the modifiable file to be in your home directory.Making your home directory immutable is an exercise in futility. You're likely to encounter many other similar issues. The standard place for configuration files and state files is your home directory — that's where dot files get their name, because they start with a
.
so thatls
won't list them by default.