=== modified file 'TODO' --- TODO 2011-11-29 04:03:46 +0000 +++ TODO 2011-11-29 19:25:06 +0000 @@ -41,6 +41,7 @@ * mandos (server) ** TODO [#B] Log level :BUGS: +** TODO [#A] Save state to new file and move instead of overwrite ** TODO [#C] config for TXT record ** TODO Log level option === modified file 'mandos' --- mandos 2011-11-27 20:06:35 +0000 +++ mandos 2011-11-29 20:58:01 +0000 @@ -576,7 +576,7 @@ self.checker_callback_tag = None self.checker = None if os.WIFEXITED(condition): - self.last_checker_status = os.WEXITSTATUS(condition) + self.last_checker_status = os.WEXITSTATUS(condition) if self.last_checker_status == 0: logger.info("Checker for %(name)s succeeded", vars(self)) @@ -1069,21 +1069,21 @@ datetime_to_dbus, "LastApprovalRequest") approved_by_default = notifychangeproperty(dbus.Boolean, "ApprovedByDefault") - approval_delay = notifychangeproperty(dbus.UInt16, + approval_delay = notifychangeproperty(dbus.UInt64, "ApprovalDelay", type_func = timedelta_to_milliseconds) approval_duration = notifychangeproperty( - dbus.UInt16, "ApprovalDuration", + dbus.UInt64, "ApprovalDuration", type_func = timedelta_to_milliseconds) host = notifychangeproperty(dbus.String, "Host") - timeout = notifychangeproperty(dbus.UInt16, "Timeout", + timeout = notifychangeproperty(dbus.UInt64, "Timeout", type_func = timedelta_to_milliseconds) extended_timeout = notifychangeproperty( - dbus.UInt16, "ExtendedTimeout", + dbus.UInt64, "ExtendedTimeout", type_func = timedelta_to_milliseconds) - interval = notifychangeproperty(dbus.UInt16, + interval = notifychangeproperty(dbus.UInt64, "Interval", type_func = timedelta_to_milliseconds) @@ -1280,7 +1280,7 @@ def Host_dbus_property(self, value=None): if value is None: # get return dbus.String(self.host) - self.host = value + self.host = unicode(value) # Created - property @dbus_service_property(_interface, signature="s", access="read") @@ -1380,7 +1380,7 @@ def Checker_dbus_property(self, value=None): if value is None: # get return dbus.String(self.checker_command) - self.checker_command = value + self.checker_command = unicode(value) # CheckerRunning - property @dbus_service_property(_interface, signature="b", @@ -2236,7 +2236,7 @@ if (name != "secret" and value != old_client_settings[client_name] [name]): - setattr(client, name, value) + client[name] = value except KeyError: pass @@ -2244,10 +2244,10 @@ # enabled if its last checker was sucessful. Clients # whose checker failed before we stored its state is # assumed to have failed all checkers during downtime. - if client["enabled"] and client["last_checked_ok"]: - if ((datetime.datetime.utcnow() - - client["last_checked_ok"]) - > client["interval"]): + if client["enabled"]: + if client["expires"] <= (datetime.datetime + .utcnow()): + # Client has expired if client["last_checker_status"] != 0: client["enabled"] = False else: === modified file 'mandos-ctl' --- mandos-ctl 2011-10-15 16:48:03 +0000 +++ mandos-ctl 2011-11-29 20:30:21 +0000 @@ -93,29 +93,23 @@ >>> string_to_delta("5m 30s") datetime.timedelta(0, 330) """ - timevalue = datetime.timedelta(0) - regexp = re.compile("\d+[dsmhw]") + value = datetime.timedelta(0) + regexp = re.compile("(\d+)([dsmhw]?)") - for s in regexp.findall(interval): - try: - suffix = unicode(s[-1]) - value = int(s[:-1]) - if suffix == "d": - delta = datetime.timedelta(value) - elif suffix == "s": - delta = datetime.timedelta(0, value) - elif suffix == "m": - delta = datetime.timedelta(0, 0, 0, 0, value) - elif suffix == "h": - delta = datetime.timedelta(0, 0, 0, 0, 0, value) - elif suffix == "w": - delta = datetime.timedelta(0, 0, 0, 0, 0, 0, value) - else: - raise ValueError - except (ValueError, IndexError): - raise ValueError - timevalue += delta - return timevalue + for num, suffix in regexp.findall(interval): + if suffix == "d": + value += datetime.timedelta(int(num)) + elif suffix == "s": + value += datetime.timedelta(0, int(num)) + elif suffix == "m": + value += datetime.timedelta(0, 0, 0, 0, int(num)) + elif suffix == "h": + value += datetime.timedelta(0, 0, 0, 0, 0, int(num)) + elif suffix == "w": + value += datetime.timedelta(0, 0, 0, 0, 0, 0, int(num)) + elif suffix == "": + value += datetime.timedelta(0, 0, 0, int(num)) + return value def print_clients(clients, keywords): def valuetostring(value, keyword):