0

Recently cpupower stopped working when calling it without sudo.

I have the following line in /etc/sudoers/.

dimfred dimfred-schlap= NOPASSWD: /usr/bin/cpupower frequency-set *

Is this correct? AFAIK * should normally replace the following paramaters.

My usecase would be to call this line from a script with attached parameters. E.g. sudo cpupower frequency-set --min 0.8Ghz --max 0.8Ghz

When I run the command I get still prompted for the password.

The weird thing is that everything worked and suddenly broke. I don't know what happened there.

Running on: Ubuntu 20.04 Kernel 5.4.0-48-generic

Fell free to ask for any other information you need. Thanks.

EDIT:

So I came around with writing subscripts. Those call a kind of "profile" (parameters for cpupower), the scripts itself are called without parameters. They work properly. Still would be interested why the above does not work cause I am not very pleased with having n extra scripts for each profile I have.

EDIT2: So the answer was: order matters. I had first my command then the include. Found it in this answer: Why is sudoers NOPASSWD option not working?

Dimfred
  • 31
  • 1
  • 5

1 Answers1

0

Your sudoers file entry does NOT give you root all the time, just when you invoke rootness by prefacing your command with sudo, e.g.

sudo cpupower ...
waltinator
  • 36,399
  • I am sry. I also tried calling it with sudo then it still asks me for the password. I edit the question. – Dimfred Oct 01 '20 at 07:48
  • Btw I finally found the answer... it is so simple. The order matters. I first had my command in sudoers then the include. The other way round it works... https://askubuntu.com/questions/100051/why-is-sudoers-nopasswd-option-not-working – Dimfred Jul 19 '21 at 19:41