Bug 1367038

Summary: firewall-cmd crashes if /run/dbus/system_bus_socket does not exist
Product: Red Hat Enterprise Linux 7 Reporter: Thomas Woerner <twoerner>
Component: firewalldAssignee: Thomas Woerner <twoerner>
Status: CLOSED ERRATA QA Contact: Tomas Dolezal <todoleza>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: extras-qa, todoleza, twoerner, watanabe.yu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: firewalld-0.4.3.2-5.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1358380 Environment:
Last Closed: 2016-11-03 21:04:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1358380    
Bug Blocks:    

Description Thomas Woerner 2016-08-15 11:14:28 UTC
+++ This bug was initially created as a clone of Bug #1358380 +++

Description of problem:

If /run/dbus/system_bus_socket does not exist (e.g. chrooting environment), firewall-cmd crashes as follows.
=====================
[root@localhost ~]# firewall-cmd --reload
Not using slip
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/firewall/client.py", line 2200, in __init__
    self.bus = slip.dbus.SystemBus()
  File "<string>", line 2, in SystemBus
  File "/usr/lib64/python3.5/site-packages/dbus/_dbus.py", line 194, in __new__
    private=private)
  File "/usr/lib64/python3.5/site-packages/dbus/_dbus.py", line 100, in __new__
    bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
  File "/usr/lib64/python3.5/site-packages/dbus/bus.py", line 122, in __new__
    bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/firewall-cmd", line 913, in <module>
    fw = FirewallClient()
  File "<decorator-gen-615>", line 2, in __init__
  File "/usr/lib/python3.5/site-packages/firewall/client.py", line 53, in handle_exceptions
    return func(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/firewall/client.py", line 2204, in __init__
    self.bus = dbus.SystemBus()
  File "/usr/lib64/python3.5/site-packages/dbus/_dbus.py", line 194, in __new__
    private=private)
  File "/usr/lib64/python3.5/site-packages/dbus/_dbus.py", line 100, in __new__
    bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
  File "/usr/lib64/python3.5/site-packages/dbus/bus.py", line 122, in __new__
    bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
=====================

This affects, e.g. when we run the following command:
# dnf --releasever=24 --installroot=/tmp/newsysimage install systemd-journal-remote

Version-Release number of selected component (if applicable):

firewalld-0.4.3.2-1.fc24.noarch
firewalld-0.4.3.2-1.fc25.noarch

How reproducible:

always

Steps to Reproduce:
1. dnf --releasever=24 --installroot=/tmp/newsysimage install systemd-journal-remote

Actual results:

crash with the above report.

Expected results:

firewall-cmd safely fails, that is, just output error message and exit.

Additional info:

firewall-cmd --reload is used in %firewalld_reload rpm macro.
So, when we install software which use the macro in their post scripts to chrooting environment, the above crash always occurs.
Fortunately, the crash does not cause any actual problem as we do not need to reload in such cases.

--- Additional comment from Thomas Woerner on 2016-08-15 06:52:24 EDT ---

Fixed upstream:

https://github.com/t-woerner/firewalld/commit/d9579e983f5a196e7ed155035c0e8283c4f9f904
https://github.com/t-woerner/firewalld/commit/937eb926a1ec6f09a3ff825296927e9964232204

Related to this is also the following upstream fix:

https://github.com/t-woerner/firewalld/commit/63f4f46180d5fe26a68ef6517d2f612fb74a3254

Comment 5 errata-xmlrpc 2016-11-03 21:04:12 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2597.html