Nixpkgs: Rebuild causes sudo to be required to adjust screen brightness

Created on 23 Mar 2016  路  29Comments  路  Source: NixOS/nixpkgs

The last two times that I've done a sudo nix-channel --update and sudo nixos-rebuild-switch, I end up in a state where I get this prompt every time I try to adjust screen brightness in Gnome 3:

Authentication is needed to run `/nix/store/...-gnome-settings-daemon-3.18.2/libexec/gsd-backlight-helper' as the super user

It stays this way until the next time I log in, at which point I can again adjust screen brightness without root, as expected.

Version info:

> uname -a
Linux renzo 4.4.4 #1-NixOS SMP Thu Mar 3 23:10:04 UTC 2016 x86_64 GNU/Linux
> nixos-version
16.09pre78286.0bf8a1a (Emu)
> nix-env --version
nix-env (Nix) 1.11.2
> nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion
"16.09pre78848.9549257"
bug GNOME

All 29 comments

I confirm the problem

I'm seeing this on release-16.09.

Hm, I get this for 17.09 (worked in one of the beta releases) now. I haven't restarted after nixos-rebuild switch though.

I can't confirm whether this still happens to me anymore because, for the last few months, nixos-rebuild switch on my laptop just causes the display manager to crash.

@chris-martin are you using GDM? If so I think this is finally fixed here: https://github.com/NixOS/nixpkgs/issues/21439#event-1348870891 (at least until we introduce wayland).

This still seems to happen for 17.09 after a rebuild-switch and the workaround seems to be a reboot.

I cannot reproduce this on current unstable. Is this still happening with GNOME 3.26?

I still cannot attempt to reproduce due to https://github.com/NixOS/nixpkgs/issues/14168#issuecomment-334958454

@teh Yes, I'm using GDM. Should I try rebuilding from the unstable channel?

Yes, switch no longer restarts display-manager on unstable.

Hmm, I just came across this issue on 5b53774f89ee4288554d5f45cf58c74787e421fb

Okay, apparently the issue happens whenever gnome-settings-daemon is rebuild. The polkit policy file in the system profile will point to the new derivation but GNOME will still use the old gsd-backlight-helper.

Apparently, GNOME Shell is using DBus to call org.gnome.SettingsDaemon.Power.Screen interface. The interface is provided by ${gnome3.gnome-settings-daemon}/libexec/gsd-power but it is just a program ran by XDG autostart, not a systemd service, so it is not restarted when the service is updated. This might fix that: https://bugzilla.gnome.org/show_bug.cgi?id=758413

Edit: I tried killing gsd-power but it killed my session.

Was hit by this too.

The most straightforward way to fix that would be:

If we don't want (cannot) restart gsd-power (just like don't want/cannot restart gnome-session), we should add some hacks here...

Hello,

I still have this issue going on but I am not able to confirm it happens after a nixos-rebuild switch.
What I experience is that from time to time, the issue starts and won't stop until reboot.

Not sure if relevant but I have the redshift service activated.

My version info:

> uname -a
Linux cosmo-mu 4.14.85 #1-NixOS SMP Sat Dec 1 08:43:00 UTC 2018 x86_64 GNU/Linux
> nixos-version
19.03pre161545.7c73f53d836 (Koi)
> nix-env --version
nix-env (Nix) 2.1.3
> nix-instantiate --eval '<nixpkgs>' -A lib.version
"19.03pre161545.7c73f53d836"
> gnome-shell --version
GNOME Shell 3.28.3

@tcosmo we have already determined the exact cause in https://github.com/NixOS/nixpkgs/issues/14168#issuecomment-381759563. Unfortunately, the solution is non-trivial and ugly due to the way gnome-settings-daemon is designed (non-restartable).

Thank you for your answer!

@jtojnar, where was that "solution" link supposed to point? I don't understand how multiple-outputs.sh could be related to this issue. Did you mean https://github.com/NixOS/nixpkgs/issues/14168#issuecomment-422948774?

I was glancing through gsd-backlight.c and noticed there's a feature intended for testing that seems like it would be an easy workaround for this.

I think these two steps should fix the observed symptom:

  • wrap libexec/gsd-power to set GSD_BACKLIGHT_HELPER=/run/wrappers/bin/gsd-backlight-helper, and
  • set the NixOS option security.wrappers.gsd-backlight-helper.source = "${gnome-settings-daemon}/libexec/gsd-backlight-helper";

This bypasses polkit, which means there's no security policy preventing someone on an inactive console from setting the backlight brightness.

How silly is this approach? I haven't actually tried it yet; should I bother?

@jameysharp Sorry for the wrong link; you got the right one.

Your approach actually sounds workable. The helper code is small and quite self-contained (only linking against gudev).

Gnome-settings-daemon currently has a merge request to turn it into a systemd user unit https://gitlab.gnome.org/GNOME/gnome-settings-daemon/merge_requests/27 as part of the SystemdUser initiative. Perhaps this will help. https://wiki.gnome.org/Initiatives/SystemdUser

I think we could be fine with what @jameysharp suggested until we have a more robust solution.

Also think we should probably have a gnome-settings-daemon module.

HI ! For the brightness control - setting hardware.brightnessctl.enable to true and adding my user to the video group helped - no admin prompt anymore.

Is this issue more broad than being about controlling the brightness now ? If so - would it help to change the title/description ? If not - is there anything else that we need to do to close it ? Thanks so much ! :)

@cyplo Ths is specifically about changing brightness in GNOME after rebuild. It will be fixed by #57620

@jtojnar thank you ! :)
If this helps as a data point - it does work for me in gnome3 after sudo nixos-rebuild switch --upgrade and has been every time.

@cyplo The error occurs only when gnome-settings-daemon is changed so it is possible you have not encountered it.

Hi all I get this problem on 20.03, the backlight worked on 19.09 and after nixos-rebuild upgrade it stopped working.

> sudo light -v 3 -A 10                                                                                                         
helpers.c:21: Error: could not open '/etc/light/targets/sysfs/backlight/auto/minimum' for reading
helpers.c:21: Error: Verify it exists with the right permissions

OR

> echo "200" | sudo tee /sys/class/backlight/intel_backlight/brightness

But in gnome it does not respond, and as you can see I need root access to change these files. It is strange that I also noticed my username not showing up on gdm, instead I have a username box. I wonder if this might be just a group missing for my user. Any thoughts? Is this related?

> uname -a                  
Linux fox 5.4.33 #1-NixOS SMP Fri Apr 17 08:50:26 UTC 2020 x86_64 GNU/Linux
> nix-env --version
nix-env (Nix) 2.3.4
> nixos-version 
20.03.1418.5272327b81e (Markhor)
> nix-instantiate --eval '<nixpkgs>' -A lib.version       
"20.03.1418.5272327b81e"

thanks in advance

I just found some stuff into journactl

Apr 22 14:17:52 fox .gsd-power-wrap[1821]: Error executing backlight helper: Child process stopped by signal 0
Apr 22 14:17:52 fox pkexec[14137]: myusername: The value for the SHELL variable was not found the /etc/shells file [USER=root] [TTY=unknown] [CWD=/home/myusername] [COMMAND=/run/current-system/sw/bin/gnome-settings-daemon/gsd-backlight-helper /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight 713]

Hi all I get this problem on 20.03, the backlight worked on 19.09 and after nixos-rebuild upgrade it stopped working.

> sudo light -v 3 -A 10                                                                                                         
helpers.c:21: Error: could not open '/etc/light/targets/sysfs/backlight/auto/minimum' for reading
helpers.c:21: Error: Verify it exists with the right permissions

OR

> echo "200" | sudo tee /sys/class/backlight/intel_backlight/brightness

So you mean when you rebuild-ed on that one occasion adjusting screen brightness wouldn't work, and after a reboot it went away? Was this a rebuild from 19.09 -> 20.03?
What was the nixos-version of the system generation before the rebuild?
Lastly, this was in GNOME (it's not mentioned in your comment) and you mentioned a light command, I'm not sure how that has anything to do with GNOME. Was adjusting the brightness not working in the brightness slider in the shell?

It is strange that I also noticed my username not showing up on gdm, instead I have a username box. I wonder if this might be just a group missing for my user. Any thoughts? Is this related?

There must be some sort of issue with accountsservice and GDM.
Perhaps you could open a separate bug for this?

Apr 22 14:17:52 fox pkexec[14137]: myusername: The value for the SHELL variable was not found the /etc/shells file [USER=root] [TTY=unknown] [CWD=/home/myusername] [COMMAND=/run/current-system/sw/bin/gnome-settings-daemon/gsd-backlight-helper /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight 713]

That looks like you changed your shell maybe, and pkexec is accessing $SHELL, and that path doesn't exist anymore.

Thanks @worldofpeace, the shell was the problem.

I was using zsh but it was not present on /etc/shells, to fix this I added to /etc/configuration.nix:

  users.extraUsers.adisbladis = {
    shell = pkgs.zsh;
  };    
  programs.zsh.enable = true;

I also found that users.mutableUsers = true; so i used chsh but this is probably related to other issues I was having:

sudo chsh myuser --shell `which zsh`

Just to answer your previous question, I did upgrade by changing /etc/configuration.nix and channel, after I issued sudo nix-build upgrade to simply put.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

teto picture teto  路  3Comments

ayyess picture ayyess  路  3Comments

matthiasbeyer picture matthiasbeyer  路  3Comments

vaibhavsagar picture vaibhavsagar  路  3Comments

ghost picture ghost  路  3Comments