From: Daniel J Walsh <dwalsh@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Ivan Gyurdiev <ivg2@cornell.edu>,
Joshua Brindle <jbrindle@tresys.com>,
SE Linux <selinux@tycho.nsa.gov>
Subject: Re: Latest policycoreutils patch
Date: Wed, 18 Jan 2006 14:07:40 -0500 [thread overview]
Message-ID: <43CE91FC.7040205@redhat.com> (raw)
In-Reply-To: <1137610343.8926.202.camel@moss-spartans.epoch.ncsc.mil>
[-- Attachment #1: Type: text/plain, Size: 270 bytes --]
chcat -L -l now uses getseuserbyname.
chcat verifies all users exist
cut and paste errors in error messages in seobject.py
Fixes to seobject.py to return ports in two different formats for use
with system-config-selinux ...
Better error reporting with setsebool
[-- Attachment #2: policycoreutils-rhat.patch --]
[-- Type: text/x-patch, Size: 5417 bytes --]
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 @@
print "Usage %s -d File ..." % sys.argv[0]
print "Usage %s -l -d user ..." % sys.argv[0]
print "Usage %s -L" % sys.argv[0]
+ print "Usage %s -L -l user" % sys.argv[0]
print "Use -- to end option list. For example"
print "chcat -- -CompanyConfidential /docs/businessplan.odt"
print "chcat -l +CompanyConfidential juser"
@@ -298,12 +299,8 @@
return 0
def listusercats(users):
- seusers = seobject.loginRecords().get_all()
for u in users:
- if u in seusers.keys():
- cats=seobject.translate(seusers[u][1])
- else:
- cats=seobject.translate(seusers["__default__"][1])
+ cats=seobject.translate(selinux.getseuserbyname(u)[2])
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))
+ 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:
- usage()
sys.exit(listusercats(cmds))
else:
if len(cmds) > 0:
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 13:26:43.000000000 -0500
@@ -421,11 +421,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 +458,7 @@
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 delete(self, port, proto):
( k, proto_d, low, high ) = self.__genkey(port, proto)
@@ -491,22 +491,44 @@
for idx in range(self.psize):
u = semanage_port_by_idx(self.plist, idx)
con = semanage_port_get_con(u)
- name = semanage_context_get_type(con)
+ type = semanage_context_get_type(con)
+ 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)]=[]
+ dict[(low, high)]=(type, proto, level)
+ return dict
+
+ def get_all_by_type(self):
+ dict={}
+ (rc, self.plist, self.psize) = semanage_port_list(self.sh)
+ if rc < 0:
+ raise ValueError("Could not list ports")
+
+ for idx in range(self.psize):
+ u = semanage_port_by_idx(self.plist, idx)
+ con = semanage_port_get_con(u)
+ type = semanage_context_get_type(con)
+ 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 (type, proto) not in dict.keys():
+ dict[(type,proto)]=[]
if low == high:
- dict[(name,proto)].append("%d" % low)
+ dict[(type,proto)].append("%d" % low)
else:
- dict[(name,proto)].append("%d-%d" % (low, high))
+ dict[(type,proto)].append("%d-%d" % (low, high))
return dict
def list(self, heading=1):
if heading:
- print "%-30s %-8s %s\n" % ("SELinux Port Name", "Proto", "Port Number")
- dict=self.get_all()
+ print "%-30s %-8s %s\n" % ("SELinux Port Type", "Proto", "Port Number")
+ dict=self.get_all_by_type()
keys=dict.keys()
keys.sort()
for i in keys:
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
@@ -130,7 +130,7 @@
for (j = 0; j < boolcnt; j++) {
- if (semanage_bool_create(handle, &boolean) < 0)
+ if (semanage_bool_create(handle, &boolean) < 0)
goto err;
if (semanage_bool_set_name(handle, boolean, boollist[j].name) < 0)
@@ -144,9 +144,10 @@
if (permanent && semanage_bool_modify_local(handle, bool_key, boolean) < 0)
goto err;
- if (semanage_bool_set_active(handle, bool_key, boolean) < 0)
+ if (semanage_bool_set_active(handle, bool_key, boolean) < 0) {
+ fprintf(stderr, "Could not change boolean %s\n", boollist[j].name);
goto err;
-
+ }
semanage_bool_key_free(bool_key);
semanage_bool_free(boolean);
bool_key = NULL;
next prev parent reply other threads:[~2006-01-18 19:07 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-17 20:34 Latest policycoreutils patch Daniel J Walsh
2006-01-18 1:36 ` Joshua Brindle
2006-01-18 1:37 ` Joshua Brindle
2006-01-18 3:40 ` Daniel J Walsh
2006-01-18 3:41 ` Joshua Brindle
2006-01-18 3:48 ` Daniel J Walsh
2006-01-18 3:51 ` Joshua Brindle
2006-01-18 7:02 ` Ivan Gyurdiev
2006-01-18 15:44 ` Daniel J Walsh
2006-01-18 18:00 ` Ivan Gyurdiev
2006-01-18 18:12 ` Ivan Gyurdiev
2006-01-18 18:30 ` Stephen Smalley
2006-01-18 18:36 ` Ivan Gyurdiev
2006-01-18 18:52 ` Stephen Smalley
2006-01-18 19:04 ` Ivan Gyurdiev
2006-01-18 19:32 ` Stephen Smalley
2006-01-18 19:07 ` Daniel J Walsh [this message]
2006-01-18 19:15 ` Ivan Gyurdiev
2006-01-18 19:19 ` Daniel J Walsh
2006-01-18 19:59 ` Stephen Smalley
2006-01-18 20:01 ` Ivan Gyurdiev
2006-01-19 14:27 ` Daniel J Walsh
2006-01-18 16:13 ` Stephen Smalley
-- strict thread matches above, loose matches on Subject: below --
2006-09-07 13:31 Daniel J Walsh
2006-09-08 14:00 ` Karl MacMillan
2006-09-08 14:33 ` Joshua Brindle
2006-09-08 14:55 ` Karl MacMillan
2006-09-08 14:35 ` Stephen Smalley
2006-09-08 16:37 ` Daniel J Walsh
2006-09-08 20:25 ` Stephen Smalley
2006-09-11 12:25 ` Joshua Brindle
2006-09-12 12:45 ` Karl MacMillan
2006-09-13 15:14 ` Joshua Brindle
2006-11-06 15:25 Daniel J Walsh
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=43CE91FC.7040205@redhat.com \
--to=dwalsh@redhat.com \
--cc=ivg2@cornell.edu \
--cc=jbrindle@tresys.com \
--cc=sds@tycho.nsa.gov \
--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.