mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
adjust setattr expectations when run as root
Summary: Rather than EPERM we get EACCESS when running as root Reviewed By: chadaustin Differential Revision: D6853303 fbshipit-source-id: c6743c8d036a24255d2d31c560034c972a0253c7
This commit is contained in:
parent
f82026e4fb
commit
7ab70a5493
@ -39,24 +39,25 @@ class SetAttrTest:
|
||||
filename = os.path.join(self.mount, 'hello')
|
||||
|
||||
# Chown should fail with EPERM unless we are setting it
|
||||
# to the same current ownership
|
||||
# to the same current ownership.
|
||||
# If we're running as root, this is EACCES instead.
|
||||
st = os.lstat(filename)
|
||||
os.chown(filename, st.st_uid, st.st_gid)
|
||||
|
||||
with self.assertRaises(OSError) as context:
|
||||
os.chown(filename, st.st_uid + 1, st.st_gid)
|
||||
self.assertEqual(
|
||||
errno.EPERM,
|
||||
errno.EACCES if os.geteuid() == 0 else errno.EPERM,
|
||||
context.exception.errno,
|
||||
msg="changing uid of a file should raise EPERM"
|
||||
msg="changing uid of a file should raise EPERM/EACCES"
|
||||
)
|
||||
|
||||
with self.assertRaises(OSError) as context:
|
||||
os.chown(filename, st.st_uid, st.st_gid + 1)
|
||||
self.assertEqual(
|
||||
errno.EPERM,
|
||||
errno.EACCES if os.geteuid() == 0 else errno.EPERM,
|
||||
context.exception.errno,
|
||||
msg="changing gid of a file should raise EPERM"
|
||||
msg="changing gid of a file should raise EPERM/EACCES"
|
||||
)
|
||||
|
||||
def test_truncate(self):
|
||||
|
Loading…
Reference in New Issue
Block a user