/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 Hogeborn
  • Date: 2010-09-25 19:55:17 UTC
  • Revision ID: teddy@fukt.bsnet.se-20100925195517-u0qfi01huxl72f75
* mandos (Client.runtime_expansions): New attribute containing the
                                      allowed runtime expansions.

* mandos-clients.conf.xml (OPTIONS): Reordered alphabetically.

* mandos-ctl: Bug fix: print timeout and interval values pretty again.

* mandos-ctl.xml (EXAMPLE): Added more examples.

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
 
113
114
def has_actions(options):
114
115
    return any((options.enable,
115
116
                options.disable,
161
162
        parser.add_option("-D", "--deny", action="store_true",
162
163
                          help="Deny any current client request")
163
164
        options, client_names = parser.parse_args()
164
 
 
 
165
        
165
166
        if has_actions(options) and not client_names and not options.all:
166
167
            parser.error('Options requires clients names or --all.')
167
168
        if options.verbose and has_actions(options):
195
196
            print >> sys.stderr, "Access denied: Accessing mandos server through dbus."
196
197
            sys.exit(1)
197
198
            
198
 
        # Compile list of clients to process
199
 
        clients=[]
200
 
 
 
199
        # Compile dict of (clients: properties) to process
 
200
        clients={}
 
201
        
201
202
        if options.all or not client_names:
202
 
            clients = (bus.get_object(busname, path) for path in mandos_clients.iterkeys())
 
203
            clients = dict((bus.get_object(busname, path), properties)
 
204
                           for path, properties in
 
205
                           mandos_clients.iteritems())
203
206
        else:
204
207
            for name in client_names:
205
208
                for path, client in mandos_clients.iteritems():
206
209
                    if client['Name'] == name:
207
210
                        client_objc = bus.get_object(busname, path)
208
 
                        clients.append(client_objc)
 
211
                        clients[client_objc] = client
209
212
                        break
210
213
                else:
211
214
                    print >> sys.stderr, "Client not found on server: %r" % name
219
222
            else:
220
223
                keywords = defaultkeywords
221
224
                
222
 
            print_clients(mandos_clients.values(), keywords)
 
225
            print_clients(clients.values(), keywords)
223
226
        else:
224
227
            # Process each client in the list by all selected options
225
228
            for client in clients: