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

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