jonls / redshift

Redshift adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night.
http://jonls.dk/redshift
GNU General Public License v3.0
5.92k stars 429 forks source link

redshift.conf is not read if it is a symlink #858

Closed andornaut closed 2 years ago

andornaut commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. ln -s $PATH_TO_REDSHIFT_CONFIG ~/.config/redshift.conf
  2. Start redshift redshift -v

Expected The settings in the configuration ~/.config/redshift.conf are used. Actual The configuration file is ignored.

Context I use a dotfile manager named "gog" to save redshift.conf to ~/.local/share/gog/.../redshift.conf, which is then symlinked to ~/.config/redshift.conf. This used to work, but upon upgrading redshift recently this no longer works as expected. I was using the version of redshift distributed with Ubuntu 20.04, and am now using the version distributed with 21.10: 1.12-4.2ubuntu1.

Example where the configuration file is ignored.

$ ls -l ~/.config/redshift.conf
lrwxrwxrwx 1 andornaut andornaut 70 Dec 28 10:00 redshift.conf -> '/home/andornaut/.local/share/gog/andornaut/$HOME/.config/redshift.conf'
...

$ redshift -v
Trying location provider `geoclue2'...

I use the manual location provider, not geoclue2. This symlink scenario does not work.

On the otherhand, the configuration file is used when the configuration file is not a symlink:

$ ls -l ~/.config/redshift.conf
-rw-rw-r-- 1 andornaut andornaut 294 Dec 28 09:55 /home/andornaut/.config/redshift.conf

$ redshift -v
Solar elevations: day above 3.0, night below -6.0

The no-symlink scenario above works as expected.

Additionally, using the -c flag doesn't appear to work at all:

$ chmod 644 redshift.conf
$ ls -l redshift.conf
-rw-r--r-- 1 andornaut andornaut 312 Dec 28 10:15 redshift.conf

$ redshift -c redshift.conf
fopen: Permission denied
Unable to load config file.

Software versions (please complete the following information):

mkapalka commented 2 years ago

I had the same issue but in the end the problem was not with Redshift but with an Apparmor profile for Redshift that was blocking access to files outside of the default Redshift config directory. The solution is to create a local override of the profile:

sudo vi /etc/apparmor.d/local/usr.bin.redshift

add this line:

owner @{HOME}/.../redshift.conf r,

(you need to put the correct path above) Then reload Apparmor configuration:

sudo systemctl reload apparmor

I tested this on Debian but it should work also for Ubuntu.

andornaut commented 2 years ago

Thanks @mkapalka!

ghost commented 2 years ago

I had the same issue but in the end the problem was not with Redshift but with an Apparmor profile for Redshift that was blocking access to files outside of the default Redshift config directory. The solution is to create a local override of the profile:

sudo vi /etc/apparmor.d/local/usr.bin.redshift

add this line:

owner @{HOME}/.../redshift.conf r,

(you need to put the correct path above) Then reload Apparmor configuration:

sudo systemctl reload apparmor

I tested this on Debian but it should work also for Ubuntu.

For some reason Reloading apparmor didn't work I had to reboot my system to make the changes take effect Any explanations why?