You are not logged in.

#1 2010-07-25 07:56:08

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

[solved] Sudo and file access

If I want certain users to be able to access wakealarm, do I have create a script in order to modify wakealarm and edit sudoers so the users can run the script as root, or is there a way via the sudoers file I can grant to specific users access to just wakealarm?

Last edited by omgwtfbyobbq (2010-07-25 22:15:14)

Offline

#2 2010-07-25 07:57:34

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Sudo and file access

Files permissions can do that: you specify a group that can read / write / execute that file / directory and add some users to the group.

Offline

#3 2010-07-25 07:59:31

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: [solved] Sudo and file access

I'd rather not mess w/ the file permissions because other programs (mythtv offhand) use wakealarm too.

Offline

#4 2010-07-25 08:02:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Sudo and file access

omgwtfbyobbq wrote:

I'd rather not mess w/ the file permissions because other programs (mythtv offhand) use wakealarm too.

So use visudo and add your program there.

http://ubuntu-tutorials.com/2007/03/01/ … th-visudo/

Last edited by karol (2010-07-25 08:05:07)

Offline

#5 2010-07-25 08:06:32

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: [solved] Sudo and file access

I know I can do that, but is there a way I can just use sudo to dictate file access for individual users? I don't need or want to run the whole script as root (I suppose I could create a script that only accessed wakealarm, let that grab a variable from my other script, and let my users execute that as root, but that seems too kludgy), I'd just like to let certain users access wakealarm while maintaining file permissions.

Last edited by omgwtfbyobbq (2010-07-25 08:09:10)

Offline

#6 2010-07-25 08:08:37

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Sudo and file access

omgwtfbyobbq wrote:

I know I can do that, but is there a way I can just use sudo to dictate file access for individual users?

Sure, there's a bunch of examples in the man page http://www.gratisoft.us/sudo/sudo.man.html

To edit the index.html file as user www:
$ sudo -u www vi ~www/htdocs/index.html

omgwtfbyobbq wrote:

I suppose I could create a script that only accessed wakealarm

Above you have a one-liner where you edit as user www - is that what you want?


omgwtfbyobbq wrote:

is there a way I can just use sudo to dictate file access for individual users?

Yes, you can let individual users (or groups) run all programs or just a specified few.

Last edited by karol (2010-07-25 08:19:22)

Offline

#7 2010-07-25 08:17:06

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: [solved] Sudo and file access

Not as far as I know. Access has to be w/o a password. If possible, I'm guessing the config would look something like this.

%users ALL = NOPASSWD: echo $somenumber > /sys/class/rtc/rtc0/wakealarm

I shouldn't let users run echo willy nilly, but I can't seem to figure out how to restrict access to specific files.

Offline

#8 2010-07-25 08:21:52

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Sudo and file access

omgwtfbyobbq wrote:

Not as far as I know. Access has to be w/o a password. If possible, I'm guessing the config would look something like this.

%users ALL = NOPASSWD: echo $somenumber > /sys/class/rtc/rtc0/wakealarm

I shouldn't let users run echo willy nilly, but I can't seem to figure out how to restrict access to specific files.

Ah, so you want them to run echo, not some_other_app. I think you need to create a script, 'chmod +x' it and put it in the sudoers file.

%users ALL = NOPASSWD: echo $somenumber > /sys/class/rtc/rtc0/wakealarm

This allows all users to run it.

%myusers ALL = NOPASSWD: /path/to/myscript

This allows only the users in 'myusers' group to run '/path/to/myscript' script.



In the mean time I edited the previous post :-)

Last edited by karol (2010-07-25 08:24:38)

Offline

#9 2010-07-25 08:25:15

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: [solved] Sudo and file access

That's what I was thinking, but it's just so clumsy.

Offline

#10 2010-07-25 08:30:40

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Sudo and file access

omgwtfbyobbq wrote:

That's what I was thinking, but it's just so clumsy.

The users still need to have permissions regarding editing /sys - giving them permission for that script doesn't automatically grant that.

Offline

#11 2010-07-25 08:34:29

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Sudo and file access

Maybe you can create another layer: a cronjob that looks inside a file that users can edit and sets wakealarm to the desired value. I don't know if it's more or less clumsy in your opinion.

Offline

#12 2010-07-25 08:44:40

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: [solved] Sudo and file access

I'm not sure if it would be suitable. At least it's another option. Thanks for the help btw.

Offline

#13 2010-07-25 08:49:59

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] Sudo and file access

omgwtfbyobbq wrote:

I'm not sure if it would be suitable. At least it's another option. Thanks for the help btw.

This way you can set file permissions (write) for that file and keep all the other permissions on your system intact.

Offline

#14 2010-07-25 15:41:17

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

Re: [solved] Sudo and file access

I really hate to say it, but this is an area where Windows has a leg up on us. 

There is a concept called ACL (Access Control List) that provides finer granularity for access permissions than those provided by user, group, and other.
DEC's VMS was very good it, and NTFS is pretty good.

There now seems to be support for it in linux -- try man acl, or try this article:http://linuxcommando.blogspot.com/2007/ … s-you.html


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#15 2010-07-25 19:53:11

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: [solved] Sudo and file access

ewaller wrote:

...DEC's VMS was very good it...

OpenVMS is still very good at it.  It's not dead and some of us use it everyday. :-)


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#16 2010-07-25 22:14:31

omgwtfbyobbq
Member
Registered: 2006-07-04
Posts: 226

Re: [solved] Sudo and file access

ACL looks perfect, thanks for the info ewaller!

Offline

Board footer

Powered by FluxBB