=== modified file 'DBUS-API' --- DBUS-API 2011-09-18 16:04:23 +0000 +++ DBUS-API 2011-10-02 19:18:24 +0000 @@ -5,7 +5,7 @@ This file documents the D-Bus interface to the Mandos server. * Bus: System bus - Bus name: "se.bsnet.fukt.Mandos" + Bus name: "se.recompile.Mandos" * Object Paths: @@ -17,7 +17,7 @@ * Mandos Server Interface: - Interface name: "se.bsnet.fukt.Mandos" + Interface name: "se.recompile.Mandos" ** Methods: *** GetAllClients() → (ao: Clients) @@ -44,7 +44,7 @@ * Mandos Client Interface: - Interface name: "se.bsnet.fukt.Mandos.Client" + Interface name: "se.recompile.Mandos.Client" ** Methods *** Approve(b: Approve) → nothing === modified file 'dbus-mandos.conf' --- dbus-mandos.conf 2009-11-09 07:35:16 +0000 +++ dbus-mandos.conf 2011-10-02 19:18:24 +0000 @@ -7,12 +7,18 @@ + + + + + + === modified file 'mandos' --- mandos 2011-09-26 21:06:14 +0000 +++ mandos 2011-10-02 19:33:45 +0000 @@ -62,6 +62,7 @@ import functools import cPickle as pickle import multiprocessing +import types import dbus import dbus.service @@ -626,24 +627,19 @@ def _get_all_dbus_properties(self): """Returns a generator of (name, attribute) pairs """ - return ((prop._dbus_name, prop) - for name, prop in - inspect.getmembers(self, self._is_dbus_property)) + return ((prop.__get__(self)._dbus_name, prop.__get__(self)) + for cls in self.__class__.__mro__ + for name, prop in inspect.getmembers(cls, self._is_dbus_property)) def _get_dbus_property(self, interface_name, property_name): """Returns a bound method if one exists which is a D-Bus property with the specified name and interface. """ - for name in (property_name, - property_name + "_dbus_property"): - prop = getattr(self, name, None) - if (prop is None - or not self._is_dbus_property(prop) - or prop._dbus_name != property_name - or (interface_name and prop._dbus_interface - and interface_name != prop._dbus_interface)): - continue - return prop + for cls in self.__class__.__mro__: + for name, value in inspect.getmembers(cls, self._is_dbus_property): + if value._dbus_name == property_name and value._dbus_interface == interface_name: + return value.__get__(self) + # No such property raise DBusPropertyNotFound(self.dbus_object_path + ":" + interface_name + "." @@ -758,6 +754,61 @@ return dbus.String(dt.isoformat(), variant_level=variant_level) +class transitional_dbus_metaclass(DBusObjectWithProperties.__metaclass__): + def __new__(mcs, name, bases, attr): + for attrname, old_dbusobj in inspect.getmembers(bases[0]): + new_interface = getattr(old_dbusobj, "_dbus_interface", "").replace("se.bsnet.fukt.", "se.recompile.") + if (getattr(old_dbusobj, "_dbus_is_signal", False) + and old_dbusobj._dbus_interface.startswith("se.bsnet.fukt.Mandos")): + unwrappedfunc = dict(zip(old_dbusobj.func_code.co_freevars, + old_dbusobj.__closure__))["func"].cell_contents + newfunc = types.FunctionType(unwrappedfunc.func_code, + unwrappedfunc.func_globals, + unwrappedfunc.func_name, + unwrappedfunc.func_defaults, + unwrappedfunc.func_closure) + new_dbusfunc = dbus.service.signal( + new_interface, old_dbusobj._dbus_signature)(newfunc) + attr["_transitional_" + attrname] = new_dbusfunc + + def fixscope(func1, func2): + def newcall(*args, **kwargs): + func1(*args, **kwargs) + func2(*args, **kwargs) + return newcall + + attr[attrname] = fixscope(old_dbusobj, new_dbusfunc) + + elif (getattr(old_dbusobj, "_dbus_is_method", False) + and old_dbusobj._dbus_interface.startswith("se.bsnet.fukt.Mandos")): + new_dbusfunc = (dbus.service.method + (new_interface, + old_dbusobj._dbus_in_signature, + old_dbusobj._dbus_out_signature) + (types.FunctionType + (old_dbusobj.func_code, + old_dbusobj.func_globals, + old_dbusobj.func_name, + old_dbusobj.func_defaults, + old_dbusobj.func_closure))) + + attr[attrname] = new_dbusfunc + elif (getattr(old_dbusobj, "_dbus_is_property", False) + and old_dbusobj._dbus_interface.startswith("se.bsnet.fukt.Mandos")): + new_dbusfunc = (dbus_service_property + (new_interface, + old_dbusobj._dbus_signature, + old_dbusobj._dbus_access, + old_dbusobj._dbus_get_args_options["byte_arrays"]) + (types.FunctionType + (old_dbusobj.func_code, + old_dbusobj.func_globals, + old_dbusobj.func_name, + old_dbusobj.func_defaults, + old_dbusobj.func_closure))) + + attr[attrname] = new_dbusfunc + return type.__new__(mcs, name, bases, attr) class ClientDBus(Client, DBusObjectWithProperties): """A Client class using D-Bus @@ -1174,6 +1225,8 @@ return super(ProxyClient, self).__setattr__(name, value) self._pipe.send(('setattr', name, value)) +class ClientDBusTransitional(ClientDBus): + __metaclass__ = transitional_dbus_metaclass class ClientHandler(socketserver.BaseRequestHandler, object): """A class to handle client connections. @@ -1881,8 +1934,10 @@ # End of Avahi example code if use_dbus: try: - bus_name = dbus.service.BusName("se.bsnet.fukt.Mandos", + bus_name = dbus.service.BusName("se.recompile.Mandos", bus, do_not_queue=True) + bus_name_transitional = dbus.service.BusName("se.bsnet.fukt.Mandos", + bus, do_not_queue=True) except dbus.exceptions.NameExistsException as e: logger.error(unicode(e) + ", disabling D-Bus") use_dbus = False @@ -1901,7 +1956,7 @@ client_class = Client if use_dbus: - client_class = functools.partial(ClientDBus, bus = bus) + client_class = functools.partial(ClientDBusTransitional, bus = bus) def client_config_items(config, section): special_settings = { "approved_by_default": @@ -1994,7 +2049,9 @@ del _interface - mandos_dbus_service = MandosDBusService() + class MandosDBusServiceTransitional(MandosDBusService): + __metaclass__ = transitional_dbus_metaclass + mandos_dbus_service = MandosDBusServiceTransitional() def cleanup(): "Cleanup function; run on exit" === modified file 'mandos-ctl' --- mandos-ctl 2011-09-18 14:28:47 +0000 +++ mandos-ctl 2011-10-02 19:18:24 +0000 @@ -55,7 +55,7 @@ "ExtendedTimeout" : "Extended Timeout" } defaultkeywords = ("Name", "Enabled", "Timeout", "LastCheckedOK") -domain = "se.bsnet.fukt" +domain = "se.recompile" busname = domain + ".Mandos" server_path = "/" server_interface = domain + ".Mandos" === modified file 'mandos-monitor' --- mandos-monitor 2011-09-18 14:28:47 +0000 +++ mandos-monitor 2011-10-02 19:18:24 +0000 @@ -49,7 +49,7 @@ logging.getLogger('dbus.proxies').setLevel(logging.CRITICAL) # Some useful constants -domain = 'se.bsnet.fukt' +domain = 'se.recompile' server_interface = domain + '.Mandos' client_interface = domain + '.Mandos.Client' version = "1.3.1"