116
115
self.opened = False
116
self.proxy.connect_to_signal(u"CheckerCompleted",
117
self.checker_completed,
120
self.proxy.connect_to_signal(u"CheckerStarted",
121
self.checker_started,
124
self.proxy.connect_to_signal(u"GotSecret",
128
self.proxy.connect_to_signal(u"NeedApproval",
132
self.proxy.connect_to_signal(u"Rejected",
118
136
last_checked_ok = isoformat_to_datetime(self.properties
119
137
[u"LastCheckedOK"])
120
138
if last_checked_ok is None:
130
147
if self.last_checker_failed:
131
self.using_timer(True)
133
if self.need_approval:
134
self.using_timer(True)
136
self.proxy.connect_to_signal(u"CheckerCompleted",
137
self.checker_completed,
140
self.proxy.connect_to_signal(u"CheckerStarted",
141
self.checker_started,
144
self.proxy.connect_to_signal(u"GotSecret",
148
self.proxy.connect_to_signal(u"NeedApproval",
152
self.proxy.connect_to_signal(u"Rejected",
157
def property_changed(self, property=None, value=None):
158
super(self, MandosClientWidget).property_changed(property,
160
if property == u"ApprovalPending":
161
using_timer(bool(value))
163
def using_timer(self, flag):
164
"""Call this method with True or False when timer should be
165
activated or deactivated.
167
old = self._update_timer_callback_lock
169
self._update_timer_callback_lock += 1
171
self._update_timer_callback_lock -= 1
172
if old == 0 and self._update_timer_callback_lock:
173
148
self._update_timer_callback_tag = (gobject.timeout_add
175
150
self.update_timer))
176
elif old and self._update_timer_callback_lock == 0:
177
gobject.source_remove(self._update_timer_callback_tag)
178
self._update_timer_callback_tag = None
180
152
def checker_completed(self, exitstatus, condition, command):
181
153
if exitstatus == 0:
182
154
if self.last_checker_failed:
183
155
self.last_checker_failed = False
184
self.using_timer(False)
156
gobject.source_remove(self._update_timer_callback_tag)
157
self._update_timer_callback_tag = None
185
158
#self.logger(u'Checker for client %s (command "%s")'
186
159
# u' was successful'
187
160
# % (self.properties[u"Name"], command))
191
164
if not self.last_checker_failed:
192
165
self.last_checker_failed = True
193
self.using_timer(True)
166
self._update_timer_callback_tag = (gobject.timeout_add
194
169
if os.WIFEXITED(condition):
195
170
self.logger(u'Checker for client %s (command "%s")'
196
171
u' failed with exit code %s'
227
202
message = u'Client %s will get its secret in %s seconds'
228
203
self.logger(message
229
204
% (self.properties[u"Name"], timeout/1000))
230
self.using_timer(True)
232
206
def rejected(self, reason):
233
207
self.logger(u'Client %s was rejected; reason: %s'
268
242
if not self.properties[u"Enabled"]:
269
243
message = u"DISABLED"
270
244
elif self.properties[u"ApprovalPending"]:
271
timeout = datetime.timedelta(milliseconds
274
last_approval_request = isoformat_to_datetime(
275
self.properties[u"LastApprovalRequest"])
276
if last_approval_request is not None:
277
timer = timeout - (datetime.datetime.utcnow()
278
- last_approval_request)
280
timer = datetime.timedelta()
281
245
if self.properties[u"ApprovedByDefault"]:
282
message = u"Approval in %s. (d)eny?"
246
message = u"Connection established to client. (d)eny?"
284
message = u"Denial in %s. (a)pprove?"
285
message = message % unicode(timer).rsplit(".", 1)[0]
248
message = u"Seeks approval to send secret. (a)pprove?"
286
249
elif self.last_checker_failed:
287
250
timeout = datetime.timedelta(milliseconds
288
251
= self.properties
293
256
self.properties[u"LastEnabled"]))
294
257
timer = timeout - (datetime.datetime.utcnow() - last_ok)
295
258
message = (u'A checker has failed! Time until client'
296
u' gets disabled: %s'
297
260
% unicode(timer).rsplit(".", 1)[0])
299
262
message = u"enabled"