Skip to content

Commit

Permalink
improvement(client): catch exceptions for unexpecte arguments in Fire…
Browse files Browse the repository at this point in the history
…wallClient._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.
  • Loading branch information
thom311 authored and erig0 committed Nov 21, 2023
1 parent cc88ab5 commit c14ebc9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/firewall/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c14ebc9

Please sign in to comment.