Skip to content

Commit

Permalink
add type hints
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@23915 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 24, 2019
1 parent 745dc6e commit 5e72314
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/xpra/server/auth/file_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

class Authenticator(FileAuthenticatorBase):

def authenticate_hmac(self, challenge_response, client_salt=None):
def authenticate_hmac(self, challenge_response, client_salt=None) -> bool:
log("file_auth.authenticate_hmac(%r, %r)", challenge_response, client_salt)
if not self.salt:
log.error("Error: illegal challenge response received - salt cleared or unset")
return None
Expand Down
13 changes: 7 additions & 6 deletions src/xpra/server/auth/sys_auth_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
DEFAULT_GID = os.environ.get("XPRA_AUTHENTICATION_DEFAULT_GID", "nobody")


def parse_uid(v):
def parse_uid(v) -> int:
if v:
try:
return int(v)
Expand All @@ -35,7 +35,7 @@ def parse_uid(v):
return os.getuid()
return -1

def parse_gid(v):
def parse_gid(v) -> int:
if v:
try:
return int(v)
Expand Down Expand Up @@ -71,10 +71,10 @@ def __init__(self, username, **kwargs):
log.warn("Warning: unused keyword arguments for %s authentication:", self)
log.warn(" %s", unused)

def get_uid(self):
def get_uid(self) -> int:
raise NotImplementedError()

def get_gid(self):
def get_gid(self) -> int:
raise NotImplementedError()

def requires_challenge(self):
Expand Down Expand Up @@ -146,6 +146,7 @@ def authenticate_check(self, challenge_response, client_salt=None) -> bool:
return ret

def authenticate_hmac(self, challenge_response, client_salt=None) -> bool:
log("sys_auth_base.authenticate_hmac(%r, %r)", challenge_response, client_salt)
if not self.salt:
log.error("Error: illegal challenge response received - salt cleared or unset")
return None
Expand Down Expand Up @@ -199,12 +200,12 @@ def __init__(self, username, **kwargs):
except Exception:
log("cannot load password database entry for '%s'", username, exc_info=True)

def get_uid(self):
def get_uid(self) -> int:
if self.pw is None:
raise Exception("username '%s' not found" % self.username)
return self.pw.pw_uid

def get_gid(self):
def get_gid(self) -> int:
if self.pw is None:
raise Exception("username '%s' not found" % self.username)
return self.pw.pw_gid

0 comments on commit 5e72314

Please sign in to comment.