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.

classification
Title: PosixGroupsTester fails as root
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nobody Nosy List: belopolsky, exarkun, nobody, pitrou, quiver, ronaldoussoren
Priority: normal Keywords: patch

Created on 2010-08-12 20:47 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
2.6.diff quiver, 2010-08-13 06:42 fix for 2.6 branch
test_setgroups.diff quiver, 2010-08-13 14:21 fix for 2.7 test_setgroups
py3k.diff quiver, 2010-08-13 14:26 fix for py3k branch(test_initgroups/test_setgroups)
Messages (7)
msg113705 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-12 20:47
I get the following test_posix failures when run as root (Mandriva Linux):

======================================================================
ERROR: test_initgroups (test.test_posix.PosixGroupsTester)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/py3k/__svn__/Lib/test/test_posix.py", line 418, in test_initgroups
    g = g2 + 1
UnboundLocalError: local variable 'g2' referenced before assignment

======================================================================
FAIL: test_setgroups (test.test_posix.PosixGroupsTester)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/py3k/__svn__/Lib/test/test_posix.py", line 428, in test_setgroups
    self.assertListEqual(groups, posix.getgroups())
AssertionError: First sequence is not a list: range(0, 16)


Under 2.6, there's another failure:

======================================================================
ERROR: test_setgroups (test.test_posix.PosixGroupsTester)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/cpython/26/Lib/test/test_posix.py", line 356, in test_setgroups
    self.assertListEqual(groups, posix.getgroups())
AttributeError: 'PosixGroupsTester' object has no attribute 'assertListEqual'
msg113744 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-08-13 05:55
I won't have time to look at this until sunday.

Alexander Belopolsky wrote these patch tests. Alexanders: do you have time to look into this?
msg113745 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2010-08-13 06:42
> Under 2.6, there's another failure:
As for 2.6/2.7 issues, changing 'assertListEqual' to 'assertEqual' should suffice.
msg113774 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2010-08-13 13:50
test_initgroups fails only if the test is invoked by a root and
the user is assigned to only one group.

If I understand test_initgroups correctly, it
(1)looks for an unused gid,
(2)inits process user's group with that gid,
(3)checks if initgroups worked.

Attached patch simplifies step #1
"max(self.saved_groups) + 1" is used.

test_initgroups passed when root's groups are as follows::
* [0]
* [0, 3, 5]
* [0, 1, 2]
msg113778 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2010-08-13 14:25
> FAIL: test_setgroups (test.test_posix.PosixGroupsTester)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/home/antoine/py3k/__svn__/Lib/test/test_posix.py", line 428, in test_setgroups
>     self.assertListEqual(groups, posix.getgroups())
> AssertionError: First sequence is not a list: range(0, 16)

This one is just a list/range data type issue.

patch for test_initgroups/test_setgroups against py3k attached
msg113782 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-13 15:05
George's patches work for me (thank you!).
msg115591 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-04 17:34
I've committed modified patches for 3.x, 3.1 and 2.7. Thanks again George.
History
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53790
2010-09-04 17:34:42pitrousetstatus: open -> closed

assignee: ronaldoussoren -> nobody
versions: - Python 2.6
nosy: + nobody

messages: + msg115591
resolution: fixed
stage: needs patch -> resolved
2010-08-13 15:05:01pitrousetmessages: + msg113782
2010-08-13 14:26:39quiversetfiles: + py3k.diff
2010-08-13 14:25:40quiversetmessages: + msg113778
2010-08-13 14:21:17quiversetfiles: + test_setgroups.diff
2010-08-13 14:20:47quiversetfiles: - test_setgroups.diff
2010-08-13 13:50:13quiversetfiles: + test_setgroups.diff

messages: + msg113774
2010-08-13 06:42:21quiversetfiles: + 2.6.diff

nosy: + quiver
messages: + msg113745

keywords: + patch
2010-08-13 05:55:13ronaldoussorensetnosy: + belopolsky
messages: + msg113744
2010-08-12 20:47:20pitroucreate