From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 30 14:59:37 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B41D1065670 for ; Mon, 30 Nov 2009 14:59:37 +0000 (UTC) (envelope-from ap00@mail.ru) Received: from mx74.mail.ru (mx74.mail.ru [94.100.176.89]) by mx1.freebsd.org (Postfix) with ESMTP id D7BC38FC18 for ; Mon, 30 Nov 2009 14:59:36 +0000 (UTC) Received: from [91.190.115.253] (port=59456 helo=pstation) by mx74.mail.ru with asmtp id 1NF7ix-0002Bq-00; Mon, 30 Nov 2009 17:59:35 +0300 Date: Mon, 30 Nov 2009 18:03:53 +0300 From: Anthony Pankov X-Mailer: The Bat! (v1.51) Personal X-Priority: 3 (Normal) Message-ID: <3024979203.20091130180353@mail.ru> To: Clifton Royston , Mike Meyer , Nate Eldredge In-Reply-To: <20091129201340.GA7066@lava.net> References: <20091128120018.16D2C10656C7@hub.freebsd.org> <20091128182803.GA13793@lava.net> <5870478546.20091129131902@mail.ru> <20091129201340.GA7066@lava.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: Not detected X-Mras: Ok Cc: freebsd-hackers@freebsd.org Subject: Re[2]: ucred when euid/egid X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Anthony Pankov List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Nov 2009 14:59:37 -0000 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