From patchwork Thu Aug 4 18:34:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Zaman X-Patchwork-Id: 9264071 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 18CB76048B for ; Thu, 4 Aug 2016 18:38:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AE3C283E4 for ; Thu, 4 Aug 2016 18:38:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3E2E2841F; Thu, 4 Aug 2016 18:38:58 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from emsm-gh1-uea10.nsa.gov (smtp.nsa.gov [8.44.101.8]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E0AC283E4 for ; Thu, 4 Aug 2016 18:38:57 +0000 (UTC) Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP; 04 Aug 2016 18:38:56 +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 u74IctOZ012176; Thu, 4 Aug 2016 14:38:55 -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 u74IZPH8250330 for ; Thu, 4 Aug 2016 14:35:25 -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 u74IZRCW011429 for ; Thu, 4 Aug 2016 14:35:27 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BhAQBGiqNXdETcVdFcHQGCeoEDfLEshWSEDByGAQKBSEwBAQEBAQETAQoLFBeFEAIBAxIuAQE3AQ9AETQBBQEcO4gPAaEUgTI+MYpUhSoBAQWLRQEBAQEBBQIBHAgQhA+NYQuDB4gqhXJ0iimGGohqZYFShw2Feo5pMIEPglmCAmEBhyoBAQE X-IPAS-Result: A1BhAQBGiqNXdETcVdFcHQGCeoEDfLEshWSEDByGAQKBSEwBAQEBAQETAQoLFBeFEAIBAxIuAQE3AQ9AETQBBQEcO4gPAaEUgTI+MYpUhSoBAQWLRQEBAQEBBQIBHAgQhA+NYQuDB4gqhXJ0iimGGohqZYFShw2Feo5pMIEPglmCAmEBhyoBAQE X-IronPort-AV: E=Sophos;i="5.28,471,1464667200"; d="scan'208";a="5626394" 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; 04 Aug 2016 14:36:10 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/AES128-GCM-SHA256; 04 Aug 2016 18:34:44 +0000 Received: by mail-pa0-f68.google.com with SMTP id q2so17934708pap.0 for ; Thu, 04 Aug 2016 11:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perfinion-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kbz288feIw8Mxxme9x/nELh4CJej6W3fwMVnLrnKtMQ=; b=C8g9pdgzGOqfaaNr6/idqQMKY013mfSY9JqvQFmKS/UnEqL5rdWb9tB0S+B4zU3Tru N7m8zp3VdBeMtXPwQrukaGccBZQi2IW1iwi5KAzdG0CftT5qUaUpbS1w0dDNw/H56Bre lKP+b1jIQSquD1hZ0NfHPSn3SH/Rn+FE/iC4HbdlAygi4lnD5ISAARfDympg0ld8a94x S69xJT22DWDnpt20Wi4eHJILncSx7XVWvlf0cvYtOawRqIOGvdVfr6TPBefmfFUJ/nlA afVJlD0Y6AlEoMl9hJHoaAd82Jcga0uOEvCBRDCUXgaaP9YP4dA0LARKMBggkrv8fFyF 83Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kbz288feIw8Mxxme9x/nELh4CJej6W3fwMVnLrnKtMQ=; b=mlbMKLPdYyMIFB57qG4OGw28jWbdZz+7/NnLO/rvMST68czElmz5h7GiUKVwfylh5X KGFdmba9MfTceCEEWmkKvXUdtnvyq+9oGB9BH7iijADtNhU+ynxga7CrL8i3lA3zfehY AS6Xkjltj26VMH2M0SIfqO9TK7Ruv79Kdu3s3oCWDCP3ujcewEfwtjJMzSHxuBjnSugW FAZict+LD2JsRswzeLls4duC63FqtJRG0LBmvD3CK0W/RkawbE6YrlHF+75g2ILj4VeR Sf2ppI3v9cpZLgQYnGHRfjbsOtcorZfsSre8MsAAGCYT9qyqIm9Q2gO7r1x+zyKDMHBv Ow8w== X-Gm-Message-State: AEkoouvZkj8MtBbhF7nFuVEsOqtoDT8iHQ5wok0oJ6NRP1yu27R33Ez2gisPw07Z6U6vQw== X-Received: by 10.66.221.229 with SMTP id qh5mr44235858pac.66.1470335683080; Thu, 04 Aug 2016 11:34:43 -0700 (PDT) Received: from localhost ([2404:e800:e600:57b:dcfa:b5a4:c9d2:f744]) by smtp.gmail.com with ESMTPSA id m24sm22062781pfi.34.2016.08.04.11.34.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 11:34:42 -0700 (PDT) From: Jason Zaman To: selinux@tycho.nsa.gov Subject: [PATCH 08/12] policycoreutils: import sepolicy directly Date: Fri, 5 Aug 2016 02:34:01 +0800 Message-Id: <1470335645-24224-9-git-send-email-jason@perfinion.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1470335645-24224-1-git-send-email-jason@perfinion.com> References: <1470335645-24224-1-git-send-email-jason@perfinion.com> 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 instead of from sepolicy import foo. Makes it easier to grep for consumers that still need to be fixed. --- policycoreutils/gui/domainsPage.py | 4 +-- policycoreutils/gui/polgengui.py | 58 ++++++++++++++++++------------------ policycoreutils/semanage/seobject.py | 7 ++--- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/policycoreutils/gui/domainsPage.py b/policycoreutils/gui/domainsPage.py index 56c66fe..9992d00 100644 --- a/policycoreutils/gui/domainsPage.py +++ b/policycoreutils/gui/domainsPage.py @@ -25,8 +25,8 @@ import gobject import sys import seobject import selinux +import sepolicy from semanagePage import * -from sepolicy import get_all_entrypoint_domains ## ## I18N @@ -70,7 +70,7 @@ class domainsPage(semanagePage): self.permissive_button = xml.get_widget("permissiveButton") self.enforcing_button = xml.get_widget("enforcingButton") - self.domains = get_all_entrypoint_domains() + self.domains = sepolicy.get_all_entrypoint_domains() self.load() def get_modules(self): diff --git a/policycoreutils/gui/polgengui.py b/policycoreutils/gui/polgengui.py index 0a153c6..1c349a7 100644 --- a/policycoreutils/gui/polgengui.py +++ b/policycoreutils/gui/polgengui.py @@ -29,7 +29,7 @@ import gobject import gnome import sys try: - from sepolicy import generate + import sepolicy except ValueError, e: sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e))) sys.exit(1) @@ -194,10 +194,10 @@ class childWindow: self.tooltip_dict[label] = label.get_tooltip_text() try: - self.all_types = generate.get_all_types() + self.all_types = sepolicy.generate.get_all_types() self.all_modules = get_all_modules() - self.all_roles = generate.get_all_roles() - self.all_users = generate.get_all_users() + self.all_roles = sepolicy.generate.get_all_roles() + self.all_users = sepolicy.generate.get_all_users() except RuntimeError, e: self.all_types = [] self.all_modules = [] @@ -225,16 +225,16 @@ class childWindow: self.boolean_description_entry = xml.get_widget("boolean_description_entry") self.pages = {} - for i in generate.USERS: + for i in sepolicy.generate.USERS: self.pages[i] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.ROLE_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] - self.pages[generate.RUSER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.ADMIN_PAGE, self.USER_TRANSITION_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] - self.pages[generate.LUSER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] - self.pages[generate.SANDBOX] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] - self.pages[generate.EUSER] = [self.SELECT_TYPE_PAGE, self.EXISTING_USER_PAGE, self.TRANSITION_PAGE, self.ROLE_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] + self.pages[sepolicy.generate.RUSER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.ADMIN_PAGE, self.USER_TRANSITION_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] + self.pages[sepolicy.generate.LUSER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] + self.pages[sepolicy.generate.SANDBOX] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] + self.pages[sepolicy.generate.EUSER] = [self.SELECT_TYPE_PAGE, self.EXISTING_USER_PAGE, self.TRANSITION_PAGE, self.ROLE_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] - for i in generate.APPLICATIONS: + for i in sepolicy.generate.APPLICATIONS: self.pages[i] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.COMMON_APPS_PAGE, self.FILES_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] - self.pages[generate.USER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.USER_TRANSITION_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.COMMON_APPS_PAGE, self.FILES_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] + self.pages[sepolicy.generate.USER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.USER_TRANSITION_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.COMMON_APPS_PAGE, self.FILES_PAGE, self.BOOLEAN_PAGE, self.SELECT_DIR_PAGE] self.current_page = 0 self.back_button.set_sensitive(0) @@ -340,7 +340,7 @@ class childWindow: self.error(e.message) def confine_application(self): - return self.get_type() in generate.APPLICATIONS + return self.get_type() in sepolicy.generate.APPLICATIONS def forward(self, arg): type = self.get_type() @@ -437,41 +437,41 @@ class childWindow: def get_type(self): if self.sandbox_radiobutton.get_active(): - return generate.SANDBOX + return sepolicy.generate.SANDBOX if self.cgi_radiobutton.get_active(): - return generate.CGI + return sepolicy.generate.CGI if self.user_radiobutton.get_active(): - return generate.USER + return sepolicy.generate.USER if self.init_radiobutton.get_active(): - return generate.DAEMON + return sepolicy.generate.DAEMON if self.dbus_radiobutton.get_active(): - return generate.DBUS + return sepolicy.generate.DBUS if self.inetd_radiobutton.get_active(): - return generate.INETD + return sepolicy.generate.INETD if self.login_user_radiobutton.get_active(): - return generate.LUSER + return sepolicy.generate.LUSER if self.admin_user_radiobutton.get_active(): - return generate.AUSER + return sepolicy.generate.AUSER if self.xwindows_user_radiobutton.get_active(): - return generate.XUSER + return sepolicy.generate.XUSER if self.terminal_user_radiobutton.get_active(): - return generate.TUSER + return sepolicy.generate.TUSER if self.root_user_radiobutton.get_active(): - return generate.RUSER + return sepolicy.generate.RUSER if self.existing_user_radiobutton.get_active(): - return generate.EUSER + return sepolicy.generate.EUSER def generate_policy(self, *args): outputdir = self.output_entry.get_text() try: - my_policy = generate.policy(self.get_name(), self.get_type()) + my_policy = sepolicy.generate.policy(self.get_name(), self.get_type()) iter = self.boolean_store.get_iter_first() while(iter): my_policy.add_boolean(self.boolean_store.get_value(iter, 0), self.boolean_store.get_value(iter, 1)) iter = self.boolean_store.iter_next(iter) - if self.get_type() in generate.APPLICATIONS: + if self.get_type() in sepolicy.generate.APPLICATIONS: my_policy.set_program(self.exec_entry.get_text()) my_policy.gen_symbols() @@ -484,14 +484,14 @@ class childWindow: my_policy.set_use_audit(self.audit_checkbutton.get_active() == 1) my_policy.set_use_terminal(self.terminal_checkbutton.get_active() == 1) my_policy.set_use_mail(self.mail_checkbutton.get_active() == 1) - if self.get_type() is generate.DAEMON: + if self.get_type() is sepolicy.generate.DAEMON: my_policy.set_init_script(self.init_script_entry.get_text()) - if self.get_type() == generate.USER: + if self.get_type() == sepolicy.generate.USER: selected = [] self.user_transition_treeview.get_selection().selected_foreach(foreach, selected) my_policy.set_transition_users(selected) else: - if self.get_type() == generate.RUSER: + if self.get_type() == sepolicy.generate.RUSER: selected = [] self.admin_treeview.get_selection().selected_foreach(foreach, selected) my_policy.set_admin_domains(selected) diff --git a/policycoreutils/semanage/seobject.py b/policycoreutils/semanage/seobject.py index 5100720..2cc56d9 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -31,8 +31,7 @@ import stat from semanage import * PROGNAME = "policycoreutils" import sepolicy -from sepolicy import boolean_desc, boolean_category, gen_bool_dict -gen_bool_dict() +sepolicy.gen_bool_dict() from IPy import IP import gettext @@ -2189,11 +2188,11 @@ class booleanRecords(semanageRecords): def get_desc(self, name): name = selinux.selinux_boolean_sub(name) - return boolean_desc(name) + return sepolicy.boolean_desc(name) def get_category(self, name): name = selinux.selinux_boolean_sub(name) - return boolean_category(name) + return sepolicy.boolean_category(name) def customized(self): l = []