SELinux Security Module development
 help / color / mirror / Atom feed
* [PATCH] gui: fix "file type" selection in fcontextPage
@ 2021-02-16 20:08 Vit Mojzis
  2021-02-17 15:26 ` Ondrej Mosnacek
  0 siblings, 1 reply; 4+ messages in thread
From: Vit Mojzis @ 2021-02-16 20:08 UTC (permalink / raw)
  To: selinux

A change in seobject.py file_type_str_to_option made the "file type"
list not compatible with items in this ComboBox.
See: 317743bbe2a235a5c68f1066b4153e0726a3118f

Avoid this in the future by populating the ComboBox using keys from
file_type_str_to_option.

This change disables translations on the file types, but those cause
other issues (adding file context fails the same way as with 'socket
file' since the translated strings differ form
file_type_str_to_option.keys, 'properties' of a file context entry
shows no file type for the same reason).

Fixes:
 Traceback (most recent call last):
  File "/usr/share/system-config-selinux/system-config-selinux.py", line 136, in add
    self.tabs[self.notebook.get_current_page()].addDialog()
  File "/usr/share/system-config-selinux/semanagePage.py", line 143, in addDialog
    if self.add() is False:
  File "/usr/share/system-config-selinux/fcontextPage.py", line 195, in add
    (rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, seobject.file_type_str_to_option[ftype], fspec))
 KeyError: 'socket file'
---
 gui/fcontextPage.py          |  7 +++++++
 gui/system-config-selinux.ui | 26 --------------------------
 2 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/gui/fcontextPage.py b/gui/fcontextPage.py
index 370bbee4..d26aa1b4 100644
--- a/gui/fcontextPage.py
+++ b/gui/fcontextPage.py
@@ -102,6 +102,13 @@ class fcontextPage(semanagePage):
         self.load()
         self.fcontextEntry = xml.get_object("fcontextEntry")
         self.fcontextFileTypeCombo = xml.get_object("fcontextFileTypeCombo")
+        # Populate file type combo_box
+        liststore = self.fcontextFileTypeCombo.get_model()
+        for ftype in seobject.file_type_str_to_option.keys():
+            iter = liststore.append()
+            liststore.set_value(iter, 0, ftype)
+        iter = liststore.get_iter_first()
+        self.fcontextFileTypeCombo.set_active_iter(iter)
         self.fcontextTypeEntry = xml.get_object("fcontextTypeEntry")
         self.fcontextMLSEntry = xml.get_object("fcontextMLSEntry")
 
diff --git a/gui/system-config-selinux.ui b/gui/system-config-selinux.ui
index 7cc1cc53..e7b84a64 100644
--- a/gui/system-config-selinux.ui
+++ b/gui/system-config-selinux.ui
@@ -401,32 +401,6 @@ Level</property>
       <!-- column-name gchararray -->
       <column type="gchararray"/>
     </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">all files</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">regular file</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">directory</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">character device</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">block device</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">socket file</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">symbolic link</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">named pipe</col>
-      </row>
-    </data>
   </object>
   <object class="GtkDialog" id="fcontextDialog">
     <property name="can_focus">False</property>
-- 
2.29.2


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

end of thread, other threads:[~2021-02-24 15:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-16 20:08 [PATCH] gui: fix "file type" selection in fcontextPage Vit Mojzis
2021-02-17 15:26 ` Ondrej Mosnacek
2021-02-19 14:23   ` [PATCH v2] " Vit Mojzis
2021-02-24 14:16     ` Petr Lautrbach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox