/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: Björn Påhlsson
  • Date: 2010-09-09 22:06:10 UTC
  • mto: (237.4.3 mandos-release)
  • mto: This revision was merged to the branch mainline in revision 421.
  • Revision ID: belorn@fukt.bsnet.se-20100909220610-fcpkaykznlq22oaw
minor debug info for plugin-runner.
Commit before merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    'last_enabled': u'Last Enabled',
25
25
    'checker': u'Checker',
26
26
    }
27
 
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok',
28
 
                   'checker')
 
27
defaultkeywords = ('name', 'enabled', 'timeout', 'last_checked_ok')
29
28
domain = 'se.bsnet.fukt'
30
29
busname = domain + '.Mandos'
31
30
server_path = '/'
32
31
server_interface = domain + '.Mandos'
33
32
client_interface = domain + '.Mandos.Client'
34
33
version = "1.0.14"
35
 
bus = dbus.SystemBus()
36
 
mandos_dbus_objc = bus.get_object(busname, server_path)
 
34
try:
 
35
    bus = dbus.SystemBus()
 
36
    mandos_dbus_objc = bus.get_object(busname, server_path)
 
37
except dbus.exceptions.DBusException:
 
38
    sys.exit(1)
 
39
    
37
40
mandos_serv = dbus.Interface(mandos_dbus_objc,
38
41
                             dbus_interface = server_interface)
39
42
mandos_clients = mandos_serv.GetAllClientsWithProperties()
128
131
                  help="Start checker for client")
129
132
parser.add_option("--stop-checker", action="store_true",
130
133
                  help="Stop checker for client")
131
 
parser.add_option("-V", "--is-valid", action="store_true",
132
 
                  help="Check if client is still valid")
 
134
parser.add_option("-V", "--is-enabled", action="store_true",
 
135
                  help="Check if client is enabled")
133
136
parser.add_option("-r", "--remove", action="store_true",
134
137
                  help="Remove client")
135
138
parser.add_option("-c", "--checker", type="string",
142
145
                  help="Set host for client")
143
146
parser.add_option("-s", "--secret", type="string",
144
147
                  help="Set password blob (file) for client")
 
148
parser.add_option("-A", "--approve", action="store_true",
 
149
                  help="Approve any current client request")
 
150
parser.add_option("-D", "--deny", action="store_true",
 
151
                  help="Deny any current client request")
145
152
options, client_names = parser.parse_args()
146
153
 
147
154
# Compile list of clients to process
178
185
        client.StartChecker(dbus_interface=client_interface)
179
186
    if options.stop_checker:
180
187
        client.StopChecker(dbus_interface=client_interface)
181
 
    if options.is_valid:
 
188
    if options.is_enabled:
182
189
        sys.exit(0 if client.Get(client_interface,
183
190
                                 u"enabled",
184
191
                                 dbus_interface=dbus.PROPERTIES_IFACE)
203
210
        client.Set(client_interface, u"secret",
204
211
                   dbus.ByteArray(open(options.secret, u'rb').read()),
205
212
                   dbus_interface=dbus.PROPERTIES_IFACE)
 
213
    if options.approve:
 
214
        client.Approve(dbus.Boolean(True), dbus_interface=client_interface)
 
215
    if options.deny:
 
216
        client.Approve(dbus.Boolean(False), dbus_interface=client_interface)