/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos

* plugin-runner.c: Only space changes.
* plugins.d/mandos-client.c: - '' -
* plugins.d/password-prompt.c: - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
import SocketServer
37
37
import socket
38
 
import optparse
 
38
from optparse import OptionParser
39
39
import datetime
40
40
import errno
41
41
import gnutls.crypto
66
66
import ctypes
67
67
import ctypes.util
68
68
 
69
 
version = "1.0.5"
 
69
version = "1.0.3"
70
70
 
71
71
logger = logging.Logger('mandos')
72
72
syslogger = (logging.handlers.SysLogHandler
178
178
class Client(dbus.service.Object):
179
179
    """A representation of a client host served by this server.
180
180
    Attributes:
181
 
    name:       string; from the config file, used in log messages and
182
 
                        D-Bus identifiers
 
181
    name:       string; from the config file, used in log messages
183
182
    fingerprint: string (40 or 32 hexadecimal digits); used to
184
183
                 uniquely identify the client
185
184
    secret:     bytestring; sent verbatim (over TLS) to client
226
225
        if config is None:
227
226
            config = {}
228
227
        logger.debug(u"Creating client %r", self.name)
229
 
        self.use_dbus = False   # During __init__
 
228
        self.use_dbus = use_dbus
 
229
        if self.use_dbus:
 
230
            self.dbus_object_path = (dbus.ObjectPath
 
231
                                     ("/Mandos/clients/"
 
232
                                      + self.name.replace(".", "_")))
 
233
            dbus.service.Object.__init__(self, bus,
 
234
                                         self.dbus_object_path)
230
235
        # Uppercase and remove spaces from fingerprint for later
231
236
        # comparison purposes with return value from the fingerprint()
232
237
        # function
256
261
        self.disable_initiator_tag = None
257
262
        self.checker_callback_tag = None
258
263
        self.checker_command = config["checker"]
259
 
        self.last_connect = None
260
 
        # Only now, when this client is initialized, can it show up on
261
 
        # the D-Bus
262
 
        self.use_dbus = use_dbus
263
 
        if self.use_dbus:
264
 
            self.dbus_object_path = (dbus.ObjectPath
265
 
                                     ("/clients/"
266
 
                                      + self.name.replace(".", "_")))
267
 
            dbus.service.Object.__init__(self, bus,
268
 
                                         self.dbus_object_path)
269
264
    
270
265
    def enable(self):
271
266
        """Start this client's checker and timeout hooks"""
453
448
            return now < (self.last_checked_ok + self.timeout)
454
449
    
455
450
    ## D-Bus methods & signals
456
 
    _interface = u"se.bsnet.fukt.Mandos.Client"
 
451
    _interface = u"org.mandos_system.Mandos.Client"
457
452
    
458
453
    # BumpTimeout - method
459
454
    BumpTimeout = dbus.service.method(_interface)(bump_timeout)
508
503
                dbus.String("checker_running"):
509
504
                    dbus.Boolean(self.checker is not None,
510
505
                                 variant_level=1),
511
 
                dbus.String("object_path"):
512
 
                    dbus.ObjectPath(self.dbus_object_path,
513
 
                                    variant_level=1)
514
506
                }, signature="sv")
515
507
    
516
508
    # IsStillValid - method
897
889
 
898
890
 
899
891
def main():
900
 
    parser = optparse.OptionParser(version = "%%prog %s" % version)
 
892
    parser = OptionParser(version = "%%prog %s" % version)
901
893
    parser.add_option("-i", "--interface", type="string",
902
894
                      metavar="IF", help="Bind to interface IF")
903
895
    parser.add_option("-a", "--address", type="string",
1039
1031
                            avahi.DBUS_INTERFACE_SERVER)
1040
1032
    # End of Avahi example code
1041
1033
    if use_dbus:
1042
 
        bus_name = dbus.service.BusName(u"se.bsnet.fukt.Mandos", bus)
 
1034
        bus_name = dbus.service.BusName(u"org.mandos-system.Mandos",
 
1035
                                        bus)
1043
1036
    
1044
1037
    clients.update(Set(Client(name = section,
1045
1038
                              config
1099
1092
        class MandosServer(dbus.service.Object):
1100
1093
            """A D-Bus proxy object"""
1101
1094
            def __init__(self):
1102
 
                dbus.service.Object.__init__(self, bus, "/")
1103
 
            _interface = u"se.bsnet.fukt.Mandos"
1104
 
            
 
1095
                dbus.service.Object.__init__(self, bus,
 
1096
                                             "/Mandos")
 
1097
            _interface = u"org.mandos_system.Mandos"
 
1098
 
1105
1099
            @dbus.service.signal(_interface, signature="oa{sv}")
1106
1100
            def ClientAdded(self, objpath, properties):
1107
1101
                "D-Bus signal"
1108
1102
                pass
1109
 
            
1110
 
            @dbus.service.signal(_interface, signature="os")
1111
 
            def ClientRemoved(self, objpath, name):
 
1103
 
 
1104
            @dbus.service.signal(_interface, signature="o")
 
1105
            def ClientRemoved(self, objpath):
1112
1106
                "D-Bus signal"
1113
1107
                pass
1114
 
            
 
1108
 
1115
1109
            @dbus.service.method(_interface, out_signature="ao")
1116
1110
            def GetAllClients(self):
1117
1111
                return dbus.Array(c.dbus_object_path for c in clients)
1118
 
            
 
1112
 
1119
1113
            @dbus.service.method(_interface, out_signature="a{oa{sv}}")
1120
1114
            def GetAllClientsWithProperties(self):
1121
1115
                return dbus.Dictionary(
1122
1116
                    ((c.dbus_object_path, c.GetAllProperties())
1123
1117
                     for c in clients),
1124
1118
                    signature="oa{sv}")
1125
 
            
 
1119
 
1126
1120
            @dbus.service.method(_interface, in_signature="o")
1127
1121
            def RemoveClient(self, object_path):
1128
1122
                for c in clients:
1132
1126
                        c.use_dbus = False
1133
1127
                        c.disable()
1134
1128
                        # Emit D-Bus signal
1135
 
                        self.ClientRemoved(object_path, c.name)
 
1129
                        self.ClientRemoved(object_path)
1136
1130
                        return
1137
1131
                raise KeyError
1138
 
            
 
1132
            @dbus.service.method(_interface)
 
1133
            def Quit(self):
 
1134
                main_loop.quit()
 
1135
 
1139
1136
            del _interface
1140
 
        
 
1137
    
1141
1138
        mandos_server = MandosServer()
1142
1139
    
1143
1140
    for client in clients: