/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 23:52:17 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100925235217-4hhqfryz1ste6uw3
* mandos (ClientDBus.__init__): Bug fix: Translate "-" in client names
                                to "_" in D-Bus object paths.
  (MandosServer.handle_ipc): Bug fix: Send only address string to
                             D-Bus signal, not whole tuple.

* mandos-ctl: New options "--approve-by-default", "--deny-by-default",
              "--approval-delay", and "--approval-duration".
* mandos-ctl.xml (SYNOPSIS, OPTIONS): Document new options.

* mandos-monitor (MandosClientWidget.update): Fix spelling.

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"
 
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
        
820
815
                                    variant_level=1)))
821
816
        return r
822
817
    
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
818
    def start_checker(self, *args, **kwargs):
833
819
        old_checker = self.checker
834
820
        if self.checker is not None:
909
895
    @dbus.service.signal(_interface, signature=u"tb")
910
896
    def NeedApproval(self, timeout, default):
911
897
        "D-Bus signal"
912
 
        return self.need_approval()
 
898
        pass
913
899
    
914
900
    ## Methods
915
 
    
 
901
 
916
902
    # Approve - method
917
903
    @dbus.service.method(_interface, in_signature=u"b")
918
904
    def Approve(self, value):
919
905
        self.approve(value)
920
 
    
 
906
 
921
907
    # CheckedOK - method
922
908
    @dbus.service.method(_interface)
923
909
    def CheckedOK(self):
1043
1029
        return dbus.String(self._datetime_to_dbus(self
1044
1030
                                                  .last_checked_ok))
1045
1031
    
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
1032
    # Timeout - property
1056
1033
    @dbus_service_property(_interface, signature=u"t",
1057
1034
                           access=u"readwrite")
1684
1661
    parser.add_option("--debug", action=u"store_true",
1685
1662
                      help=u"Debug mode; run in foreground and log to"
1686
1663
                      u" terminal")
1687
 
    parser.add_option("--debuglevel", type=u"string", metavar="LEVEL",
 
1664
    parser.add_option("--debuglevel", type=u"string", metavar="Level",
1688
1665
                      help=u"Debug level for stdout output")
1689
1666
    parser.add_option("--priority", type=u"string", help=u"GnuTLS"
1690
1667
                      u" priority string (see GnuTLS documentation)")