sudoers.d Not Working

Technical issues/questions of an intermediate or advanced nature.
johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

sudoers.d Not Working

Post#1 by johnywhy » 31 Aug 2018, 20:13

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

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

sudoers.d Not Working

Post#2 by Ed_P » 31 Aug 2018, 22:08

Menu > Preferences > System Settings > Power Management > Brightness

Works for me and I always signon as guest.
Ed

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

sudoers.d Not Working

Post#3 by ncmprhnsbl » 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
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

sudoers.d Not Working

Post#4 by johnywhy » 01 Sep 2018, 05:29

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.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

sudoers.d Not Working

Post#5 by ncmprhnsbl » 01 Sep 2018, 06:28

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..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

sudoers.d Not Working

Post#6 by johnywhy » 01 Sep 2018, 08:14

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

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

sudoers.d Not Working

Post#7 by brokenman » 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 and then you can move to the sudo problem.
How do i become super user?
Wear your underpants on the outside and put on a cape.

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

sudoers.d Not Working

Post#8 by johnywhy » 01 Sep 2018, 18:24

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
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

sudoers.d Not Working

Post#9 by brokenman » 01 Sep 2018, 18:29

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.
How do i become super user?
Wear your underpants on the outside and put on a cape.

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

sudoers.d Not Working

Post#10 by johnywhy » 01 Sep 2018, 18:38

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 :)
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

sudoers.d Not Working

Post#11 by brokenman » 01 Sep 2018, 18:52

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
How do i become super user?
Wear your underpants on the outside and put on a cape.

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

sudoers.d Not Working

Post#12 by johnywhy » 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.

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
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

sudoers.d Not Working

Post#13 by Ed_P » 02 Sep 2018, 00:08

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.
Ed

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

sudoers.d Not Working

Post#14 by johnywhy » 02 Sep 2018, 00:40

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 :)
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

sudoers.d Not Working

Post#15 by brokenman » 02 Sep 2018, 01:31

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.
How do i become super user?
Wear your underpants on the outside and put on a cape.

Post Reply