/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-monitor

  • Committer: teddy at recompile
  • Date: 2012-02-25 03:49:47 UTC
  • mto: (237.7.109 trunk)
  • mto: This revision was merged to the branch mainline in revision 300.
  • Revision ID: teddy@recompile.se-20120225034947-qdjgp2h92bpote0d
* mandos: Use os.devnull instead of os.path.devnull.  Fix some white
          space.
  (PGPEngine.encrypt, PGPEngine.decrypt): Bug fix: open /dev/null for
                                          writing, not reading.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
domain = 'se.recompile'
53
53
server_interface = domain + '.Mandos'
54
54
client_interface = domain + '.Mandos.Client'
55
 
version = "1.5.1"
 
55
version = "1.5.3"
56
56
 
57
57
# Always run in monochrome mode
58
58
urwid.curses_display.curses.has_colors = lambda : False
131
131
        
132
132
        self._update_timer_callback_tag = None
133
133
        self._update_timer_callback_lock = 0
134
 
        self.last_checker_failed = False
135
134
        
136
135
        # The widget shown normally
137
136
        self._text_widget = urwid.Text("")
145
144
        
146
145
        last_checked_ok = isoformat_to_datetime(self.properties
147
146
                                                ["LastCheckedOK"])
148
 
        if last_checked_ok is None:
149
 
            self.last_checker_failed = True
150
 
        else:
151
 
            self.last_checker_failed = ((datetime.datetime.utcnow()
152
 
                                         - last_checked_ok)
153
 
                                        > datetime.timedelta
154
 
                                        (milliseconds=
155
 
                                         self.properties
156
 
                                         ["Interval"]))
157
147
        
158
 
        if self.last_checker_failed:
 
148
        if self.properties ["LastCheckerStatus"] != 0:
159
149
            self.using_timer(True)
160
150
        
161
151
        if self.need_approval:
189
179
                                                         value)
190
180
        if property == "ApprovalPending":
191
181
            using_timer(bool(value))
192
 
        
 
182
        if property == "LastCheckerStatus":
 
183
            using_timer(value != 0)
 
184
            #self.logger('Checker for client %s (command "%s")'
 
185
            #            ' was successful'
 
186
            #            % (self.properties["Name"], command))
 
187
    
193
188
    def using_timer(self, flag):
194
189
        """Call this method with True or False when timer should be
195
190
        activated or deactivated.
210
205
    
211
206
    def checker_completed(self, exitstatus, condition, command):
212
207
        if exitstatus == 0:
213
 
            if self.last_checker_failed:
214
 
                self.last_checker_failed = False
215
 
                self.using_timer(False)
216
 
            #self.logger('Checker for client %s (command "%s")'
217
 
            #            ' was successful'
218
 
            #            % (self.properties["Name"], command))
219
208
            self.update()
220
209
            return
221
210
        # Checker failed
222
 
        if not self.last_checker_failed:
223
 
            self.last_checker_failed = True
224
 
            self.using_timer(True)
225
211
        if os.WIFEXITED(condition):
226
212
            self.logger('Checker for client %s (command "%s")'
227
213
                        ' failed with exit code %s'
249
235
        pass
250
236
    
251
237
    def got_secret(self):
252
 
        self.last_checker_failed = False
253
238
        self.logger('Client %s received its secret'
254
239
                    % self.properties["Name"])
255
240
    
316
301
            else:
317
302
                message = "Denial in %s. (a)pprove?"
318
303
            message = message % unicode(timer).rsplit(".", 1)[0]
319
 
        elif self.last_checker_failed:
 
304
        elif self.properties["LastCheckerStatus"] != 0:
320
305
            # When checker has failed, print a timer until client expires
321
306
            expires = self.properties["Expires"]
322
307
            if expires == "":