Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: The current user does not have permission for operation #53

Open
801k opened this issue Oct 19, 2022 · 9 comments
Open

ERROR: The current user does not have permission for operation #53

801k opened this issue Oct 19, 2022 · 9 comments

Comments

@801k
Copy link

801k commented Oct 19, 2022

Hello! First of all, thank you for your work!
I have been using this script for a year, maybe more, without any problems. Without problems it still works, but after the last Arch update it shows "ERROR: The current user does not have permission for operation" on every line when changing the fan speed level. But everything works fine and the fan speed changes. I tried running it as a script or as a service, it's the same in the log. With sudo there is no this error.
Because it works well it is not a big problem, but I want to understand what is causing this Error. Thank you!

My specs:

GPU: GTX 1650 Super (Palit StormX) with single fan.
OS: Arch
Kernel: 6.0.2-arch1-1
Driver version: 520.56.06

@AERDU
Copy link

AERDU commented Oct 19, 2022

I tried figuring this out yesterday, I think there was another issue opened here which could run it if they ran xorg as root, however it's a pretty ugly workaround. What ended up working for me was adding export DISPLAY=":0" at the top of the shell script, a line after the shebang. I ended up scrapping the old .service file and created another one you run at root:

[Unit]
Description=Nfancurve service
After=multi-user.target

[Service]
ExecStart=/usr/bin/nfancurve -c /etc/nfancurve.conf
KillSignal=SIGINT

[Install]
WantedBy=default.target

The biggest issue with this script is that if you enable the script to run at boot, it will fail. Your graphical environment has to be running before the service will work. There are different options to make this work, depending on what setup you have, here are two options: https://unix.stackexchange.com/questions/397853/how-to-set-a-systemd-unit-to-start-after-loading-the-desktop

I'm using i3, but if you're using a DE you might be able to start it with xsession. My solution is really hacky and would be nice if someone else had a cleaner fix.

**also forgot to add, im using the AUR package, thats why it's called nfancurve instead of temp.sh

@801k
Copy link
Author

801k commented Oct 20, 2022

AERDU, thank you very much for your answer!

I tried your solution and it works just perfect for service autostarting. But I still have in my log:

Oct 20 12:23:02 v01k-desktop systemd[661]: Started Nfancurve service.
Oct 20 12:23:02 v01k-desktop nfancurve[668]: Number of Fans detected:
Oct 20 12:23:02 v01k-desktop nfancurve[668]: 1
Oct 20 12:23:02 v01k-desktop nfancurve[668]: Number of GPUs detected:
Oct 20 12:23:02 v01k-desktop nfancurve[668]: 1
Oct 20 12:23:02 v01k-desktop nfancurve[722]: ERROR: The current user does not have permission for operation
Oct 20 12:23:02 v01k-desktop nfancurve[722]: Attribute 'GPUFanControlState' (v01k-desktop:0[gpu:0]) assigned value 1.
Oct 20 12:23:02 v01k-desktop nfancurve[668]: Started process for 1 GPU and 1 Fan
Oct 20 12:23:02 v01k-desktop nfancurve[724]: ERROR: The current user does not have permission for operation
Oct 20 12:23:02 v01k-desktop nfancurve[724]: Attribute 'GPUTargetFanSpeed' (v01k-desktop:0[fan:0]) assigned value 35.

As I said, the fan speed level changes well even with this error.

I'm sorry, but I don't understand a little bit this moment that you wrote: "...and created another one you run at root". I'm not very experienced with Linux services and don't understand how to run service with --user as root. Please clarify this moment for me. Thank you!

P.S. I'm also using i3 and the package from AUR.

@AERDU
Copy link

AERDU commented Oct 20, 2022

move the .service file to /usr/lib/systemd/system/ instead of /usr/lib/systemd/user/, run systemctl daemon-reload for good meassures, and then load/enable the service with systemctl enable --now nfancurve.service. When you specify --user you run a service file from /usr/lib/systemd/user which has insufficient permission, as it runs it as your current user.

