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 vstinner
Recipients vstinner
Date 2019-06-25.11:07:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561460829.65.0.100916954906.issue37400@roundup.psfhosted.org>
In-reply-to
Content
https://buildbot.python.org/all/#/builders/167/builds/1265

test_chown (test.test_os.ChownFileTests) ... ERROR

======================================================================
ERROR: test_chown (test.test_os.ChownFileTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_os.py", line 1327, in test_chown
    os.chown(support.TESTFN, uid, gid_1)
PermissionError: [Errno 1] Operation not permitted: '@test_95158_tmp'

Extract of the test:

    import grp
    groups = [g.gr_gid for g in grp.getgrall() if getpass.getuser() in g.gr_mem]
    if hasattr(os, 'getgid'):
        process_gid = os.getgid()
        if process_gid not in groups:
            groups.append(process_gid)

    @unittest.skipUnless(len(groups) > 1, "test needs more than one group")
    def test_chown(self):
        gid_1, gid_2 = groups[:2]
        uid = os.stat(support.TESTFN).st_uid
        os.chown(support.TESTFN, uid, gid_1)  # <======== FAIL HERE
        gid = os.stat(support.TESTFN).st_gid
        self.assertEqual(gid, gid_1)
        os.chown(support.TESTFN, uid, gid_2)
        gid = os.stat(support.TESTFN).st_gid
        self.assertEqual(gid, gid_2)

Extract of test.pythoninfo:

os.uid: 1002
os.umask: 077
os.gid: 1002
os.groups: 1002


I'm not sure that the code to manually get groups from grp.getgrall() is correct. Why not relying on the *current* groups, os.getgroups()?

Note: there is also os.getgrouplist(), I'm not sure of the difference between os.getgroups() and os.getgrouplist(). I know that os.getgrouplist() was modified recently to use:

    /*
     * NGROUPS_MAX is defined by POSIX.1 as the maximum
     * number of supplimental groups a users can belong to.
     * We have to increment it by one because
     * getgrouplist() returns both the supplemental groups
     * and the primary group, i.e. all of the groups the
     * user belongs to.
     */
    ngroups = 1 + MAX_GROUPS;
History
Date User Action Args
2019-06-25 11:07:09vstinnersetrecipients: + vstinner
2019-06-25 11:07:09vstinnersetmessageid: <1561460829.65.0.100916954906.issue37400@roundup.psfhosted.org>
2019-06-25 11:07:09vstinnerlinkissue37400 messages
2019-06-25 11:07:09vstinnercreate