1138
1138
class ProxyClient(object):
1139
1139
def __init__(self, child_pipe, fpr, address):
1140
1140
self._pipe = child_pipe
1141
self._pipe.send(('init', fpr, address))
1141
self._pipe.send((u'init', fpr, address))
1142
1142
if not self._pipe.recv():
1143
1143
raise KeyError()
1145
1145
def __getattribute__(self, name):
1146
if(name == '_pipe'):
1146
if(name == u'_pipe'):
1147
1147
return super(ProxyClient, self).__getattribute__(name)
1148
self._pipe.send(('getattr', name))
1148
self._pipe.send((u'getattr', name))
1149
1149
data = self._pipe.recv()
1150
if data[0] == 'data':
1150
if data[0] == u'data':
1152
if data[0] == 'function':
1152
if data[0] == u'function':
1153
1153
def func(*args, **kwargs):
1154
self._pipe.send(('funcall', name, args, kwargs))
1154
self._pipe.send((u'funcall', name, args, kwargs))
1155
1155
return self._pipe.recv()[1]
1158
1158
def __setattr__(self, name, value):
1159
if(name == '_pipe'):
1159
if(name == u'_pipe'):
1160
1160
return super(ProxyClient, self).__setattr__(name, value)
1161
self._pipe.send(('setattr', name, value))
1161
self._pipe.send((u'setattr', name, value))
1164
1164
class ClientHandler(socketserver.BaseRequestHandler, object):
1557
1557
parent_pipe.send(True)
1558
1558
# remove the old hook in favor of the new above hook on same fileno
1560
if command == 'funcall':
1560
if command == u'funcall':
1561
1561
funcname = request[1]
1562
1562
args = request[2]
1563
1563
kwargs = request[3]
1565
parent_pipe.send(('data', getattr(client_object, funcname)(*args, **kwargs)))
1565
parent_pipe.send((u'data', getattr(client_object, funcname)(*args, **kwargs)))
1567
if command == 'getattr':
1567
if command == u'getattr':
1568
1568
attrname = request[1]
1569
1569
if callable(client_object.__getattribute__(attrname)):
1570
parent_pipe.send(('function',))
1570
parent_pipe.send((u'function',))
1572
parent_pipe.send(('data', client_object.__getattribute__(attrname)))
1572
parent_pipe.send((u'data', client_object.__getattribute__(attrname)))
1574
if command == 'setattr':
1574
if command == u'setattr':
1575
1575
attrname = request[1]
1576
1576
value = request[2]
1577
1577
setattr(client_object, attrname, value)
1672
1672
##################################################################
1673
1673
# Parsing of options, both command line and config file
1675
parser = optparse.OptionParser(version = "%%prog %s" % version)
1676
parser.add_option("-i", u"--interface", type=u"string",
1677
metavar="IF", help=u"Bind to interface IF")
1678
parser.add_option("-a", u"--address", type=u"string",
1675
parser = optparse.OptionParser(version = u"%%prog %s" % version)
1676
parser.add_option(u"-i", u"--interface", type=u"string",
1677
metavar=u"IF", help=u"Bind to interface IF")
1678
parser.add_option(u"-a", u"--address", type=u"string",
1679
1679
help=u"Address to listen for requests on")
1680
parser.add_option("-p", u"--port", type=u"int",
1680
parser.add_option(u"-p", u"--port", type=u"int",
1681
1681
help=u"Port number to receive requests on")
1682
parser.add_option("--check", action=u"store_true",
1682
parser.add_option(u"--check", action=u"store_true",
1683
1683
help=u"Run self-test")
1684
parser.add_option("--debug", action=u"store_true",
1684
parser.add_option(u"--debug", action=u"store_true",
1685
1685
help=u"Debug mode; run in foreground and log to"
1687
parser.add_option("--debuglevel", type=u"string", metavar="LEVEL",
1687
parser.add_option(u"--debuglevel", type=u"string", metavar="LEVEL",
1688
1688
help=u"Debug level for stdout output")
1689
parser.add_option("--priority", type=u"string", help=u"GnuTLS"
1689
parser.add_option(u"--priority", type=u"string", help=u"GnuTLS"
1690
1690
u" priority string (see GnuTLS documentation)")
1691
parser.add_option("--servicename", type=u"string",
1691
parser.add_option(u"--servicename", type=u"string",
1692
1692
metavar=u"NAME", help=u"Zeroconf service name")
1693
parser.add_option("--configdir", type=u"string",
1693
parser.add_option(u"--configdir", type=u"string",
1694
1694
default=u"/etc/mandos", metavar=u"DIR",
1695
1695
help=u"Directory to search for configuration"
1697
parser.add_option("--no-dbus", action=u"store_false",
1697
parser.add_option(u"--no-dbus", action=u"store_false",
1698
1698
dest=u"use_dbus", help=u"Do not provide D-Bus"
1699
1699
u" system bus interface")
1700
parser.add_option("--no-ipv6", action=u"store_false",
1700
parser.add_option(u"--no-ipv6", action=u"store_false",
1701
1701
dest=u"use_ipv6", help=u"Do not use IPv6")
1702
1702
options = parser.parse_args()[0]