[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Re[2]: ucred when euid/egid
From:       Anthony Pankov <ap00 () mail ! ru>
Date:       2009-11-30 15:03:53
Message-ID: 3024979203.20091130180353 () mail ! ru
[Download RAW message or body]


Thanks all for comment.

As i can understand all suggest to change primordial situation to
suit direct use of seteuid/gid.

I thought there is a cheat|hack|fix less expensive then redesign
current permissions model in my project.

So, if there is no way for seteuided program
to gain access in accordance to euid group membership and it is not a
bug, i'll give up.

P.S.
In terms of home directories it looked like this:

rw-rw----   someone:filegroup    ~someone/thefile
rw-rw----   someone:proggroup    ~someone/progdata
rw-rw----   someone2:filegroup   ~someone2/thefile
rw-rw----   someone2:proggroup   ~someone2/progdata
rw-rw----   someone3:filegroup   ~someone3/thefile
rw-rw----   someone3:proggroup   ~someone3/progdata
...


Sunday, November 29, 2009, 11:13:40 PM, you wrote:

CR> On Sun, Nov 29, 2009 at 01:19:02PM +0300, Anthony Pankov wrote:
>> 
>> Thank you for reply.
>> 
>> So, seteuid/gid isn't enough to gain group access as for real uid.
>> But how i can achieve this? What functions should i call from
>> 'theprog' to gain access for the groups euid user belongs to?
>> 
>> May be i solve the problem in wrong way?
>> 
>> The full problem is:
>> 
>> There is a file owned by group filegroup:
>>  rw-rw----   someone:filegroup    thefile
>> 
>> There is a programs data owned by group proggroup:
>> 
>>  rw-rw----   someone2:proggroup    progdata
>> 
>> I need a program (theprog) that can access 'thefile' and
>> 'progdata' simultaneously. Program can be executed by anyone.
 
CR> This is a clearer statement of the problem, in terms of what you're
CR> trying to accomplish.  

CR> If you can make the program data owned by a special program user, and
CR> require the users of the program to make their files group-accessible
CR> by this special filegroup, then you can do it fairly simply, like this:

CR> Make each users' "thefile" be owned by group filegroup, for example:
CR>   rw-rw----   someone:filegroup    ~someone/thefile
CR>   rw-rw----   someone2:filegroup   ~someone2/thefile
CR>   rw-rw----   someone3:filegroup   ~someone3/thefile
CR>   ...

CR> Make the program's data file owned by *user* proguser:
CR>   rw-rw----   proguser:proggroup    progdata

CR> Now you can make the program setuid proguser/setgid filegroup:
CR>   r-sr-sr-x   proguser:filegroup    theprog
 
CR> This lets it be executed by any user and access its own data (via the
CR> suid) and the files the users have put into filegroup (via the sgid).


CR> Note that the users should not themselves be members of filegroup 
CR> unless it's OK for them to read/write each others' data.  You may need
CR> either to provide an sgid utility which can be used to create or chown
CR> that file to filegroup, or require them to be put in a shared directory
CR> with filegroup gid and the directory sticky bit set.

CR> Alteratively you could drop the sgid and simply require the file be group
CR> readable/writable by the user's own group.  In that case you have
CR>   r-sr-xr-x   proguser:bin          theprog
CR> and
CR>   rw-rw----   someone:somegroup    ~someone/thefile


>> My idea was to seteuid theprog to user who is memeber of one group
>> (filegroup) and setegid theprog to another group (proggroup). In that
>> way i was going to give theprog rights to work with both files.
>>
>> P.S. I don't want to use file ACLs.

CR> The standard Unix permissions aren't really extensible in that way. 

CR> You can do it as I've outlined above; that's getting close to the
CR> limits of what you can readily do with the standard permissions.  If it
CR> gets more complicated, you will need to either do ACLs or something
CR> still more creative.  

CR> sudo, for instance, does allow you to set a vector of groups to match
CR> the user you're executing as.  It may be possible to leverage the sudo
CR> command into doing something more elaborate if you need to, with a
CR> suitably crafted sudoers config file; you could also look into the code
CR> that sudo uses to set the group vector, but that will require you to
CR> write a suid root utility which adds a lot of security risks.

CR> Hope this helps,
CR>   -- Clifton




-- 
Best regards,
 Anthony                            mailto:ap00@mail.ru


_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic