Skip to content

Commit

Permalink
gui: fix "file type" selection in fcontextPage
Browse files Browse the repository at this point in the history
A change in seobject.py file_type_str_to_option made the "file type"
list not compatible with items in this ComboBox.
See commit 317743b ("python/semanage: fix export of fcontext socket
entries")

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'

Signed-off-by: Vit Mojzis <[email protected]>
  • Loading branch information
vmojzis authored and bachradsusi committed Feb 24, 2021
1 parent b69d77b commit 9b4e9c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
7 changes: 7 additions & 0 deletions gui/fcontextPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ def __init__(self, xml):
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")

Expand Down
26 changes: 0 additions & 26 deletions gui/system-config-selinux.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 9b4e9c4

Please sign in to comment.