Coverage for /home/antoine/projects/xpra-git/dist/python3/lib64/python/xpra/client/auth/file_handler.py : 85%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of Xpra.
2# Copyright (C) 2019-2020 Antoine Martin <antoine@xpra.org>
3# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
4# later version. See the file COPYING for details.
6import os
8from xpra.os_util import load_binary_file
9from xpra.log import Logger
11log = Logger("auth")
13class Handler:
15 def __init__(self, client, **kwargs):
16 self.client = client
17 self.password_file = kwargs.get("filename", None)
18 if not self.password_file:
19 if client.password_file:
20 self.password_file = client.password_file[0]
21 client.password_file = client.password_file[1:]
23 def __repr__(self):
24 return "file"
26 def get_digest(self) -> str:
27 return None
29 def handle(self, packet) -> bool:
30 log("handle(..) password_file=%s", self.password_file)
31 if not self.password_file:
32 return False
33 filename = os.path.expanduser(self.password_file)
34 data = load_binary_file(filename)
35 log("loaded password data from %s: %s", filename, bool(data))
36 if not data:
37 return False
38 self.client.send_challenge_reply(packet, data)
39 return True