mirror of https://github.com/python/cpython
bugfixes
This commit is contained in:
parent
d1972af22a
commit
541df3e99e
|
@ -16,6 +16,10 @@ class Client:
|
||||||
"""RPC Client class. No need to derive a class -- it's fully generic."""
|
"""RPC Client class. No need to derive a class -- it's fully generic."""
|
||||||
|
|
||||||
def __init__(self, address, verbose = VERBOSE):
|
def __init__(self, address, verbose = VERBOSE):
|
||||||
|
self._pre_init(address, verbose)
|
||||||
|
self._post_init()
|
||||||
|
|
||||||
|
def _pre_init(self, address, verbose = VERBOSE):
|
||||||
if type(address) == type(0):
|
if type(address) == type(0):
|
||||||
address = ('', address)
|
address = ('', address)
|
||||||
self._address = address
|
self._address = address
|
||||||
|
@ -29,6 +33,8 @@ class Client:
|
||||||
self._replies = {} # Unprocessed replies
|
self._replies = {} # Unprocessed replies
|
||||||
self._rf = self._socket.makefile('r')
|
self._rf = self._socket.makefile('r')
|
||||||
self._wf = self._socket.makefile('w')
|
self._wf = self._socket.makefile('w')
|
||||||
|
|
||||||
|
def _post_init(self):
|
||||||
self._methods = self._call('.methods')
|
self._methods = self._call('.methods')
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
@ -127,15 +133,16 @@ class SecureClient(Client, Security):
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
import string
|
import string
|
||||||
apply(Client.__init__, (self,) + args)
|
apply(self._pre_init, args)
|
||||||
Security.__init__(self)
|
Security.__init__(self)
|
||||||
line = self._rf.readline()
|
line = self._rf.readline()
|
||||||
challenge = string.atoi(string.strip(firstline))
|
challenge = string.atoi(string.strip(line))
|
||||||
response = self._encode_challenge(challenge)
|
response = self._encode_challenge(challenge)
|
||||||
line = `long(response)`
|
line = `long(response)`
|
||||||
if line[-1] in 'Ll': line = line[:-1]
|
if line[-1] in 'Ll': line = line[:-1]
|
||||||
self._wf.write(line + '\n')
|
self._wf.write(line + '\n')
|
||||||
self._wf.flush()
|
self._wf.flush()
|
||||||
|
self._post_init()
|
||||||
|
|
||||||
class _stub:
|
class _stub:
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ class Security:
|
||||||
env = os.environ
|
env = os.environ
|
||||||
if env.has_key('PYTHON_KEYFILE'):
|
if env.has_key('PYTHON_KEYFILE'):
|
||||||
keyfile = env['PYTHON_KEYFILE']
|
keyfile = env['PYTHON_KEYFILE']
|
||||||
elif env.has_key('HOME'):
|
|
||||||
keyfile = env['HOME'] + '.python_keyfile'
|
|
||||||
else:
|
else:
|
||||||
keyfile = '.python_keyfile'
|
keyfile = '.python_keyfile'
|
||||||
|
if env.has_key('HOME'):
|
||||||
|
keyfile = os.path.join(env['HOME'], keyfile)
|
||||||
try:
|
try:
|
||||||
self._key = eval(open(keyfile).readline())
|
self._key = eval(open(keyfile).readline())
|
||||||
except IOError:
|
except IOError:
|
||||||
|
@ -23,4 +23,4 @@ class Security:
|
||||||
|
|
||||||
def _encode_challenge(self, challenge):
|
def _encode_challenge(self, challenge):
|
||||||
p, m = self._key
|
p, m = self._key
|
||||||
return pow(challenge, p, m)
|
return pow(long(challenge), p, m)
|
||||||
|
|
Loading…
Reference in New Issue