Page 1 of 2

sudoers.d Not Working

Posted: 31 Aug 2018, 20:13
by johnywhy
On my Porteus, root can adjust brightness with:
$ echo 9000000 > /sys/class/backlight/intel_backlight/brightness

On Mint, this works to make brightness adjustable by non-root users.
Fails on Porteus:

$ sudo visudo -f /etc/sudoers.d/brightness
Paste into editor:
ALL ALL = (ALL) NOPASSWD: /usr/bin/tee /sys/class/backlight/intel_backlight/brightness

$ echo 9000000 > /sys/class/backlight/intel_backlight/brightness
bash: /sys/class/backlight/intel_backlight/brightness: Permission denied

How to fix?

THX

sudoers.d Not Working

Posted: 31 Aug 2018, 22:08
by Ed_P
Menu > Preferences > System Settings > Power Management > Brightness

Works for me and I always signon as guest.

sudoers.d Not Working

Posted: 31 Aug 2018, 22:38
by ncmprhnsbl
don't you need to preface that with sudo? ie:

Code: Select all

$ sudo echo 9000000 > /sys/class/backlight/intel_backlight/brightness

sudoers.d Not Working

Posted: 01 Sep 2018, 05:29
by johnywhy
ncmprhnsbl wrote:
31 Aug 2018, 22:38
don't you need to preface that with sudo? ie:

Code: Select all

$ sudo echo 9000000 > /sys/class/backlight/intel_backlight/brightness
the purpose of sudoers.d is to create custom security rules.
https://www.digitalocean.com/community/ ... and-centos

It can be used to give non-root users write-access to a file, so they don't have to sudo. The sudoers.d rule for that is:

Code: Select all

ALL ALL = (ALL) NOPASSWD: /usr/bin/tee /sys/class/backlight/intel_backlight/brightness
Works for me on Mint.

sudoers.d Not Working

Posted: 01 Sep 2018, 06:28
by ncmprhnsbl
johnywhy wrote:
01 Sep 2018, 05:29
it can be used to give non-root users write-access to a file, so they don't have to sudo.
i've never seen it described that way... i would say: it gives all non-root users write-access to a file, so they don't have to supply a password when using sudo.
what you're suggesting would mean that sudoers/sudoers.d is parsed every time a command is given to check if a file or binary is allowed, as opposed to when sudo is invoked..
unless i'm completely wrong .. :O
i can't comment on what goes on in Mint..

sudoers.d Not Working

Posted: 01 Sep 2018, 08:14
by johnywhy
your description is prolly more correct.
i was under the impression various rules can be created, not just the one you described.

anyways, still not working.

THX

sudoers.d Not Working

Posted: 01 Sep 2018, 17:51
by brokenman

Code: Select all

sudo tee /sys/class/backlight/intel_backlight/brightness <<< 50
Working for me as guest. Confirm this works and then you can move to the sudo problem.

sudoers.d Not Working

Posted: 01 Sep 2018, 18:24
by johnywhy
brokenman wrote:
01 Sep 2018, 17:51

Code: Select all

sudo tee /sys/class/backlight/intel_backlight/brightness <<< 50
Working for me as guest. Confirm this works
it asks me for password

sudoers.d Not Working

Posted: 01 Sep 2018, 18:29
by brokenman
Yes that is its job, but does it work once you enter the password? If so then we can move to the sudo without password problem.

sudoers.d Not Working

Posted: 01 Sep 2018, 18:38
by johnywhy

Code: Select all

sudo tee /sys/class/backlight/intel_backlight/brightness <<< 50
Working for me as guest. Confirm this works
ok, yes, it works with guest password.

Only asks for password on first try. Subsequent calls don't ask for password. Seems to have a time-limit.

But it likes 5000000. 50 would be black :)

sudoers.d Not Working

Posted: 01 Sep 2018, 18:52
by brokenman
If you want sudo to run any command as guest without requiring a password (which I dont recommend) you can add this to your sudoers file.

Code: Select all

guest ALL=(ALL) NOPASSWD: ALL
So from a root console:
Type: visudo
Hit insert key
paste above at last line in using SHIFT + INSERT
Hit escape key
Type: \:x (don't type the backslash it is just to disable the smile from appearing. Just type colon x)
Now you should be able to change your brightness without a password.

You can find your maximum brightness which most certainly is not 5 million:

Code: Select all

cat /sys/class/backlight/intel_backlight/max_brightness

sudoers.d Not Working

Posted: 01 Sep 2018, 19:09
by johnywhy
brokenman wrote:
01 Sep 2018, 18:52
to run any command as guest without requiring a password (which I dont recommend)
But i don't want to do that. I only want all users to adjust brightness without a password.

This didn't work for me:

Code: Select all

ALL ALL = (ALL) NOPASSWD: /usr/bin/tee /sys/class/backlight/intel_backlight/brightness
brokenman wrote:
01 Sep 2018, 18:52
You can find your maximum brightness which most certainly is not 5 million:
nope, it's about 13 million
# cat /sys/class/backlight/intel_backlight/max_brightness
12750000

sudoers.d Not Working

Posted: 02 Sep 2018, 00:08
by Ed_P
johnywhy wrote:
01 Sep 2018, 19:09
brokenman wrote:
01 Sep 2018, 18:52
to run any command as guest without requiring a password (which I dont recommend)
But i don't want to do that. I only want all users to adjust brightness without a password.
Why can't they use this approach? :%)
Ed_P wrote:
31 Aug 2018, 22:08
Menu > Preferences > System Settings > Power Management > Brightness

Works for me and I always signon as guest.

sudoers.d Not Working

Posted: 02 Sep 2018, 00:40
by johnywhy
Ed_P wrote:
02 Sep 2018, 00:08
Why can't they use this approach?
Menu > Preferences > System Settings > Power Management > Brightness
hi Ed! Cuz i'm trying not to run Power Manager. Consumes a lot of RAM :)

sudoers.d Not Working

Posted: 02 Sep 2018, 01:31
by brokenman
nope, it's about 13 million
Wow, That's about the brightness of a star!

So just change the file permissions if you want guest to write to it.

Code: Select all

chmod 666 /sys/class/backlight/intel_backlight/brightness
Or just use the keyboard to change brightness. That doesn't chew.