You are not logged in.

#1 2021-12-22 22:28:15

drlkf00
Member
Registered: 2013-05-04
Posts: 10

[Solved] redshift can't read Xauthority when X is running in systemd

So, I switched my whole Xorg setup to systemd user units and I managed to make everything work except for one thing: redshift refuses to start. Now first I want to mention that redshift was already in a systemd unit before these modifications, and I tried running redshift from the terminal as well and the same thing happens, so there must be something related to Xorg running inside systemd there, but I cannot figure out what.

So the first error that comes is that redshift cannot find a way to connect to the graphical server.

Could not connect to wayland display, exiting.
Failed to start adjustment method wayland.
Trying next method...
No protocol specified
`RANDR Query Version' returned error -1
Initialization of randr failed.
Trying next method...
No protocol specified
X request failed: XOpenDisplay
Initialization of vidmode failed.
Trying next method...
No more methods to try.

Connecting to Wayland, obviously that makes sense, I'm not using Wayland. Now Randr, that one should definitely work, and vidmode seems related to Xorg so I assume it should work as well. Running it with the dummy method (-m dummy) works, so no configuration issue there (I don't have a configuration file anyway). So I went on to investigate Randr, and running strace indeed shows that something in the realm of complete mystery is happening:

access("/home/drlkf/.local/share/Xauthority", R_OK) = 0
openat(AT_FDCWD, "/home/drlkf/.local/share/Xauthority", O_RDONLY) = -1 EACCES (Permission denied)

What ? access returns ok for read access but redshift does not manage to open the file. So I went and made a wrapper script that contains the following:

#!/bin/bash

>/dev/null cat "$XAUTHORITY" && echo yay!
exec redshift -l 48.8:2.3 -t 7500:4000 -m randr

and sure enough the wrapper script can read the file but not redshift:

Dec 22 22:34:47 t450s systemd[1072176]: Started Color temperature modifier.
Dec 22 22:34:47 t450s fake-redshift[1289173]: yay!
Dec 22 22:34:47 t450s fake-redshift[1289173]: No protocol specified
Dec 22 22:34:47 t450s fake-redshift[1289173]: `RANDR Query Version' returned error -1
Dec 22 22:34:47 t450s fake-redshift[1289173]: Initialization of randr failed.
Dec 22 22:34:47 t450s systemd[1072176]: redshift.service: Main process exited, code=exited, status=1/FAILURE
Dec 22 22:34:47 t450s systemd[1072176]: redshift.service: Failed with result 'exit-code'.

I tried to make the full path readable to everyone, setting XAUTHORITY to /tmp/Xauthority with mode 777, even running redshift as root, still nothing works.

I found some posts on the internet about XAUTHLOCALHOSTNAME, I tried setting it to localhost, t450s (my hostname) and unsetting it, same outcome.

At this point I'm at my wits' end, I have no idea what is going on. Having access return ok and open fail right after makes 0 sense to me. I'm considering just leaving it as is and stop using redshift altogether. Maybe
someone here has seen this before ?

Last edited by drlkf00 (2021-12-22 22:52:30)

Offline

#2 2021-12-22 22:39:56

seth
Member
Registered: 2012-09-03
Posts: 57,660

Re: [Solved] redshift can't read Xauthority when X is running in systemd

type redshift
stat /usr/bin/redshift

suid'?

Offline

#3 2021-12-22 22:53:39

drlkf00
Member
Registered: 2013-05-04
Posts: 10

Re: [Solved] redshift can't read Xauthority when X is running in systemd

I figured it out, apparmor had a whitelist for the redshift binary to authorize reading of specific files.

Offline

Board footer

Powered by FluxBB