[PATCH 54/67] policycoreutils: semanage: FIXME: Dont print heading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


This patch looks good to me. acked.

If you tell semanage to list the contents of an object and the list is
empty, we should not print the header.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5yWVUACgkQrlYvE4MpobO7xACfc6CoyyNxGsDOSxebO4MnpkGr
0w8AnAzaEkRV2731Myu0Lg7Q4zpSgr/A
=acAj
-----END PGP SIGNATURE-----
>From b17cef0a9ca9bcc8f27d0975dc39a51290ae30e8 Mon Sep 17 00:00:00 2001
From: Dan Walsh <dwalsh@xxxxxxxxxx>
Date: Mon, 29 Aug 2011 14:18:55 -0400
Subject: [PATCH 54/67] policycoreutils: semanage: FIXME: Dont print heading
 if no items selected

Signed-off-by: Dan Walsh <dwalsh@xxxxxxxxxx>
---
 policycoreutils/semanage/seobject.py |   51 +++++++++++++++++++++++++++------
 1 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/policycoreutils/semanage/seobject.py b/policycoreutils/semanage/seobject.py
index 4f6b1cf..e4b6c0d 100644
--- a/policycoreutils/semanage/seobject.py
+++ b/policycoreutils/semanage/seobject.py
@@ -254,9 +254,13 @@ class moduleRecords(semanageRecords):
                return l
 
 	def list(self, heading = 1, locallist = 0):
+		all = self.get_all()
+		if len(all) == 0:
+			return 
+
 		if heading:
 			print "\n%-25s%-10s\n" % (_("Modules Name"), _("Version"))
-                for t in self.get_all():
+                for t in all:
                        if t[2] == 0:
                               disabled = _("Disabled")
                        else:
@@ -335,6 +339,8 @@ class permissiveRecords(semanageRecords):
 	def list(self, heading = 1, locallist = 0):
 		import setools
 		all = map(lambda y: y["name"], filter(lambda x: x["permissive"], setools.seinfo(setools.TYPE)))
+		if len(all) == 0:
+			return 
 
 		if heading:
 			print "\n%-25s\n" % (_("Builtin Permissive Types"))
@@ -342,6 +348,10 @@ class permissiveRecords(semanageRecords):
                 for t in all:
 			if t not in customized:
 				print t
+
+		if len(customized) == 0:
+			return 
+
 		if heading:
 			print "\n%-25s\n" % (_("Customized Permissive Types"))
 		for t in customized:
@@ -592,7 +602,10 @@ class loginRecords(semanageRecords):
 	def list(self,heading = 1, locallist = 0):
 		ddict = self.get_all(locallist)
 		keys = ddict.keys()
+		if len(keys) == 0:
+			return 
 		keys.sort()
+
 		if is_mls_enabled == 1:
 			if heading:
 				print "\n%-25s %-25s %-25s\n" % (_("Login Name"), _("SELinux User"), _("MLS/MCS Range"))
@@ -825,7 +838,10 @@ class seluserRecords(semanageRecords):
 	def list(self, heading = 1, locallist = 0):
 		ddict = self.get_all(locallist)
 		keys = ddict.keys()
+		if len(keys) == 0:
+			return 
 		keys.sort()
+
 		if is_mls_enabled == 1:
 			if heading:
 				print "\n%-15s %-10s %-10s %-30s" % ("", _("Labeling"), _("MLS/"), _("MLS/"))
@@ -1080,11 +1096,14 @@ class portRecords(semanageRecords):
                 return l
 
 	def list(self, heading = 1, locallist = 0):
-		if heading:
-			print "%-30s %-8s %s\n" % (_("SELinux Port Type"), _("Proto"), _("Port Number"))
 		ddict = self.get_all_by_type(locallist)
 		keys = ddict.keys()
+		if len(keys) == 0:
+			return 
 		keys.sort()
+
+		if heading:
+			print "%-30s %-8s %s\n" % (_("SELinux Port Type"), _("Proto"), _("Port Number"))
 		for i in keys:
 			rec = "%-30s %-8s " % i
 			rec += "%s" % ddict[i][0]
@@ -1302,11 +1321,14 @@ class nodeRecords(semanageRecords):
                return l
 
        def list(self, heading = 1, locallist = 0):
-               if heading:
-                       print "%-18s %-18s %-5s %-5s\n" % ("IP Address", "Netmask", "Protocol", "Context")
                ddict = self.get_all(locallist)
                keys = ddict.keys()
+	       if len(keys) == 0:
+		       return 
                keys.sort()
+
+               if heading:
+                       print "%-18s %-18s %-5s %-5s\n" % ("IP Address", "Netmask", "Protocol", "Context")
                if is_mls_enabled:
 			for k in keys:
 				val = ''
@@ -1490,11 +1512,14 @@ class interfaceRecords(semanageRecords):
                 return l
 
 	def list(self, heading = 1, locallist = 0):
-		if heading:
-			print "%-30s %s\n" % (_("SELinux Interface"), _("Context"))
 		ddict = self.get_all(locallist)
 		keys = ddict.keys()
+		if len(keys) == 0:
+			return 
 		keys.sort()
+
+		if heading:
+			print "%-30s %s\n" % (_("SELinux Interface"), _("Context"))
 		if is_mls_enabled:
 			for k in keys:
 				print "%-30s %s:%s:%s:%s " % (k,ddict[k][0], ddict[k][1],ddict[k][2], translate(ddict[k][3], False))
@@ -1793,8 +1818,11 @@ class fcontextRecords(semanageRecords):
 	def list(self, heading = 1, locallist = 0 ):
 		fcon_dict = self.get_all(locallist)
                 keys = fcon_dict.keys()
+		if len(keys) == 0:
+			return 
                 keys.sort()
-		if len(keys) > 0 and heading:
+
+		if heading:
 			print "%-50s %-18s %s\n" % (_("SELinux fcontext"), _("type"), _("Context"))
 		for k in keys:
 			if fcon_dict[k]:
@@ -1977,10 +2005,13 @@ class booleanRecords(semanageRecords):
                               if ddict[k]:
                                      print "%s=%s" %  (k, ddict[k][2])
                        return
-		if heading:
-			print "%-30s %s  %s %s\n" % (_("SELinux boolean"),_("State"), _("Default"), _("Description"))
 		ddict = self.get_all(locallist)
 		keys = ddict.keys()
+		if len(keys) == 0:
+			return 
+
+		if heading:
+			print "%-30s %s  %s %s\n" % (_("SELinux boolean"),_("State"), _("Default"), _("Description"))
 		for k in keys:
 			if ddict[k]:
 				print "%-30s (%-5s,%5s)  %s" %  (k, on_off[selinux.security_get_boolean_active(k)], on_off[ddict[k][2]], self.get_desc(k))
-- 
1.7.6.2


[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux