Blame SOURCES/0031-dbus-Fix-FileNotFoundError-in-org.selinux.relabel_on.patch

9bbebd
From 6e5ccf2dd3329b400b70b7806b9c6128c5c50995 Mon Sep 17 00:00:00 2001
9bbebd
From: Petr Lautrbach <plautrba@redhat.com>
9bbebd
Date: Fri, 15 Nov 2019 09:15:49 +0100
9bbebd
Subject: [PATCH] dbus: Fix FileNotFoundError in org.selinux.relabel_on_boot
9bbebd
9bbebd
When org.selinux.relabel_on_boot(0) was called twice, it failed with
9bbebd
FileNotFoundError.
9bbebd
9bbebd
Fixes:
9bbebd
    $ dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.relabel_on_boot int64:1
9bbebd
    method return sender=:1.53 -> dest=:1.54 reply_serial=2
9bbebd
    $ dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.relabel_on_boot int64:0
9bbebd
    method return sender=:1.53 -> dest=:1.55 reply_serial=2
9bbebd
    $ dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.relabel_on_boot int64:0
9bbebd
    Error org.freedesktop.DBus.Python.FileNotFoundError: FileNotFoundError: [Errno 2] No such file or directory: '/.autorelabel'
9bbebd
9bbebd
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
9bbebd
---
9bbebd
 dbus/selinux_server.py | 5 ++++-
9bbebd
 1 file changed, 4 insertions(+), 1 deletion(-)
9bbebd
9bbebd
diff --git a/dbus/selinux_server.py b/dbus/selinux_server.py
9bbebd
index b9debc071485..be4f4557a9fa 100644
9bbebd
--- a/dbus/selinux_server.py
9bbebd
+++ b/dbus/selinux_server.py
9bbebd
@@ -85,7 +85,10 @@ class selinux_server(slip.dbus.service.Object):
9bbebd
             fd = open("/.autorelabel", "w")
9bbebd
             fd.close()
9bbebd
         else:
9bbebd
-            os.unlink("/.autorelabel")
9bbebd
+            try:
9bbebd
+                os.unlink("/.autorelabel")
9bbebd
+            except FileNotFoundError:
9bbebd
+                pass
9bbebd
 
9bbebd
     def write_selinux_config(self, enforcing=None, policy=None):
9bbebd
         path = selinux.selinux_path() + "config"
9bbebd
-- 
9bbebd
2.23.0
9bbebd