|
|
dddd59 |
commit d9579e983f5a196e7ed155035c0e8283c4f9f904
|
|
|
dddd59 |
Author: Thomas Woerner <twoerner@redhat.com>
|
|
|
dddd59 |
Date: Mon Aug 15 11:51:32 2016 +0200
|
|
|
dddd59 |
|
|
|
dddd59 |
firewall.client: Generate new DBUS_ERROR if SystemBus can not be aquired
|
|
|
dddd59 |
|
|
|
dddd59 |
This happens for example in change roots. The SystemBus() call in slip.dbus
|
|
|
dddd59 |
fails and also the dbus.SystemBus() call.
|
|
|
dddd59 |
|
|
|
dddd59 |
New error code: DBUS_ERROR
|
|
|
dddd59 |
|
|
|
dddd59 |
diff --git a/src/firewall/client.py b/src/firewall/client.py
|
|
|
dddd59 |
index 177a74e..5875df2 100644
|
|
|
dddd59 |
--- a/src/firewall/client.py
|
|
|
dddd59 |
+++ b/src/firewall/client.py
|
|
|
dddd59 |
@@ -2207,8 +2207,13 @@ class FirewallClient(object):
|
|
|
dddd59 |
self.bus = slip.dbus.SystemBus()
|
|
|
dddd59 |
self.bus.default_timeout = None
|
|
|
dddd59 |
except Exception:
|
|
|
dddd59 |
- print("Not using slip")
|
|
|
dddd59 |
- self.bus = dbus.SystemBus()
|
|
|
dddd59 |
+ try:
|
|
|
dddd59 |
+ self.bus = dbus.SystemBus()
|
|
|
dddd59 |
+ except dbus.exceptions.DBusException as e:
|
|
|
dddd59 |
+ raise FirewallError(errors.DBUS_ERROR,
|
|
|
dddd59 |
+ e.get_dbus_message())
|
|
|
dddd59 |
+ else:
|
|
|
dddd59 |
+ print("Not using slip.dbus")
|
|
|
dddd59 |
else:
|
|
|
dddd59 |
self.bus = bus
|
|
|
dddd59 |
|
|
|
dddd59 |
diff --git a/src/firewall/errors.py b/src/firewall/errors.py
|
|
|
dddd59 |
index d939864..34d1d18 100644
|
|
|
dddd59 |
--- a/src/firewall/errors.py
|
|
|
dddd59 |
+++ b/src/firewall/errors.py
|
|
|
dddd59 |
@@ -44,6 +44,7 @@ IPSET_WITH_TIMEOUT = 32
|
|
|
dddd59 |
BUILTIN_IPSET = 33
|
|
|
dddd59 |
ALREADY_SET = 34
|
|
|
dddd59 |
MISSING_IMPORT = 35
|
|
|
dddd59 |
+DBUS_ERROR = 36
|
|
|
dddd59 |
|
|
|
dddd59 |
INVALID_ACTION = 100
|
|
|
dddd59 |
INVALID_SERVICE = 101
|
|
|
dddd59 |
|
|
|
dddd59 |
commit 937eb926a1ec6f09a3ff825296927e9964232204
|
|
|
dddd59 |
Author: Thomas Woerner <twoerner@redhat.com>
|
|
|
dddd59 |
Date: Mon Aug 15 11:55:19 2016 +0200
|
|
|
dddd59 |
|
|
|
dddd59 |
firewall-cmd, firewallctl: Gracefully fail if SystemBus can not be aquired
|
|
|
dddd59 |
|
|
|
dddd59 |
diff --git a/src/firewall-cmd b/src/firewall-cmd
|
|
|
dddd59 |
index 3cf3059..75513c7 100755
|
|
|
dddd59 |
--- a/src/firewall-cmd
|
|
|
dddd59 |
+++ b/src/firewall-cmd
|
|
|
dddd59 |
@@ -911,7 +911,13 @@ if a.help:
|
|
|
dddd59 |
sys.exit(0)
|
|
|
dddd59 |
|
|
|
dddd59 |
zone = a.zone
|
|
|
dddd59 |
-fw = FirewallClient()
|
|
|
dddd59 |
+
|
|
|
dddd59 |
+try:
|
|
|
dddd59 |
+ fw = FirewallClient()
|
|
|
dddd59 |
+except FirewallError as msg:
|
|
|
dddd59 |
+ code = FirewallError.get_code(str(msg))
|
|
|
dddd59 |
+ cmd.print_and_exit("Error: %s" % msg, code)
|
|
|
dddd59 |
+
|
|
|
dddd59 |
fw.setExceptionHandler(cmd.exception_handler)
|
|
|
dddd59 |
if fw.connected == False:
|
|
|
dddd59 |
if a.state:
|
|
|
dddd59 |
commit 63f4f46180d5fe26a68ef6517d2f612fb74a3254
|
|
|
dddd59 |
Author: Thomas Woerner <twoerner@redhat.com>
|
|
|
dddd59 |
Date: Mon Aug 15 11:57:06 2016 +0200
|
|
|
dddd59 |
|
|
|
dddd59 |
firewall.core.fw_nm: Ignore NetworkManager if NM.Client connect fails
|
|
|
dddd59 |
|
|
|
dddd59 |
This happens for example in change roots.
|
|
|
dddd59 |
|
|
|
dddd59 |
diff --git a/src/firewall/core/fw_nm.py b/src/firewall/core/fw_nm.py
|
|
|
dddd59 |
index 5f8c8f8..c958e9a 100644
|
|
|
dddd59 |
--- a/src/firewall/core/fw_nm.py
|
|
|
dddd59 |
+++ b/src/firewall/core/fw_nm.py
|
|
|
dddd59 |
@@ -27,6 +27,7 @@ __all__ = [ "check_nm_imported", "nm_is_imported",
|
|
|
dddd59 |
"nm_get_bus_name", "nm_get_dbus_interface" ]
|
|
|
dddd59 |
|
|
|
dddd59 |
import gi
|
|
|
dddd59 |
+from gi.repository import GLib
|
|
|
dddd59 |
try:
|
|
|
dddd59 |
gi.require_version('NM', '1.0')
|
|
|
dddd59 |
except ValueError:
|
|
|
dddd59 |
@@ -35,8 +36,7 @@ else:
|
|
|
dddd59 |
try:
|
|
|
dddd59 |
from gi.repository import NM
|
|
|
dddd59 |
_nm_imported = True
|
|
|
dddd59 |
- except (ImportError, ValueError):
|
|
|
dddd59 |
- NetworkManager = None
|
|
|
dddd59 |
+ except (ImportError, ValueError, GLib.Error):
|
|
|
dddd59 |
_nm_imported = False
|
|
|
dddd59 |
|
|
|
dddd59 |
from firewall import errors
|