[MERGE] OSX's mkdtemp assigns wrong group by default

Vincent Ladeuil v.ladeuil+lp at free.fr
Sun Aug 31 18:40:27 BST 2008


>>>>> "john" == John Arbash Meinel <john at arbash-meinel.com> writes:

    john> Vincent Ladeuil wrote:
    >> This patch fixes the TestPermissions tests failing under OSX.
    >> 
    >> The root cause is that OSX create temporary directories assigned
    >> to the 'wheel' group and the tests want to set the group sticky
    >> bit. The user running the tests is not a 'wheel' member and
    >> cannot do that.
    >> 
    >> The fix introduces a dedicated osutils._mac_mkdtemp that set a
    >> correct group and makes it the osutils.mkdtemp when run under
    >> OSX.
    >> 
    >> It also fixes all direct calls to tempfile.mkdtemp to
    >> osutils.mkdtemp
    >> 
    >> An alternative approach will be to skip the permissions tests on
    >> OSX since bzr itself doesn't directly care about group owner
    >> (outside of the failing tests).
    >> 
    >> Vincent & Guillermo
    >> 
    >> 

    john> It is *good* to switch everything over to osutils.mkdtemp() since we really
    john> need that for Windows anyway. I don't know that we need to create a custom
    john> function just for that one test.

    john> Why not just modify the test to do:

    john> dir = mkdtemp()
    john> if sys.platform == 'darwin':
    john>   # OS X creates temp dirs with the 'wheel' group, which users are not likely
    john>   # to be in, and this prevents us from setting the sgid bit
    john>   os.chown(dir, os.getuid(), os.getgid())

Conditional logic in tests ? >-/ 

    john> I would certainly be more comfortable modifying the one
    john> test that needs group, rather than everytime someone
    john> creates a temp dir.

But then we risk writing tests suffering from the same problem.

    john> (I *would* like to test the sgid bit, as it has effects
    john> when you to chmod 2775 .bzr, to make sure that the
    john> subdirs created also have setgid.)

I agree with that and with the discomfort about chown-ing every
test dir, but I think conditional logic in tests is even worse.

I need to think more about it.

     Vincent



More information about the bazaar mailing list