diff options
author | Guido van Rossum <guido@python.org> | 1995-06-21 01:00:17 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-06-21 01:00:17 (GMT) |
commit | 45babef8c28f7756bc751bda0f261fc68a7b1e18 (patch) | |
tree | 7d392dd78c21635871d101603a40fe7ae623e995 /Demo/pdist/server.py | |
parent | 37a291180c7340f6e748ea3584beb5b8023fa2e7 (diff) | |
download | cpython-45babef8c28f7756bc751bda0f261fc68a7b1e18.zip cpython-45babef8c28f7756bc751bda0f261fc68a7b1e18.tar.gz cpython-45babef8c28f7756bc751bda0f261fc68a7b1e18.tar.bz2 |
security stuff added
Diffstat (limited to 'Demo/pdist/server.py')
-rwxr-xr-x | Demo/pdist/server.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Demo/pdist/server.py b/Demo/pdist/server.py index c8acf19..4efb180 100755 --- a/Demo/pdist/server.py +++ b/Demo/pdist/server.py @@ -109,3 +109,36 @@ class Server: basenames = filter(lambda x, names=names: x not in names, basenames) names[len(names):] = basenames return names + + +from security import Security + + +class SecureServer(Server, Security): + + def __init__(self, *args): + apply(Server.__init__, (self,) + args) + Security.__init__(self) + + def _verify(self, conn, address): + challenge = self._generate_challenge() + conn.send("%d\n" % challenge) + response = "" + while "\n" not in response and len(response) < 100: + data = conn.recv(100) + if not data: + break + response = response + data + try: + response = string.atol(string.strip(response)) + except string.atol_error: + if self._verbose > 0: + print "Invalid response syntax", `response` + return 0 + if not self._compare_challenge_response(challenge, response): + if self._verbose > 0: + print "Invalid response value", `response` + return 0 + if self._verbose > 1: + print "Response matches challenge. Go ahead!" + return 1 |