Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results #60865

Closed
gpshead opened this issue Dec 11, 2012 · 10 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@gpshead
Copy link
Member

gpshead commented Dec 11, 2012

BPO 16661
Nosy @gpshead, @pitrou, @ned-deily

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2012-12-16.14:03:08.184>
created_at = <Date 2012-12-11.03:46:15.914>
labels = ['type-bug', 'library']
title = 'test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results'
updated_at = <Date 2012-12-16.21:31:01.960>
user = 'https://github.com/gpshead'

bugs.python.org fields:

activity = <Date 2012-12-16.21:31:01.960>
actor = 'ned.deily'
assignee = 'rosslagerwall'
closed = True
closed_date = <Date 2012-12-16.14:03:08.184>
closer = 'rosslagerwall'
components = ['Library (Lib)']
creation = <Date 2012-12-11.03:46:15.914>
creator = 'gregory.p.smith'
dependencies = []
files = []
hgrepos = []
issue_num = 16661
keywords = []
message_count = 10.0
messages = ['177320', '177321', '177322', '177323', '177325', '177409', '177411', '177598', '177600', '177629']
nosy_count = 5.0
nosy_names = ['gregory.p.smith', 'pitrou', 'ned.deily', 'rosslagerwall', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue16661'
versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

@gpshead
Copy link
Member Author

gpshead commented Dec 11, 2012

test_posix.test_getgrouplist is failing for me on my Linux (ubuntu precise) based desktop at work.

It looks like posix.getgrouplist() is returning all of the larger GIDs. The lowest one it is reporting for my user is 499 but the more distro specific groups that I am are not included in its 18 element long list it returns so the test fails:

test test_posix failed -- Traceback (most recent call last):
  File "cpython/default/Lib/test/test_posix.py", line 660, in test_getgrouplist
    pwd.getpwuid(os.getuid())[3])))
AssertionError: Items in the first set but not the second:
128
4
104
44
46
20
24
25

strace reveals that the 'id -G' command this test is trying to compare against calls getgroups() while posix.getgrouplist() appears to do something else that does not make that syscall.

posix.getgroups() does the same thing as 'id -G', this test for posix.getgrouplist(username, uid) is making an incorrect assertion.

@gpshead gpshead added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 11, 2012
@rosslagerwall
Copy link
Mannequin

rosslagerwall mannequin commented Dec 11, 2012

It seems like getgrouplist returns the information from the system
database whereas getgroups (and consequently id -G) returns the
supplementary groups for the calling process.

I'm not exactly sure how getgrouplist() can be effectively tested then.

@rosslagerwall rosslagerwall mannequin changed the title test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results Dec 11, 2012
@gpshead
Copy link
Member Author

gpshead commented Dec 11, 2012

would the values returned by getgrouplist always be a non empty subset of
getgroups? (regardless, I expect the id -G process output parsing can be
removed)

@gpshead gpshead changed the title test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results test_posix.test_getgrouplist fails on some systems - incorrectly comparing getgroups and getgrouplist results Dec 11, 2012
@rosslagerwall
Copy link
Mannequin

rosslagerwall mannequin commented Dec 11, 2012

I wouldn't think so. A call to setgroups can add or remove groups for
the calling process. If it removes groups, then getgrouplist() won't
return a subset of getgroups().

@gpshead
Copy link
Member Author

gpshead commented Dec 11, 2012

Given this is more of a code coverage test than any need to test the
functionality of the OS library call, just asserting that it returns a
non-empty list is a decent test. :)

@python-dev
Copy link
Mannequin

python-dev mannequin commented Dec 13, 2012

New changeset ce85fe971e0a by Ross Lagerwall in branch '3.3':
Issue bpo-16661: Fix the os.getgrouplist() test by not assuming that it
http://hg.python.org/cpython/rev/ce85fe971e0a

New changeset 05a37954a30c by Ross Lagerwall in branch 'default':
Merge with 3.3 for bpo-16661
http://hg.python.org/cpython/rev/05a37954a30c

@rosslagerwall
Copy link
Mannequin

rosslagerwall mannequin commented Dec 13, 2012

Is that fixed now? I simplified the test to check for a non-empty list being returned.

@rosslagerwall rosslagerwall mannequin closed this as completed Dec 15, 2012
@rosslagerwall rosslagerwall mannequin self-assigned this Dec 15, 2012
@pitrou
Copy link
Member

pitrou commented Dec 16, 2012

Apparently this also needs fixing on 2.7 and 3.2, see e.g. http://buildbot.python.org/all/builders/AMD64%20Mountain%20Lion%20%5BSB%5D%203.2

@pitrou pitrou reopened this Dec 16, 2012
@rosslagerwall
Copy link
Mannequin

rosslagerwall mannequin commented Dec 16, 2012

getgrouplist() is new in 3.3. Those failures are from getgroups() failing. I'll open a separate issue for that.

@rosslagerwall rosslagerwall mannequin closed this as completed Dec 16, 2012
@ned-deily
Copy link
Member

The getgroups test failure on OS X is likely the known limitation documented in bpo-10433.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants