Policycoreutils latest diffs.
Please use < 0 to check for error everywhere.
This is correct behavior, even though the only error code I currently use is -1. Once commit numbers are included (commit numbers are positive integers), some of those calls might fail if you check with != 0.
I already fixed a few earlier - not sure this patch is affected, but < 0 should be used in general.
--
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 6 lines
scripts/genhomedircon +0
-4- rc = commands.getstatusoutput("grep -v '^ *#' %s" % self.selinuxdir+self.type+"/seusers") - if rc[0] == 0 and rc[1] != "": - ulist = rc[1].split("\n") - for u in ulist:
scripts/genhomedircon line 224
Quoted 10 lines
scripts/genhomedircon +5
-1- if len(u)==0: + try: + fd =open(self.selinuxdir+self.type+"/seusers") + for u in fd.read().split('\n'): + u=u.strip() + if len(u)==0 or u[0]=="#": continue user = u.split(":") if len(user) < 3: continue
Somebody pointed out that len(user) < 3 assumes the mls component of the seusers file is required. This is not consistent with libsemanage and libselinux, which consider it optional.
--
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.
Fixes to restorecon to handle user_only_changed even in the -vv case.
Many fixes to chcat to get it working in the hundreds of different ways it can be used...
Changed fixfiles to sort before doing the diff. New way of handling file_context seems to change the file_context sort order on every update causing fixfiles to falsely think things have changed. This might not be ideal since ordering could cause problems.
genhomedircon fixes to make it work within anaconda. Eliminated all calls to getstatusoutput.
Added test files to be run to make sure there are no regressions on updates. Probably should get these to run automatically some how.
semanage modified to handle ports. Currenly does not work because of some of Ivan's changes to libsepol, libsemanage and libselinux have not been added.
restorecon/restorecon.8 +1 -1
@@ -45,7 +45,7 @@ show changes in file labels, if type, role, or user are changing. .TP .B \-F -Force reset of context to match file_context for customizable files +Force reset of context to match file_context for customizable files, or the user section, if it has changed. .TP .SH "ARGUMENTS" .B pathname...
restorecon/restorecon.c +18 -24
71 lines not on this page · raw message
scripts/chcat +76 -43
194 lines not on this page · raw message
scripts/chcat.8 +6 -0
@@ -11,6 +11,9 @@ .B chcat [\fI-d\fR] \fIFILE\fR... .br +.B chcat +[\fI-l\fR] +.br .PP Change/Remove the security CATEGORY for each FILE. .PP
@@ -18,6 +21,9 @@ .TP \fB\-d\fR delete the category from each file. +.TP +\fB\-l\fR +list available categories. .SH "SEE ALSO" .TP chcon(1), selinux(8)
scripts/fixfiles +2 -2
@@ -62,8 +62,8 @@ TEMPFILE=`mktemp ${FC}.XXXXXXXXXX` test -z "$TEMPFILE" && exit PREFCTEMPFILE=`mktemp ${PREFC}.XXXXXXXXXX` - sed -r -e 's,:s0, ,g' $PREFC > ${PREFCTEMPFILE} - sed -r -e 's,:s0, ,g' $FC | \ + sed -r -e 's,:s0, ,g' $PREFC | sort -u > ${PREFCTEMPFILE} + sed -r -e 's,:s0, ,g' $FC | sort -u | \ /usr/bin/diff -b ${PREFCTEMPFILE} - | \ grep '^[<>]'|cut -c3-| grep ^/ | \ egrep -v '(^/home|^/root|^/tmp|^/dev)' |\
scripts/genhomedircon +130 -108
326 lines not on this page · raw message
scripts/selisteners +37 -0
@@ -0,0 +1,37 @@ +#! /usr/bin/env python +# Copyright (C) 2005 Red Hat +# see file 'COPYING' for use and warranty information +# +# listeners - this script finds all processes listening on a TCP or UDP Port +# configuration entries for user home directories based on their +# default roles and is run when building the policy. Specifically, we +# replace HOME_ROOT, HOME_DIR, and ROLE macros in .fc files with +# generic and user-specific values. +# +# Based off original script by Dan Walsh, <[email protected]> +# +# ASSUMPTIONS: +# +# The file CONTEXTDIR/files/homedir_template exists. This file is used to +# set up the home directory context for each real user. +# +# If a user has more than one role, genhomedircon uses the first role in the list. +# +# If a user is not listed in CONTEXTDIR/seusers, he will default to user_u, role user +# +# "Real" users (as opposed to system users) are those whose UID is greater than +# or equal STARTING_UID (usually 500) and whose login is not a member of +# EXCLUDE_LOGINS. Users who are explicitly defined in CONTEXTDIR/seusers +# are always "real" (including root, in the default configuration). +# +# +import commands, string +import selinux +rc=commands.getstatusoutput("netstat -aptul") +out=rc[1].split("\n") +for i in out: + x=i.split() + y=x[-1].split("/") + if len(y)==2: + pid=string.atoi(y[0]) + print "%s %-40s %-10s\t%-20s\t%s" % (x[0], x[3], pid,y[1],selinux.getpidcon(pid)[1])
scripts/tests/chcat_test +43 -0
43 lines not on this page · raw message
scripts/tests/setrans.conf +23 -0
@@ -0,0 +1,23 @@ +# +# Multi-Category Security translation table for SELinux +# +# Uncomment the following to disable translation libary +# disable=1 +# +# Objects can be categorized with 0-256 categories defined by the admin. +# Objects can be in more than one category at a time. +# Categories are stored in the system as c0-c255. Users can use this +# table to translate the categories into a more meaningful output. +# Examples: +# s0:c0=CompanyConfidential +# s0:c1=PatientRecord +# s0:c2=Unclassified +# s0:c3=TopSecret +# s0:c1,c3=CompanyConfidentialRedHat +s0= +s0-s0:c0.c255=SystemLow-SystemHigh +s0:c0.c255=SystemHigh +s0:c0=Company_Confidential +s0:c1=Marketing +s0:c2=Payroll +s0:c3=NDA_Yoyodyne
semanage/semanage +287 -127
607 lines not on this page · raw message
semanage/tests/semanage_test +67 -0
67 lines not on this page · raw message
Quoted 2 lines
Please use < 0 to check for error everywhere.
Another issue is that I'm rather confused by some of the current semanage code w' respect to local vs in-policy, so I'll try to explain again . All functions ending in _local (and the seusers one) act with respect to the local store. All functions not ending in _local act with respect to the final result (which includes local modifications stacked on top of policy). They do not act on policy alone.
Let's look at two cases of code that I don't understand:
This is from port.modify. The libsemanage meaning of modify includes adding things if they don't exist, but I understand this is not the case in the tool, so that explains all the exists checks... However:
(rc,exists) = semanage_port_exists_local(self.sh, k) if exists:
(rc,p) = semanage_port_query_local(self.sh, k) (rc,exists) = semanage_port_exists(self.sh, k) if exists:
(rc,p) = semanage_port_query(self.sh, k)
else:
raise ValueError("port %s/%s is not
defined." % (proto,port))
if rc != 0:
raise ValueError("Could not query port for
%s/%s" % (proto, port))
This doesn't make sense, because of something exists locally, and your query succeeded, it will always exists in the final result, and the second query will return the exact same thing, so you already know the result to both of those function calls.
This is from the port add function:
(rc,exists) = semanage_port_exists(self.sh, k) if exists:
raise ValueError("Port %s/%s already defined" %
(proto, port))
(rc,exists) = semanage_port_exists_local(self.sh, k) if exists:
raise ValueError("Port %s/%s already defined
locally" % (proto, port))
Here, the second exception will never occur, because if the port exists locally, then it exists in-policy as well, and the first value error will be thrown.
--
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 3 lines
Let's look at two cases of code that I don't understand:
Here's another one from the user add:
(rc,exists) = semanage_user_exists_local(self.sh, k) if not exists:
(rc,exists) = semanage_user_exists(self.sh, k) if not exists:
raise ValueError("SELinux user %s is
already defined." % name)
This doesn't make sense, because you take the same action regardless of whether the exist test fails locally, or on the final result (which combines policy with local modifications). Hence, you might as well skip the first one and go straight to the second one (which will include the first one).
--
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 4 lines
delete
if does not exist local; error since you can not delete an object from the server? Prevent the user from deleting SELinux User "root"
Right.. I would two tests, and then if exists fails say: object does not exist if exists_local fails say: object is built into policy and can't be deleted.
There's still the issue of how the user would know that at all, since list does not indicate what's local and what isn't, but it's a good point to start at.
Quoted 3 lines
Add
if does exist: error
yes, that should be sufficient.
Quoted 3 lines
Modify:
If does not exist local; you are not allowed to modify, see above.
That's tricky. That depends on what you want modify to do.
The libsemanage modify_local function is with respect to the local store, but anything you write in the store at all will modify policy, so you can go either way with your higher level modify. The question is what you're modifying, and does the user understand that.
I think to be consistent with add(), you should modify with respect to policy, and not do any checks here.
====
Btw, if there's interest in writing an API that works on policy alone, minus local modifications, that can be done - it just requires writing down another policy after expand, and before any local things are written down.
--
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 14 lines · Daniel J Walsh
Fixes to restorecon to handle
user_only_changedeven in the -vv case.Many fixes to chcat to get it working in the hundreds of different ways it can be used...
Changed fixfiles to sort before doing the diff. New way of handling
file_contextseems to change thefile_contextsort order on every update causing fixfiles to falsely think things have changed. This might not be ideal since ordering could cause problems.genhomedircon fixes to make it work within anaconda. Eliminated all calls to getstatusoutput.
Quoted 6 lines
Added test files to be run to make sure there are no regressions on updates. Probably should get these to run automatically some how.
semanage modified to handle ports. Currenly does not work because of some of Ivan's changes to libsepol, libsemanage and libselinux have not been added.
I merged the diffs to existing files as of policycoreutils 1.29.3. However, I didn't add the new files yet, namely selisteners and the test files. selisteners likely needs more polishing to be generally useful. For the test scripts, I think we need them to be in a form more amenable to automated testing (i.e. checking the return values and/or output themselves against expected values), and possibly they should be added to the selinux testsuite in the ltp instead of included in policycoreutils itself (especially since you have to install a custom setrans.conf for your chcat tests, and semanage may be manipulating the active policy).
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 5 lines
That's tricky. That depends on what you want modify to do.
The libsemanagemodify_localfunction is with respect to the local store, but anything you write in the store at all will modify policy, so you can go either way with your higher level modify. The question is what you're modifying, and does the user understand that.
In case I wasn't clear here, overrides are allowed for all object types, which means you can modify things that are built into policy.
That's regardless of which function you use to add things to store - add vs set vs modify. In fact, all three functions do pretty much the same thing, and I've been meaning to get rid of some of them, but now that we must preserve a stable API that might be a problem - modify can be used to implement all the others. The other two are only useful if you want the library to do an exists check for you (which you shouldn't do), or for performance reasons, but I'm thinking that set is algorithmically guaranteed to take the same time as modify.
--
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 3 lines
No, I think this is a bad idea, the purpose of local files is to override policy defaults. The base policy package should stay the same so that upgrades via RPM do not smash changes. Using an alternate base if it exists and the base.pp otherwise adds unnecessary complexity.
I meant a read-only API.
--
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 4 lines
Quoted 3 lines
But I thought we were only going to allow modifying of local stuff. Do we want a user to be able to modify the SELinux USER Root or
user_u? I don't think so.why not? that is a fairly arbitrary decision, maybe we shouldn't allow them to modify the ssh port either?
Speaking of overriding things, is it currently possible to override the entire ethereal security module, for example?
Is there a modules.local? It's always been my opinion that modules should be just another record type, and the fs directory should be just another backend to the database...
--
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 7 lines
Quoted 6 lines
Speaking of overriding things, is it currently possible to override the entire ethereal security module, for example?
Is there a modules.local? It's always been my opinion that modules should be just another record type, and the fs directory should be just another backend to the database...I really don't want to get into this again. Generalizing module store for the sake of doing so would be a tremendous waste of time. The policy server will allow transfering of the binary modules to machines over the network (with access control) so why would they ever need to be stored in some other medium.
Maybe so... I don't think it'd be that difficult, and I think there would be benefits in terms of shared code and uniform interface. Anyway, my point was uniform interface is a good thing - modules should be less special and more like the other things.
My first question still stands, whether or not the store is generalized - it seems potentially useful to have a modules.local folder. It actually seems like a namespace conflict not to have one - what if I write a module, put it in the modules folder, and then it gets overwritten by policy when somebody makes another one with the same name. What if I want a more restrictive version of mozilla? Or a more relaxed one? Or I want to make a program that has a policy interoperate with my secret 3rd party extension that I can't upstream.
--
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 5 lines · Ivan Gyurdiev
Quoted 3 lines
Let's look at two cases of code that I don't understand:
Here's another one from the user add:
Quoted 13 lines
(rc,exists) =
semanage_user_exists_local(self.sh, k)if not exists:
(rc,exists) =semanage_user_exists(self.sh, k)if not exists:
raise ValueError("SELinux user %s is
already defined." % name)This doesn't make sense, because you take the same action regardless of whether the exist test fails locally, or on the final result (which combines policy with local modifications). Hence, you might as well skip the first one and go straight to the second one (which will include the first one).
Ok, I might have misunderstood the symantics. But Should the following checks be in place
delete
if does not exist local; error since you can not delete an object from the server? Prevent the user from deleting SELinux User "root"
Add
if does exist: error
Modify:
If does not exist local; you are not allowed to modify, see above.
--
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 18 lines · Ivan Gyurdiev
Quoted 4 lines
delete
if does not exist local; error since you can not delete an object from the server? Prevent the user from deleting SELinux User "root"Right.. I would two tests, and then if exists fails say: object does not exist if
exists_localfails say: object is built into policy and can't be deleted.There's still the issue of how the user would know that at all, since list does not indicate what's local and what isn't, but it's a good point to start at.
Quoted 3 lines
Add
if does exist: erroryes, that should be sufficient.
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Modify:
If does not exist local; you are not allowed to modify, see above.That's tricky. That depends on what you want modify to do.
The libsemanagemodify_localfunction is with respect to the local store, but anything you write in the store at all will modify policy, so you can go either way with your higher level modify. The question is what you're modifying, and does the user understand that.
even if something does not exist locally a 'modify' of an existing object would involve using local settings to override what is in the policy. AFAIK all the current stuff should support overriding the policydb so you can modify any policy resource whether it is local or not.
Quoted 6 lines
I think to be consistent with
add(), you should modify with respect to policy, and not do any checks here.====
Btw, if there's interest in writing an API that works on policy alone, minus local modifications, that can be done - it just requires writing down another policy after expand, and before any local things are written down.
No, I think this is a bad idea, the purpose of local files is to override policy defaults. The base policy package should stay the same so that upgrades via RPM do not smash changes. Using an alternate base if it exists and the base.pp otherwise adds unnecessary complexity.
--
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 14 lines · Ivan Gyurdiev
Quoted 4 lines
delete
if does not exist local; error since you can not delete an object from the server? Prevent the user from deleting SELinux User "root"Right.. I would two tests, and then if exists fails say: object does not exist if
exists_localfails say: object is built into policy and can't be deleted.There's still the issue of how the user would know that at all, since list does not indicate what's local and what isn't, but it's a good point to start at.
Quoted 3 lines
Add
if does exist: erroryes, that should be sufficient.
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
Modify:
If does not exist local; you are not allowed to modify, see above.That's tricky. That depends on what you want modify to do.
The libsemanagemodify_localfunction is with respect to the local store, but anything you write in the store at all will modify policy, so you can go either way with your higher level modify. The question is what you're modifying, and does the user understand that.
But I thought we were only going to allow modifying of local stuff. Do we want a user to be able to modify the SELinux USER Root or user_u? I don't think so.
I think modify should be akin to delete. You can only modify if it exists_local.
Quoted 4 lines
I think to be consistent with
add(), you should modify with respect to policy, and not do any checks here.====
Btw, if there's interest in writing an API that works on policy alone, minus local modifications, that can be done - it just requires writing down another policy after expand, and before any local things are written down.
--
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 · Daniel J Walsh
Quoted 21 lines · Ivan Gyurdiev
Quoted 4 lines
delete
if does not exist local; error since you can not delete an object from the server? Prevent the user from deleting SELinux User "root"Right.. I would two tests, and then if exists fails say: object does not exist if
exists_localfails say: object is built into policy and can't be deleted.There's still the issue of how the user would know that at all, since list does not indicate what's local and what isn't, but it's a good point to start at.
Quoted 3 lines
Add
if does exist: erroryes, that should be sufficient.
Quoted 3 lines
Modify:
If does not exist local; you are not allowed to modify, see above.
Quoted 8 lines
Quoted 6 lines
That's tricky. That depends on what you want modify to do.
The libsemanagemodify_localfunction is with respect to the local store, but anything you write in the store at all will modify policy, so you can go either way with your higher level modify. The question is what you're modifying, and does the user understand that.But I thought we were only going to allow modifying of local stuff. Do we want a user to be able to modify the SELinux USER Root or
user_u? I don't think so.
why not? that is a fairly arbitrary decision, maybe we shouldn't allow them to modify the ssh port either?
Quoted 9 lines
I think modify should be akin to delete. You can only modify if it
exists_local.Quoted 4 lines
I think to be consistent with
add(), you should modify with respect to policy, and not do any checks here.====
Btw, if there's interest in writing an API that works on policy alone, minus local modifications, that can be done - it just requires writing down another policy after expand, and before any local things are written down.
--
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 9 lines · Ivan Gyurdiev
Quoted 4 lines
Quoted 3 lines
But I thought we were only going to allow modifying of local stuff. Do we want a user to be able to modify the SELinux USER Root or
user_u? I don't think so.why not? that is a fairly arbitrary decision, maybe we shouldn't allow them to modify the ssh port either?
Speaking of overriding things, is it currently possible to override the entire ethereal security module, for example?
Is there a modules.local? It's always been my opinion that modules should be just another record type, and the fs directory should be just another backend to the database...
I really don't want to get into this again. Generalizing module store for the sake of doing so would be a tremendous waste of time. The policy server will allow transfering of the binary modules to machines over the network (with access control) so why would they ever need to be stored in some other medium.
--
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.