/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:
79
79
import codecs
80
80
import unittest
81
81
import random
82
 
import shlex
83
82
 
84
83
import dbus
85
84
import dbus.service
95
94
    __metaclass__ = type
96
95
    str = unicode
97
96
 
98
 
# Add collections.abc.Callable if it does not exist
99
 
try:
100
 
    collections.abc.Callable
101
 
except AttributeError:
102
 
    class abc:
103
 
        Callable = collections.Callable
104
 
    collections.abc = abc
105
 
    del abc
106
 
 
107
 
# Add shlex.quote if it does not exist
108
 
try:
109
 
    shlex.quote
110
 
except AttributeError:
111
 
    shlex.quote = re.escape
112
 
 
113
97
# Show warnings by default
114
98
if not sys.warnoptions:
115
99
    import warnings
143
127
if sys.version_info < (3, 2):
144
128
    configparser.Configparser = configparser.SafeConfigParser
145
129
 
146
 
version = "1.8.10"
 
130
version = "1.8.9"
147
131
stored_state_file = "clients.pickle"
148
132
 
149
133
logger = logging.getLogger()
1134
1118
        if self.checker is None:
1135
1119
            # Escape attributes for the shell
1136
1120
            escaped_attrs = {
1137
 
                attr: shlex.quote(str(getattr(self, attr)))
 
1121
                attr: re.escape(str(getattr(self, attr)))
1138
1122
                for attr in self.runtime_expansions}
1139
1123
            try:
1140
1124
                command = self.checker_command % escaped_attrs
2764
2748
        if command == 'getattr':
2765
2749
            attrname = request[1]
2766
2750
            if isinstance(client_object.__getattribute__(attrname),
2767
 
                          collections.abc.Callable):
 
2751
                          collections.Callable):
2768
2752
                parent_pipe.send(('function', ))
2769
2753
            else:
2770
2754
                parent_pipe.send((