From f8ffb4e460760330300a1c2f9ed4ead8497233b5 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 19 Jan 2006 14:45:25 +0000 Subject: [PATCH] * Thu Jan 19 2006 Dan Walsh 1.29.8-4 - Fixes for "add"-"modify" error messages - Fixes for chcat --- policycoreutils-rhat.patch | 111 ++++++++++++++++++++++++------------- policycoreutils.spec | 6 +- 2 files changed, 78 insertions(+), 39 deletions(-) diff --git a/policycoreutils-rhat.patch b/policycoreutils-rhat.patch index 7125f32..0048733 100644 --- a/policycoreutils-rhat.patch +++ b/policycoreutils-rhat.patch @@ -1,7 +1,43 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/chcat policycoreutils-1.29.8/scripts/chcat --- nsapolicycoreutils/scripts/chcat 2006-01-18 11:12:43.000000000 -0500 -+++ policycoreutils-1.29.8/scripts/chcat 2006-01-18 13:52:39.000000000 -0500 -@@ -281,6 +281,7 @@ ++++ policycoreutils-1.29.8/scripts/chcat 2006-01-19 09:41:13.000000000 -0500 +@@ -25,11 +25,19 @@ + import commands, sys, os, pwd, string, getopt, re, selinux + import seobject + ++def verify_users(users): ++ for u in users: ++ try: ++ pwd.getpwnam(u) ++ except KeyError, e: ++ error( "User %s does not exist" % u) ++ + def chcat_user_add(orig, newcat, users): + errors=0 + logins = seobject.loginRecords() + seusers=logins.get_all() + add_ind=0 ++ verify_users(users) + for u in users: + if u in seusers.keys(): + user=seusers[u] +@@ -98,6 +106,7 @@ + logins = seobject.loginRecords() + seusers=logins.get_all() + add_ind=0 ++ verify_users(users) + for u in users: + if u in seusers.keys(): + user=seusers[u] +@@ -174,6 +183,7 @@ + logins = seobject.loginRecords() + seusers=logins.get_all() + add_ind=0 ++ verify_users(users) + for u in users: + if u in seusers.keys(): + user=seusers[u] +@@ -281,6 +291,7 @@ print "Usage %s -d File ..." % sys.argv[0] print "Usage %s -l -d user ..." % sys.argv[0] print "Usage %s -L" % sys.argv[0] @@ -9,11 +45,17 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/chcat policycore print "Use -- to end option list. For example" print "chcat -- -CompanyConfidential /docs/businessplan.odt" print "chcat -l +CompanyConfidential juser" -@@ -298,12 +299,8 @@ +@@ -297,13 +308,14 @@ + fd.close() return 0 ++ def listusercats(users): - seusers = seobject.loginRecords().get_all() ++ if len(users) == 0: ++ users.append(os.getlogin()) ++ ++ verify_users(users) for u in users: - if u in seusers.keys(): - cats=seobject.translate(seusers[u][1]) @@ -23,19 +65,8 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/scripts/chcat policycore cats=cats.split("-") if len(cats) > 1 and cats[1] != "s0": print "%s: %s" % (u, cats[1]) -@@ -350,10 +347,17 @@ - if delete_ind: - sys.exit(chcat_replace(["s0"], ["s0"], cmds, login_ind)) +@@ -352,8 +364,6 @@ -+ if login_ind: -+ if len(cmds) >= 1: -+ for u in cmds: -+ try: -+ pwd.getpwnam(u) -+ except KeyError, e: -+ error( "User %s does not exist" % u) -+ else: -+ cmds.append(os.getlogin()) if list_ind: if login_ind: - if len(cmds) < 1: @@ -177,7 +208,7 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/semanage/semanage.8 poli diff --exclude-from=exclude -N -u -r nsapolicycoreutils/semanage/seobject.py policycoreutils-1.29.8/semanage/seobject.py --- nsapolicycoreutils/semanage/seobject.py 2006-01-18 11:12:43.000000000 -0500 -+++ policycoreutils-1.29.8/semanage/seobject.py 2006-01-18 17:03:01.000000000 -0500 ++++ policycoreutils-1.29.8/semanage/seobject.py 2006-01-19 09:43:38.000000000 -0500 @@ -21,9 +21,18 @@ # # @@ -281,20 +312,6 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/semanage/seobject.py pol class semanageRecords: def __init__(self): self.sh = semanage_handle_create() -@@ -421,11 +506,11 @@ - - rc = semanage_port_modify_local(self.sh, k, p) - if rc < 0: -- raise ValueError("Failed to add port %s/%s" % (proto, port)) -+ raise ValueError("Failed to modify port %s/%s" % (proto, port)) - - rc = semanage_commit(self.sh) - if rc < 0: -- raise ValueError("Failed to add port %s/%s" % (proto, port)) -+ raise ValueError("Failed to modify port %s/%s" % (proto, port)) - - def modify(self, port, proto, serange, setype): - if serange == "" and setype == "": @@ -458,7 +543,7 @@ rc = semanage_commit(self.sh) @@ -313,11 +330,9 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/semanage/seobject.py pol + if type == "reserved_port_t": + continue + level = semanage_context_get_mls(con) - proto=semanage_port_get_proto_str(u) - low=semanage_port_get_low(u) - high = semanage_port_get_high(u) -- if (name, proto) not in dict.keys(): -- dict[(name,proto)]=[] ++ proto=semanage_port_get_proto_str(u) ++ low=semanage_port_get_low(u) ++ high = semanage_port_get_high(u) + dict[(low, high)]=(type, proto, level) + return dict + @@ -334,9 +349,11 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/semanage/seobject.py pol + if type == "reserved_port_t": + continue + level = semanage_context_get_mls(con) -+ proto=semanage_port_get_proto_str(u) -+ low=semanage_port_get_low(u) -+ high = semanage_port_get_high(u) + proto=semanage_port_get_proto_str(u) + low=semanage_port_get_low(u) + high = semanage_port_get_high(u) +- if (name, proto) not in dict.keys(): +- dict[(name,proto)]=[] + if (type, proto) not in dict.keys(): + dict[(type,proto)]=[] if low == high: @@ -356,6 +373,24 @@ diff --exclude-from=exclude -N -u -r nsapolicycoreutils/semanage/seobject.py pol keys=dict.keys() keys.sort() for i in keys: +@@ -614,7 +721,7 @@ + + rc = semanage_commit(self.sh) + if rc < 0: +- raise ValueError("Failed to add interface %s" % interface) ++ raise ValueError("Failed to modify interface %s" % interface) + + def delete(self, interface): + (rc,k) = semanage_iface_key_create(self.sh, interface) +@@ -779,7 +886,7 @@ + + rc = semanage_commit(self.sh) + if rc < 0: +- raise ValueError("Failed to add file context for %s" % target) ++ raise ValueError("Failed to modify file context for %s" % target) + + def delete(self, target, ftype): + (rc,k) = semanage_fcontext_key_create(self.sh, target, self.file_types[ftype]) diff --exclude-from=exclude -N -u -r nsapolicycoreutils/setsebool/setsebool.c policycoreutils-1.29.8/setsebool/setsebool.c --- nsapolicycoreutils/setsebool/setsebool.c 2006-01-04 13:07:46.000000000 -0500 +++ policycoreutils-1.29.8/setsebool/setsebool.c 2006-01-18 13:27:42.000000000 -0500 diff --git a/policycoreutils.spec b/policycoreutils.spec index ada784e..8cb2473 100644 --- a/policycoreutils.spec +++ b/policycoreutils.spec @@ -4,7 +4,7 @@ Summary: SELinux policy core utilities. Name: policycoreutils Version: 1.29.8 -Release: 3 +Release: 4 License: GPL Group: System Environment/Base Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz @@ -97,6 +97,10 @@ rm -rf ${RPM_BUILD_ROOT} %{_libdir}/python2.4/site-packages/seobject.py* %changelog +* Thu Jan 19 2006 Dan Walsh 1.29.8-4 +- Fixes for "add"-"modify" error messages +- Fixes for chcat + * Wed Jan 18 2006 Dan Walsh 1.29.8-3 - Add management of translation file to semaange and seobject