Alexander Belopolsky <alexander.belopol...@gmail.com> added the comment:
After some head-scratching, I figured out how to reproduce stock python2.5 behavior. It turns out that defining _DARWIN_C_SOURCE not only allows getgroups() output to exceed NGROUPS_MAX (as documented), but also effectively disables setgroups() which is not documented. With no-darwin-ext.diff patch and previously attached tg.py, I see $ cat tg.py import os g = os.getgroups() print(g) os.setgroups(g[:5]) print(os.getgroups()) $ sudo ./python.exe tg.py [0, 101, 204, 100, 98, 80, 61, 29, 20, 12, 9, 8, 5, 4, 3, 2] [0, 101, 204, 100, 98] which is the same as with stock python2.5: $ sudo python2.5 tg.py [0, 101, 204, 100, 98, 80, 61, 29, 20, 12, 9, 8, 5, 4, 3, 2] [0, 101, 204, 100, 98] Note that root is a member of 18 groups on my system, but the last two are truncated by os.getgroups(). It is tempting to adopt no-darwin-ext.diff as a solution to this issue because allowing more than NGROUPS_MAX (or sysconf(_SC_NGROUPS_MAX) which should be the same) groups is really a Mac OS bug. In order to have both working os.setgroups() and os.getgroups() supporting more than NGROUPS_MAX results, it appears that the two functions should be compiled in separate compilation units which is probably too big of a price to pay for the functionality. Also, my issue7900.diff, while likely to work in most practical situation is vulnerable to a race condition if group membership is expanded between two calls to getgroups. ---------- Added file: http://bugs.python.org/file16326/no-darwin-ext.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7900> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com