/mandos/trunk

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

« back to all changes in this revision

Viewing changes to mandos

  • Committer: teddy at bsnet
  • Date: 2010-09-27 16:27:13 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100927162713-jucnyd63612ximvw
* mandos-monitor: Change key for removing a client from "r" to "R".

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
# "AvahiService" class, and some lines in "main".
12
12
13
13
# Everything else is
14
 
# Copyright © 2008,2009 Teddy Hogeborn
15
 
# Copyright © 2008,2009 Björn Påhlsson
 
14
# Copyright © 2008-2010 Teddy Hogeborn
 
15
# Copyright © 2008-2010 Björn Påhlsson
16
16
17
17
# This program is free software: you can redistribute it and/or modify
18
18
# it under the terms of the GNU General Public License as published by
246
246
    checker:    subprocess.Popen(); a running checker process used
247
247
                                    to see if the client lives.
248
248
                                    'None' if no process is running.
249
 
    checker_callback_tag:  - '' -
 
249
    checker_callback_tag: a gobject event source tag, or None
250
250
    checker_command: string; External command which is run to check
251
251
                     if client lives.  %() expansions are done at
252
252
                     runtime with vars(self) as dict, so that for
255
255
    created:    datetime.datetime(); (UTC) object creation
256
256
    current_checker_command: string; current running checker_command
257
257
    disable_hook:  If set, called by disable() as disable_hook(self)
258
 
    disable_initiator_tag: - '' -
 
258
    disable_initiator_tag: a gobject event source tag, or None
259
259
    enabled:    bool()
260
260
    fingerprint: string (40 or 32 hexadecimal digits); used to
261
261
                 uniquely identify the client
262
262
    host:       string; available for use by the checker command
263
263
    interval:   datetime.timedelta(); How often to start a new checker
 
264
    last_approval_request: datetime.datetime(); (UTC) or None
264
265
    last_checked_ok: datetime.datetime(); (UTC) or None
265
266
    last_enabled: datetime.datetime(); (UTC)
266
267
    name:       string; from the config file, used in log messages and
321
322
        self.host = config.get(u"host", u"")
322
323
        self.created = datetime.datetime.utcnow()
323
324
        self.enabled = False
 
325
        self.last_approval_request = None
324
326
        self.last_enabled = None
325
327
        self.last_checked_ok = None
326
328
        self.timeout = string_to_delta(config[u"timeout"])
422
424
                                      (self.timeout_milliseconds(),
423
425
                                       self.disable))
424
426
    
 
427
    def need_approval(self):
 
428
        self.last_approval_request = datetime.datetime.utcnow()
 
429
    
425
430
    def start_checker(self):
426
431
        """Start a new checker subprocess if one is not running.
427
432
        
815
820
                                    variant_level=1)))
816
821
        return r
817
822
    
 
823
    def need_approval(self, *args, **kwargs):
 
824
        r = Client.need_approval(self, *args, **kwargs)
 
825
        # Emit D-Bus signal
 
826
        self.PropertyChanged(
 
827
            dbus.String(u"LastApprovalRequest"),
 
828
            (self._datetime_to_dbus(self.last_approval_request,
 
829
                                    variant_level=1)))
 
830
        return r
 
831
    
818
832
    def start_checker(self, *args, **kwargs):
819
833
        old_checker = self.checker
820
834
        if self.checker is not None:
895
909
    @dbus.service.signal(_interface, signature=u"tb")
896
910
    def NeedApproval(self, timeout, default):
897
911
        "D-Bus signal"
898
 
        pass
 
912
        return self.need_approval()
899
913
    
900
914
    ## Methods
901
 
 
 
915
    
902
916
    # Approve - method
903
917
    @dbus.service.method(_interface, in_signature=u"b")
904
918
    def Approve(self, value):
905
919
        self.approve(value)
906
 
 
 
920
    
907
921
    # CheckedOK - method
908
922
    @dbus.service.method(_interface)
909
923
    def CheckedOK(self):
1029
1043
        return dbus.String(self._datetime_to_dbus(self
1030
1044
                                                  .last_checked_ok))
1031
1045
    
 
1046
    # LastApprovalRequest - property
 
1047
    @dbus_service_property(_interface, signature=u"s", access=u"read")
 
1048
    def LastApprovalRequest_dbus_property(self):
 
1049
        if self.last_approval_request is None:
 
1050
            return dbus.String(u"")
 
1051
        return dbus.String(self.
 
1052
                           _datetime_to_dbus(self
 
1053
                                             .last_approval_request))
 
1054
    
1032
1055
    # Timeout - property
1033
1056
    @dbus_service_property(_interface, signature=u"t",
1034
1057
                           access=u"readwrite")