@@ -3205,7 +3205,11 @@ def root_is_uid_gid_0():
32053205 import pwd , grp
32063206 except ImportError :
32073207 return False
3208- if pwd .getpwuid (0 )[0 ] != 'root' :
3208+ try :
3209+ if pwd .getpwuid (0 )[0 ] != 'root' :
3210+ return False
3211+ except KeyError :
3212+ # On Cygwin, there is no root user (uid 0)
32093213 return False
32103214 if grp .getgrgid (0 )[0 ] != 'root' :
32113215 return False
@@ -3985,6 +3989,9 @@ def test_realpath_limit_attack(self):
39853989 check_flag = False )):
39863990 if sys .platform == 'win32' :
39873991 self .expect_exception ((FileNotFoundError , FileExistsError ))
3992+ elif sys .platform == 'cygwin' :
3993+ exc = self .expect_exception (OSError )
3994+ self .assertEqual (exc .errno , errno .ELOOP )
39883995 elif self .raised_exception :
39893996 # Cannot symlink/hardlink: tarfile falls back to getmember()
39903997 self .expect_exception (KeyError )
@@ -4006,7 +4013,8 @@ def test_realpath_limit_attack(self):
40064013 # 206: ERROR_FILENAME_EXCED_RANGE
40074014 self .assertIn (exc .winerror , (3 , 5 , 206 ))
40084015 else :
4009- self .assertEqual (exc .errno , errno .ENAMETOOLONG )
4016+ self .assertIn (exc .errno ,
4017+ (errno .ENAMETOOLONG , errno .ELOOP ))
40104018
40114019 @symlink_test
40124020 def test_parent_symlink2 (self ):
0 commit comments