From patchwork Wed Oct 19 12:36:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vit Mojzis X-Patchwork-Id: 9383939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C4E660487 for ; Wed, 19 Oct 2016 12:38:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BB44299FA for ; Wed, 19 Oct 2016 12:38:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F86229A01; Wed, 19 Oct 2016 12:38:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (smtp.nsa.gov [8.44.101.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9BB8A299FA for ; Wed, 19 Oct 2016 12:38:08 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.31,514,1473120000"; d="scan'208";a="34550" IronPort-PHdr: =?us-ascii?q?9a23=3ApMa/cBGvy5hxCkyXoM6yh51GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ75o8mwAkXT6L1XgUPTWs2DsrQf2rCQ7v6rBDZIyK3CmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBy?= =?us-ascii?q?brysXNWD1YLqiavvodX6WEZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu?= =?us-ascii?q?5blitCLFOXmAvgtI/rpMYwuxlKv7od0+IIEeCjJ+VrBYBfWS8rN2Ez+d3DqQjI?= =?us-ascii?q?TQzJ4GAVFGoRjElmGQ/AuS/7Qt/UtSnot/E1jDefOs/kTKscQzmu7653DhTvjX?= =?us-ascii?q?FUZHYC7GjLh5ko3+pgqxW7qkk6mtbZ?= X-IPAS-Result: =?us-ascii?q?A2H0BQDSaAdY/wHyM5BcHQEFAQsBGAEFAQsBgxEBAQEBAR1?= =?us-ascii?q?XfLBgigojC4Fwhh5MAQEBAQEBAQECAQJfJ4IyBAMTBQU5ECsqAg0iRAI3FCAOA?= =?us-ascii?q?wkCFykICAMBKQQVHwsFGASIMQ7EAQEkhj2IbhEBhXsFiD6RTYYpiWECgjqHRoV?= =?us-ascii?q?1ApB+VFWEdnABhhx4gSgBAQE?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 19 Oct 2016 12:37:58 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u9JCaFwD014309; Wed, 19 Oct 2016 08:36:41 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u9JCaCee205318 for ; Wed, 19 Oct 2016 08:36:12 -0400 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u9JCaBXM014307 for ; Wed, 19 Oct 2016 08:36:11 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1CiAABhZwdYhxy3hNFcHAEBBAEBCgEBgzwBAQEBAXR8pH6CBgGJW4V6hBcXEIV6ghRMAQIBAQEBAQITAQEBCgsJCR2GEIEOQ4hSDsN0ATCGPY57BYg+kU2GKYlhAoI6jTsCkH6BKYIzY4FgPDQBiDwBAQE X-IPAS-Result: A1CiAABhZwdYhxy3hNFcHAEBBAEBCgEBgzwBAQEBAXR8pH6CBgGJW4V6hBcXEIV6ghRMAQIBAQEBAQITAQEBCgsJCR2GEIEOQ4hSDsN0ATCGPY57BYg+kU2GKYlhAoI6jTsCkH6BKYIzY4FgPDQBiDwBAQE X-IronPort-AV: E=Sophos;i="5.31,514,1473134400"; d="scan'208";a="5771130" Received: from emsm-gh1-uea10.corp.nsa.gov (HELO emsm-gh1-uea10.nsa.gov) ([10.208.41.36]) by goalie.tycho.ncsc.mil with ESMTP; 19 Oct 2016 08:36:10 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3A+TY3ZRCs6UXkKnCbwSpwUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSP74p8bcNUDSrc9gkEXOFd2CrakV0ayL7eu9AyQp2tWoiDg6aptCVhsI24?= =?us-ascii?q?09vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09?= =?us-ascii?q?fr2zQd+IyZnpnL3os7ToICxwzAKnZr1zKBjk5S7wjeIxxbVYF6Aq1xHSqWFJce?= =?us-ascii?q?kFjUlhJFaUggqurpzopM0roGxsvKc6+spBV7jqV7gpRrxfSjI9OiY649O4mwPE?= =?us-ascii?q?SF6x52dUd2IUgBtTS1zb6Rb4TJbqmjH3uup0xG+ROsigHuN8Yiir86o+EEygsy?= =?us-ascii?q?wALTNsqGw=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0G5AQDuZwdYhxy3hNFcHAEBBAEBCgEBG?= =?us-ascii?q?AEFAQsBgxEBAQEBAXR8pH6CBgGJW4V6hBcXEIFwhAqCFEwBAQEBAQEBAQIBAhA?= =?us-ascii?q?BAQEKCwkJHS+CMhgMORArKgINIoE8gQ5DiFIOw3QBMIY9jnsFiD6RTYYpiWECg?= =?us-ascii?q?jqNOwKQfoEpgxaBYDw0AYg8AQEB?= X-IPAS-Result: =?us-ascii?q?A0G5AQDuZwdYhxy3hNFcHAEBBAEBCgEBGAEFAQsBgxEBAQE?= =?us-ascii?q?BAXR8pH6CBgGJW4V6hBcXEIFwhAqCFEwBAQEBAQEBAQIBAhABAQEKCwkJHS+CM?= =?us-ascii?q?hgMORArKgINIoE8gQ5DiFIOw3QBMIY9jnsFiD6RTYYpiWECgjqNOwKQfoEpgxa?= =?us-ascii?q?BYDw0AYg8AQEB?= X-IronPort-AV: E=Sophos;i="5.31,514,1473120000"; d="scan'208";a="21966" Received: from mx1.redhat.com ([209.132.183.28]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2016 12:36:09 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F512C056793 for ; Wed, 19 Oct 2016 12:36:07 +0000 (UTC) Received: from Thinkpad_450.brq.redhat.com ([10.34.250.234]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9JCa6uw003315; Wed, 19 Oct 2016 08:36:06 -0400 From: Vit Mojzis To: selinux@tycho.nsa.gov Subject: [PATCH] policycoreutils/gui: fix system-config-selinux editing features Date: Wed, 19 Oct 2016 14:36:03 +0200 Message-Id: <1476880563-20144-1-git-send-email-vmojzis@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Oct 2016 12:36:07 +0000 (UTC) X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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(-) diff --git a/policycoreutils/gui/fcontextPage.py b/policycoreutils/gui/fcontextPage.py index c176de4..2e26666 100644 --- a/policycoreutils/gui/fcontextPage.py +++ b/policycoreutils/gui/fcontextPage.py @@ -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) diff --git a/policycoreutils/gui/portsPage.py b/policycoreutils/gui/portsPage.py index b6445db..b8fdaad 100644 --- a/policycoreutils/gui/portsPage.py +++ b/policycoreutils/gui/portsPage.py @@ -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: diff --git a/policycoreutils/gui/semanagePage.py b/policycoreutils/gui/semanagePage.py index 1f14d56..27367f3 100644 --- a/policycoreutils/gui/semanagePage.py +++ b/policycoreutils/gui/semanagePage.py @@ -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): diff --git a/policycoreutils/gui/system-config-selinux.glade b/policycoreutils/gui/system-config-selinux.glade index 05a697e..4547b3f 100644 --- a/policycoreutils/gui/system-config-selinux.glade +++ b/policycoreutils/gui/system-config-selinux.glade @@ -729,7 +729,7 @@ regular file directory character device block device -socket +socket file symbolic link named pipe