/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-10-13 06:12:52 UTC
  • Revision ID: teddy@fukt.bsnet.se-20101013061252-3a918xedja5caya8
* debian/mandos-client.lintian-overrides: Added plugins.d/plymouth.

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
81
81
        SO_BINDTODEVICE = None
82
82
 
83
83
 
84
 
version = "1.0.14"
 
84
version = "1.2.3"
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:  - '' -
 
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")
1661
1684
    parser.add_option("--debug", action=u"store_true",
1662
1685
                      help=u"Debug mode; run in foreground and log to"
1663
1686
                      u" terminal")
1664
 
    parser.add_option("--debuglevel", type=u"string", metavar="Level",
 
1687
    parser.add_option("--debuglevel", type=u"string", metavar="LEVEL",
1665
1688
                      help=u"Debug level for stdout output")
1666
1689
    parser.add_option("--priority", type=u"string", help=u"GnuTLS"
1667
1690
                      u" priority string (see GnuTLS documentation)")
1824
1847
        # No console logging
1825
1848
        logger.removeHandler(console)
1826
1849
    
 
1850
    # Need to fork before connecting to D-Bus
 
1851
    if not debug:
 
1852
        # Close all input and output, do double fork, etc.
 
1853
        daemon()
1827
1854
    
1828
1855
    global main_loop
1829
1856
    # From the Avahi example code
1847
1874
    if server_settings["interface"]:
1848
1875
        service.interface = (if_nametoindex
1849
1876
                             (str(server_settings[u"interface"])))
1850
 
 
1851
 
    if not debug:
1852
 
        # Close all input and output, do double fork, etc.
1853
 
        daemon()
1854
 
        
 
1877
    
1855
1878
    global multiprocessing_manager
1856
1879
    multiprocessing_manager = multiprocessing.Manager()
1857
1880