Changing UNIX primary group
Justin Johnson
justinjohnson at fastmail.fm
Wed Aug 13 15:30:47 EDT 2003
Okay, I'll have to do some more research. Maybe I *will* have to run the
script setuid root. Shucks! Thanks for the grp.getgrnam help. Just
what I needed. :-)
On Wed, 13 Aug 2003 14:11:01 -0500, "Jeff Epler" <jepler at unpythonic.net>
said:
> On Wed, Aug 13, 2003 at 12:10:02PM -0600, Justin Johnson wrote:
> > Thanks. I was hoping for a python solution though. :-( Does anyone
> > know of a way to do this in python?
>
> Unix doesn't let you setgid() to groups in the supplemental group list
> without the same permission needed to change to any group.
>
> But depending what you need to do, you might be able to use set-group-id
> directories. For instance, if I am group g1 and have a group list [g1,
> g2, g3], then I can read files readable by any of those groups, and
> create files in directories writable by any of those groups. But if you
> make a directory d2 that is setgid g2 and d3 setgid g3, then when I
> create a file in d2 it will belong to group g2.
>
> Barring that, you could modify the setgid() call in the kernel, to permit
> the change if the requested group is in the auxiliary group list.
> It looks like something you could do in an afternoon if you have the
> source for your kernel (bsd, linux, etc) and can program C.
>
> "Justin Johnson" <justinjohnson at fastmail.fm> wrote in message
> news:<mailman.1060697959.27558.python-list at python.org>...
> > Also [setgid] only accepts the gid, but I'd rather pass in
> > the group name, or somehow lookup the gid based on the name.
>
> See grp.getgrnam(). Example:
> >>> grp.getgrnam("utmp")
> ('utmp', 'x', 22, [])
>
> Jeff
More information about the Python-list
mailing list