/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-04-09 19:33:36 UTC
  • Revision ID: teddy@recompile.se-20190409193336-6sddo74ybosqog38
Installation: Fix UMASK even if set by some other initramfs hook

* Makefile (install-client-nokey): Install initramfs-tools-conf-hook
               as "/usr/share/initramfs-tools/conf-hooks.d/zz-mandos".
* debian/mandos-client.dirs: Add
  "usr/share/initramfs-tools/conf-hooks.d".
* initramfs-tools-conf-hook: New.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
 
79
79
locale.setlocale(locale.LC_ALL, "")
80
80
 
81
 
version = "1.8.4"
 
81
version = "1.8.3"
82
82
 
83
83
 
84
84
def main():
1780
1780
        self.assert_command_from_args(["--is-enabled", "client"],
1781
1781
                                      command.IsEnabled)
1782
1782
 
1783
 
    def assert_command_from_args(self, args, command_cls, length=1,
1784
 
                                 clients=None, **cmd_attrs):
 
1783
    def assert_command_from_args(self, args, command_cls,
 
1784
                                 **cmd_attrs):
1785
1785
        """Assert that parsing ARGS should result in an instance of
1786
1786
COMMAND_CLS with (optionally) all supplied attributes (CMD_ATTRS)."""
1787
1787
        options = self.parser.parse_args(args)
1788
1788
        check_option_syntax(self.parser, options)
1789
1789
        commands = commands_from_options(options)
1790
 
        self.assertEqual(length, len(commands))
1791
 
        for command in commands:
1792
 
            if isinstance(command, command_cls):
1793
 
                break
1794
 
        else:
1795
 
            self.assertIsInstance(command, command_cls)
1796
 
        if clients is not None:
1797
 
            self.assertEqual(clients, options.client)
 
1790
        self.assertEqual(1, len(commands))
 
1791
        command = commands[0]
 
1792
        self.assertIsInstance(command, command_cls)
1798
1793
        for key, value in cmd_attrs.items():
1799
1794
            self.assertEqual(value, getattr(command, key))
1800
1795
 
1801
 
    def assert_commands_from_args(self, args, commands, clients=None):
1802
 
        for cmd in commands:
1803
 
            self.assert_command_from_args(args, cmd,
1804
 
                                          length=len(commands),
1805
 
                                          clients=clients)
1806
 
 
1807
1796
    def test_is_enabled_short(self):
1808
1797
        self.assert_command_from_args(["-V", "client"],
1809
1798
                                      command.IsEnabled)
2000
1989
                                      verbose=True)
2001
1990
 
2002
1991
 
2003
 
    def test_manual_page_example_1(self):
2004
 
        self.assert_command_from_args("--verbose".split(),
2005
 
                                      command.PrintTable,
2006
 
                                      clients=[],
2007
 
                                      verbose=True)
2008
 
 
2009
 
    def test_manual_page_example_2(self):
2010
 
        self.assert_command_from_args(
2011
 
            "--verbose foo1.example.org foo2.example.org".split(),
2012
 
            command.PrintTable, clients=["foo1.example.org",
2013
 
                                         "foo2.example.org"],
2014
 
            verbose=True)
2015
 
 
2016
 
    def test_manual_page_example_3(self):
2017
 
        self.assert_command_from_args("--enable --all".split(),
2018
 
                                      command.Enable,
2019
 
                                      clients=[])
2020
 
 
2021
 
    def test_manual_page_example_4(self):
2022
 
        self.assert_commands_from_args(
2023
 
            ("--timeout=PT5M --interval=PT1M foo1.example.org"
2024
 
             " foo2.example.org").split(),
2025
 
            [command.SetTimeout, command.SetInterval],
2026
 
            clients=["foo1.example.org", "foo2.example.org"])
2027
 
 
2028
 
    def test_manual_page_example_5(self):
2029
 
        self.assert_command_from_args("--approve --all".split(),
2030
 
                                      command.Approve,
2031
 
                                      clients=[])
2032
 
 
2033
 
 
2034
1992
class TestCommand(unittest.TestCase):
2035
1993
    """Abstract class for tests of command classes"""
2036
1994