1006
1007
gnutls.connection
1007
1008
.X509Credentials()))
1009
line = self.request.makefile().readline()
1010
logger.debug(u"Protocol version: %r", line)
1012
if int(line.strip().split()[0]) > 1:
1014
except (ValueError, IndexError, RuntimeError), error:
1015
logger.error(u"Unknown protocol version: %s", error)
1018
1010
# Note: gnutls.connection.X509Credentials is really a
1019
1011
# generic GnuTLS certificate credentials object so long as
1020
1012
# no X.509 keys are added to it. Therefore, we can use it
1032
1024
.gnutls_priority_set_direct(session._c_object,
1033
1025
priority, None))
1027
# Start communication using the Mandos protocol
1028
# Get protocol number
1029
line = self.request.makefile().readline()
1030
logger.debug(u"Protocol version: %r", line)
1032
if int(line.strip().split()[0]) > 1:
1034
except (ValueError, IndexError, RuntimeError), error:
1035
logger.error(u"Unknown protocol version: %s", error)
1038
# Start GnuTLS connection
1036
1040
session.handshake()
1037
1041
except gnutls.errors.GNUTLSError, error:
1057
1061
ipc.write(u"NOTFOUND %s %s\n"
1058
1062
% (fpr, unicode(self.client_address)))
1065
class ClientProxy(object):
1066
"""Client proxy object. Not for calling methods."""
1067
def __init__(self, client):
1068
self.client = client
1069
def __getattr__(self, name):
1070
if name.startswith("ipc_"):
1072
ipc.write("%s %s\n" % (name[4:].upper(),
1075
if not hasattr(self.client, name):
1076
raise AttributeError
1077
ipc.write(u"GETATTR %s %s\n"
1078
% (name, self.client.fingerprint))
1079
return pickle.load(ipc_return)
1080
clientproxy = ClientProxy(client)
1060
1081
# Have to check if client.enabled, since it is
1061
1082
# possible that the client was disabled since the
1062
1083
# GnuTLS session was established.
1063
ipc.write(u"GETATTR enabled %s\n" % fpr)
1064
enabled = pickle.load(ipc_return)
1066
ipc.write(u"DISABLED %s\n" % client.name)
1084
if not clientproxy.enabled:
1085
clientproxy.ipc_disabled()
1068
# Send "NEED_APPROVAL" here and hang waiting
1069
# for response? Leave timeout to parent process?
1070
ipc.write(u"SENDING %s\n" % client.name)
1088
clientproxy.ipc_sending()
1072
1090
while sent_size < len(client.secret):
1073
1091
sent = session.send(client.secret[sent_size:])