From 1fd2520a1ff82657b32a19eb5933c01b81e15ef4 Mon Sep 17 00:00:00 2001 From: Vendula Poncova Date: Mar 04 2021 12:19:34 +0000 Subject: [PATCH 1/4] Replace pydbus with dasbus Drop the dependency on pydbus. Use dasbus instead. --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c882601..c05c90a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,7 @@ build:debian: - echo "Do your build here" - apt-get update - apt-get -y install autoconf automake libglib2.0-dev libdbus-glib-1-dev libnotify-dev libgtk-3-dev gcc - - apt-get -y install python3-selinux python3-gi python3-pydbus python3-dbus python3-six python3-sepolicy + - apt-get -y install python3-selinux python3-gi python3-dasbus python3-dbus python3-six python3-sepolicy - apt-get -y install xdg-utils make intltool libaudit-dev libauparse-dev - cd framework - ./autogen.sh diff --git a/framework/configure.ac b/framework/configure.ac index 84301a5..b20a9ee 100644 --- a/framework/configure.ac +++ b/framework/configure.ac @@ -70,13 +70,13 @@ else $python_module_result]) fi -AC_MSG_CHECKING([for the pydbus python3 module]) -python_module_result=`$PYTHON -c "import pydbus" 2>&1` +AC_MSG_CHECKING([for the dasbus python3 module]) +python_module_result=`$PYTHON -c "import dasbus" 2>&1` if test -z "$python_module_result"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) - AC_MSG_ERROR([cannot import Python3 module pydbus. + AC_MSG_ERROR([cannot import Python3 module dasbus. Please check your Python3 installation. The error was: $python_module_result]) fi diff --git a/framework/src/SetroubleshootPrivileged.py b/framework/src/SetroubleshootPrivileged.py index 899e687..d2a9ea4 100644 --- a/framework/src/SetroubleshootPrivileged.py +++ b/framework/src/SetroubleshootPrivileged.py @@ -19,23 +19,23 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from gi.repository import GLib -from pydbus import SystemBus +from dasbus.connection import SystemMessageBus import setroubleshoot.util import signal loop = GLib.MainLoop() class Privileged(object): - """ - - - - - - - - - + __dbus_xml__ = """ + + + + + + + + + """ def __init__(self, timeout=10): @@ -58,6 +58,10 @@ class Privileged(object): loop.quit() if __name__ == "__main__": - bus = SystemBus() - bus.publish("org.fedoraproject.SetroubleshootPrivileged", Privileged()) - loop.run() + bus = SystemMessageBus() + try: + bus.publish_object("/org/fedoraproject/SetroubleshootPrivileged", Privileged()) + bus.register_service("org.fedoraproject.SetroubleshootPrivileged") + loop.run() + finally: + bus.disconnect() diff --git a/framework/src/seapplet b/framework/src/seapplet index 79b5ef2..b5f65d1 100644 --- a/framework/src/seapplet +++ b/framework/src/seapplet @@ -26,7 +26,7 @@ from gi.repository import Gtk gi.require_version('Notify', '0.7') from gi.repository import Notify -from pydbus import SystemBus +from dasbus.connection import SystemMessageBus import selinux import sys @@ -52,13 +52,14 @@ class SEApplet(GObject.Object): def __init__(self): - bus = SystemBus() - self.bus_signal = bus.subscribe( - iface='org.fedoraproject.SetroubleshootdIface', - signal='alert', - signal_fired=self.send_notification + bus = SystemMessageBus() + Setroubleshootd = bus.get_proxy( + 'org.fedoraproject.Setroubleshootd', + '/org/fedoraproject/Setroubleshootd' ) + Setroubleshootd.alert.connect(self.send_notification) + super(SEApplet, self).__init__() Notify.init("seapplet") # lets initialise with the application name @@ -80,11 +81,6 @@ class SEApplet(GObject.Object): except: pass - Setroubleshootd = bus.get( - 'org.fedoraproject.Setroubleshootd', - '/org/fedoraproject/Setroubleshootd' - ) - (count, red) = Setroubleshootd.check_for_new(last_id) if count > 0: @@ -119,8 +115,7 @@ class SEApplet(GObject.Object): launcher.launch(None, context) self.status_icon.set_visible(False) - def send_notification(self, sender, dobject, iface, signal, params): - + def send_notification(self, *params): status_icon = self.__init_status_icon() status_icon.set_visible(True) diff --git a/framework/src/setroubleshoot/util.py b/framework/src/setroubleshoot/util.py index 657c882..02c4f75 100755 --- a/framework/src/setroubleshoot/util.py +++ b/framework/src/setroubleshoot/util.py @@ -69,7 +69,7 @@ __all__ = [ import bz2 import six import datetime -from pydbus import SystemBus +from dasbus.connection import SystemMessageBus import glob from gi.repository import GObject import os @@ -522,8 +522,11 @@ Finds an SELinux module which defines given SELinux context """ if use_dbus: - bus = SystemBus() - remote_object = bus.get("org.fedoraproject.SetroubleshootPrivileged") + bus = SystemMessageBus() + remote_object = bus.get_proxy( + "org.fedoraproject.SetroubleshootPrivileged", + "/org/fedoraproject/SetroubleshootPrivileged" + ) return str(remote_object.get_rpm_nvr_by_scontext(str(scontext))) else: context = selinux.context_new(str(scontext)) From 7e02f26a04dc522adb65a3f94341cb4a23993595 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mar 04 2021 13:18:35 +0000 Subject: [PATCH 2/4] gitlab-ci: install dasbus via pip3 on debian Fixes: # apt-get -y install python3-selinux python3-gi python3-dasbus python3-dbus python3-six python3-sepolicy Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package python3-dasbus --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c05c90a..145ff17 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,8 +31,9 @@ build:debian: - echo "Do your build here" - apt-get update - apt-get -y install autoconf automake libglib2.0-dev libdbus-glib-1-dev libnotify-dev libgtk-3-dev gcc - - apt-get -y install python3-selinux python3-gi python3-dasbus python3-dbus python3-six python3-sepolicy - - apt-get -y install xdg-utils make intltool libaudit-dev libauparse-dev + - apt-get -y install python3-selinux python3-gi python3-dbus python3-six python3-sepolicy + - apt-get -y install xdg-utils make intltool libaudit-dev libauparse-dev python3-pip + - pip3 install dasbus - cd framework - ./autogen.sh - make From fc4ce50a450484544cf88c4044d474e08d2ecde4 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mar 04 2021 13:21:11 +0000 Subject: [PATCH 3/4] gitlab-ci: run apt-get and dnf just once --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 145ff17..79a4974 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,9 +30,10 @@ build:debian: script: - echo "Do your build here" - apt-get update - - apt-get -y install autoconf automake libglib2.0-dev libdbus-glib-1-dev libnotify-dev libgtk-3-dev gcc - - apt-get -y install python3-selinux python3-gi python3-dbus python3-six python3-sepolicy - - apt-get -y install xdg-utils make intltool libaudit-dev libauparse-dev python3-pip + - > + apt-get -y install autoconf automake libglib2.0-dev libdbus-glib-1-dev libnotify-dev + libgtk-3-dev gcc python3-selinux python3-gi python3-dbus python3-six python3-sepolicy + xdg-utils make intltool libaudit-dev libauparse-dev python3-pip - pip3 install dasbus - cd framework - ./autogen.sh @@ -44,8 +45,11 @@ build:fedora: stage: build script: - echo "Do your build here" - - dnf -y install 'dnf-command(builddep)' make gcc automake autoconf - - dnf -y builddep setroubleshoot + - > + dnf -y install make gcc automake autoconf libcap-ng-devel intltool gettext + python3 python3-devel desktop-file-utils dbus-glib-devel gtk2-devel libnotify-devel + audit-libs-devel libselinux-devel polkit-devel python3-libselinux python3-dasbus + python3-gobject gtk3-devel xdg-utils intltool gettext python3 python3-devel - cd framework - ./autogen.sh - make From d43f0cb83e681bdc17d0f7596f2ac5a593213d31 Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Mar 10 2021 12:46:53 +0000 Subject: [PATCH 4/4] framework: export alert dbus signal Fixes: Traceback (most recent call last): File "/usr/bin/seapplet", line 158, in my = SEApplet() File "/usr/bin/seapplet", line 61, in __init__ Setroubleshootd.alert.connect(self.send_notification) File "/usr/lib/python3.9/site-packages/dasbus/client/proxy.py", line 161, in __getattr__ member = self._get_member(self._get_interface(name), name) File "/usr/lib/python3.9/site-packages/dasbus/client/proxy.py", line 223, in _get_interface raise AttributeError( AttributeError: DBus object has no attribute 'alert'. --- diff --git a/framework/src/setroubleshoot/server.py b/framework/src/setroubleshoot/server.py index c3a378a..aef0346 100755 --- a/framework/src/setroubleshoot/server.py +++ b/framework/src/setroubleshoot/server.py @@ -480,6 +480,10 @@ class SetroubleshootdDBusObject(dbus.service.Object): def restart(self, reason): pass + @dbus.service.signal(dbus_system_interface, signature='ss') + def alert(self, level, local_id): + pass + @dbus.service.method(dbus_system_interface) def start(self): self.alarm(0)