policycoreutils/gui: fix system-config-selinux editing features
PATCH 1/1 policycoreutils/gui: fix system-config-selinux editing features
Return column definitions to portsPage (gui fails to load otherwise).
fcontextPage:
"ftype" dropdown was filled from 2 sources (system-config-selinux.glade and fcontextPage - from seobject module) which resulted in duplicate and invalid options. When given to "semanage fcontext -f", ftype has to be converted to 1 letter argument mode.
TreeView.get_selection().get_selected() can return "None" if no item is selected (the list can be empty). Test if correct iterator was acquired.
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1344842
--- policycoreutils/gui/fcontextPage.py | 17 +++++------------ policycoreutils/gui/portsPage.py | 6 ++++++ policycoreutils/gui/semanagePage.py | 4 ++-- policycoreutils/gui/system-config-selinux.glade | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-)
policycoreutils/gui/fcontextPage.py +5 -12
@@ -105,13 +105,6 @@ class fcontextPage(semanagePage): self.load() self.fcontextEntry = xml.get_widget("fcontextEntry") self.fcontextFileTypeCombo = xml.get_widget("fcontextFileTypeCombo") - liststore = self.fcontextFileTypeCombo.get_model() - for k in seobject.file_types: - if len(k) > 0 and k[0] != '-': - iter = liststore.append() - liststore.set_value(iter, 0, k) - iter = liststore.get_iter_first() - self.fcontextFileTypeCombo.set_active_iter(iter) self.fcontextTypeEntry = xml.get_widget("fcontextTypeEntry") self.fcontextMLSEntry = xml.get_widget("fcontextMLSEntry")
@@ -183,7 +176,7 @@ class fcontextPage(semanagePage): fspec = store.get_value(iter, SPEC_COL) ftype = store.get_value(iter, FTYPE_COL) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -d -f '%s' '%s'" % (ftype, fspec)) + (rc, out) = getstatusoutput("semanage fcontext -d -f '%s' '%s'" % (seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0:
@@ -194,14 +187,14 @@ class fcontextPage(semanagePage): self.error(e.args[0]) def add(self): - ftype = ["", "--", "-d", "-c", "-b", "-s", "-l", "-p"] fspec = self.fcontextEntry.get_text().strip() type = self.fcontextTypeEntry.get_text().strip() mls = self.fcontextMLSEntry.get_text().strip() list_model = self.fcontextFileTypeCombo.get_model() - active = self.fcontextFileTypeCombo.get_active() + it = self.fcontextFileTypeCombo.get_active_iter() + ftype = list_model.get_value(it,0) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, ftype[active], fspec)) + (rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0: self.error(out)
@@ -220,7 +213,7 @@ class fcontextPage(semanagePage): iter = self.fcontextFileTypeCombo.get_active_iter() ftype = list_model.get_value(iter, 0) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -m -t %s -r %s -f '%s' '%s'" % (type, mls, ftype, fspec)) + (rc, out) = getstatusoutput("semanage fcontext -m -t %s -r %s -f '%s' '%s'" % (type, mls, seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0: self.error(out)
policycoreutils/gui/portsPage.py +6 -0
@@ -23,6 +23,12 @@ import os import gobject import sys import seobject + +TYPE_COL = 0 +PROTOCOL_COL = 1 +MLS_COL = 2 +PORT_COL = 3 + try: from subprocess import getstatusoutput except ImportError:
policycoreutils/gui/semanagePage.py +2 -2
@@ -130,8 +130,8 @@ class semanagePage: dlg.destroy() def deleteDialog(self): - store, iter = self.view.get_selection().get_selected() - if self.verify(_("Are you sure you want to delete %s '%s'?" % (self.description, store.get_value(iter, 0))), _("Delete %s" % self.description)) == gtk.RESPONSE_YES: + store, it = self.view.get_selection().get_selected() + if (it is not None) and (self.verify(_("Are you sure you want to delete %s '%s'?" % (self.description, store.get_value(it, 0))), _("Delete %s" % self.description)) == gtk.RESPONSE_YES): self.delete() def use_menus(self):
policycoreutils/gui/system-config-selinux.glade +1 -1
@@ -729,7 +729,7 @@ regular file directory character device block device -socket +socket file symbolic link named pipe </property>
Signature · 1 line
2.7.4
Quoted 10 lines · Vit Mojzis
Return column definitions to portsPage (gui fails to load otherwise).
fcontextPage:
"ftype" dropdown was filled from 2 sources (system-config-selinux.glade and fcontextPage - from seobject module) which resulted in duplicate and invalid options. When given to "semanage fcontext -f", ftype has to be converted to 1 letter argument mode.TreeView.get_selection().get_selected() can return "None" if no item is selected (the list can be empty). Test if correct iterator was acquired.
Thanks. However, I can't seem to get system-config-selinux built from upstream to run before or after this patch:
$ system-config-selinux
Traceback (most recent call last):
File "/usr/share/system-config-selinux/system-config-selinux.py", line
36, in <module>
import gnome
ImportError: No module named gnomeAre there other changes in Fedora that are required?
Quoted 112 lines
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1344842Signed-off-by vmojzis <[email protected]>--- policycoreutils/gui/fcontextPage.py | 17 +++++------------ policycoreutils/gui/portsPage.py | 6 ++++++ policycoreutils/gui/semanagePage.py | 4 ++-- policycoreutils/gui/system-config-selinux.glade | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-)policycoreutils/gui/fcontextPage.py +5
-12@@ -105,13 +105,6 @@ class fcontextPage(semanagePage): self.load() self.fcontextEntry = xml.get_widget("fcontextEntry") self.fcontextFileTypeCombo = xml.get_widget("fcontextFileTypeCombo") - liststore = self.fcontextFileTypeCombo.get_model() - for k in seobject.file_types: - if len(k) > 0 and k[0] != '-': - iter = liststore.append() - liststore.set_value(iter, 0, k) - iter = liststore.get_iter_first() - self.fcontextFileTypeCombo.set_active_iter(iter) self.fcontextTypeEntry = xml.get_widget("fcontextTypeEntry") self.fcontextMLSEntry = xml.get_widget("fcontextMLSEntry")@@ -183,7 +176,7 @@ class fcontextPage(semanagePage): fspec = store.get_value(iter, SPEC_COL) ftype = store.get_value(iter, FTYPE_COL) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -d -f '%s' '%s'" % (ftype, fspec)) + (rc, out) = getstatusoutput("semanage fcontext -d -f '%s' '%s'" % (seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0:@@ -194,14 +187,14 @@ class fcontextPage(semanagePage): self.error(e.args[0]) def add(self): - ftype = ["", "--", "-d", "-c", "-b", "-s", "-l", "-p"] fspec = self.fcontextEntry.get_text().strip() type = self.fcontextTypeEntry.get_text().strip() mls = self.fcontextMLSEntry.get_text().strip() list_model = self.fcontextFileTypeCombo.get_model() - active = self.fcontextFileTypeCombo.get_active() + it = self.fcontextFileTypeCombo.get_active_iter() + ftype = list_model.get_value(it,0) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, ftype[active], fspec)) + (rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0: self.error(out)@@ -220,7 +213,7 @@ class fcontextPage(semanagePage): iter = self.fcontextFileTypeCombo.get_active_iter() ftype = list_model.get_value(iter, 0) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -m -t %s -r %s -f '%s' '%s'" % (type, mls, ftype, fspec)) + (rc, out) = getstatusoutput("semanage fcontext -m -t %s -r %s -f '%s' '%s'" % (type, mls, seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0: self.error(out)policycoreutils/gui/portsPage.py +6
-0@@ -23,6 +23,12 @@ import os import gobject import sys import seobject + +TYPE_COL = 0 +PROTOCOL_COL = 1 +MLS_COL = 2 +PORT_COL = 3 + try: from subprocess import getstatusoutput except ImportError:policycoreutils/gui/semanagePage.py +2
-2@@ -130,8 +130,8 @@ class semanagePage: dlg.destroy() def deleteDialog(self): - store, iter = self.view.get_selection().get_selected() - if self.verify(_("Are you sure you want to delete %s '%s'?" % (self.description, store.get_value(iter, 0))), _("Delete %s" % self.description)) == gtk.RESPONSE_YES: + store, it = self.view.get_selection().get_selected() + if (it is not None) and (self.verify(_("Are you sure you want to delete %s '%s'?" % (self.description, store.get_value(it, 0))), _("Delete %s" % self.description)) == gtk.RESPONSE_YES): self.delete() def use_menus(self):policycoreutils/gui/system-config-selinux.glade +1
-1@@ -729,7 +729,7 @@ regular file directory character device block device -socket +socket file symbolic link named pipe </property>
Quoted 14 lines · Stephen Smalley
Quoted 10 lines · Vit Mojzis
Return column definitions to portsPage (gui fails to load otherwise).
fcontextPage:
"ftype" dropdown was filled from 2 sources (system-config-selinux.glade and fcontextPage - from seobject module) which resulted in duplicate and invalid options. When given to "semanage fcontext -f", ftype has to be converted to 1 letter argument mode.TreeView.get_selection().get_selected() can return "None" if no item is selected (the list can be empty). Test if correct iterator was acquired.
Thanks. However, I can't seem to get system-config-selinux built from upstream to run before or after this patch:
Quoted 8 lines
$ system-config-selinux Traceback (most recent call last): File "/usr/share/system-config-selinux/system-config-selinux.py", line 36, in <module> import gnome ImportError: No module named gnomeAre there other changes in Fedora that are required?
Never mind, found the dependency. Thanks, applied. I do still see this unrelated warning:/usr/share/system-config-selinux/system-config-selinux.py:80: Warning:g_object_get_valist: object class 'GnomeProgram' has no property named 'default-icon'
xml =gtk.glade.XML("/usr/share/system-config-selinux/system-config-selinux.glade", domain=PROGNAME)
Quoted 120 lines
Quoted 105 lines
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1344842Signed-off-by vmojzis <[email protected]>--- policycoreutils/gui/fcontextPage.py | 17 +++++------------ policycoreutils/gui/portsPage.py | 6 ++++++ policycoreutils/gui/semanagePage.py | 4 ++-- policycoreutils/gui/system-config-selinux.glade | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-)policycoreutils/gui/fcontextPage.py +5
-12@@ -105,13 +105,6 @@ class fcontextPage(semanagePage): self.load() self.fcontextEntry = xml.get_widget("fcontextEntry") self.fcontextFileTypeCombo = xml.get_widget("fcontextFileTypeCombo") - liststore = self.fcontextFileTypeCombo.get_model() - for k in seobject.file_types: - if len(k) > 0 and k[0] != '-': - iter = liststore.append() - liststore.set_value(iter, 0, k) - iter = liststore.get_iter_first() - self.fcontextFileTypeCombo.set_active_iter(iter) self.fcontextTypeEntry = xml.get_widget("fcontextTypeEntry") self.fcontextMLSEntry = xml.get_widget("fcontextMLSEntry")@@ -183,7 +176,7 @@ class fcontextPage(semanagePage): fspec = store.get_value(iter, SPEC_COL) ftype = store.get_value(iter, FTYPE_COL) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -d -f '%s' '%s'" % (ftype, fspec)) + (rc, out) = getstatusoutput("semanage fcontext -d -f '%s' '%s'" % (seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0:@@ -194,14 +187,14 @@ class fcontextPage(semanagePage): self.error(e.args[0]) def add(self): - ftype = ["", "--", "-d", "-c", "-b", "-s", "-l", "-p"] fspec = self.fcontextEntry.get_text().strip() type = self.fcontextTypeEntry.get_text().strip() mls = self.fcontextMLSEntry.get_text().strip() list_model = self.fcontextFileTypeCombo.get_model() - active = self.fcontextFileTypeCombo.get_active() + it = self.fcontextFileTypeCombo.get_active_iter() + ftype = list_model.get_value(it,0) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, ftype[active], fspec)) + (rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0: self.error(out)@@ -220,7 +213,7 @@ class fcontextPage(semanagePage): iter = self.fcontextFileTypeCombo.get_active_iter() ftype = list_model.get_value(iter, 0) self.wait() - (rc, out) = getstatusoutput("semanage fcontext -m -t %s -r %s -f '%s' '%s'" % (type, mls, ftype, fspec)) + (rc, out) = getstatusoutput("semanage fcontext -m -t %s -r %s -f '%s' '%s'" % (type, mls, seobject.file_type_str_to_option[ftype], fspec)) self.ready() if rc != 0: self.error(out)policycoreutils/gui/portsPage.py +6
-0@@ -23,6 +23,12 @@ import os import gobject import sys import seobject + +TYPE_COL = 0 +PROTOCOL_COL = 1 +MLS_COL = 2 +PORT_COL = 3 + try: from subprocess import getstatusoutput except ImportError:policycoreutils/gui/semanagePage.py +2
-2@@ -130,8 +130,8 @@ class semanagePage: dlg.destroy() def deleteDialog(self): - store, iter = self.view.get_selection().get_selected() - if self.verify(_("Are you sure you want to delete %s '%s'?" % (self.description, store.get_value(iter, 0))), _("Delete %s" % self.description)) == gtk.RESPONSE_YES: + store, it = self.view.get_selection().get_selected() + if (it is not None) and (self.verify(_("Are you sure you want to delete %s '%s'?" % (self.description, store.get_value(it, 0))), _("Delete %s" % self.description)) == gtk.RESPONSE_YES): self.delete() def use_menus(self):policycoreutils/gui/system-config-selinux.glade +0
-0policycoreutils/gui/system-config-selinux.glade regular file · line 735
Quoted 8 lines
policycoreutils/gui/system-config-selinux.glade +1
-1@@ -729,7 +729,7 @@ regular file directory character device block device -socket +socket file symbolic link named pipe </property>_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].