Skip to content

Commit

Permalink
小优化
Browse files Browse the repository at this point in the history
  • Loading branch information
jark006 committed Sep 27, 2024
1 parent 8a1feb4 commit 756cbf5
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions mypyftpdlib/authorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ def _check_permissions(self, username, perm):
if username == 'anonymous' and \
p in self.write_perms and not \
warned:
warnings.warn("write permissions assigned to anonymous user.",
RuntimeWarning, stacklevel=2)
print("\n警告:当前允许【匿名用户】登录,且拥有【写入、修改】文件权限,请谨慎对待。\n建议给匿名方式选择【只读】权限。\n")
warned = 1

def _issubpath(self, a, b):
Expand Down Expand Up @@ -451,8 +450,6 @@ def get_home_dir(self, username):
except KeyError:
raise AuthorizerError(self.msg_no_such_user)
else:
if not PY3:
home = home.decode('utf8')
return home

@staticmethod
Expand Down Expand Up @@ -646,10 +643,7 @@ def _has_valid_shell(username):
except ImportError:
pass
else: # pragma: no cover
if PY3:
import winreg
else:
import _winreg as winreg
import winreg

__all__.extend(['BaseWindowsAuthorizer', 'WindowsAuthorizer'])

Expand Down Expand Up @@ -718,8 +712,6 @@ def get_home_dir(self, username):
"No profile directory defined for user %s" % username)
value = winreg.QueryValueEx(key, "ProfileImagePath")[0]
home = win32api.ExpandEnvironmentStrings(value)
if not PY3 and not isinstance(home, unicode):
home = home.decode('utf8')
return home

@classmethod
Expand Down Expand Up @@ -875,6 +867,4 @@ def get_home_dir(self, username):
home = overridden_home
else:
home = BaseWindowsAuthorizer.get_home_dir(self, username)
if not PY3 and not isinstance(home, unicode):
home = home.decode('utf8')
return home

0 comments on commit 756cbf5

Please sign in to comment.