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

Signed-off-by: vmojzis <vmojzis@redhat.com>
This commit is contained in:
Vit Mojzis 2016-10-19 14:36:03 +02:00 committed by Stephen Smalley
parent 58f892399b
commit 530904eaaa
4 changed files with 14 additions and 15 deletions

View file

@ -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)

View file

@ -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:

View file

@ -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):

View file

@ -729,7 +729,7 @@ regular file
directory
character device
block device
socket
socket file
symbolic link
named pipe
</property>