/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: 2022-04-23 21:14:38 UTC
  • Revision ID: teddy@recompile.se-20220423211438-qadwdpyodk1zfra5
Debian package: Client: Update Lintian override file

* debian/mandos-client.lintian-overrides: Remove all empty commented
  lines.  Re-word text to avoid negation.  Rename "setuid-binary" tag
  to "elevated-privileges".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python3 -bbI
2
2
# -*- after-save-hook: (lambda () (let ((command (if (fboundp 'file-local-name) (file-local-name (buffer-file-name)) (or (file-remote-p (buffer-file-name) 'localname) (buffer-file-name))))) (if (= (progn (if (get-buffer "*Test*") (kill-buffer "*Test*")) (process-file-shell-command (format "%s --check" (shell-quote-argument command)) nil "*Test*")) 0) (let ((w (get-buffer-window "*Test*"))) (if w (delete-window w))) (progn (with-current-buffer "*Test*" (compilation-mode)) (display-buffer "*Test*" '(display-buffer-in-side-window)))))); coding: utf-8 -*-
3
3
#
4
 
# Mandos Monitor - Control and monitor the Mandos server
 
4
# Mandos Control - Control or query the Mandos server
5
5
#
6
 
# Copyright © 2008-2019 Teddy Hogeborn
7
 
# Copyright © 2008-2019 Björn Påhlsson
 
6
# Copyright © 2008-2020 Teddy Hogeborn
 
7
# Copyright © 2008-2020 Björn Påhlsson
8
8
#
9
9
# This file is part of Mandos.
10
10
#
89
89
 
90
90
locale.setlocale(locale.LC_ALL, "")
91
91
 
92
 
version = "1.8.9"
 
92
version = "1.8.14"
93
93
 
94
94
 
95
95
def main():
497
497
                             self.properties_iface, interface, key,
498
498
                             value)
499
499
 
 
500
        def call_method(self, methodname, busname, objectpath,
 
501
                        interface, *args):
 
502
            raise NotImplementedError()
 
503
 
 
504
 
500
505
    class MandosBus(SystemBus):
501
506
        busname_domain = "se.recompile"
502
507
        busname = busname_domain + ".Mandos"
721
726
            with self.convert_exception(dbus.Error):
722
727
                value =  method(*args)
723
728
            # DBussy returns values either as an empty list or as a
724
 
            # tuple: (signature, value)
 
729
            # list of one element with the return value
725
730
            if value:
726
731
                return self.type_filter(value[0])
727
732
 
733
738
 
734
739
        def type_filter(self, value):
735
740
            """Convert the most bothersome types to Python types"""
 
741
            # A D-Bus Variant value is represented as the Python type
 
742
            # Tuple[dbussy.DBUS.Signature, Any]
736
743
            if isinstance(value, tuple):
737
744
                if (len(value) == 2
738
745
                    and isinstance(value[0],
1627
1634
        finally:
1628
1635
            dbus_logger.removeFilter(counting_handler)
1629
1636
 
1630
 
        self.assertNotIsInstance(e, dbus.ConnectFailed)
 
1637
        self.assertNotIsInstance(e.exception, dbus.ConnectFailed)
1631
1638
 
1632
1639
        # Make sure the dbus logger was suppressed
1633
1640
        self.assertEqual(0, counting_handler.count)
1770
1777
            self.call_method(bus, "methodname", "busname",
1771
1778
                             "objectpath", "interface")
1772
1779
 
1773
 
        self.assertNotIsInstance(e, dbus.ConnectFailed)
 
1780
        self.assertNotIsInstance(e.exception, dbus.ConnectFailed)
1774
1781
 
1775
1782
    def test_get_converts_to_correct_exception(self):
1776
1783
        bus = pydbus_adapter.SystemBus(
2432
2439
        busname = "se.recompile.Mandos"
2433
2440
        client_interface = "se.recompile.Mandos.Client"
2434
2441
        command.Approve().run(self.bus.clients, self.bus)
 
2442
        self.assertTrue(self.bus.clients)
2435
2443
        for clientpath in self.bus.clients:
2436
2444
            self.assertIn(("Approve", busname, clientpath,
2437
2445
                           client_interface, (True,)), self.bus.calls)
2440
2448
        busname = "se.recompile.Mandos"
2441
2449
        client_interface = "se.recompile.Mandos.Client"
2442
2450
        command.Deny().run(self.bus.clients, self.bus)
 
2451
        self.assertTrue(self.bus.clients)
2443
2452
        for clientpath in self.bus.clients:
2444
2453
            self.assertIn(("Approve", busname, clientpath,
2445
2454
                           client_interface, (False,)),
2446
2455
                          self.bus.calls)
2447
2456
 
2448
2457
    def test_Remove(self):
 
2458
        busname = "se.recompile.Mandos"
 
2459
        server_path = "/"
 
2460
        server_interface = "se.recompile.Mandos"
 
2461
        orig_clients = self.bus.clients.copy()
2449
2462
        command.Remove().run(self.bus.clients, self.bus)
2450
 
        for clientpath in self.bus.clients:
2451
 
            self.assertIn(("RemoveClient", dbus_busname,
2452
 
                           dbus_server_path, dbus_server_interface,
 
2463
        self.assertFalse(self.bus.clients)
 
2464
        for clientpath in orig_clients:
 
2465
            self.assertIn(("RemoveClient", busname,
 
2466
                           server_path, server_interface,
2453
2467
                           (clientpath,)), self.bus.calls)
2454
2468
 
2455
2469
    expected_json = {
2657
2671
        else:
2658
2672
            cmd_args = [() for x in range(len(self.values_to_get))]
2659
2673
            values_to_get = self.values_to_get
 
2674
        self.assertTrue(values_to_get)
2660
2675
        for value_to_get, cmd_arg in zip(values_to_get, cmd_args):
2661
2676
            for clientpath in self.bus.clients:
2662
2677
                self.bus.clients[clientpath][self.propname] = (
2663
2678
                    Unique())
2664
2679
            self.command(*cmd_arg).run(self.bus.clients, self.bus)
 
2680
            self.assertTrue(self.bus.clients)
2665
2681
            for clientpath in self.bus.clients:
2666
2682
                value = (self.bus.clients[clientpath]
2667
2683
                         [self.propname])