You are not logged in.

#1 2014-10-05 17:10:49

Archizzle
Member
Registered: 2014-10-05
Posts: 4

Changing the root permission of certain commands

I use the following alias in my .bashrc.

alias br='sudo tee /sys/class/backlight/intel_backlight/brightness <<<'

ex:
$ br 200

I would like to make it available without root permission though.
Maybe change it so that it's root-free to a certain extent (up to 400 for example).

Thank you for reading.

Greetings from Germany.

Offline

#2 2014-10-05 17:37:26

smirky
Member
From: Bulgaria
Registered: 2013-02-23
Posts: 277
Website

Re: Changing the root permission of certain commands

$ pacman -S xorg-xbacklight

You can try this as a non-root alternative.


Personal spot  ::  https://www.smirky.net/  ::  Try not to get lost!

Offline

#3 2014-10-05 17:38:12

rin
Member
Registered: 2013-12-24
Posts: 31

Re: Changing the root permission of certain commands

I had an indicator on my desktop for a while, displaying the HDD temperature, but the hddtemp command requires root, so I have this line in my /etc/sudoers file:

tom ALL=(ALL) NOPASSWD: /usr/bin/hddtemp

You could move the br alias into a script, alias br='/location/of/script', and add the script to the sudoers file as above. Probably a good idea to make the script owned by root for security.
The script could handle the cases where it's over 400.

Last edited by rin (2014-10-05 17:39:38)

Offline

#4 2014-10-05 19:23:09

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,742

Re: Changing the root permission of certain commands

Welcome to Arch Linux smile  Interesting idea.  You might get it to work by creating a sudoers rule to allow anyone to run a particular script. Then, write that as a script rather then an alias.  Or, do it in a compiled language and set the usid bit.  It won't work for scripts though.

edit:  Rin, Sorry, I did  miss your bit about sudoers, or did you edit your post at the same time I was posting?
hmm

Last edited by ewaller (2014-10-05 19:25:15)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#5 2014-10-08 07:14:21

rwd
Member
Registered: 2009-02-08
Posts: 671

Re: Changing the root permission of certain commands

you can use an udev rule to change permissions of a particular device or property of a device. I use this for a macbook for example:

ACTION=="add", KERNEL=="apple_backlight", SUBSYSTEM=="backlight", RUN+="/usr/bin/chmod 0666 /sys/class/backlight/%k/brightness /sys/class/backlight/%k/bl_power"

Offline

#6 2014-10-08 07:40:50

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,536

Re: Changing the root permission of certain commands

@rwd
Well that's for a device, less for a subsequent command.


do it good first, it will be faster than do it twice the saint wink

Offline

#7 2014-10-08 07:48:52

rwd
Member
Registered: 2009-02-08
Posts: 671

Re: Changing the root permission of certain commands

Maybe I misread Archizzle's question. But if the goal is to let a non privileged user write/read to a device then that udev rule makes it so. In that case the command can get rid of 'sudo'.

Offline

#8 2014-10-08 08:29:27

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,536

Re: Changing the root permission of certain commands

rwd wrote:

the command can get rid of 'sudo'.

As above mentioned we may get rid of sudo when setting an appropriated rule in /etc/sudoers.d/, too wink


do it good first, it will be faster than do it twice the saint wink

Offline

#9 2014-10-08 08:44:19

rwd
Member
Registered: 2009-02-08
Posts: 671

Re: Changing the root permission of certain commands

TheSaint wrote:
rwd wrote:

the command can get rid of 'sudo'.

As above mentioned we may get rid of sudo when setting an appropriated rule in /etc/sudoers.d/, too wink

It is just a different way to achieve the same goal. I personally don't like giving scripts root privileges, with setuid/setguid or sudoers because it may lead to  privilege escalation in case of bugs in the script, but that may just be me being a bit too cautious.

Last edited by rwd (2014-10-08 08:51:23)

Offline

#10 2014-10-08 15:28:44

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,742

Re: Changing the root permission of certain commands

rwd wrote:
TheSaint wrote:
rwd wrote:

the command can get rid of 'sudo'.

As above mentioned we may get rid of sudo when setting an appropriated rule in /etc/sudoers.d/, too wink

It is just a different way to achieve the same goal. I personally don't like giving scripts root privileges, with setuid/setguid or sudoers because it may lead to  privilege escalation in case of bugs in the script, but that may just be me being a bit too cautious.

Just a note, setuid/setgid does not work with scripts by design.  It does work with compiled binaries.   Scripts do work with sudo.


OP.  How about creating a new group, adding the desired users to that group, change the group of the programs in question to that group, turn on group execute and turn off world execute for those programs.

That, or ACLs.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB