This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Unsupported provider

classification
Title: please add posix.getgrouplist()
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rosslagerwall Nosy List: belopolsky, giampaolo.rodola, nvetoshkin, pitrou, python-dev, r.david.murray, ronaldoussoren, rosslagerwall
Priority: low Keywords: easy, patch

Created on 2010-07-23 13:10 by ronaldoussoren, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
9344.patch rosslagerwall, 2010-12-12 10:41 patch to implement getgrouplist for py3k against r87178 review
9344_v2.patch rosslagerwall, 2011-01-04 05:19 Updated patch review
Messages (16)
msg111309 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-07-23 13:10
A number of unix systems expose a getgroupslist function to fetch the groups that a user is a member of. It would be nice if that function were exposed to python.

See issue7900 for more information on why that would be useful.
msg118791 - (view) Author: Vetoshkin Nikita (nvetoshkin) Date: 2010-10-15 16:08
Did a bit of digging and found that getgrouplist signature differs on (at least) Linux and Mac OS:
 - http://www.kernel.org/doc/man-pages/online/pages/man3/getgrouplist.3.html
 -http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/getgrouplist.3.html
msg119062 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-10-18 18:50
I don't see how this difference is relevant for exposing the functionality in python:

Linux:

int getgrouplist(const char *user, gid_t group,
                        gid_t *groups, int *ngroups);

MacOS:

int
     getgrouplist(const char *name, int basegid, int *groups, int *ngroups);

The only difference is that Linux uses gid_t and MacOS uses int.  The requested posix.getgrouplist() will take a python string and a python integer and return a list of integers.
msg119065 - (view) Author: Vetoshkin Nikita (nvetoshkin) Date: 2010-10-18 18:57
@Alexander, it was just a note, that implementation in posixmodule.c won't be the same across all flavours of Unix :)
msg123834 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2010-12-12 10:41
Attached is a patch (against the latest revision, 87178) which adds the functionality to the posix module as well as adds a testcase for it.

I haven't added it to the os module, I'm not sure if that should be done.

I tested it on Linux & FreeBSD and it works as expected. Since I don't have an OS X system, I could not test it on there.
msg125293 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2011-01-04 05:19
A slightly updated patch. Targeting for 3.3.
msg125304 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-01-04 11:09
I can't say anything about the functionality, but the patch looks good to me (works under Linux and Solaris - the latter missing getgrouplist()).
msg130927 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-03-14 23:11
Patch looks good, but this likely runs into the same problem as #7900: the user can be a member of more than NGROUPS_MAX on OSX.

I'll test this tomorrow (by creating a temporary user that is a member of more than 16 groups).
msg132021 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2011-03-24 19:20
Looks good to me as well.  Just a nit-pick: in python code base "sizeof" is not separated from the opening parenthesis.  I understand the desire to distinguish "sizeof" from a function, but it is probably better to be consistent.
msg132022 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2011-03-24 19:23
Ronald, does it have the same problem as #7900 on OS X or can I commit?
msg138028 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2011-06-09 20:55
I haven't tested yet, but feel free to commit and I'll fix any OSX issues later.
msg138049 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-06-10 05:33
New changeset 9ebee3211be9 by Ross Lagerwall in branch 'default':
Issue #9344: Add os.getgrouplist().
http://hg.python.org/cpython/rev/9ebee3211be9
msg138051 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2011-06-10 05:59
Thanks!
msg138103 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-06-10 16:21
Nit: when a patch gets committed and the issue closed, the preferred resolution is "fixed" ;)
(see http://docs.python.org/devguide/triaging.html#resolution)
msg138105 - (view) Author: Ross Lagerwall (rosslagerwall) (Python committer) Date: 2011-06-10 16:24
> Nit: when a patch gets committed and the issue closed, the preferred
> resolution is "fixed" ;)
> (see http://docs.python.org/devguide/triaging.html#resolution)

Sure, I will try remember that.
msg138476 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-06-16 22:59
Actually, when it is a feature request rather than a bug fix we usually use 'accepted'.  It doesn't matter a whole lot, though.
History
Date User Action Args
2022-04-11 14:57:04adminsetgithub: 53590
2011-06-16 22:59:08r.david.murraysetnosy: + r.david.murray
messages: + msg138476
2011-06-10 16:24:12rosslagerwallsetmessages: + msg138105
2011-06-10 16:21:32pitrousetresolution: accepted -> fixed
messages: + msg138103
2011-06-10 05:59:50rosslagerwallsetstatus: open -> closed
resolution: accepted
messages: + msg138051

stage: commit review -> resolved
2011-06-10 05:33:18python-devsetnosy: + python-dev
messages: + msg138049
2011-06-09 20:55:34ronaldoussorensetmessages: + msg138028
2011-03-24 19:23:23rosslagerwallsetmessages: + msg132022
2011-03-24 19:20:35belopolskysetassignee: belopolsky -> rosslagerwall
messages: + msg132021
2011-03-14 23:11:13ronaldoussorensetnosy: ronaldoussoren, belopolsky, pitrou, giampaolo.rodola, nvetoshkin, rosslagerwall
messages: + msg130927
2011-01-17 13:36:32giampaolo.rodolasetnosy: + giampaolo.rodola
2011-01-04 11:09:19pitrousetnosy: + pitrou

messages: + msg125304
stage: needs patch -> commit review
2011-01-04 05:19:35rosslagerwallsetfiles: + 9344_v2.patch

versions: + Python 3.3, - Python 3.2
messages: + msg125293
nosy: ronaldoussoren, belopolsky, nvetoshkin, rosslagerwall
2010-12-12 10:41:02rosslagerwallsetfiles: + 9344.patch

nosy: + rosslagerwall
messages: + msg123834

keywords: + patch
2010-10-18 18:57:41nvetoshkinsetmessages: + msg119065
2010-10-18 18:50:44belopolskysetmessages: + msg119062
2010-10-15 16:08:38nvetoshkinsetnosy: + nvetoshkin
messages: + msg118791
2010-07-23 15:45:08belopolskysetassignee: belopolsky
type: enhancement
components: + Extension Modules
stage: needs patch
2010-07-23 13:11:21ronaldoussorensetnosy: + belopolsky
2010-07-23 13:10:56ronaldoussorencreate