/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 at recompile
  • Date: 2020-12-03 20:30:45 UTC
  • Revision ID: teddy@recompile.se-20201203203045-iqd6nq9y5nwalh1x
Minor fix of a test function

In dracut-module/password-agent, the test function
test_send_password_to_socket_EMSGSIZE() (which tests that the
send_password_to_socket() task function aborts properly when getting
EMSGSIZE when writing to the password socket), part of the test code
is supposed to find a message size which definitely does trigger
EMSGSIZE when send()ing to a socket.  Without a "break" in the proper
place, however, the size given is always exactly 1024 bytes too large.

This is very probably not a problem, since a too large message will
still be too large if it is increased by 1024 bytes, and send(2) in
practice checks the size before reading the buffer.  The biggest issue
would be if some version of send(2) would try to look at the last 1024
bytes of the message buffer before checking the message size; this
would then lead to a buffer over-read when running this test function.
(But even then there would be no security implications since the tests
are not run in the normal operation of the program.)

* dracut-module/password-agent.c
  (test_send_password_to_socket_EMSGSIZE): Break out early when ssret
  < 0 and errno == EMSGSIZE; don't allow loop to increase message_size
  again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
 
90
90
locale.setlocale(locale.LC_ALL, "")
91
91
 
92
 
version = "1.8.14"
 
92
version = "1.8.13"
93
93
 
94
94
 
95
95
def main():
2439
2439
        busname = "se.recompile.Mandos"
2440
2440
        client_interface = "se.recompile.Mandos.Client"
2441
2441
        command.Approve().run(self.bus.clients, self.bus)
2442
 
        self.assertTrue(self.bus.clients)
2443
2442
        for clientpath in self.bus.clients:
2444
2443
            self.assertIn(("Approve", busname, clientpath,
2445
2444
                           client_interface, (True,)), self.bus.calls)
2448
2447
        busname = "se.recompile.Mandos"
2449
2448
        client_interface = "se.recompile.Mandos.Client"
2450
2449
        command.Deny().run(self.bus.clients, self.bus)
2451
 
        self.assertTrue(self.bus.clients)
2452
2450
        for clientpath in self.bus.clients:
2453
2451
            self.assertIn(("Approve", busname, clientpath,
2454
2452
                           client_interface, (False,)),
2455
2453
                          self.bus.calls)
2456
2454
 
2457
2455
    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()
2462
2456
        command.Remove().run(self.bus.clients, self.bus)
2463
 
        self.assertFalse(self.bus.clients)
2464
 
        for clientpath in orig_clients:
2465
 
            self.assertIn(("RemoveClient", busname,
2466
 
                           server_path, server_interface,
 
2457
        for clientpath in self.bus.clients:
 
2458
            self.assertIn(("RemoveClient", dbus_busname,
 
2459
                           dbus_server_path, dbus_server_interface,
2467
2460
                           (clientpath,)), self.bus.calls)
2468
2461
 
2469
2462
    expected_json = {
2671
2664
        else:
2672
2665
            cmd_args = [() for x in range(len(self.values_to_get))]
2673
2666
            values_to_get = self.values_to_get
2674
 
        self.assertTrue(values_to_get)
2675
2667
        for value_to_get, cmd_arg in zip(values_to_get, cmd_args):
2676
2668
            for clientpath in self.bus.clients:
2677
2669
                self.bus.clients[clientpath][self.propname] = (
2678
2670
                    Unique())
2679
2671
            self.command(*cmd_arg).run(self.bus.clients, self.bus)
2680
 
            self.assertTrue(self.bus.clients)
2681
2672
            for clientpath in self.bus.clients:
2682
2673
                value = (self.bus.clients[clientpath]
2683
2674
                         [self.propname])