/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: 2019-03-08 22:57:26 UTC
  • Revision ID: teddy@recompile.se-20190308225726-9tmoaw98l7dmzteh
mandos-ctl: Bug fix: close an open file

* mandos-ctl (TestSetSecretCmd): Don't open /dev/null in the class
                                 definition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
300
300
    """Abstract class for Actions for setting one client property"""
301
301
    def run_on_one_client(self, client, properties):
302
302
        """Set the Client's D-Bus property"""
303
 
        log.debug("D-Bus: %s:%s:%s.Set(%r, %r, %r)", busname,
304
 
                  client.__dbus_object_path__,
305
 
                  dbus.PROPERTIES_IFACE, client_interface,
306
 
                  self.property, self.value_to_set
307
 
                  if not isinstance(self.value_to_set, dbus.Boolean)
308
 
                  else bool(self.value_to_set))
309
303
        client.Set(client_interface, self.property, self.value_to_set,
310
304
                   dbus_interface=dbus.PROPERTIES_IFACE)
311
305
 
437
431
 
438
432
class RemoveCmd(Command):
439
433
    def run_on_one_client(self, client, properties):
440
 
        log.debug("D-Bus: %s:%s:%s.RemoveClient(%r)", busname,
441
 
                  server_path, server_interface,
442
 
                  str(client.__dbus_object_path__))
443
434
        self.mandos.RemoveClient(client.__dbus_object_path__)
444
435
 
445
436
class ApproveCmd(Command):
446
437
    def run_on_one_client(self, client, properties):
447
 
        log.debug("D-Bus: %s:%s.Approve(True)",
448
 
                  client.__dbus_object_path__, client_interface)
449
438
        client.Approve(dbus.Boolean(True),
450
439
                       dbus_interface=client_interface)
451
440
 
452
441
class DenyCmd(Command):
453
442
    def run_on_one_client(self, client, properties):
454
 
        log.debug("D-Bus: %s:%s.Approve(False)",
455
 
                  client.__dbus_object_path__, client_interface)
456
443
        client.Approve(dbus.Boolean(False),
457
444
                       dbus_interface=client_interface)
458
445
 
579
566
        help="Approve any current client request")
580
567
    approve_deny.add_argument("-D", "--deny", action="store_true",
581
568
                              help="Deny any current client request")
582
 
    parser.add_argument("--debug", action="store_true",
583
 
                        help="Debug mode (show D-Bus commands)")
584
569
    parser.add_argument("--check", action="store_true",
585
570
                        help="Run self-test")
586
571
    parser.add_argument("client", nargs="*", help="Client name")
708
693
 
709
694
    clientnames = options.client
710
695
 
711
 
    if options.debug:
712
 
        log.setLevel(logging.DEBUG)
713
 
 
714
696
    try:
715
697
        bus = dbus.SystemBus()
716
 
        log.debug("D-Bus: Connect to: (name=%r, path=%r)", busname,
717
 
                  server_path)
718
698
        mandos_dbus_objc = bus.get_object(busname, server_path)
719
699
    except dbus.exceptions.DBusException:
720
700
        log.critical("Could not connect to Mandos server")
733
713
    dbus_filter = NullFilter()
734
714
    try:
735
715
        dbus_logger.addFilter(dbus_filter)
736
 
        log.debug("D-Bus: %s:%s:%s.GetManagedObjects()", busname,
737
 
                  server_path, dbus.OBJECT_MANAGER_IFACE)
738
716
        mandos_clients = {path: ifs_and_props[client_interface]
739
717
                          for path, ifs_and_props in
740
718
                          mandos_serv_object_manager