/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 recompile
  • Date: 2020-02-05 20:32:33 UTC
  • Revision ID: teddy@recompile.se-20200205203233-450ojm36jseglq4m
Server: Stagger checker runs when creating clients

To avoid checkers for all clients all running at the same time
periodically, schedule every initially scheduled future checker to run
at a time in the future a random amount of the interval, from the
current time.

* mandos (Client.init_checker): Schedule the first scheduled future
  run of a checker to be a randomly chosen amount of this client's
  "interval" (instead of a full interval).

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
import collections
79
79
import codecs
80
80
import unittest
 
81
import random
81
82
 
82
83
import dbus
83
84
import dbus.service
91
92
 
92
93
if sys.version_info.major == 2:
93
94
    __metaclass__ = type
 
95
    str = unicode
94
96
 
95
97
# Show warnings by default
96
98
if not sys.warnoptions:
122
124
            # No value found
123
125
            SO_BINDTODEVICE = None
124
126
 
125
 
if sys.version_info.major == 2:
126
 
    str = unicode
127
 
 
128
127
if sys.version_info < (3, 2):
129
128
    configparser.Configparser = configparser.SafeConfigParser
130
129
 
1037
1036
        if self.checker_initiator_tag is not None:
1038
1037
            GLib.source_remove(self.checker_initiator_tag)
1039
1038
        self.checker_initiator_tag = GLib.timeout_add(
1040
 
            int(self.interval.total_seconds() * 1000),
 
1039
            random.randrange(int(self.interval.total_seconds() * 1000
 
1040
                                 + 1)),
1041
1041
            self.start_checker)
1042
1042
        # Schedule a disable() when 'timeout' has passed
1043
1043
        if self.disable_initiator_tag is not None:
1413
1413
                raise ValueError("Byte arrays not supported for non-"
1414
1414
                                 "'ay' signature {!r}"
1415
1415
                                 .format(prop._dbus_signature))
1416
 
            value = dbus.ByteArray(b''.join(chr(byte)
1417
 
                                            for byte in value))
 
1416
            value = dbus.ByteArray(bytes(value))
1418
1417
        prop(value)
1419
1418
 
1420
1419
    @dbus.service.method(dbus.PROPERTIES_IFACE,