All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: selinux@tycho.nsa.gov
Subject: [PATCH 17/19] sepolicy: Fix several issues in 'sepolicy manpage -a'
Date: Wed,  3 May 2017 12:30:34 +0200	[thread overview]
Message-ID: <20170503103036.17514-18-plautrba@redhat.com> (raw)
In-Reply-To: <20170503103036.17514-1-plautrba@redhat.com>

Fixes:
$ sepolicy manpage -a
Traceback (most recent call last):
  File "/usr/bin/sepolicy", line 699, in <module>
    args.func(args)
  File "/usr/bin/sepolicy", line 359, in manpage
    m = ManPage(domain, path, args.root, args.source_files, args.web)
  File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 408, in __init__
    self.__gen_man_page()
  File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 495, in __gen_man_page
    self._entrypoints()
  File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 903, in _entrypoints
    if len(entrypoints) > 1:
TypeError: object of type 'map' has no len()

$ sepolicy manpage -a
Traceback (most recent call last):
  File "/usr/bin/sepolicy", line 699, in <module>
    args.func(args)
  File "/usr/bin/sepolicy", line 359, in manpage
    m = ManPage(domain, path, args.root, args.source_files, args.web)
  File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 408, in __init__
    self.__gen_man_page()
  File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 497, in __gen_man_page
    self._mcs_types()
  File "/usr/lib/python3.6/site-packages/sepolicy/manpage.py", line 927, in _mcs_types
    attributes = sepolicy.info(sepolicy.TYPE, (self.type))[0]["attributes"]
TypeError: 'generator' object is not subscriptable

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
 python/sepolicy/sepolicy/manpage.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
index 4cebb299..a4dc717a 100755
--- a/python/sepolicy/sepolicy/manpage.py
+++ b/python/sepolicy/sepolicy/manpage.py
@@ -94,11 +94,10 @@ def get_all_users_info():
 
 all_entrypoints = None
 
-
 def get_entrypoints():
     global all_entrypoints
     if not all_entrypoints:
-        all_entrypoints = sepolicy.info(sepolicy.ATTRIBUTE, "entry_type")[0]["types"]
+        all_entrypoints = next(sepolicy.info(sepolicy.ATTRIBUTE, "entry_type"))["types"]
     return all_entrypoints
 
 domains = None
@@ -939,9 +938,8 @@ selinux(8), %s(8), semanage(8), restorecon(8), chcon(1), sepolicy(8)
         return True
 
     def _entrypoints(self):
-        try:
-            entrypoints = map(lambda x: x['target'], sepolicy.search([sepolicy.ALLOW], {'source': self.type, 'permlist': ['entrypoint'], 'class': 'file'}))
-        except:
+        entrypoints = [x['target'] for x in sepolicy.search([sepolicy.ALLOW], {'source': self.type, 'permlist': ['entrypoint'], 'class': 'file'})]
+        if len(entrypoints) == 0:
             return
 
         self.fd.write("""
@@ -971,8 +969,8 @@ All executeables with the default executable label, usually stored in /usr/bin a
 %s""" % ", ".join(paths))
 
     def _mcs_types(self):
-        attributes = sepolicy.info(sepolicy.TYPE, (self.type))[0]["attributes"]
-        if "mcs_constrained_type" not in attributes:
+        mcs_constrained_type = next(sepolicy.info(sepolicy.ATTRIBUTE, "mcs_constrained_type"))
+        if self.type not in mcs_constrained_type['types']:
             return
         self.fd.write ("""
 .SH "MCS Constrained"
-- 
2.12.2

  parent reply	other threads:[~2017-05-03 10:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 10:30 Several sepolicy fixes from Fedora Petr Lautrbach
2017-05-03 10:30 ` [PATCH 01/19] policycoreutils/sepolicy: Add documentation for MCS separated domains Petr Lautrbach
2017-05-03 10:30 ` [PATCH 02/19] sepolicy: Fix spelling mistakes in commands in generated manpages Petr Lautrbach
2017-05-03 10:30 ` [PATCH 03/19] sepolicy: Add manpages for typealiased types Petr Lautrbach
2017-05-03 10:30 ` [PATCH 04/19] sepolicy: Move svirt man page out of libvirt into its own Petr Lautrbach
2017-05-03 10:30 ` [PATCH 05/19] policycoreutils/sepolicy: boolean.png is in help/ Petr Lautrbach
2017-05-03 10:30 ` [PATCH 06/19] Fix up generation of application policy Petr Lautrbach
2017-05-03 10:30 ` [PATCH 07/19] sepolicy: ptrace should be a part of deny_ptrace boolean in TEMPLATETYPE_admin Petr Lautrbach
2017-05-03 10:30 ` [PATCH 08/19] sepolicy: We should be creating _exec interfaces when we create the domtrans interface Petr Lautrbach
2017-05-03 10:30 ` [PATCH 09/19] Fix typo in executable.py template Petr Lautrbach
2017-05-03 10:30 ` [PATCH 10/19] sepolicy: Adapt to new the semodule list output Petr Lautrbach
2017-05-03 10:30 ` [PATCH 11/19] sepolicy: Don't return filter(), use [ ] notation instead Petr Lautrbach
2017-05-03 10:30 ` [PATCH 12/19] sepolicy: Simplify policy types detection Petr Lautrbach
2017-05-03 10:30 ` [PATCH 13/19] sepolicy/generate.py: Fix string formatting Petr Lautrbach
2017-05-03 10:30 ` [PATCH 14/19] policycoreutils/sepolicy: Define our own cmp() Petr Lautrbach
2017-05-03 10:30 ` [PATCH 15/19] dbus: Use text streams in selinux_server.py Petr Lautrbach
2017-05-03 10:30 ` [PATCH 16/19] sepolicy: setools.*Query wants a list in ruletype Petr Lautrbach
2017-05-03 10:30 ` Petr Lautrbach [this message]
2017-05-03 10:30 ` [PATCH 18/19] sepolicy: info() should provide attributes for a TYPE Petr Lautrbach
2017-05-03 10:30 ` [PATCH 19/19] sepolicy/gui: Update text strings to use better gettext templates Petr Lautrbach
2017-05-05 17:06   ` Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170503103036.17514-18-plautrba@redhat.com \
    --to=plautrba@redhat.com \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.