Latest policycoreutils patch
Includes Ivan and Russells changes
Now checks to make sure run as root.
Also chcat can now manipulate categories of users as well as files.
scripts/chcat +138 -16
@@ -23,15 +23,51 @@ # # import commands, sys, os, pwd, string, getopt, re, selinux +import seobject -def chcat_add(orig, newcat, files): +def chcat_user_add(orig, newcat, users): + errors=0 + logins = seobject.loginRecords() + seusers=logins.get_all() + add_ind=0 + for u in users: + if u in seusers.keys(): + user=seusers[u] + else: + add_ind=1 + user=seusers["__default__"] + range=user[1].split("-") + cats=[] + top=["s0"] + if len(range) > 1: + top=range[1].split(":") + if len(top) > 1: + cats.append(top[1]) + cats = expandCats(cats) + + for i in newcat[1:]: + if i not in cats: + cats.append(i) + new_range="%s-%s:%s" % (range[0], top[0], string.join(cats, ",")) + + if add_ind: + logins.add(u, user[0], new_range) + else: + logins.modify(u, user[0], new_range) + return errors + +def chcat_add(orig, newcat, objects,login_ind): if len(newcat) == 1: raise ValueError("Requires at least one category") + + if login_ind == 1: + return chcat_user_add(orig, newcat, objects) + errors=0 sensitivity=newcat[0] cat=newcat[1] cmd='chcon -l %s' % sensitivity - for f in files: + for f in objects: (rc, c) = selinux.getfilecon(f) con=c.split(":")[3:] clist = translate(con)
@@ -57,14 +93,50 @@ errors+=1 return errors -def chcat_remove(orig, newcat, files): +def chcat_user_remove(orig, newcat, users): + errors=0 + logins = seobject.loginRecords() + seusers=logins.get_all() + add_ind=0 + for u in users: + if u in seusers.keys(): + user=seusers[u] + else: + add_ind=1 + user=seusers["__default__"] + range=user[1].split("-") + cats=[] + top=["s0"] + if len(range) > 1: + top=range[1].split(":") + if len(top) > 1: + cats.append(top[1]) + cats = expandCats(cats) + + for i in newcat[1:]: + if i in cats: + cats.remove(i) + + new_range="%s-%s:%s" % (range[0], top[0], string.join(cats, ",")) + + if add_ind: + logins.add(u, user[0], new_range) + else: + logins.modify(u, user[0], new_range) + return errors + +def chcat_remove(orig, newcat, objects, login_ind): if len(newcat) == 1: raise ValueError("Requires at least one category") + + if login_ind == 1: + return chcat_user_remove(orig, newcat, objects) + errors=0 sensitivity=newcat[0] cat=newcat[1] - for f in files: + for f in objects: (rc, c) = selinux.getfilecon(f) con=c.split(":")[3:] clist = translate(con)
@@ -97,7 +169,29 @@ errors+=1 return errors -def chcat_replace(orig, newcat, files): +def chcat_user_replace(orig, newcat, users): + errors=0 + logins = seobject.loginRecords() + seusers=logins.get_all() + add_ind=0 + for u in users: + if u in seusers.keys(): + user=seusers[u] + else: + add_ind=1 + user=seusers["__default__"] + range=user[1].split("-") + new_range="%s-%s:%s" % (range[0],newcat[0], string.join(newcat[1:], ",")) + + if add_ind: + logins.add(u, user[0], new_range) + else: + logins.modify(u, user[0], new_range) + return errors + +def chcat_replace(orig, newcat, objects, login_ind): + if login_ind == 1: + return chcat_user_replace(orig, newcat, objects) errors=0 if len(newcat) == 1: sensitivity=newcat[0]
@@ -108,7 +202,7 @@ for cat in newcat[2:]: cmd='%s,%s' % (cmd, cat) - for f in files: + for f in objects: cmd = "%s %s" % (cmd, f) rc=commands.getstatusoutput(cmd)
@@ -181,11 +275,15 @@ def usage(): print "Usage %s CATEGORY File ..." % sys.argv[0] + print "Usage %s -l CATEGORY user ..." % sys.argv[0] print "Usage %s [[+|-]CATEGORY],...]q File ..." % sys.argv[0] + print "Usage %s -l [[+|-]CATEGORY],...]q user ..." % sys.argv[0] print "Usage %s -d File ..." % sys.argv[0] - print "Usage %s -l" % sys.argv[0] + print "Usage %s -l -d user ..." % sys.argv[0] + print "Usage %s -L" % sys.argv[0] print "Use -- to end option list. For example" - print "chcat -- -CompanyConfidential /docs/businessplan.odt." + print "chcat -- -CompanyConfidential /docs/businessplan.odt" + print "chcat -l +CompanyConfidential juser" sys.exit(1) def listcats():
@@ -199,6 +297,19 @@ fd.close() 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=cats.split("-") + if len(cats) > 1 and cats[1] != "s0": + print "%s: %s" % (u, cats[1]) + else: + print "%s:" % u + def error(msg): print "%s: %s" % (sys.argv[0], msg) sys.exit(1)
@@ -212,10 +323,12 @@ delete_ind=0 list_ind=0 + login_ind=0 try: gopts, cmds = getopt.getopt(sys.argv[1:], - 'dhl', + 'dhlL', ['list', + 'login', 'help', 'delete'])
@@ -224,8 +337,10 @@ usage() if o == "-d" or o == "--delete": delete_ind=1 - if o == "-l" or o == "--list": + if o == "-L" or o == "--list": list_ind=1 + if o == "-l" or o == "--login": + login_ind=1 if list_ind==0 and len(cmds) < 1: usage()
@@ -233,10 +348,17 @@ usage() if delete_ind: - sys.exit(chcat_replace(["s0"], ["s0"], cmds)) + sys.exit(chcat_replace(["s0"], ["s0"], cmds, login_ind)) if list_ind: - sys.exit(listcats()) + if login_ind: + if len(cmds) < 1: + usage() + sys.exit(listusercats(cmds)) + else: + if len(cmds) > 0: + usage() + sys.exit(listcats()) if len(cmds) < 2: usage()
@@ -245,19 +367,19 @@ cats=cmds[0].split(",") mod_ind=0 errors=0 - files=cmds[1:] + objects=cmds[1:] try: if check_replace(cats): - errors=chcat_replace(cats,translate(cats), files) + errors=chcat_replace(cats,translate(cats), objects, login_ind) else: for c in cats: l=[] l.append(c[1:]) if len(c) > 0 and c[0] == "+": - errors += chcat_add(c[1:],translate(l), files) + errors += chcat_add(c[1:],translate(l), objects, login_ind) continue if len(c) > 0 and c[0] == "-": - errors += chcat_remove(c[1:],translate(l), files) + errors += chcat_remove(c[1:],translate(l), objects, login_ind) continue except ValueError, e: error(e)
scripts/chcat.8 +21 -7
@@ -5,31 +5,45 @@ .B chcat \fICATEGORY FILE\fR... .br +.B chcat -l +\fICATEGORY USER\fR... +.br .B chcat \fI[[+|-]CATEGORY],...] FILE\fR... .br +.B chcat -l +\fI[[+|-]CATEGORY],...] USER\fR... +.br .B chcat [\fI-d\fR] \fIFILE\fR... .br +.B chcat -l +[\fI-d\fR] \fIUSER\fR... +.br .B chcat -[\fI-l\fR] +\fI-L\fR [-l] [ USER ... ] .br .PP -Change/Remove the security CATEGORY for each FILE. +Change/Remove the security CATEGORY for each FILE/USER. .PP -Use +/- to add/remove categories from a FILE. +Use +/- to add/remove categories from a FILE/USER. .TP \fB\-d\fR -delete the category from each file. +delete the category from each FILE/USER. .TP -\fB\-l\fR +\fB\-L\fR list available categories. +.TP +\fB\-l\fR +Tells chcat to operate on users instead of files. .SH "SEE ALSO" .TP -chcon(1), selinux(8) +chcon(1), selinux(8), semanage(8) .PP .br -This script wraps the chcon command. +When operating on files this script wraps the chcon command. .SH "FILES" /etc/selinux/{SELINUXTYPE}/setrans.conf +.br +/etc/selinux/{SELINUXTYPE}/seuser
scripts/genhomedircon +3 -0
@@ -327,6 +327,9 @@ sys.stderr.write("%s: %s\n" % ( sys.argv[0], error )) +if os.getuid() > 0 or os.geteuid() > 0: + print "You must be root to run %s." % sys.argv[0] + sys.exit(0) # # This script will generate home dir file context
semanage/semanage +27 -14
99 lines not on this page · raw message
semanage/semanage.8 +45 -29
100 lines not on this page · raw message
semanage/seobject.py +473 -275
1,033 lines not on this page · raw message
Binary files nsapolicycoreutils/semanage/seobject.pyc and policycoreutils-1.29.7/semanage/seobject.pyc differ
Quoted 3 lines · Daniel J Walsh
Includes Ivan and Russells changes
Now checks to make sure run as root.
while it's probably true that most 'direct' libsemanage sessions need root that is not true for policy server so I don't think there should be a hard coded root check (aren't we trying to rely on MAC here?)
Quoted 3 lines
Also chcat can now manipulate categories of users as well as files.
--
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 · Daniel J Walsh
Includes Ivan and Russells changes
Now checks to make sure run as root.
while it's probably true that most 'direct' libsemanage sessions need root that is not necessarily true for policy server so I don't think there should be a hard coded root check in semanage (aren't we trying to rely on MAC here anyway?)
Quoted 3 lines
Also chcat can now manipulate categories of users as well as files.
--
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 · Joshua Brindle
Quoted 3 lines · Daniel J Walsh
Includes Ivan and Russells changes
Now checks to make sure run as root.
while it's probably true that most 'direct' libsemanage sessions need root that is not necessarily true for policy server so I don't think there should be a hard coded root check in semanage (aren't we trying to rely on MAC here anyway?)
The checks are for genhomedircon and semanage both of which will be prevented from running because of DAC control.
Quoted 3 lines
Quoted 3 lines
Also chcat can now manipulate categories of users as well as files.
--
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 · Daniel J Walsh
Quoted 2 lines · Joshua Brindle
Daniel J Walsh wrote:
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Includes Ivan and Russells changes
Now checks to make sure run as root.
while it's probably true that most 'direct' libsemanage sessions need root that is not necessarily true for policy server so I don't think there should be a hard coded root check in semanage (aren't we trying to rely on MAC here anyway?)
The checks are for genhomedircon and semanage both of which will be prevented from running because of DAC control.
why not correctly handle the permission failure instead of hardcoding a root check? semanage going through the policy server will not be affected by DAC(uid) aside from the permissions on the sock file.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Also chcat can now manipulate categories of users as well as files.
--
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 10 lines · Joshua Brindle
Quoted 9 lines · Daniel J Walsh
Quoted 7 lines · Joshua Brindle
Quoted 3 lines · Daniel J Walsh
Includes Ivan and Russells changes
Now checks to make sure run as root.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
while it's probably true that most 'direct' libsemanage sessions need root that is not necessarily true for policy server so I don't think there should be a hard coded root check in semanage (aren't we trying to rely on MAC here anyway?)
The checks are for genhomedircon and semanage both of which will be prevented from running because of DAC control.
why not correctly handle the permission failure instead of hardcoding a root check? semanage going through the policy server will not be affected by DAC(uid) aside from the permissions on the sock file.
So we have nasty failures until the policy server shows up?
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Also chcat can now manipulate categories of users as well as files.
--
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 17 lines · Daniel J Walsh
Quoted 15 lines · Joshua Brindle
Quoted 13 lines · Daniel J Walsh
Quoted 9 lines · Joshua Brindle
Quoted 3 lines · Daniel J Walsh
Includes Ivan and Russells changes
Now checks to make sure run as root.
while it's probably true that most 'direct' libsemanage sessions need root that is not necessarily true for policy server so I don't think there should be a hard coded root check in semanage (aren't we trying to rely on MAC here anyway?)
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
The checks are for genhomedircon and semanage both of which will be prevented from running because of DAC control.
why not correctly handle the permission failure instead of hardcoding a root check? semanage going through the policy server will not be affected by DAC(uid) aside from the permissions on the sock file.
So we have nasty failures until the policy server shows up?
sounds like the direct_api in libsemanage needs to return an error if it doesn't think it'll be able to write to the policy store (at transaction start time, or maybe on request) , and semanage can handle it gracefully. That way only direct connections are affected and semanage won't show users any nasty failures.
--
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
sounds like the
direct_apiin libsemanage needs to return an error if it doesn't think it'll be able to write to the policy store (at transaction start time, or maybe on request) , and semanage can handle it gracefully. That way only direct connections are affected and semanage won't show users any nasty failures.
It does return a failure... you mean a more specific one?
Current failure could be for many reasons, and it also writes to the ERR stream complaining about it..
--
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 · Ivan Gyurdiev
Quoted 3 lines
sounds like the
direct_apiin libsemanage needs to return an error if it doesn't think it'll be able to write to the policy store (at transaction start time, or maybe on request) , and semanage can handle it gracefully. That way only direct connections are affected and semanage won't show users any nasty failures.It does return a failure... you mean a more specific one?
Current failure could be for many reasons, and it also writes to the ERR stream complaining about it..
Nasty errors when trying to run as a normal user. Are not pretty.
python chcat -L -l dwalsh
libsemanage.semanage_create_store: Could not access module store at /etc/selinux/targeted/modules, or it is not a directory. libsemanage.assert_init: A direct or server connection is needed to use this function - please call the corresponding connect() method libsemanage.enter_ro: could not enter read-only section
Traceback (most recent call last):
File "chcat", line 366, in ?
sys.exit(listusercats(cmds))
File "chcat", line 303, in listusercats
seusers = seobject.loginRecords().get_all()
File "/usr/lib/python2.4/site-packages/seobject.py", line 175, in get_all
raise ValueError("Could not list login mappings")
ValueError: Could not list login mappings
This needs to be legal. What is happening to cause this problem? Or do I need to code around this by reading the seusers file?
--
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 16 lines
python chcat -L -l dwalsh
libsemanage.semanage_create_store: Could not access module store at/etc/selinux/targeted/modules, or it is not a directory. libsemanage.assert_init: A direct or server connection is needed to use this function - please call the correspondingconnect()method libsemanage.enter_ro: could not enter read-only section
Traceback (most recent call last):
File "chcat", line 366, in ?
sys.exit(listusercats(cmds))
File "chcat", line 303, in listusercats
seusers = seobject.loginRecords().get_all()
File "/usr/lib/python2.4/site-packages/seobject.py", line 175, inget_all
raiseValueError("Could not list login mappings")
ValueError: Could not list login mappings
Quoted 1 line
This needs to be legal. What is happening to cause this problem? Or do I need to code around this by reading the seusers file?
It's a permissions problem - you have to be root to create the store, because you're writing to /etc/selinux/targeted/modules (or reading from it, it doesn't really matter), and at least on my machine all folders and files under that folder are owned by root, and not writable/readable by anyone else. Of course, it should fail on connect and stop there, but you're still not checking rc values where necessary.
Btw, it seems that handle_create can also fail in a variety of ways, while that is undocumented in the headers - should change the headers. It returns NULL on failure.
--
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 16 lines
Quoted 16 lines
python chcat -L -l dwalsh
libsemanage.semanage_create_store: Could not access module store at/etc/selinux/targeted/modules, or it is not a directory. libsemanage.assert_init: A direct or server connection is needed to use this function - please call the correspondingconnect()method libsemanage.enter_ro: could not enter read-only section
Traceback (most recent call last):
File "chcat", line 366, in ?
sys.exit(listusercats(cmds))
File "chcat", line 303, in listusercats
seusers = seobject.loginRecords().get_all()
File "/usr/lib/python2.4/site-packages/seobject.py", line 175, inget_all
raiseValueError("Could not list login mappings")
ValueError: Could not list login mappings
Quoted 4 lines
Quoted 1 line
This needs to be legal. What is happening to cause this problem? Or do I need to code around this by reading the seusers file?
It's a permissions problem - you have to be root to create the store, because you're writing to
/etc/selinux/targeted/modules(or reading from it, it doesn't really matter), and at least on my machine all folders and files under that folder are owned by root, and not writable/readable by anyone else. Of course, it should fail on connect and stop there, but you're still not checking rc values where necessary.Btw, it seems that
handle_createcan also fail in a variety of ways, while that is undocumented in the headers - should change the headers. It returns NULL on failure.
Apparently it needs rwx on /etc/targeted/modules, and it doesn't have write as non-root. I think it will need to write lock files in there to do anything at all.
int mode_mask = R_OK | W_OK | X_OK;
Then it has no permissions under /active as non-root, and therefore won't be able to read any information out of there.
--
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 30 lines · Ivan Gyurdiev
Quoted 27 lines
Quoted 17 lines
python chcat -L -l dwalsh libsemanage.semanage_create_store: Could not access module store at
/etc/selinux/targeted/modules, or it is not a directory. libsemanage.assert_init: A direct or server connection is needed to use this function - please call the correspondingconnect()method libsemanage.enter_ro: could not enter read-only section Traceback (most recent call last):
File "chcat", line 366, in ?
sys.exit(listusercats(cmds))
File "chcat", line 303, in listusercats
seusers = seobject.loginRecords().get_all()
File "/usr/lib/python2.4/site-packages/seobject.py", line 175, inget_all
raiseValueError("Could not list login mappings")
ValueError: Could not list login mappingsQuoted 2 lines
This needs to be legal. What is happening to cause this problem? Or do I need to code around this by reading the seusers file?
It's a permissions problem - you have to be root to create the store, because you're writing to
/etc/selinux/targeted/modules(or reading from it, it doesn't really matter), and at least on my machine all folders and files under that folder are owned by root, and not writable/readable by anyone else. Of course, it should fail on connect and stop there, but you're still not checking rc values where necessary.Quoted 3 lines
Btw, it seems that
handle_createcan also fail in a variety of ways, while that is undocumented in the headers - should change the headers. It returns NULL on failure.
Quoted 8 lines
Apparently it needs rwx on
/etc/targeted/modules, and it doesn't have write as non-root.
I think it will need to write lock files in there to do anything at all.int
mode_mask=R_OK|W_OK|X_OK;Then it has no permissions under /active as non-root, and therefore won't be able to read any information out of there.
If you want this to be useable by ordinary users (subject only to policy restrictions), then you likely want it to act on the installed seusers file instead of the libsemanage-managed one.
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 26 lines · Stephen Smalley
Quoted 24 lines · Ivan Gyurdiev
Quoted 15 lines
Quoted 15 lines
python chcat -L -l dwalsh
libsemanage.semanage_create_store: Could not access module store at/etc/selinux/targeted/modules, or it is not a directory. libsemanage.assert_init: A direct or server connection is needed to use this function - please call the correspondingconnect()method libsemanage.enter_ro: could not enter read-only section
Traceback (most recent call last):
File "chcat", line 366, in ?
sys.exit(listusercats(cmds))
File "chcat", line 303, in listusercats
seusers = seobject.loginRecords().get_all()
File "/usr/lib/python2.4/site-packages/seobject.py", line 175, inget_all
raiseValueError("Could not list login mappings")
ValueError: Could not list login mappingsQuoted 6 lines
Quoted 2 lines
This needs to be legal. What is happening to cause this problem? Or do I need to code around this by reading the seusers file?
It's a permissions problem - you have to be root to create the store, because you're writing to
/etc/selinux/targeted/modules(or reading from it, it doesn't really matter), and at least on my machine all folders and files under that folder are owned by root, and not writable/readable by anyone else. Of course, it should fail on connect and stop there, but you're still not checking rc values where necessary.Btw, it seems that
handle_createcan also fail in a variety of ways, while that is undocumented in the headers - should change the headers. It returns NULL on failure.Apparently it needs rwx on
/etc/targeted/modules, and it doesn't have write as non-root. I think it will need to write lock files in there to do anything at all.
Quoted 9 lines
Quoted 4 lines
int
mode_mask=R_OK|W_OK|X_OK;Then it has no permissions under /active as non-root, and therefore won't be able to read any information out of there.
If you want this to be useable by ordinary users (subject only to policy restrictions), then you likely want it to act on the installed seusers file instead of the libsemanage-managed one.
Shouldn't the policy server improve this situation when it's merged?
(By the way, now that you've merged my patches, there's no more dependency on semanage_store.c in database.c, which means there's no further known obstacles to implementing a pserver backend to the database, if the server is merged, and line protocol is decided upon).
--
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 · Ivan Gyurdiev
Quoted 4 lines · Stephen Smalley
If you want this to be useable by ordinary users (subject only to policy restrictions), then you likely want it to act on the installed seusers file instead of the libsemanage-managed one.
Shouldn't the policy server improve this situation when it's merged?
Policy server avoids the need for the client program to pass DAC checks on the module store, but a) some kind of checking will certainly be applied by the policy server on client requests, and b) use of policy server will not be mandatory at least in the short term (even after it is merged).
Also, the current usage pattern for file_contexts and seusers is that libselinux reads the installed files for runtime operation rather than getting the information from libsemanage, so I'm not sure why chcat -L -l wouldn't just read the installed seusers file too (preferably via libselinux function). The installed files already have DAC modes that allow user read access, subject only to policy restrictions.
Quoted 4 lines
(By the way, now that you've merged my patches, there's no more dependency on
semanage_store.cindatabase.c, which means there's no further known obstacles to implementing a pserver backend to the database, if the server is merged, and line protocol is decided upon).
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 7 lines
Policy server avoids the need for the client program to pass DAC checks on the module store, but a) some kind of checking will certainly be applied by the policy server on client requests, and b) use of policy server will not be mandatory at least in the short term (even after it is merged).
Is there a problem with making some of those store files world-readable, and making changes to allow lock files to be written by ordinary users somehow. I don't understand why the selinux copy if the data is readable, but the semanage copy is not, if they contain the same thing.
Quoted 7 lines
Also, the current usage pattern for
file_contextsand seusers is that libselinux reads the installed files for runtime operation rather than getting the information from libsemanage, so I'm not sure why chcat -L -l wouldn't just read the installed seusers file too (preferably via libselinux function). The installed files already have DAC modes that allow user read access, subject only to policy restrictions.
Libsemanage has an interface for that kind of thing already - why can't that be used? I'm starting to get confused about the difference between all those libraries again. If libselinux is to be used on runtime, and libsemanage on persistent policy, then how do you explain the need for active booleans backend in libsemanage?
--
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 · Ivan Gyurdiev
Is there a problem with making some of those store files world-readable, and making changes to allow lock files to be written by ordinary users somehow. I don't understand why the selinux copy if the data is readable, but the semanage copy is not, if they contain the same thing.
I view libsemanage as the management interface only, and thus naturally restricted to privileged entities. Certain files are then exported outside of the module store for use by a variety of programs that only want read access and nothing more. We _could_ make some of the store files readable, but I doubt we want to allow lock file creation.
In general, the protection of the module store needs more thought, at least in terms of the security contexts on its files, as it contains multiple files that ultimately end up with different SELinux security contexts when they are installed (e.g. policy ends up as policy_config_t, file_contexts as file_context_t, seusers as selinux_config_t) and may have different protection requirements. Easiest approach is to just label the entire module store with a type that is at least as restrictive as the most restrictive type on any installed file. policy_config_t has typically been the most restrictive type (under strict policy), as the fewest number of programs need to read it and it contains the policy state. file contexts is more widely accessed, although it can still be viewed as potentially sensitive. I'm not sure that leaving seusers in selinux_config_t (the default due to directory inheritance at creation) is a good idea, as that could also be sensitive (identifying what users are authorized for admin roles).
Quoted 5 lines
Libsemanage has an interface for that kind of thing already - why can't that be used? I'm starting to get confused about the difference between all those libraries again. If libselinux is to be used on runtime, and libsemanage on persistent policy, then how do you explain the need for active booleans backend in libsemanage?
For management purposes, it makes sense. And in general, viewing and modifying booleans both seem like management functions rather than ordinary user functions.
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.
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
scripts/chcat +11 -7
@@ -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:
semanage/seobject.py +32 -10
72 lines not on this page · raw message
setsebool/setsebool.c +4 -3
@@ -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 ;
Quoted 3 lines
cut and paste errors in error messages in
seobject.py
Those were not cut and paste errors, they were intentional. The message corresponds to the semanage/tool function being used. The libsemanage function is always modify_local, so that would make all such error messages say "failed to modify" for all objects.
--
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 · Ivan Gyurdiev
Quoted 3 lines
cut and paste errors in error messages in
seobject.pyThose were not cut and paste errors, they were intentional. The message corresponds to the semanage/tool function being used. The libsemanage function is always
modify_local, so that would make all such error messages say "failed to modify" for all objects.
When a user tries to add and he gets a failed to modify error, he will suspect a problem. The writers of the code can figure out that they both call the same function.
Dan
--
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 10 lines · Daniel J Walsh
Quoted 9 lines · Ivan Gyurdiev
Quoted 3 lines
cut and paste errors in error messages in
seobject.pyThose were not cut and paste errors, they were intentional. The message corresponds to the semanage/tool function being used. The libsemanage function is always
modify_local, so that would make all such error messages say "failed to modify" for all objects.
Quoted 3 lines
When a user tries to add and he gets a failed to modify error, he will suspect a problem. The writers of the code can figure out that they both call the same function.
Not sure I follow; the patch changes some occurrences of "Failed to add port" to "Failed to modify port" in the add() method.
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 4 lines
Not sure I follow; the patch changes some occurrences of "Failed to add port" to "Failed to modify port" in the
add()method.
...which is wrong, imho, it should still say "Failed to add port".
The second part of it is right, I think (I assume it's changing modify(), hard to tell without the -p flag). There's a bug in modify that says "failed to add" currently.
I agree with what Dan is saying, I just think the first place he's changing is wrong.
There's another wrong message btw, see interfaces.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 10 lines · Ivan Gyurdiev
Quoted 4 lines
Not sure I follow; the patch changes some occurrences of "Failed to add port" to "Failed to modify port" in the
add()method....which is wrong, imho, it should still say "Failed to add port".
The second part of it is right, I think (I assume it's changingmodify(), hard to tell without the -p flag). There's a bug in modify that says "failed to add" currently.I agree with what Dan is saying, I just think the first place he's changing is wrong.
Yes the first part of the patch is wrong. The messsage under the add section should stay add. I was changing the "add" to "modify" under the modify section and got carried away...
Quoted 2 lines
There's another wrong message btw, see
interfaces.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 5 lines · Daniel J Walsh
Includes Ivan and Russells changes
Now checks to make sure run as root.
Also chcat can now manipulate categories of users as well as files.
Merged as of policycoreutils 1.29.8.
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.