Policycoreutils patches
Bunch of patches separated so you can approve/deny them separately.
avc patch Removes optional_policy name from audit2allow
pyver patch removes hardcoding of python version from makefile. Will use version of installed python version.
newrole patch to use O_RDWR for terminals to fix more problem.
fixfiles patch fixes a problem with fixfiles was writing "not a tty" to the current directory when there was no terminal.
seobject patch is somewhat more controversial, but at least parts of it should be accepted.
- Fixes translation of portions of security context.
- Get rid of excess "\n"
- Restart mcstrans to relize file changed.
- Verify prefix is valid
- Modify roles correctly, currently role removal does not work without this fix.
audit2allow/avc.py +1 -1
@@ -231,7 +231,7 @@ else: file = m[0][1] ret = "\n#%s\n"% self.out() - ret += "optional_policy(`%s', `\n" % m[0][1] + ret += "optional_policy(`\n" first = True for i in m: if file != i[1]:
audit2allow/Makefile +1 -1
@@ -4,7 +4,7 @@ LIBDIR ?= $(PREFIX)/lib MANDIR ?= $(PREFIX)/share/man LOCALEDIR ?= /usr/share/locale -PYLIBVER ?= python2.4 +PYLIBVER ?= $(shell python -c 'import sys;print "python%d.%d" % sys.version_info[0:2]') PYTHONLIBDIR ?= $(LIBDIR)/$(PYLIBVER) TARGETS=audit2allow
semanage/Makefile +1 -1
@@ -3,7 +3,7 @@ LIBDIR ?= $(PREFIX)/lib SBINDIR ?= $(PREFIX)/sbin MANDIR = $(PREFIX)/share/man -PYLIBVER ?= python2.4 +PYLIBVER ?= $(shell python -c 'import sys;print "python%d.%d" % sys.version_info[0:2]') PYTHONLIBDIR ?= $(LIBDIR)/$(PYLIBVER) TARGETS=semanage
newrole/newrole.c +2 -2
@@ -1120,10 +1120,10 @@ fd =open (ttyn,O_RDONLY );if (fd !=0 ) goto err_close_pam; - fd =open (ttyn,O_WRONLY ); + fd =open (ttyn,O_RDWR );if (fd !=1 ) goto err_close_pam; - fd =open (ttyn,O_WRONLY ); + fd =open (ttyn,O_RDWR );if (fd !=2 ) goto err_close_pam;
scripts/fixfiles +3 -0
@@ -29,6 +29,9 @@ RPMILES="" OUTFILES="" LOGFILE=`tty` +if [ $1 != 0 ]; then + LOGFILE="/dev/null" +fi SYSLOGFLAG="-l" LOGGER=/usr/sbin/logger SETFILES=/sbin/setfiles
semanage/seobject.py +22 -12
@@ -94,23 +94,25 @@ return re.search("^" + reg +"$",raw) def translate(raw, prepend = 1): - if prepend == 1: - context = "a:b:c:%s" % raw + filler="a:b:c:" + if prepend == 1: + context = "%s%s" % (filler,raw) else: context = raw - (rc, trans) = selinux.selinux_raw_to_trans_context(context) + (rc, trans) = selinux.selinux_raw_to_trans_context(context) if rc != 0: return raw if prepend: - trans = trans.strip("a:b:c") + trans = trans[len(filler):] if trans == "": return raw else: return trans def untranslate(trans, prepend = 1): + filler="a:b:c:" if prepend == 1: - context = "a:b:c:%s" % trans + context = "%s%s" % (filler,trans) else: context = trans
@@ -118,7 +120,7 @@ if rc != 0: return trans if prepend: - raw = raw.strip("a:b:c") + raw = raw[len(filler):] if raw == "": return trans else:
@@ -157,7 +159,7 @@ def out(self): rec = "" for c in self.comments: - rec += c +"\n" + rec += c keys = self.ddict.keys() keys.sort() for k in keys:
@@ -204,7 +206,8 @@ os.write(fd, self.out()) os.close(fd) os.rename(newfilename, self.filename) - + os.system("/sbin/service mcstrans reload > /dev/null") + class semanageRecords: def __init__(self): self.sh = semanage_handle_create()
@@ -456,7 +460,8 @@ rc = semanage_user_set_mlslevel(self.sh, u, selevel) if rc < 0: raise ValueError(_("Could not set MLS level for %s") % name) - + if selinux.security_check_context("system_u:object_r:%s_home_t:s0" % prefix) != 0: + raise ValueError(_("Invalid prefix %s") % prefix) rc = semanage_user_set_prefix(self.sh, u, prefix) if rc < 0: raise ValueError(_("Could not add prefix %s for %s") % (r, prefix))
@@ -522,11 +527,17 @@ semanage_user_set_mlslevel(self.sh, u, untranslate(selevel)) if prefix != "": - semanage_user_set_prefix(self.sh, u, prefix) + if selinux.security_check_context("system_u:object_r:%s_home_t" % prefix) != 0: + raise ValueError(_("Invalid prefix %s") % prefix) + semanage_user_set_prefix(self.sh, u, prefix) if len(roles) != 0: - for r in roles: - semanage_user_add_role(self.sh, u, r) + for r in rlist: + if r not in roles: + semanage_user_del_role(u, r) + for r in roles: + if r not in rlist: + semanage_user_add_role(self.sh, u, r) rc = semanage_begin_transaction(self.sh) if rc < 0:
Quoted 15 lines · Daniel J Walsh
Bunch of patches separated so you can approve/deny them separately.
avc patch Removes
optional_policyname from audit2allowpyver patch removes hardcoding of python version from makefile. Will use version of installed python version.
newrole patch to use
O_RDWRfor terminals to fix more problem.fixfiles patch fixes a problem with fixfiles was writing "not a tty" to the current directory when there was no terminal.
seobject patch is somewhat more controversial, but at least parts of it should be accepted.
Quoted 6 lines
- Fixes translation of portions of security context.
- Get rid of excess "\n"
- Restart mcstrans to relize file changed.
- Verify prefix is valid
- Modify roles correctly, currently role removal does not work without this fix.
One patch per message is better for review and processing.
I don't think the fixfiles patch does what you think ($1 is the first argument, not the exit status of the prior command).
newrole patch was already acked by Karl, not sure why it hasn't been merged.
I had thought that there was some discussion of generalizing the mcstrans restart to a generic pre/post scriptlet
facility. /sbin/service and mcstrans are fairly distro-specific, right? At least wrap it with some script installed as part of policycoreutils, with a default one that does nothing, and then Fedora can ship one that does /sbin/service mcstrans restart.
prefix validity check would ideally happen in libsemanage using libsepol; we'd like to avoid making assumptions in seobject about particular context values.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 38 lines · Stephen Smalley
Quoted 15 lines · Daniel J Walsh
Bunch of patches separated so you can approve/deny them separately.
avc patch Removes
optional_policyname from audit2allowpyver patch removes hardcoding of python version from makefile. Will use version of installed python version.
newrole patch to use
O_RDWRfor terminals to fix more problem.fixfiles patch fixes a problem with fixfiles was writing "not a tty" to the current directory when there was no terminal.
seobject patch is somewhat more controversial, but at least parts of it should be accepted.
Quoted 6 lines
- Fixes translation of portions of security context.
- Get rid of excess "\n"
- Restart mcstrans to relize file changed.
- Verify prefix is valid
- Modify roles correctly, currently role removal does not work without this fix.One patch per message is better for review and processing.
I don't think the fixfiles patch does what you think ($1 is the first argument, not the exit status of the prior command).
newrole patch was already acked by Karl, not sure why it hasn't been merged.
I had thought that there was some discussion of generalizing the mcstrans restart to a generic pre/post scriptlet
facility./sbin/serviceand mcstrans are fairly distro-specific, right? At least wrap it with some script installed as part of policycoreutils, with a default one that does nothing, and then Fedora can ship one that does/sbin/servicemcstrans restart.
Quoted 3 lines
prefix validity check would ideally happen in libsemanage using libsepol; we'd like to avoid making assumptions in seobject about particular context values.
Merged everything except for the fixfiles patch and the seobject patch.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Ok this part of the seobject patch should not be controversial.
This patch fixes modification of roles.
Quoted 1 line
semanage/seobject.py +6 -2
@@ -525,8 +525,12 @@ semanage_user_set_prefix(self.sh, u, prefix) if len(roles) != 0: - for r in roles: - semanage_user_add_role(self.sh, u, r) + for r in rlist: + if r not in roles: + semanage_user_del_role(u, r) + for r in roles: + if r not in rlist: + semanage_user_add_role(self.sh, u, r) rc = semanage_begin_transaction(self.sh) if rc < 0:
Stephen Smalley
Acked-byQuoted 14 lines · Daniel J Walsh
Ok this part of the seobject patch should not be controversial.
This patch fixes modification of roles.
Quoted 1 line
plain text document attachment (diff)
diff --exclude-from=exclude --exclude POTFILES.in --exclude='*.po' --exclude='*.pot' -N -u -rnsapolicycoreutils/semanage/seobject.pypolicycoreutils-1.33.8/semanage/seobject.pysemanage/seobject.py +0
-1@@ -525,8 +525,12 @@ semanage_user_set_prefix(self.sh, u, prefix) if len(roles) != 0: - for r in roles:
semanage/seobject.py line 536
Quoted 10 lines
semanage/seobject.py +6
-1- semanage_user_add_role(self.sh, u, r) + for r in rlist: + if r not in roles: + semanage_user_del_role(u, r) + for r in roles: + if r not in rlist: + semanage_user_add_role(self.sh, u, r) rc = semanage_begin_transaction(self.sh) if rc < 0:
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 23 lines · Stephen Smalley
Quoted 22 lines · Daniel J Walsh
Ok this part of the seobject patch should not be controversial.
This patch fixes modification of roles.
Quoted 1 line
plain text document attachment (diff)
diff --exclude-from=exclude --exclude POTFILES.in --exclude='*.po' --exclude='*.pot' -N -u -rnsapolicycoreutils/semanage/seobject.pypolicycoreutils-1.33.8/semanage/seobject.pysemanage/seobject.py +6
-2@@ -525,8 +525,12 @@ semanage_user_set_prefix(self.sh, u, prefix) if len(roles) != 0: - for r in roles: - semanage_user_add_role(self.sh, u, r) + for r in rlist: + if r not in roles: + semanage_user_del_role(u, r) + for r in roles: + if r not in rlist: + semanage_user_add_role(self.sh, u, r)
Quoted 4 lines
semanage/seobject.py line 536
Quoted 2 lines
semanage/seobject.py +0
-0rc = semanage_begin_transaction(self.sh) if rc < 0:Acked-by Stephen Smalley <[email protected]>
Question though - what should happen if len(role) == 0? Is that even possible?
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 27 lines · Stephen Smalley
Quoted 25 lines · Stephen Smalley
Quoted 23 lines · Daniel J Walsh
Ok this part of the seobject patch should not be controversial.
This patch fixes modification of roles.
Quoted 2 lines
plain text document attachment (diff)
diff --exclude-from=exclude --exclude POTFILES.in --exclude='*.po' --exclude='*.pot' -N -u -rnsapolicycoreutils/semanage/seobject.pypolicycoreutils-1.33.8/semanage/seobject.pysemanage/seobject.py +6
-2@@ -525,8 +525,12 @@ semanage_user_set_prefix(self.sh, u, prefix) if len(roles) != 0: - for r in roles: - semanage_user_add_role(self.sh, u, r) + for r in rlist: + if r not in roles: + semanage_user_del_role(u, r) + for r in roles: + if r not in rlist: + semanage_user_add_role(self.sh, u, r)
Quoted 10 lines
Quoted 5 lines
semanage/seobject.py line 536
Quoted 3 lines
semanage/seobject.py +0
-0rc = semanage_begin_transaction(self.sh) if rc < 0:Acked-by Stephen Smalley <[email protected]>Question though - what should happen if len(role) == 0? Is that even possible?
semanage user -m -R "" -P staff d /usr/sbin/semanage: Requires prefix, roles, level or range
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.