@801k
Copy link
Author

801k commented Oct 20, 2022

Oh, thank you! I thought about it, but wasn't sure it is the right way :) And what do you think about why this error appeared after the last Arch update? Could it be related to the latest Nvidia driver?

@AERDU
Copy link

AERDU commented Oct 20, 2022

There's another nvidia fan controller at https://github.com/foucault/nvfancontrol that states:
"As of version 465 NVIDIA decided that is a security risk for non-root users to have access to cooler control and overclocking capabilities. So you will have to start X11 as root despite almost no distributions and desktop environment doing so for the past years because it is a massive... security risk. Trading one security risk for another!"

keep in mind that my solution does NOT start X11 as root (at least it shouldn't unless setting $DISPLAY to :0 in a root session somehow elevates xorg). I'm also not sure why you got it after a recent update, v465 was awhile ago unless you use DKMS or something.

@801k
Copy link
Author

801k commented Oct 21, 2022

AERDU, thank you very much for clarifying this problem for me. Yes, it is very strange that I got this error after a recent update, because I always update my system, maybe weekly or even more often. But now everything works fine, and then we'll see, maybe the developer will make some changes. Thanks again!

@AERDU
Copy link

AERDU commented Dec 6, 2022

Tiny improvement I made recently, instead of setting the service on a timer I just set it to restart if it exits with an error code:

[Unit]
Description=Nfancurve service
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/nfancurve -c /etc/nfancurve.conf
Restart=on-failure
RestartSec=60s

[Install]
WantedBy=default.target

This should fix the issue instantly, and don't forget to systemctl daemon-reload.

@HanM23
Copy link

HanM23 commented Dec 7, 2022

Tiny improvement I made recently, instead of setting the service on a timer I just set it to restart if it exits with an error code:

[Unit]
Description=Nfancurve service
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/nfancurve -c /etc/nfancurve.conf
Restart=on-failure
RestartSec=60s

[Install]
WantedBy=default.target

This should fix the issue instantly, and don't forget to systemctl daemon-reload.

Hello, thanks for your help here. I had the same issue too.
I followed what you wrote :

  1. move the .service file to /usr/lib/systemd/system/ instead of /usr/lib/systemd/user/
  2. export DISPLAY=":0" in the shell script.

But i still had the following errors in journalctl

dec. 07 18:33:27 smith sh[49114]: Authorization required, but no authorization protocol specified
dec. 07 18:33:20 smith sh[49087]: Authorization required, but no authorization protocol specified
dec. 07 18:33:20 smith sh[49087]: Authorization required, but no authorization protocol specified
dec. 07 18:33:13 smith sh[49085]: Authorization required, but no authorization protocol specified
dec. 07 18:33:13 smith sh[49085]: Authorization required, but no authorization protocol specified

I resolved it by adding another line in the shell script : export XAUTHORITY='/run/lightdm/root/:0'

Indeed
❯ ps aux | grep Xorg (/run/lightdm/root/:0 is after -auth in the first line)

root        1124  4.1  2.7 25744332 218424 tty7  Ssl+ 12:41  15:29 /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
<username>     51551  0.0  0.0   6572  2520 pts/4    S+   18:56   0:00 grep Xorg

I do not really like it, because normally (before the export above) XAUTHORITY was equal to /home/<username>/.Xauthority

EDIT : it also works when i add export XAUTHORITY='/home/<username>/.Xauthority' in the shell script (nfancurve.sh, i also get it from AUR), but i do not really understand what is happening with this XAUTHORITY thing.

Have you faced this issue too ?
Thanks

@AERDU
Copy link

AERDU commented Dec 12, 2022

My logs are free from any errors related to ~/.Xauthority. I don't use lightdm, so I suspect lightdm may require Xorg to run with ~/.Xauthority.

ps aux | grep -i xorg returns /usr/lib/Xorg :0 vt2 for me.

I use ly , it probably just runs xinit, which in turn runs /usr/lib/Xorg :0 vt2, which is quite different from the way Xorg was started on your machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants