All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dbus: Fix FileNotFoundError in org.selinux.relabel_on_boot
@ 2019-11-15 14:54 Petr Lautrbach
  2019-11-15 15:01 ` Stephen Smalley
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Petr Lautrbach @ 2019-11-15 14:54 UTC (permalink / raw)
  To: selinux; +Cc: Petr Lautrbach

When org.selinux.relabel_on_boot(0) was called twice, it failed with
FileNotFoundError.

Fixes:
    $ dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.relabel_on_boot int64:1
    method return sender=:1.53 -> dest=:1.54 reply_serial=2
    $ dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.relabel_on_boot int64:0
    method return sender=:1.53 -> dest=:1.55 reply_serial=2
    $ dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.relabel_on_boot int64:0
    Error org.freedesktop.DBus.Python.FileNotFoundError: FileNotFoundError: [Errno 2] No such file or directory: '/.autorelabel'

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---

Note: This is python 3 only code and it fails in travis with PYVER=python2.7 RUBYLIBVER=2.6:

$ PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8

Analyzing 187 Python scripts

./dbus/selinux_server.py:90:20: F821 undefined name 'FileNotFoundError'

./installdir/usr/share/system-config-selinux/selinux_server.py:90:20: F821 undefined name 'FileNotFoundError'

The command "PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8" exited with 1.



 dbus/selinux_server.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dbus/selinux_server.py b/dbus/selinux_server.py
index b9debc071485..be4f4557a9fa 100644
--- a/dbus/selinux_server.py
+++ b/dbus/selinux_server.py
@@ -85,7 +85,10 @@ class selinux_server(slip.dbus.service.Object):
             fd = open("/.autorelabel", "w")
             fd.close()
         else:
-            os.unlink("/.autorelabel")
+            try:
+                os.unlink("/.autorelabel")
+            except FileNotFoundError:
+                pass
 
     def write_selinux_config(self, enforcing=None, policy=None):
         path = selinux.selinux_path() + "config"
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-21 17:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-15 14:54 [PATCH] dbus: Fix FileNotFoundError in org.selinux.relabel_on_boot Petr Lautrbach
2019-11-15 15:01 ` Stephen Smalley
2019-11-16 17:04   ` Nicolas Iooss
2019-11-18  9:32     ` Petr Lautrbach
2019-11-20 13:06 ` [Non-DoD Source] " Stephen Smalley
2019-11-21 17:08 ` Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.