From c14ebc96d8f4fac792e032da348d25992d503f4c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 26 Jul 2023 19:36:58 +0200 Subject: [PATCH] improvement(client): catch exceptions for unexpecte arguments in FirewallClient._signal_receiver() Add a try-except around dbus_to_python(). Otherwise unexpected arguments of a D-Bus signal will raise an exception for @handle_exceptions decorator. When talking D-Bus, we should not treat the other peer as trusted, even if it's the firewalld daemon. On the other hand, move cb_args.extend(cb[1]) out of the try-except. This really is not supposed to fail. --- src/firewall/client.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/firewall/client.py b/src/firewall/client.py index 92c9e3563..e634cd813 100644 --- a/src/firewall/client.py +++ b/src/firewall/client.py @@ -3470,11 +3470,17 @@ def _signal_receiver(self, *dbus_args, member=None, interface=None, path=None): return # call back with dbus_args converted to python types ... - cb_args = [dbus_to_python(arg) for arg in dbus_args] try: - if cb[1]: - # add call data - cb_args.extend(cb[1]) + cb_args = [dbus_to_python(arg) for arg in dbus_args] + except TypeError: + # Unexpected D-Bus type in the argument? Seems the D-Bus API + # is unexpected. Silently ignore. + return + + if cb[1]: + # add call data + cb_args.extend(cb[1]) + try: # call back cb[0](*cb_args) except Exception as msg: