Changing UNIX primary group

Justin Johnson justinjohnson at fastmail.fm
Wed Aug 13 14:10:02 EDT 2003


Thanks.  I was hoping for a python solution though.  :-(  Does anyone
know of a way to do this in python?

On 13 Aug 2003 08:52:40 -0700, "Inyeol Lee" <Inyeol_lee at yahoo.com> said:
> "Justin Johnson" <justinjohnson at fastmail.fm> wrote in message
> news:<mailman.1060697959.27558.python-list at python.org>...
> > I have a unix id that has group1 for a primary group, and group2, group3,
> > and group4 for supplementary groups.  I'd like to change my primary group
> > before running certain commands.  So sometimes I might want group2 to be
> > the primary group, and other times group3 or group4.
> > 
> > I saw the posix module's setgid method, but it failed for me unless I was
> > running as root.  Also it only accepts the gid, but I'd rather pass in
> > the group name, or somehow lookup the gid based on the name.
> > 
> > Does anyone know a way to do all of this?
> > Thanks much.
> > -Justin
> 
> These are not python solution;
> 
> 1) make a setgid script and put your commands there, or
> 2) use shell commands;
> 
>    echo "command1; command2;" | newgrp group2
> 
> -Inyeol
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list