=== modified file 'Makefile' --- Makefile 2008-10-28 18:00:20 +0000 +++ Makefile 2008-12-21 19:19:25 +0000 @@ -76,7 +76,7 @@ PLUGINS=plugins.d/password-prompt plugins.d/mandos-client \ plugins.d/usplash plugins.d/splashy plugins.d/askpass-fifo CPROGS=plugin-runner $(PLUGINS) -PROGS=mandos mandos-keygen $(CPROGS) +PROGS=mandos mandos-keygen mandos-list $(CPROGS) DOCS=mandos.8 plugin-runner.8mandos mandos-keygen.8 \ plugins.d/mandos-client.8mandos \ plugins.d/password-prompt.8mandos mandos.conf.5 \ @@ -163,6 +163,11 @@ --expression='s/^\(VERSION="\)[^"]*"$$/\1$(version)"/' \ $@ +mandos-list: Makefile + $(SED) --in-place \ + --expression='s/^\(version = "\)[^"]*"$$/\1$(version)"/' \ + $@ + mandos.lsm: Makefile $(SED) --in-place \ --expression='s/^\(Version:\).*/\1\t$(version)/' \ === modified file 'TODO' --- TODO 2008-12-10 01:26:02 +0000 +++ TODO 2008-12-21 19:19:25 +0000 @@ -6,6 +6,9 @@ klogctl(6, NULL, 0); klogctl(7, NULL, 0); ** TODO [#C] IPv4 support +* plugin-runner +** TODO [#B] use scandir(3) instead of readdir(3) + * mandos (server) ** TODO [#B] Log level :bugs: ** TODO /etc/mandos/clients.d/*.conf @@ -14,6 +17,8 @@ ** TODO [#B] Run-time communication with server :bugs: Probably using D-Bus See also [[*Mandos-tools]] +** Handle non-existing D-Bus server. + Also, possibly a "--no-dbus" option? *** Client class *** Main server + SetLogLevel @@ -30,13 +35,15 @@ This will not be strictly necessary when the D-Bus interface is implemented. -* Mandos-tools/utilities - All of this probably using D-Bus -** TODO List clients +* mandos-list +*** Handle no D-Bus server and/or no Mandos server found better +*** [#B] --dump option ** TODO Disable client ** TODO Enable client ** TODO Reset timer +* Curses interface + * mandos-keygen ** TODO "--secfile" option Using the "secfile" option instead of "secret" === added file 'mandos-list' --- mandos-list 1970-01-01 00:00:00 +0000 +++ mandos-list 2008-12-21 19:19:25 +0000 @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- mode: python; coding: utf-8 -*- + +import dbus +from optparse import OptionParser +import locale + +locale.setlocale(locale.LC_ALL, u'') + +tablewords = { + 'name': u'Name', + 'enabled': u'Enabled', + 'timeout': u'Timeout', + 'last_checked_ok': u'Last Successful Check', + 'created': u'Created', + 'interval': u'Interval', + 'host': u'Host', + 'fingerprint': u'Fingerprint', + 'checker_running': u'Check Is Running', + 'last_enabled': u'Last Enabled', + 'checker': u'Checker', + } +busname = 'org.mandos-system.Mandos' +object_path = '/Mandos' +interface = 'org.mandos_system.Mandos' +version = "1.0.2" +defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok', + 'checker') + +parser = OptionParser(version = "%%prog %s" % version) +parser.add_option("-a", "--all", action="store_true", default=False, + help="Print all fields") +options = parser.parse_args()[0] +if options.all: + keywords = ('name', 'enabled', 'timeout', 'last_checked_ok', + 'created', 'interval', 'host', 'fingerprint', + 'checker_running', 'last_enabled', 'checker') +else: + keywords = defaultkeywords + + +bus = dbus.SystemBus() +mandos_dbus_objc = bus.get_object(busname, object_path) +mandos_serv = dbus.Interface(mandos_dbus_objc, + dbus_interface = interface) +mandos_clients = mandos_serv.GetAllClientsWithProperties() + +def valuetostring(x): + if type(x) is dbus.Boolean: + return u"Yes" if x else u"No" + else: + return unicode(x) + +format_string = u' '.join(u'%%-%ds' + % max(len(tablewords[key]), + max(len(valuetostring(client[key])) + for client + in mandos_clients.itervalues())) + for key in keywords) +print format_string % tuple(tablewords[key] for key in keywords) +for client in mandos_clients.itervalues(): + print format_string % tuple(valuetostring(client[key]) + for key in keywords) + +