/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-02 19:07:20 UTC
  • mto: (24.1.154 mandos)
  • mto: This revision was merged to the branch mainline in revision 421.
  • Revision ID: teddy@fukt.bsnet.se-20100902190720-sp0pitu30isx4pvi
* mandos (ClientDBus.approvals_pending): Bug fix: Only send D-Bus
                                         signals if connected to the
                                         D-Bus.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
 
84
84
version = "1.0.14"
85
85
 
86
 
#logger = logging.getLogger(u'mandos')
87
 
logger = logging.Logger(u'mandos')
 
86
logger = logging.getLogger(u'mandos')
88
87
syslogger = (logging.handlers.SysLogHandler
89
88
             (facility = logging.handlers.SysLogHandler.LOG_DAEMON,
90
89
              address = "/dev/log"))
99
98
                                       u' %(message)s'))
100
99
logger.addHandler(console)
101
100
 
 
101
multiprocessing_manager = multiprocessing.Manager()
 
102
 
102
103
class AvahiError(Exception):
103
104
    def __init__(self, value, *args, **kwargs):
104
105
        self.value = value
322
323
        self.checker_command = config[u"checker"]
323
324
        self.current_checker_command = None
324
325
        self.last_connect = None
 
326
        self.approvals_pending = 0
325
327
        self._approved = None
326
328
        self.approved_by_default = config.get(u"approved_by_default",
327
329
                                              True)
328
 
        self.approvals_pending = 0
329
330
        self.approved_delay = string_to_delta(
330
331
            config[u"approved_delay"])
331
332
        self.approved_duration = string_to_delta(
711
712
                                  + self.name.replace(u".", u"_")))
712
713
        DBusObjectWithProperties.__init__(self, self.bus,
713
714
                                          self.dbus_object_path)
714
 
 
715
 
    #Could possible return a bool(self._approvals_pending),
716
 
    #but this could mess up approvals_pending += 1 XXX 
717
 
    def _get_approvals_pending(self):
 
715
    
 
716
    def _get_approvals_pending(self, value):
718
717
        return self._approvals_pending
719
718
    def _set_approvals_pending(self, value):
720
719
        old_value = self._approvals_pending
721
720
        self._approvals_pending = value
722
721
        bval = bool(value)
723
722
        if (hasattr(self, "dbus_object_path")
724
 
            and bval is not bool(old_value)):
 
723
            and bval is bool(old_value)):
725
724
            dbus_bool = dbus.Boolean(bval, variant_level=1)
726
725
            self.PropertyChanged(dbus.String(u"approved_pending"),
727
726
                                 dbus_bool)
728
 
 
 
727
        return value
729
728
    approvals_pending = property(_get_approvals_pending,
730
729
                                 _set_approvals_pending)
731
730
    del _get_approvals_pending, _set_approvals_pending
829
828
        return False
830
829
    
831
830
    def approve(self, value=True):
832
 
        self.send_changedstate()
833
831
        self._approved = value
834
 
        gobject.timeout_add(self._timedelta_to_milliseconds(self.approved_duration),
835
 
                            self._reset_approved)
 
832
        gobject.timeout_add(self._timedelta_to_milliseconds(self.approved_duration, self._reset_approved))
836
833
    
837
834
    
838
835
    ## D-Bus methods, signals & properties
859
856
        pass
860
857
    
861
858
    # GotSecret - signal
862
 
    # XXXTEDDY Is sent after succesfull transfer of secret from mandos-server to mandos-client
863
859
    @dbus.service.signal(_interface)
864
860
    def GotSecret(self):
865
861
        "D-Bus signal"
1339
1335
 
1340
1336
        super(MultiprocessingMixInWithPipe,
1341
1337
              self).process_request(request, client_address)
1342
 
        self.child_pipe.close()
1343
1338
        self.add_pipe(parent_pipe)
1344
 
 
1345
1339
    def add_pipe(self, parent_pipe):
1346
1340
        """Dummy function; override as necessary"""
1347
1341
        pass
1462
1456
                                       if cond & condition)
1463
1457
        logger.debug(u"Handling IPC: FD = %d, condition = %s", source,
1464
1458
                     conditions_string)
1465
 
 
1466
 
        # XXXTEDDY error or the other end of multiprocessing.Pipe has closed
1467
 
        if condition & gobject.IO_HUP or condition & gobject.IO_ERR:
1468
 
            return False
1469
1459
        
1470
1460
        # Read a request from the child
1471
1461
        request = parent_pipe.recv()
1472
 
        logger.debug(u"IPC request: %s", repr(request))
1473
1462
        command = request[0]
1474
1463
        
1475
1464
        if command == 'init':
1515
1504
            attrname = request[1]
1516
1505
            value = request[2]
1517
1506
            setattr(client_object, attrname, value)
1518
 
 
 
1507
        
1519
1508
        return True
1520
1509
 
1521
1510
 
1789
1778
    if server_settings["interface"]:
1790
1779
        service.interface = (if_nametoindex
1791
1780
                             (str(server_settings[u"interface"])))
1792
 
 
1793
 
    global multiprocessing_manager
1794
 
    multiprocessing_manager = multiprocessing.Manager()
1795
1781
    
1796
1782
    client_class = Client
1797
1783
    if use_dbus: