=== modified file 'mandos' --- mandos 2010-09-25 20:09:10 +0000 +++ mandos 2010-09-25 23:52:17 +0000 @@ -723,9 +723,11 @@ Client.__init__(self, *args, **kwargs) # Only now, when this client is initialized, can it show up on # the D-Bus + client_object_name = unicode(self.name).translate( + {ord(u"."): ord(u"_"), + ord(u"-"): ord(u"_")}) self.dbus_object_path = (dbus.ObjectPath - (u"/clients/" - + self.name.replace(u".", u"_"))) + (u"/clients/" + client_object_name)) DBusObjectWithProperties.__init__(self, self.bus, self.dbus_object_path) @@ -1520,7 +1522,7 @@ u"dress: %s", fpr, address) if self.use_dbus: # Emit D-Bus signal - mandos_dbus_service.ClientNotFound(fpr, address) + mandos_dbus_service.ClientNotFound(fpr, address[0]) parent_pipe.send(False) return False === modified file 'mandos-ctl' --- mandos-ctl 2010-09-25 19:55:17 +0000 +++ mandos-ctl 2010-09-25 23:52:17 +0000 @@ -23,6 +23,10 @@ 'Fingerprint': u'Fingerprint', 'CheckerRunning': u'Check Is Running', 'LastEnabled': u'Last Enabled', + 'ApprovalPending': u'Approval Is Pending', + 'ApprovedByDefault': u'Approved By Default', + 'ApprovalDelay': u"Approval Delay", + 'ApprovalDuration': u"Approval Duration", 'Checker': u'Checker', } defaultkeywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK') @@ -93,7 +97,8 @@ def valuetostring(value, keyword): if type(value) is dbus.Boolean: return u"Yes" if value else u"No" - if keyword in (u"Timeout", u"Interval"): + if keyword in (u"Timeout", u"Interval", u"ApprovalDelay", + u"ApprovalDuration"): return milliseconds_to_string(value) return unicode(value) @@ -122,6 +127,9 @@ options.checker is not None, options.timeout is not None, options.interval is not None, + options.approved_by_default is not None, + options.approval_delay is not None, + options.approval_duration is not None, options.host is not None, options.secret is not None, options.approve, @@ -153,6 +161,16 @@ help="Set timeout for client") parser.add_option("-i", "--interval", type="string", help="Set checker interval for client") + parser.add_option("--approve-by-default", action="store_true", + dest=u"approved_by_default", + help="Set client to be approved by default") + parser.add_option("--deny-by-default", action="store_false", + dest=u"approved_by_default", + help="Set client to be denied by default") + parser.add_option("--approval-delay", type="string", + help="Set delay before client approve/deny") + parser.add_option("--approval-duration", type="string", + help="Set duration of one client approval") parser.add_option("-H", "--host", type="string", help="Set host for client") parser.add_option("-s", "--secret", type="string", @@ -164,12 +182,13 @@ options, client_names = parser.parse_args() if has_actions(options) and not client_names and not options.all: - parser.error('Options requires clients names or --all.') + parser.error('Options require clients names or --all.') if options.verbose and has_actions(options): - parser.error('Verbose option can only be used alone or with --all.') + parser.error('--verbose can only be used alone or with' + ' --all.') if options.all and not has_actions(options): - parser.error('--all requires an action') - + parser.error('--all requires an action.') + try: bus = dbus.SystemBus() mandos_dbus_objc = bus.get_object(busname, server_path) @@ -216,9 +235,12 @@ if not has_actions(options) and clients: if options.verbose: - keywords = ('Name', 'Enabled', 'Timeout', 'LastCheckedOK', - 'Created', 'Interval', 'Host', 'Fingerprint', - 'CheckerRunning', 'LastEnabled', 'Checker') + keywords = ('Name', 'Enabled', 'Timeout', + 'LastCheckedOK', 'Created', 'Interval', + 'Host', 'Fingerprint', 'CheckerRunning', + 'LastEnabled', 'ApprovalPending', + 'ApprovedByDefault', 'ApprovalDelay', + 'ApprovalDuration', 'Checker') else: keywords = defaultkeywords @@ -254,19 +276,39 @@ timedelta_to_milliseconds (string_to_delta(options.interval)), dbus_interface=dbus.PROPERTIES_IFACE) + if options.approval_delay: + client.Set(client_interface, u"ApprovalDelay", + timedelta_to_milliseconds + (string_to_delta(options. + approval_delay)), + dbus_interface=dbus.PROPERTIES_IFACE) + if options.approval_duration: + client.Set(client_interface, u"ApprovalDuration", + timedelta_to_milliseconds + (string_to_delta(options. + approval_duration)), + dbus_interface=dbus.PROPERTIES_IFACE) if options.timeout: client.Set(client_interface, u"Timeout", - timedelta_to_milliseconds(string_to_delta - (options.timeout)), + timedelta_to_milliseconds + (string_to_delta(options.timeout)), dbus_interface=dbus.PROPERTIES_IFACE) if options.secret: client.Set(client_interface, u"Secret", - dbus.ByteArray(open(options.secret, u'rb').read()), + dbus.ByteArray(open(options.secret, + u'rb').read()), + dbus_interface=dbus.PROPERTIES_IFACE) + if options.approved_by_default is not None: + client.Set(client_interface, u"ApprovedByDefault", + dbus.Boolean(options + .approved_by_default), dbus_interface=dbus.PROPERTIES_IFACE) if options.approve: - client.Approve(dbus.Boolean(True), dbus_interface=client_interface) - if options.deny: - client.Approve(dbus.Boolean(False), dbus_interface=client_interface) + client.Approve(dbus.Boolean(True), + dbus_interface=client_interface) + elif options.deny: + client.Approve(dbus.Boolean(False), + dbus_interface=client_interface) if __name__ == '__main__': main() === modified file 'mandos-ctl.xml' --- mandos-ctl.xml 2010-09-25 19:55:17 +0000 +++ mandos-ctl.xml 2010-09-25 23:52:17 +0000 @@ -2,7 +2,7 @@ - + %common; ]> @@ -101,6 +101,30 @@ + + + + + + + + + + + + + + + + + + + - Set the interval option of the specified - client(s); see mandos-client.conf5. + Set the interval option of the + specified client(s); see mandos-clients.conf5. + + + + + + + + + + Set the approved_by_default option of + the specified client(s) to True or + False, respectively; see + mandos-clients.conf5. + + + + + + + + + Set the approval_delay option of the + specified client(s); see mandos-clients.conf5. + + + + + + + + + Set the approval_duration option of the + specified client(s); see mandos-clients.conf5. @@ -318,8 +383,8 @@ Set the host option of the specified client(s); see mandos-client.conf5. + >mandos-clients.conf5. @@ -333,8 +398,8 @@ Set the secfile option of the specified client(s); see mandos-client.conf5. + >mandos-clients.conf5. @@ -471,10 +536,7 @@ To approve all clients currently waiting for it: - - -&COMMANDNAME; --approve --all - + &COMMANDNAME; --approve --all === modified file 'mandos-monitor' --- mandos-monitor 2010-09-14 18:22:03 +0000 +++ mandos-monitor 2010-09-25 23:52:17 +0000 @@ -256,7 +256,7 @@ self.properties[u"LastEnabled"])) timer = timeout - (datetime.datetime.utcnow() - last_ok) message = (u'A checker has failed! Time until client' - u' gets diabled: %s' + u' gets disabled: %s' % unicode(timer).rsplit(".", 1)[0]) else: message = u"enabled"