-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlD+p7oACgkQrlYvE4MpobPgoACfSwcdb9ilUr2mkSQm3OqkkNOf 7tYAn3aCoNTmKBvJCzhQwtqct+e/l6ik =29Ky -----END PGP SIGNATURE-----
>From f22c5806017b9f76236c485d63f097cae2571f31 Mon Sep 17 00:00:00 2001 From: Eric Paris <eparis@xxxxxxxxxx> Date: Fri, 11 Jan 2013 16:10:03 -0500 Subject: [PATCH 54/84] policycoreutils: semanage: list logins file entries in semanage login -l If there are entries in /etc/selinux/[POLICY]/logins they should be included in the semange login -l output. So do so! Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> --- policycoreutils/semanage/seobject.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/policycoreutils/semanage/seobject.py b/policycoreutils/semanage/seobject.py index 9b1c12a..05b8128 100644 --- a/policycoreutils/semanage/seobject.py +++ b/policycoreutils/semanage/seobject.py @@ -619,6 +619,21 @@ class loginRecords(semanageRecords): self.mylog.commit(0) raise error + def get_all_logins(self): + ddict = {} + self.logins_path = selinux.selinux_policy_root() + "/logins" + for path,dirs,files in os.walk(self.logins_path): + if path == self.logins_path: + for name in files: + try: + fd = open(path + "/" + name) + rec = fd.read().rstrip().split(":") + fd.close() + ddict[name] = (rec[1], rec[2], rec[0]) + except IndexError: + pass + return ddict + def get_all(self, locallist = 0): ddict = {} if locallist: @@ -630,7 +645,7 @@ class loginRecords(semanageRecords): for u in self.ulist: name = semanage_seuser_get_name(u) - ddict[name] = (semanage_seuser_get_sename(u), semanage_seuser_get_mlsrange(u)) + ddict[name] = (semanage_seuser_get_sename(u), semanage_seuser_get_mlsrange(u), "*") return ddict def customized(self): @@ -644,16 +659,26 @@ class loginRecords(semanageRecords): def list(self,heading = 1, locallist = 0): ddict = self.get_all(locallist) + ldict = self.get_all_logins() + lkeys = ldict.keys() keys = ddict.keys() - if len(keys) == 0: + if len(keys) == 0 and len(lkeys) == 0: return keys.sort() + lkeys.sort() if is_mls_enabled == 1: if heading: - print "\n%-25s %-25s %-25s\n" % (_("Login Name"), _("SELinux User"), _("MLS/MCS Range")) + print "\n%-20s %-20s %-20s %s\n" % (_("Login Name"), _("SELinux User"), _("MLS/MCS Range"), _("Service")) for k in keys: - print "%-25s %-25s %-25s" % (k, ddict[k][0], translate(ddict[k][1])) + u = ddict[k] + print "%-20s %-20s %-20s %s" % (k, u[0], translate(u[1]), u[2]) + if len(lkeys): + print "\nLocal customization in %s" % self.logins_path + + for k in lkeys: + u = ldict[k] + print "%-20s %-20s %-20s %s" % (k, u[0], translate(u[1]), u[2]) else: if heading: print "\n%-25s %-25s\n" % (_("Login Name"), _("SELinux User")) -- 1.8.1