/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 Hogeborn
  • Date: 2010-09-25 21:24:49 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100925212449-h9hpy9n406tkkakb
* mandos.xml (APPROVAL): New section.

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-2010 Teddy Hogeborn
15
 
# Copyright © 2008-2010 Björn Påhlsson
 
14
# Copyright © 2008,2009 Teddy Hogeborn
 
15
# Copyright © 2008,2009 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
81
81
        SO_BINDTODEVICE = None
82
82
 
83
83
 
84
 
version = "1.2.1"
 
84
version = "1.0.14"
85
85
 
86
86
#logger = logging.getLogger(u'mandos')
87
87
logger = logging.Logger(u'mandos')
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: a gobject event source tag, or None
 
249
    checker_callback_tag:  - '' -
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: a gobject event source tag, or None
 
258
    disable_initiator_tag: - '' -
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
265
264
    last_checked_ok: datetime.datetime(); (UTC) or None
266
265
    last_enabled: datetime.datetime(); (UTC)
267
266
    name:       string; from the config file, used in log messages and
322
321
        self.host = config.get(u"host", u"")
323
322
        self.created = datetime.datetime.utcnow()
324
323
        self.enabled = False
325
 
        self.last_approval_request = None
326
324
        self.last_enabled = None
327
325
        self.last_checked_ok = None
328
326
        self.timeout = string_to_delta(config[u"timeout"])
424
422
                                      (self.timeout_milliseconds(),
425
423
                                       self.disable))
426
424
    
427
 
    def need_approval(self):
428
 
        self.last_approval_request = datetime.datetime.utcnow()
429
 
    
430
425
    def start_checker(self):
431
426
        """Start a new checker subprocess if one is not running.
432
427
        
728
723
        Client.__init__(self, *args, **kwargs)
729
724
        # Only now, when this client is initialized, can it show up on
730
725
        # the D-Bus
731
 
        client_object_name = unicode(self.name).translate(
732
 
            {ord(u"."): ord(u"_"),
733
 
             ord(u"-"): ord(u"_")})
734
726
        self.dbus_object_path = (dbus.ObjectPath
735
 
                                 (u"/clients/" + client_object_name))
 
727
                                 (u"/clients/"
 
728
                                  + self.name.replace(u".", u"_")))
736
729
        DBusObjectWithProperties.__init__(self, self.bus,
737
730
                                          self.dbus_object_path)
738
731
        
820
813
                                    variant_level=1)))
821
814
        return r
822
815
    
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
 
    
832
816
    def start_checker(self, *args, **kwargs):
833
817
        old_checker = self.checker
834
818
        if self.checker is not None:
909
893
    @dbus.service.signal(_interface, signature=u"tb")
910
894
    def NeedApproval(self, timeout, default):
911
895
        "D-Bus signal"
912
 
        return self.need_approval()
 
896
        pass
913
897
    
914
898
    ## Methods
915
 
    
 
899
 
916
900
    # Approve - method
917
901
    @dbus.service.method(_interface, in_signature=u"b")
918
902
    def Approve(self, value):
919
903
        self.approve(value)
920
 
    
 
904
 
921
905
    # CheckedOK - method
922
906
    @dbus.service.method(_interface)
923
907
    def CheckedOK(self):
1043
1027
        return dbus.String(self._datetime_to_dbus(self
1044
1028
                                                  .last_checked_ok))
1045
1029
    
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
 
    
1055
1030
    # Timeout - property
1056
1031
    @dbus_service_property(_interface, signature=u"t",
1057
1032
                           access=u"readwrite")
1545
1520
                               u"dress: %s", fpr, address)
1546
1521
                if self.use_dbus:
1547
1522
                    # Emit D-Bus signal
1548
 
                    mandos_dbus_service.ClientNotFound(fpr, address[0])
 
1523
                    mandos_dbus_service.ClientNotFound(fpr, address)
1549
1524
                parent_pipe.send(False)
1550
1525
                return False
1551
1526
            
1684
1659
    parser.add_option("--debug", action=u"store_true",
1685
1660
                      help=u"Debug mode; run in foreground and log to"
1686
1661
                      u" terminal")
1687
 
    parser.add_option("--debuglevel", type=u"string", metavar="LEVEL",
 
1662
    parser.add_option("--debuglevel", type=u"string", metavar="Level",
1688
1663
                      help=u"Debug level for stdout output")
1689
1664
    parser.add_option("--priority", type=u"string", help=u"GnuTLS"
1690
1665
                      u" priority string (see GnuTLS documentation)")