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.

Author barry
Recipients barry, brett.cannon, ned.deily, ronaldoussoren
Date 2018-10-26.20:35:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1540586105.51.0.788709270274.issue35070@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, I've rebooted :)   I've modified your C program a little and here's the code and output.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main()
{
    gid_t grouplist[32];
    int n;
    int gidsetsize;

    for (gidsetsize = 0; gidsetsize < 22; ++gidsetsize) {
        n = getgroups(gidsetsize, grouplist);
        printf("calling grouplist with gidsetsize = %i, returns %i: ", gidsetsize, n);
        for (int j = 0; j < n; j++) {
            printf("%i ", grouplist[j]);
        }
        printf("\n");
    }
    exit(0);
}

calling grouplist with gidsetsize = 0, returns 15: -483891656 32766 -483891672 32766 -483891728 32766 427353334 1 -483891696 32766 0 0 0 0 -483891672 
calling grouplist with gidsetsize = 1, returns -1: 
calling grouplist with gidsetsize = 2, returns -1: 
calling grouplist with gidsetsize = 3, returns -1: 
calling grouplist with gidsetsize = 4, returns -1: 
calling grouplist with gidsetsize = 5, returns -1: 
calling grouplist with gidsetsize = 6, returns -1: 
calling grouplist with gidsetsize = 7, returns -1: 
calling grouplist with gidsetsize = 8, returns -1: 
calling grouplist with gidsetsize = 9, returns -1: 
calling grouplist with gidsetsize = 10, returns -1: 
calling grouplist with gidsetsize = 11, returns -1: 
calling grouplist with gidsetsize = 12, returns -1: 
calling grouplist with gidsetsize = 13, returns -1: 
calling grouplist with gidsetsize = 14, returns -1: 
calling grouplist with gidsetsize = 15, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 16, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 17, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 18, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 19, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 20, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 
calling grouplist with gidsetsize = 21, returns 15: 101 503 701 501 12 62 80 502 33 98 100 204 250 395 398 

% id -G
101 503 701 501 12 62 80 502 33 98 100 204 250 395 398

I've also made a small change to test_posix.py:

diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 86c04b9f32..5074b45fc0 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1047,8 +1047,9 @@ class PosixTester(unittest.TestCase):
         # groups, ignoring order, duplicates, and the effective gid.
         # #10822/#26944 - It is implementation defined whether
         # posix.getgroups() includes the effective gid.
-        symdiff = idg_groups.symmetric_difference(posix.getgroups())
-        self.assertTrue(not symdiff or symdiff == {posix.getegid()})
+        groups = posix.getgroups()
+        symdiff = idg_groups.symmetric_difference(groups)
+        self.assertTrue(not symdiff or symdiff == {posix.getegid()}, (idg_groups, groups, symdiff))
 
     # tests for the posix *at functions follow
 
But when I run ./python.exe -m test test.test_posix here's what I get:

Run tests sequentially
0:00:00 load avg: 1.62 [1/1] test.test_posix
test test.test_posix failed -- Traceback (most recent call last):
  File "/Users/bwarsaw/projects/python/cpython/Lib/test/test_posix.py", line 1052, in test_getgroups
    self.assertTrue(not symdiff or symdiff == {posix.getegid()}, (idg_groups, groups, symdiff))
AssertionError: False is not true : ({33, 98, 100, 101, 395, 12, 204, 398, 80, 501, 502, 503, 250, 701, 62}, [101], {33, 98, 100, 395, 12, 204, 398, 80, 501, 502, 503, 250, 701, 62})

So it seems like getgroups(2) is doing the right thing, but not Python.  Weird.
History
Date User Action Args
2018-10-26 20:35:05barrysetrecipients: + barry, brett.cannon, ronaldoussoren, ned.deily
2018-10-26 20:35:05barrysetmessageid: <1540586105.51.0.788709270274.issue35070@psf.upfronthosting.co.za>
2018-10-26 20:35:05barrylinkissue35070 messages
2018-10-26 20:35:05barrycreate