test_mkdir_permissions and test_sftp_server_modes depend break when setgid option set on a parent directory

Bug #109124 reported by Jonathan Lange
4
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Low
Unassigned

Bug Description

test_transport_implementations.TransportTests.test_mkdir_permissions and test_permissions.TestSftpPermissions.test_sftp_server_modes fail if they are run beneath a directory with the setgid bit set.

e.g.

jml@rhino:~/Code/Bazaar/bzr.dev$ chmod g+s .
jml@rhino:~/Code/Bazaar/bzr.dev$ ./bzr selftest test_permissions\|test_transport_implementations
       bzr: /home/jml/Code/Bazaar/bzr.dev/bzr
    bzrlib: /home/jml/Code/Bazaar/bzr.dev/bzrlib

/var/lib/python-support/python2.5/paramiko/message.py:226: DeprecationWarning: integer argument expected, got float
  self.packet.write(struct.pack('>I', n))
FAIL: test_permissions.TestSftpPermissions.test_sftp_server_modes
    mode of 'c' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

FAIL: test_transport_implementations.TransportTests.test_mkdir_permissions(LocalURLServer)
    mode of 'dnomode' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

FAIL: test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPAbsoluteServer)
    mode of 'dnomode' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

FAIL: test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPHomeDirServer)
    mode of 'dnomode' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

FAIL: test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPSiblingAbsoluteServer)
    mode of 'dnomode' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

[764/764 in 43s, 5 failed, 16 skipped] branch_implementations.test_permissions.TestPermissions.test_new_branch(RemoteBranchFormat)
======================================================================
FAIL: test_sftp_server_modes (bzrlib.tests.test_permissions.TestSftpPermissions)

vvvv[log from bzrlib.tests.test_permissions.TestSftpPermissions.test_sftp_server_modes]

^^^^[log from bzrlib.tests.test_permissions.TestSftpPermissions.test_sftp_server_modes]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/test_permissions.py", line 286, in test_sftp_server_modes
    self.assertTransportMode(t, 'c', 0777 &~umask)
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 922, in assertTransportMode
    'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 807, in assertEqual
    pformat(a, indent=4), pformat(b, indent=4)))
AssertionError: mode of 'c' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

======================================================================
FAIL: test_mkdir_permissions (bzrlib.tests.test_transport_implementations.TransportTests)

vvvv[log from bzrlib.tests.test_transport_implementations.TransportTests.test_mkdir_permissions(LocalURLServer)]

^^^^[log from bzrlib.tests.test_transport_implementations.TransportTests.test_mkdir_permissions(LocalURLServer)]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/test_transport_implementations.py", line 528, in test_mkdir_permissions
    self.assertTransportMode(t, 'dnomode', 0777 & ~umask)
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 922, in assertTransportMode
    'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 807, in assertEqual
    pformat(a, indent=4), pformat(b, indent=4)))
AssertionError: mode of 'dnomode' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

======================================================================
FAIL: test_mkdir_permissions (bzrlib.tests.test_transport_implementations.TransportTests)

vvvv[log from bzrlib.tests.test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPAbsoluteServer)]

^^^^[log from bzrlib.tests.test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPAbsoluteServer)]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/test_transport_implementations.py", line 528, in test_mkdir_permissions
    self.assertTransportMode(t, 'dnomode', 0777 & ~umask)
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 922, in assertTransportMode
    'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 807, in assertEqual
    pformat(a, indent=4), pformat(b, indent=4)))
AssertionError: mode of 'dnomode' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

======================================================================
FAIL: test_mkdir_permissions (bzrlib.tests.test_transport_implementations.TransportTests)

vvvv[log from bzrlib.tests.test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPHomeDirServer)]

^^^^[log from bzrlib.tests.test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPHomeDirServer)]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/test_transport_implementations.py", line 528, in test_mkdir_permissions
    self.assertTransportMode(t, 'dnomode', 0777 & ~umask)
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 922, in assertTransportMode
    'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 807, in assertEqual
    pformat(a, indent=4), pformat(b, indent=4)))
AssertionError: mode of 'dnomode' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

======================================================================
FAIL: test_mkdir_permissions (bzrlib.tests.test_transport_implementations.TransportTests)

vvvv[log from bzrlib.tests.test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPSiblingAbsoluteServer)]

^^^^[log from bzrlib.tests.test_transport_implementations.TransportTests.test_mkdir_permissions(SFTPSiblingAbsoluteServer)]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/test_transport_implementations.py", line 528, in test_mkdir_permissions
    self.assertTransportMode(t, 'dnomode', 0777 & ~umask)
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 922, in assertTransportMode
    'mode of %r incorrect (%o != %o)' % (path, mode, actual_mode))
  File "/home/jml/Code/Bazaar/bzr.dev/bzrlib/tests/__init__.py", line 807, in assertEqual
    pformat(a, indent=4), pformat(b, indent=4)))
AssertionError: mode of 'dnomode' incorrect (755 != 2755)
not equal:
a = 493
b = 1517

----------------------------------------------------------------------
Ran 764 tests in 43.776s

FAILED (failures=5)
16 tests skipped
tests failed

Kent Gibson (warthog618)
Changed in bzr:
status: Unconfirmed → Confirmed
Revision history for this message
Martin Pool (mbp) wrote :

Still happening in 0.92dev:

mbp@grace% mkdir /tmp/d
mbp@grace% chmod g+s /tmp/d
mbp@grace% TMPDIR=/tmp/d ./bzr selftest test_mkdir_perm
testing: /home/mbp/bzr/test-cleanup/bzr
   /home/mbp/bzr/test-cleanup/bzrlib (0.92.0dev0 python2.5.1.final.0)

Changed in bzr:
importance: Undecided → Medium
status: Confirmed → Triaged
Revision history for this message
Vincent Ladeuil (vila) wrote :

On a related note, these tests also fail on OSX because /tmp is in group 'wheel', i.e. the user running the test can't change the group permissions.

Revision history for this message
Ali Polatel (hawking) wrote :

I wrote a patch for bzrlib.tests.TestCase.assertTransportMode to test whether
actual_mode is setgid before calling assertEqual.
Not sure if this is the best solution though...

Martin Pool (mbp)
Changed in bzr:
status: Triaged → Confirmed
Revision history for this message
Robert Collins (lifeless) wrote :

@vila, @poolie is this still happening?

Revision history for this message
Martin Pool (mbp) wrote :

I suspect this dates from a time when we put the test temp files in . rather than $TMPDIR. It's much less likely that /tmp will be setgid. It's possible you have TMPDIR=~/tmp and you might hit this but it can wait until someone hits it again.

Changed in bzr:
importance: Medium → Low
Revision history for this message
Vincent Ladeuil (vila) wrote :

As poolie said: using TMPDIR should help reproduce the problem.

I won't look into it but I fixed OSX issues since then so it may have been fixed.
We'll know better when we'll have a OSX slave back into babune, which I intend to do as soon as we get the test suite passing on windows.

Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.