Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fba807a

Browse files
author
Charles-François Natali
committed
Issue #5113: Fix a test_posix failure on HP-UX, where non-root users can
chown() to root under certain circumstances.
2 parents c8ce715 + ab2d58e commit fba807a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Lib/test/test_posix.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import time
1111
import os
1212
import fcntl
13+
import platform
1314
import pwd
1415
import shutil
1516
import stat
@@ -390,6 +391,9 @@ def test_mknod(self):
390391

391392
def _test_all_chown_common(self, chown_func, first_param):
392393
"""Common code for chown, fchown and lchown tests."""
394+
# test a successful chown call
395+
chown_func(first_param, os.getuid(), os.getgid())
396+
393397
if os.getuid() == 0:
394398
try:
395399
# Many linux distros have a nfsnobody user as MAX_UID-2
@@ -401,12 +405,15 @@ def _test_all_chown_common(self, chown_func, first_param):
401405
chown_func(first_param, ent.pw_uid, ent.pw_gid)
402406
except KeyError:
403407
pass
408+
elif platform.system() in ('HP-UX', 'SunOS'):
409+
# HP-UX and Solaris can allow a non-root user to chown() to root
410+
# (issue #5113)
411+
raise unittest.SkipTest("Skipping because of non-standard chown() "
412+
"behavior")
404413
else:
405414
# non-root cannot chown to root, raises OSError
406415
self.assertRaises(OSError, chown_func,
407416
first_param, 0, 0)
408-
# test a successful chown call
409-
chown_func(first_param, os.getuid(), os.getgid())
410417

411418
@unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()")
412419
def test_chown(self):

0 commit comments

Comments
 (0)