/mandos/trunk

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

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: teddy at bsnet
  • Date: 2010-09-14 18:22:03 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100914182203-w26c64tdthto4jg2
* mandos-monitor.xml: New.
* Makefile (PROGS): Add "mandos-monitor".
  (DOCS): Add "mandos-monitor.xml".
  (mandos-monitor.8, mandos-monitor.8.xhtml, mandos-monitor): New.
  (install-server): Install "mandos-ctl" and "mandos-monitor" too.
  (uninstall-server): Remove "mandos-ctl" and "mandos-monitor" too.
* mandos-monitor: Don't log uninteresting messages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
    def valuetostring(value, keyword):
94
94
        if type(value) is dbus.Boolean:
95
95
            return u"Yes" if value else u"No"
96
 
        if keyword in (u"Timeout", u"Interval"):
 
96
        if keyword in (u"timeout", u"interval"):
97
97
            return milliseconds_to_string(value)
98
98
        return unicode(value)
99
99
    
110
110
    for client in clients:
111
111
        print format_string % tuple(valuetostring(client[key], key)
112
112
                                    for key in keywords)
113
 
 
114
113
def has_actions(options):
115
114
    return any((options.enable,
116
115
                options.disable,
162
161
        parser.add_option("-D", "--deny", action="store_true",
163
162
                          help="Deny any current client request")
164
163
        options, client_names = parser.parse_args()
165
 
        
 
164
 
166
165
        if has_actions(options) and not client_names and not options.all:
167
166
            parser.error('Options requires clients names or --all.')
168
167
        if options.verbose and has_actions(options):
196
195
            print >> sys.stderr, "Access denied: Accessing mandos server through dbus."
197
196
            sys.exit(1)
198
197
            
199
 
        # Compile dict of (clients: properties) to process
200
 
        clients={}
201
 
        
 
198
        # Compile list of clients to process
 
199
        clients=[]
 
200
 
202
201
        if options.all or not client_names:
203
 
            clients = dict((bus.get_object(busname, path), properties)
204
 
                           for path, properties in
205
 
                           mandos_clients.iteritems())
 
202
            clients = (bus.get_object(busname, path) for path in mandos_clients.iterkeys())
206
203
        else:
207
204
            for name in client_names:
208
205
                for path, client in mandos_clients.iteritems():
209
206
                    if client['Name'] == name:
210
207
                        client_objc = bus.get_object(busname, path)
211
 
                        clients[client_objc] = client
 
208
                        clients.append(client_objc)
212
209
                        break
213
210
                else:
214
211
                    print >> sys.stderr, "Client not found on server: %r" % name
222
219
            else:
223
220
                keywords = defaultkeywords
224
221
                
225
 
            print_clients(clients.values(), keywords)
 
222
            print_clients(mandos_clients.values(), keywords)
226
223
        else:
227
224
            # Process each client in the list by all selected options
228
225
            for client in clients: