Patch to semanage
Allows semanage to use equivalence.
Also adds better support for booleans and modules, add support for setting dontaudit rules.
semanage/semanage +50 -9
@@ -44,16 +44,17 @@ text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D} [-n] +semanage {module,boolean|login|user|port|interface|node|fcontext|translation} -{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range semanage interface -{a|d|m} [-tr] interface_spec semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask] addr -semanage fcontext -{a|d|m} [-frst] file_spec +semanage fcontext -{a|d|m} [-frst] [-e path ] file_spec semanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean | boolean_file -semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:
@@ -68,6 +69,7 @@ -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store to manage + --dontaudit Turn on or off dontaudit rules Object-specific Options (see above):
@@ -84,6 +86,7 @@ -F, --file Treat target as an input file for command, change multiple settings -p, --proto Port protocol (tcp or udp) or internet protocol version of node (ipv4 or ipv6) -M, --mask Netmask + -e, --equil Make target equil to this paths labeling -P, --prefix Prefix for home directory labeling -L, --level Default SELinux Level (MLS/MCS Systems only) -R, --roles SELinux Roles (ex: "sysadm_r staff_r")
@@ -115,11 +118,14 @@ valid_option["node"] = [] valid_option["node"] += valid_everyone + [ '-M', '--mask', '-t', '--type', '-r', '--range', '-p', '--protocol'] valid_option["fcontext"] = [] - valid_option["fcontext"] += valid_everyone + [ '-f', '--ftype', '-s', '--seuser', '-t', '--type', '-r', '--range'] + valid_option["fcontext"] += valid_everyone + [ '-e', '--equil', '-f', '--ftype', '-s', '--seuser', '-t', '--type', '-r', '--range'] valid_option["translation"] = [] valid_option["translation"] += valid_everyone + [ '-T', '--trans' ] valid_option["boolean"] = [] valid_option["boolean"] += valid_everyone + [ '--on', "--off", "-1", "-0", "-F", "--file"] + valid_option["module"] = [] + valid_option["module"] += [ '-a', '--add', '-d', '--delete', '-l', '--list', '-h', '--help', '-n', '--noheading', '--dontaudit'] + valid_option["permissive"] = [] valid_option["permissive"] += [ '-a', '--add', '-d', '--delete', '-l', '--list', '-h', '--help', '-n', '--noheading', '-D', '--deleteall' ] return valid_option
@@ -192,7 +198,10 @@ locallist = False use_file = False store = "" + equil="" + dontaudit = "" + object = argv[0] option_dict=get_options() if object not in option_dict.keys():
@@ -201,10 +210,12 @@ args = argv[1:] gopts, cmds = getopt.getopt(args, - '01adf:i:lhmnp:s:FCDR:L:r:t:T:P:S:M:', + '01ade:f:i:lhmnp:s:FCDR:L:r:t:T:P:S:M:', ['add', 'delete', 'deleteall', + 'dontaudit=', + 'equil=', 'ftype=', 'file', 'help',
@@ -241,16 +252,24 @@ if modify or add: raise ValueError(_("%s bad option") % o) delete = True + if o == "-D" or o == "--deleteall": if modify: raise ValueError(_("%s bad option") % o) deleteall = True + if o == "-f" or o == "--ftype": - ftype=a + ftype = a + + if o == "-e" or o == "--equil": + equil = a if o == "-F" or o == "--file": use_file = True + if o == "--dontaudit": + dontaudit = not int(a) + if o == "-h" or o == "--help": raise ValueError(_("%s bad option") % o)
@@ -323,6 +342,9 @@ if object == "boolean": OBJECT = seobject.booleanRecords(store) + + if object == "module": + OBJECT = seobject.moduleRecords(store) if object == "translation": OBJECT = seobject.setransRecords()
@@ -341,6 +363,13 @@ OBJECT.deleteall() return + if dontaudit != "": + if object == "module": + OBJECT.dontaudit(dontaudit) + else: + raise ValueError(_("%s bad option") % o) + return + if len(cmds) != 1: raise ValueError(_("%s bad option") % o)
@@ -362,11 +391,17 @@ if object == "interface": OBJECT.add(target, serange, setype) + if object == "module": + OBJECT.add(target) + if object == "node": OBJECT.add(target, mask, proto, serange, setype) if object == "fcontext": - OBJECT.add(target, setype, ftype, serange, seuser) + if equil == "": + OBJECT.add(target, setype, ftype, serange, seuser) + else: + OBJECT.add_equil(target, equil) if object == "permissive": OBJECT.add(target)
@@ -386,6 +421,9 @@ rlist = roles.split() OBJECT.modify(target, rlist, selevel, serange, prefix) + if object == "module": + OBJECT.modify(target) + if object == "port": OBJECT.modify(target, proto, serange, setype)
@@ -396,7 +434,10 @@ OBJECT.modify(target, mask, proto, serange, setype) if object == "fcontext": - OBJECT.modify(target, setype, ftype, serange, seuser) + if equil == "": + OBJECT.modify(target, setype, ftype, serange, seuser) + else: + OBJECT.modify_equil(target, equil) return
@@ -405,7 +446,7 @@ OBJECT.delete(target, proto) elif object == "fcontext": - OBJECT.delete(target, ftype) + OBJECT.delete(target, ftype) elif object == "node": OBJECT.delete(target, mask, proto)
Quoted 19 lines · Daniel J Walsh
Allows semanage to use equivalence.
Also adds better support for booleans and modules, add support for setting dontaudit rules.
--- nsapolicycoreutils/semanage/semanage 2009-05-18 13:53:14.000000000
-0400
+++ policycoreutils-2.0.67/semanage/semanage 2009-07-07 16:47:35.000000000
-0400semanage/semanage +0
-1@@ -44,16 +44,17 @@ text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
semanage/semanage +1
-1+semanage {module,boolean|login|user|port|interface|node|fcontext|translation} -{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name
semanage/semanage line 57
Quoted 10 lines
semanage/semanage +3
-2semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range semanage interface -{a|d|m} [-tr] interface_spec semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask] addr -semanage fcontext -{a|d|m} [-frst] file_spec +semanage fcontext -{a|d|m} [-frst] [-e path ] file_spec semanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean | boolean_file -semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module
So, you're adding module support to semanage, duplicating what semodule already does? Are you proposing that we deprecate semodule or is there a reason we need duplicate functionality? Or am I missing something?
Quoted 15 lines
Primary Options:
semanage/semanage +1
-0@@ -68,6 +69,7 @@ -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store to manage + --dontaudit Turn on or off dontaudit rules Object-specific Options (see above):@@ -84,6 +86,7 @@ -F, --file Treat target as an input file for command, changemultiple settings
-p, --proto Port protocol (tcp or udp) or internet protocol version
of node (ipv4 or ipv6)
Quoted 2 lines
-M, --mask Netmask+ -e, --equil Make target equil to this paths labeling
Did you mean for this to be "equal" instead of "equil?" Perhaps I'm missing something, but dictionary.com turned up no results for equil. That said, I like the idea as this seems to be a nice convenience feature.
<snip>
semanage/semanage line 348
Quoted 8 lines
semanage/semanage +3
-0@@ -323,6 +342,9 @@ if object == "boolean": OBJECT = seobject.booleanRecords(store) + + if object == "module": + OBJECT = seobject.moduleRecords(store)
The moduleRecords() method does not seem to exist anywhere that I can find it. I'm guessing there is a corresponding patch to seobject.py?
Quoted 23 lines
semanage/semanage +10
-0if object == "translation": OBJECT = seobject.setransRecords()@@ -341,6 +363,13 @@ OBJECT.deleteall() return + if dontaudit != "": + if object == "module": + OBJECT.dontaudit(dontaudit) + else: + raise ValueError(_("%s bad option") % o) + return + if len(cmds) != 1: raise ValueError(_("%s bad option") % o)@@ -362,11 +391,17 @@ if object == "interface": OBJECT.add(target, serange, setype) + if object == "module": + OBJECT.add(target) +
semanage/semanage line 405
Quoted 10 lines
semanage/semanage +4
-1if object == "node": OBJECT.add(target, mask, proto, serange, setype) if object == "fcontext": - OBJECT.add(target, setype, ftype, serange, seuser) + if equil == "": + OBJECT.add(target, setype, ftype, serange, seuser) + else: + OBJECT.add_equil(target, equil)
The add_equil() method does not seem to exist either. I'm guessing there are more missing methods as well.
Thanks,
Chad
--
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 lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command.
Eventually replace semodule/setsebool with semanage command.
Some white space fixing in seobject.py
semanage/semanage +50 -9
@@ -44,16 +44,17 @@ text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D} [-n] +semanage {module,boolean|login|user|port|interface|node|fcontext|translation} -{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range semanage interface -{a|d|m} [-tr] interface_spec semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask] addr -semanage fcontext -{a|d|m} [-frst] file_spec +semanage fcontext -{a|d|m} [-frst] [-e path ] file_spec semanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean | boolean_file -semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:
@@ -68,6 +69,7 @@ -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store to manage + --dontaudit Turn on or off dontaudit rules Object-specific Options (see above):
@@ -84,6 +86,7 @@ -F, --file Treat target as an input file for command, change multiple settings -p, --proto Port protocol (tcp or udp) or internet protocol version of node (ipv4 or ipv6) -M, --mask Netmask + -e, --equal Make target equal to this paths labeling -P, --prefix Prefix for home directory labeling -L, --level Default SELinux Level (MLS/MCS Systems only) -R, --roles SELinux Roles (ex: "sysadm_r staff_r")
@@ -115,11 +118,14 @@ valid_option["node"] = [] valid_option["node"] += valid_everyone + [ '-M', '--mask', '-t', '--type', '-r', '--range', '-p', '--protocol'] valid_option["fcontext"] = [] - valid_option["fcontext"] += valid_everyone + [ '-f', '--ftype', '-s', '--seuser', '-t', '--type', '-r', '--range'] + valid_option["fcontext"] += valid_everyone + [ '-e', '--equal', '-f', '--ftype', '-s', '--seuser', '-t', '--type', '-r', '--range'] valid_option["translation"] = [] valid_option["translation"] += valid_everyone + [ '-T', '--trans' ] valid_option["boolean"] = [] valid_option["boolean"] += valid_everyone + [ '--on', "--off", "-1", "-0", "-F", "--file"] + valid_option["module"] = [] + valid_option["module"] += [ '-a', '--add', '-d', '--delete', '-l', '--list', '-h', '--help', '-n', '--noheading', '--dontaudit'] + valid_option["permissive"] = [] valid_option["permissive"] += [ '-a', '--add', '-d', '--delete', '-l', '--list', '-h', '--help', '-n', '--noheading', '-D', '--deleteall' ] return valid_option
@@ -192,7 +198,10 @@ locallist = False use_file = False store = "" + equal="" + dontaudit = "" + object = argv[0] option_dict=get_options() if object not in option_dict.keys():
@@ -201,10 +210,12 @@ args = argv[1:] gopts, cmds = getopt.getopt(args, - '01adf:i:lhmnp:s:FCDR:L:r:t:T:P:S:M:', + '01ade:f:i:lhmnp:s:FCDR:L:r:t:T:P:S:M:', ['add', 'delete', 'deleteall', + 'dontaudit=', + 'equal=', 'ftype=', 'file', 'help',
@@ -241,16 +252,24 @@ if modify or add: raise ValueError(_("%s bad option") % o) delete = True + if o == "-D" or o == "--deleteall": if modify: raise ValueError(_("%s bad option") % o) deleteall = True + if o == "-f" or o == "--ftype": - ftype=a + ftype = a + + if o == "-e" or o == "--equal": + equal = a if o == "-F" or o == "--file": use_file = True + if o == "--dontaudit": + dontaudit = not int(a) + if o == "-h" or o == "--help": raise ValueError(_("%s bad option") % o)
@@ -323,6 +342,9 @@ if object == "boolean": OBJECT = seobject.booleanRecords(store) + + if object == "module": + OBJECT = seobject.moduleRecords(store) if object == "translation": OBJECT = seobject.setransRecords()
@@ -341,6 +363,13 @@ OBJECT.deleteall() return + if dontaudit != "": + if object == "module": + OBJECT.dontaudit(dontaudit) + else: + raise ValueError(_("%s bad option") % o) + return + if len(cmds) != 1: raise ValueError(_("%s bad option") % o)
@@ -362,11 +391,17 @@ if object == "interface": OBJECT.add(target, serange, setype) + if object == "module": + OBJECT.add(target) + if object == "node": OBJECT.add(target, mask, proto, serange, setype) if object == "fcontext": - OBJECT.add(target, setype, ftype, serange, seuser) + if equal == "": + OBJECT.add(target, setype, ftype, serange, seuser) + else: + OBJECT.add_equal(target, equal) if object == "permissive": OBJECT.add(target)
@@ -386,6 +421,9 @@ rlist = roles.split() OBJECT.modify(target, rlist, selevel, serange, prefix) + if object == "module": + OBJECT.modify(target) + if object == "port": OBJECT.modify(target, proto, serange, setype)
@@ -396,7 +434,10 @@ OBJECT.modify(target, mask, proto, serange, setype) if object == "fcontext": - OBJECT.modify(target, setype, ftype, serange, seuser) + if equal == "": + OBJECT.modify(target, setype, ftype, serange, seuser) + else: + OBJECT.modify_equal(target, equal) return
@@ -405,7 +446,7 @@ OBJECT.delete(target, proto) elif object == "fcontext": - OBJECT.delete(target, ftype) + OBJECT.delete(target, ftype) elif object == "node": OBJECT.delete(target, mask, proto)
semanage/semanage.8 +2 -0
@@ -21,6 +21,8 @@ .br .B semanage permissive \-{a|d} type .br +.B semanage module \-{a|d} policy_package +.br .B semanage translation \-{a|d|m} [\-T] level .P
semanage/seobject.py +191 -92
733 lines not on this page · raw message
Quoted 6 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command. Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.py
I'm looking at this patch now. There are a couple of changes that I believe are not part of the rest, but I wonder if you could verify this (and maybe tell me why they're here).
Quoted 15 lines
policycoreutils/semanage/seobject.py +1
-1@@ -21,7 +21,7 @@ # # -import pwd, grp, string, selinux, tempfile, os, re, sys +import pwd, grp, string, selinux, tempfile, os, re, sys, stat from semanage import *; PROGNAME = "policycoreutils" import sepolgen.module as module
policycoreutils/semanage/seobject.py class setransRecords: · line 279
Quoted 7 lines
policycoreutils/semanage/seobject.py +1
-0@@ -273,6 +273,7 @@ class setransRecords: (fd, newfilename) = tempfile.mkstemp('', self.filename) os.write(fd, self.out()) os.close(fd) + os.chmod(newfilename, os.stat(self.filename)[stat.ST_MODE]) os.rename(newfilename, self.filename) os.system("/sbin/service mcstrans reload > /dev/null")
I'm guessing there was some problem with the permissions on setrans files?
policycoreutils/semanage/seobject.py class portRecords(semanageRecords): · line 1033
Quoted 9 lines
policycoreutils/semanage/seobject.py +1
-1@@ -983,7 +1027,7 @@ class portRecords(semanageRecords): proto_str = semanage_port_get_proto_str(proto) low = semanage_port_get_low(port) high = semanage_port_get_high(port) - ddict[(low, high)] = (ctype, proto_str, level) + ddict[(low, high, proto_str)] = (ctype, level) return ddict def get_all_by_type(self, locallist = 0):
Was this just plain wrong before? I'm not familiar with this. Was there not a user before (and presumably there is one now)?
Everything else seems to fall into one of your 3 categories above.
Thanks,
Chad
--
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 22 lines · Chad Sellers
Quoted 6 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command. Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyI'm looking at this patch now. There are a couple of changes that I believe are not part of the rest, but I wonder if you could verify this (and maybe tell me why they're here).
Quoted 9 lines
policycoreutils/semanage/seobject.py +0
-0@@ -21,7 +21,7 @@ # #
Quoted 14 lines
policycoreutils/semanage/seobject.py class setransRecords: · line 279
Quoted 13 lines
policycoreutils/semanage/seobject.py +2
-1-import pwd, grp, string, selinux, tempfile, os, re, sys +import pwd, grp, string, selinux, tempfile, os, re, sys, stat from semanage import *; PROGNAME = "policycoreutils" import sepolgen.module as module@@ -273,6 +273,7 @@ class setransRecords: (fd, newfilename) = tempfile.mkstemp('', self.filename) os.write(fd, self.out()) os.close(fd) + os.chmod(newfilename, os.stat(self.filename)[stat.ST_MODE]) os.rename(newfilename, self.filename) os.system("/sbin/service mcstrans reload > /dev/null")I'm guessing there was some problem with the permissions on setrans files?
Well the tool was not maintainng the permissions, But I believe we should just remove all handling of setrans records, since this stuff will not work with the latest code. semanage should no longer manage the translatetions.
Quoted 14 lines
policycoreutils/semanage/seobject.py class portRecords(semanageRecords): · line 1033
Quoted 10 lines
policycoreutils/semanage/seobject.py +1
-1@@ -983,7 +1027,7 @@ class portRecords(semanageRecords): proto_str = semanage_port_get_proto_str(proto) low = semanage_port_get_low(port) high = semanage_port_get_high(port) - ddict[(low, high)] = (ctype, proto_str, level) + ddict[(low, high, proto_str)] = (ctype, level) return ddict def get_all_by_type(self, locallist = 0):Was this just plain wrong before? I'm not familiar with this. Was there not a user before (and presumably there is one now)?
Quoted 5 lines
Everything else seems to fall into one of your 3 categories above.
Thanks,
Chad
Yes this was a bug.
--
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 · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command. Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.py
I've split this patch into the 3 separate patches (whitespace, equal, modules) for review purposes, as it was too difficult to get through with the 3 different patches interspersed. Please try to split up functional patches in the future.
This message will apply to the equal patch only.
Quoted 26 lines
policycoreutils/semanage/seobject.py +17
-0@@ -1408,6 +1408,48 @@ class interfaceRecords(semanageRecords): class fcontextRecords(semanageRecords): def __init__(self, store = ""): semanageRecords.__init__(self, store) + self.equiv = {} + self.equal_ind = False + try: + fd = open(selinux.selinux_file_context_subs_path(), "r") + for i in fd.readlines(): + src, dst = i.split() + self.equiv[src] = dst + fd.close() + except IOError: + pass + + def commit(self): + if self.equal_ind: + subs_file = selinux.selinux_file_context_subs_path() + tmpfile = "%s.tmp" % subs_file + fd = open(tmpfile, "w") + for src in self.equiv.keys():
policycoreutils/semanage/seobject.py class interfaceRecords(semanageRecords): · line 1437
Quoted 10 lines
policycoreutils/semanage/seobject.py +10
-0+ fd.write("%s %s\n" % (src, self.equiv[src])) + fd.close() + try: + os.chmod(tmpfile, os.stat(subs_file)[stat.ST_MODE]) + except: + pass + os.rename(tmpfile,subs_file) + self.equal_ind = False + semanageRecords.commit(self) +
Using subs in this manner has interesting side-effects, as all subs does is string substitution before looking up the context. This can result in weirdness when the string is passed to the regex matcher, such as:
1. Regular files will not match directory entries (/foo is a regular file):
[root@f10 selinux]# semanage fcontext -a -e /usr /foo
[root@f10 selinux]# restorecon -nv /foo
restorecon reset /foo context unconfined_u:object_r:user_home_t:s0->system_u:object_r:etc_runtime_t:s0
2. Regular expression matching can cause matches to depend on whether a / is appended:
[root@f10 selinux]# semanage fcontext -a -e /usr/ /foo
[root@f10 selinux]# restorecon -nv /foo
restorecon reset /foo context unconfined_u:object_r:user_home_t:s0->system_u:object_r:usr_t:s0
<snip>
Unfortunately, I don't see an easy fix to these problems. We could augment the subs functionality to allow the user to specify the kind of file they want to match, but that would just make things more complex in trying to work around the problem. Or, we could just decide to live with the peculiarities (and at least document them for people who get confused).
Thanks,
Chad
--
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 · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command. Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.py
As I said previously, I've split this patch into the 3 separate patches (whitespace, equal, modules) for review purposes, as it was too difficult to get through with the 3 different patches interspersed. Please try to split up functional patches in the future.
This message will apply to the modules patch only.
Quoted 28 lines
policycoreutils/semanage/semanage +0
-1@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
policycoreutils/semanage/semanage +1
-1+semanage {module,boolean|login|user|port|interface|node|fcontext|translation} -{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask]addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level
semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:
policycoreutils/semanage/semanage Primary Options: · line 73
Quoted 5 lines
policycoreutils/semanage/semanage +1
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store to manage + --dontaudit Turn on or off dontaudit rules
Need to specify that this takes an integer argument (1 or 0) here. Also, need to specify which command this is valid for, which appears to be the module command. Why is this an option for the module command? It doesn't seem to have anything to do with a particular module. Should this just be its own command?
Quoted 132 lines
policycoreutils/semanage/semanage +0
-0Object-specific Options (see above):@@ -121,6 +123,8 @@ Object-specific Options (see above): valid_option["translation"] += valid_everyone + [ '-T', '--trans' ] valid_option["boolean"] = [] valid_option["boolean"] += valid_everyone + [ '--on', "--off", "-1","-0", "-F", "--file"]
policycoreutils/semanage/semanage +2
-0+ valid_option["module"] = [] + valid_option["module"] += [ '-a', '--add', '-d', '--delete', '-l','--list', '-h', '--help', '-n', '--noheading', '--dontaudit']
valid_option["permissive"] = [] valid_option["permissive"] += [ '-a', '--add', '-d', '--delete','-l', '--list', '-h', '--help', '-n', '--noheading', '-D', '--deleteall' ]
returnvalid_optionpolicycoreutils/semanage/semanage +21
-0@@ -194,6 +198,7 @@ Object-specific Options (see above): use_file = False store = "" equal = "" + dontaudit = "" object = argv[0] option_dict=get_options()@@ -207,6 +212,7 @@ Object-specific Options (see above): ['add', 'delete', 'deleteall', + 'dontaudit=', 'equal=', 'ftype=', 'file',@@ -259,6 +265,9 @@ Object-specific Options (see above): if o == "-F" or o == "--file": use_file = True + if o == "--dontaudit": + dontaudit = not int(a) + if o == "-h" or o == "--help": raise ValueError(_("%s bad option") % o)@@ -331,6 +340,9 @@ Object-specific Options (see above): if object == "boolean": OBJECT = seobject.booleanRecords(store) + + if object == "module": + OBJECT = seobject.moduleRecords(store) if object == "translation": OBJECT = seobject.setransRecords()@@ -349,6 +361,13 @@ Object-specific Options (see above): OBJECT.deleteall() return + if dontaudit != "": + if object == "module": + OBJECT.dontaudit(dontaudit) + else: + raise ValueError(_("%s bad option") % o) + return + if len(cmds) != 1: raise ValueError(_("%s bad option") % o)@@ -370,6 +389,9 @@ Object-specific Options (see above): if object == "interface": OBJECT.add(target, serange, setype) + if object == "module": + OBJECT.add(target) + if object == "node": OBJECT.add(target, mask, proto, serange, setype)@@ -397,6 +419,9 @@ Object-specific Options (see above): rlist = roles.split() OBJECT.modify(target, rlist, selevel, serange, prefix) + if object == "module": + OBJECT.modify(target) + if object == "port": OBJECT.modify(target, proto, serange, setype)policycoreutils/semanage/semanage.8 +2
-0@@ -21,6 +21,8 @@ semanage \- SELinux Policy Management tool .br .B semanage permissive \-{a|d} type .br +.B semanage module \-{a|d} policy_package +.br .B semanage translation \-{a|d|m} [\-T] level .Ppolicycoreutils/semanage/seobject.py +25
-0@@ -314,6 +314,49 @@ class semanageRecords: self.transaction = False self.commit() +class moduleRecords(semanageRecords): + def __init__(self, store): + semanageRecords.__init__(self, store) + + def get_all(self): + l = [] + (rc, mlist, number) = semanage_module_list(self.sh) + if rc < 0: + raise ValueError(_("Could not list SELinux modules")) + + for i in range(number): + mod = semanage_module_list_nth(mlist, i) + name = semanage_module_get_name(mod) + l.append(name) + return l + + def dontaudit(self, dontaudit = 0): + self.begin() + rc = semanage_set_disable_dontaudit(self.sh, dontaudit) + self.commit() + rc = semanage_reload_policy(self.sh) + + def list(self, heading = 1, locallist = 0): + if heading: + print "\n%-25s\n" % (_("Modules"))
policycoreutils/semanage/seobject.py class semanageRecords: · line 351
Quoted 10 lines
policycoreutils/semanage/seobject.py +10
-0+ for t in self.get_all(): + print t + + def add(self, modules): + import glob + for m in modules.split(): + rc = semanage_module_install_file(self.sh, m); + if rc >= 0: + self.commit() +
Why import glob here? It doesn't look like you use it.
Quoted 11 lines
policycoreutils/semanage/seobject.py +8
-0+ def delete(self, modules): + for m in modules.split(): + rc = semanage_module_remove(self.sh, m) + if rc < 0: + raise ValueError(_("Could not remove module %s (remove failed)") % name) + + self.commit() + class permissiveRecords(semanageRecords): def __init__(self, store):
Quoted 1 line
semanageRecords.__init__(self, store)
Other than that, I have no problem with the code in the patch. The bigger problem with this is that it's still incomplete at this point. There's still no support for:
- base modules
- build (without changing anything)
- reload (without changing anything)
- module version number in listing
- install/upgrade distinction (though I'm perfectly fine with ditching this)
I'm not comfortable merging this before at least base modules are supported. Having an additional tool that doesn't meet the basic requirements for users will just lead to confusion.
Thanks,
Chad
--
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 43 lines · Chad Sellers
Quoted 6 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command. Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyAs I said previously, I've split this patch into the 3 separate patches (whitespace, equal, modules) for review purposes, as it was too difficult to get through with the 3 different patches interspersed. Please try to split up functional patches in the future.
This message will apply to the modules patch only.
Quoted 27 lines
policycoreutils/semanage/semanage +0
-1@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
policycoreutils/semanage/semanage +1
-1+semanage {module,boolean|login|user|port|interface|node|fcontext|translation} -{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask]addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level
semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:
Quoted 12 lines
policycoreutils/semanage/semanage Primary Options: · line 73
Quoted 6 lines
policycoreutils/semanage/semanage +1
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store to manage + --dontaudit Turn on or off dontaudit rulesNeed to specify that this takes an integer argument (1 or 0) here. Also, need to specify which command this is valid for, which appears to be the module command. Why is this an option for the module command? It doesn't seem to have anything to do with a particular module. Should this just be its own command?
I think it should be just for the modules command.
Quoted 175 lines
Quoted 132 lines
policycoreutils/semanage/semanage +0
-0Object-specific Options (see above):@@ -121,6 +123,8 @@ Object-specific Options (see above): valid_option["translation"] += valid_everyone + [ '-T', '--trans' ] valid_option["boolean"] = [] valid_option["boolean"] += valid_everyone + [ '--on', "--off", "-1","-0", "-F", "--file"]
policycoreutils/semanage/semanage +2
-0+ valid_option["module"] = [] + valid_option["module"] += [ '-a', '--add', '-d', '--delete', '-l','--list', '-h', '--help', '-n', '--noheading', '--dontaudit']
valid_option["permissive"] = [] valid_option["permissive"] += [ '-a', '--add', '-d', '--delete','-l', '--list', '-h', '--help', '-n', '--noheading', '-D', '--deleteall' ]
returnvalid_optionpolicycoreutils/semanage/semanage +21
-0@@ -194,6 +198,7 @@ Object-specific Options (see above): use_file = False store = "" equal = "" + dontaudit = "" object = argv[0] option_dict=get_options()@@ -207,6 +212,7 @@ Object-specific Options (see above): ['add', 'delete', 'deleteall', + 'dontaudit=', 'equal=', 'ftype=', 'file',@@ -259,6 +265,9 @@ Object-specific Options (see above): if o == "-F" or o == "--file": use_file = True + if o == "--dontaudit": + dontaudit = not int(a) + if o == "-h" or o == "--help": raise ValueError(_("%s bad option") % o)@@ -331,6 +340,9 @@ Object-specific Options (see above): if object == "boolean": OBJECT = seobject.booleanRecords(store) + + if object == "module": + OBJECT = seobject.moduleRecords(store) if object == "translation": OBJECT = seobject.setransRecords()@@ -349,6 +361,13 @@ Object-specific Options (see above): OBJECT.deleteall() return + if dontaudit != "": + if object == "module": + OBJECT.dontaudit(dontaudit) + else: + raise ValueError(_("%s bad option") % o) + return + if len(cmds) != 1: raise ValueError(_("%s bad option") % o)@@ -370,6 +389,9 @@ Object-specific Options (see above): if object == "interface": OBJECT.add(target, serange, setype) + if object == "module": + OBJECT.add(target) + if object == "node": OBJECT.add(target, mask, proto, serange, setype)@@ -397,6 +419,9 @@ Object-specific Options (see above): rlist = roles.split() OBJECT.modify(target, rlist, selevel, serange, prefix) + if object == "module": + OBJECT.modify(target) + if object == "port": OBJECT.modify(target, proto, serange, setype)policycoreutils/semanage/semanage.8 +2
-0@@ -21,6 +21,8 @@ semanage \- SELinux Policy Management tool .br .B semanage permissive \-{a|d} type .br +.B semanage module \-{a|d} policy_package +.br .B semanage translation \-{a|d|m} [\-T] level .Ppolicycoreutils/semanage/seobject.py +25
-0@@ -314,6 +314,49 @@ class semanageRecords: self.transaction = False self.commit() +class moduleRecords(semanageRecords): + def __init__(self, store): + semanageRecords.__init__(self, store) + + def get_all(self): + l = [] + (rc, mlist, number) = semanage_module_list(self.sh) + if rc < 0: + raise ValueError(_("Could not list SELinux modules")) + + for i in range(number): + mod = semanage_module_list_nth(mlist, i) + name = semanage_module_get_name(mod) + l.append(name) + return l + + def dontaudit(self, dontaudit = 0): + self.begin() + rc = semanage_set_disable_dontaudit(self.sh, dontaudit) + self.commit() + rc = semanage_reload_policy(self.sh) + + def list(self, heading = 1, locallist = 0): + if heading: + print "\n%-25s\n" % (_("Modules"))policycoreutils/semanage/seobject.py class semanageRecords: · line 351
Quoted 10 lines
policycoreutils/semanage/seobject.py +10
-0+ for t in self.get_all(): + print t + + def add(self, modules): + import glob + for m in modules.split(): + rc = semanage_module_install_file(self.sh, m); + if rc >= 0: + self.commit() +Why import glob here? It doesn't look like you use it.
Quoted 11 lines
policycoreutils/semanage/seobject.py +8
-0+ def delete(self, modules): + for m in modules.split(): + rc = semanage_module_remove(self.sh, m) + if rc < 0: + raise ValueError(_("Could not remove module %s (remove failed)") % name) + + self.commit() + class permissiveRecords(semanageRecords): def __init__(self, store):Quoted 1 line
semanageRecords.__init__(self, store)Other than that, I have no problem with the code in the patch. The bigger problem with this is that it's still incomplete at this point. There's still no support for:
- base modules
- build (without changing anything)
- reload (without changing anything)
- module version number in listing
- install/upgrade distinction (though I'm perfectly fine with ditching this)I'm not comfortable merging this before at least base modules are supported. Having an additional tool that doesn't meet the basic requirements for users will just lead to confusion.
Thanks,
Chad
Quoted 6 lines
--
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.
Yes dontaudit should only be for the modules command.
--
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 58 lines · Daniel J Walsh
Quoted 45 lines · Chad Sellers
Quoted 6 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command. Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyAs I said previously, I've split this patch into the 3 separate patches (whitespace, equal, modules) for review purposes, as it was too difficult to get through with the 3 different patches interspersed. Please try to split up functional patches in the future.
This message will apply to the modules patch only.
Quoted 29 lines
policycoreutils/semanage/semanage +0
-2@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
+semanage {module,boolean|login|user|port|interface|node|fcontext|translation}policycoreutils/semanage/semanage +0
-1-{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask]addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level
semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:Quoted 12 lines
policycoreutils/semanage/semanage Primary Options: · line 73
Quoted 6 lines
policycoreutils/semanage/semanage +1
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store to manage + --dontaudit Turn on or off dontaudit rulesNeed to specify that this takes an integer argument (1 or 0) here. Also, need to specify which command this is valid for, which appears to be the module command. Why is this an option for the module command? It doesn't seem to have anything to do with a particular module. Should this just be its own command?
Quoted 1 line
I think it should be just for the modules command.
Care to explain why? As your usage above shows, the module command is for adding or deleting modules. This functionality has nothing to do with that. --dontaudit is for specifying globally that dontaudit's should be turned on/off. It's not an option that modifies the behavior of adding or deleting a module, it's a completely separate thing.
Thanks,
Chad
--
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 60 lines · Chad Sellers
Quoted 58 lines · Daniel J Walsh
Quoted 57 lines · Chad Sellers
Quoted 6 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command. Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyAs I said previously, I've split this patch into the 3 separate patches (whitespace, equal, modules) for review purposes, as it was too difficult to get through with the 3 different patches interspersed. Please try to split up functional patches in the future.
This message will apply to the modules patch only.
Quoted 30 lines
policycoreutils/semanage/semanage +0
-2@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
+semanage {module,boolean|login|user|port|interface|node|fcontext|translation}policycoreutils/semanage/semanage +0
-1-{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask]addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level
semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:policycoreutils/semanage/semanage Primary Options: · line 73
Quoted 5 lines
policycoreutils/semanage/semanage +1
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store to manage + --dontaudit Turn on or off dontaudit rulesNeed to specify that this takes an integer argument (1 or 0) here. Also, need to specify which command this is valid for, which appears to be the module command. Why is this an option for the module command? It doesn't seem to have anything to do with a particular module. Should this just be its own command?
Quoted 8 lines
Quoted 1 line
I think it should be just for the modules command.
Care to explain why? As your usage above shows, the module command is for adding or deleting modules. This functionality has nothing to do with that. --dontaudit is for specifying globally that dontaudit's should be turned on/off. It's not an option that modifies the behavior of adding or deleting a module, it's a completely separate thing.
No I don't care to explain why, now that you shot down my idea. :^)
I guess it should be a separate command
What do you think of.
semanage dontaudit -a
semanage dontaudit -d
Quoted 10 lines
Thanks,
Chad--
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.
--
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 67 lines · Daniel J Walsh
Quoted 59 lines · Chad Sellers
Quoted 57 lines · Daniel J Walsh
Quoted 56 lines · Chad Sellers
Quoted 6 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command. Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyAs I said previously, I've split this patch into the 3 separate patches (whitespace, equal, modules) for review purposes, as it was too difficult to get through with the 3 different patches interspersed. Please try to split up functional patches in the future.
This message will apply to the modules patch only.
Quoted 30 lines
policycoreutils/semanage/semanage +0
-2@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
+semanage {module,boolean|login|user|port|interface|node|fcontext|translation}policycoreutils/semanage/semanage +0
-1-{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask]addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level
semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:policycoreutils/semanage/semanage Primary Options: · line 73
Quoted 5 lines
policycoreutils/semanage/semanage +1
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store to manage + --dontaudit Turn on or off dontaudit rulesNeed to specify that this takes an integer argument (1 or 0) here. Also, need to specify which command this is valid for, which appears to be the module command. Why is this an option for the module command? It doesn't seem to have anything to do with a particular module. Should this just be its own command?
Quoted 7 lines
Quoted 1 line
I think it should be just for the modules command.
Care to explain why? As your usage above shows, the module command is for adding or deleting modules. This functionality has nothing to do with that. --dontaudit is for specifying globally that dontaudit's should be turned on/off. It's not an option that modifies the behavior of adding or deleting a module, it's a completely separate thing.
Quoted 9 lines
No I don't care to explain why, now that you shot down my idea. :^)
I guess it should be a separate command
What do you think of.
semanage dontaudit -a
semanage dontaudit -d
I like it being a separate command since it really is a global thing but the syntax above seems very confusing. Can we depart from the add/remove paradigm for this one and use something more appropriate, like on/off, enable/disable, audit/dontaudit, or something similar?
--
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 89 lines · Joshua Brindle
Quoted 88 lines · Daniel J Walsh
Quoted 72 lines · Chad Sellers
Quoted 69 lines · Daniel J Walsh
Quoted 51 lines · Chad Sellers
Quoted 7 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command.
Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyAs I said previously, I've split this patch into the 3 separate patches
(whitespace, equal, modules) for review purposes, as it was too difficult to
get through with the 3 different patches interspersed. Please try to split
up functional patches in the future.This message will apply to the modules patch only.
Quoted 32 lines
policycoreutils/semanage/semanage +0
-2@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
+semanage {module,boolean|login|user|port|interface|node|fcontext|translation}policycoreutils/semanage/semanage +0
-1-{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-Mnetmask]
addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:Quoted 17 lines
Quoted 7 lines
policycoreutils/semanage/semanage +0
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store tomanage
+ --dontaudit Turn on or off dontaudit rulesNeed to specify that this takes an integer argument (1 or 0) here. Also,
need to specify which command this is valid for, which appears to be the
module command. Why is this an option for the module command? It doesn't
seem to have anything to do with a particular module. Should this just be
its own command?Quoted 1 line
I think it should be just for the modules command.
Quoted 9 lines
Care to explain why? As your usage above shows, the module command is for
adding or deleting modules. This functionality has nothing to do with that.
--dontaudit is for specifying globally that dontaudit's should be turned on/off. It's not an option that modifies the behavior of adding or deleting
a module, it's a completely separate thing.No I don't care to explain why, now that you shot down my idea. :^)
I guess it should be a separate command
What do you think of.
Quoted 17 lines
Quoted 3 lines
semanage dontaudit -a
semanage dontaudit -dI like it being a separate command since it really is a global thing but the syntax above seems very confusing. Can we depart from the add/remove paradigm for this one and use something more appropriate, like on/off, enable/disable, audit/dontaudit, or something similar?
Signature · 4 lines
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.
semanage dontaudit on
semanage dontaudit off
--
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 108 lines · Daniel J Walsh
Quoted 89 lines · Joshua Brindle
Quoted 88 lines · Daniel J Walsh
Quoted 72 lines · Chad Sellers
Quoted 69 lines · Daniel J Walsh
Quoted 51 lines · Chad Sellers
Quoted 7 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command.
Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyAs I said previously, I've split this patch into the 3 separate patches
(whitespace, equal, modules) for review purposes, as it was too difficult to
get through with the 3 different patches interspersed. Please try to split
up functional patches in the future.This message will apply to the modules patch only.
Quoted 32 lines
policycoreutils/semanage/semanage +0
-2@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
+semanage {module,boolean|login|user|port|interface|node|fcontext|translation}policycoreutils/semanage/semanage +0
-1-{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-Mnetmask]
addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:Quoted 17 lines
Quoted 7 lines
policycoreutils/semanage/semanage +0
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store tomanage
+ --dontaudit Turn on or off dontaudit rulesNeed to specify that this takes an integer argument (1 or 0) here. Also,
need to specify which command this is valid for, which appears to be the
module command. Why is this an option for the module command? It doesn't
seem to have anything to do with a particular module. Should this just be
its own command?Quoted 1 line
I think it should be just for the modules command.
Quoted 9 lines
Care to explain why? As your usage above shows, the module command is for
adding or deleting modules. This functionality has nothing to do with that.
--dontaudit is for specifying globally that dontaudit's should be turned on/off. It's not an option that modifies the behavior of adding or deleting
a module, it's a completely separate thing.No I don't care to explain why, now that you shot down my idea. :^)
I guess it should be a separate command
What do you think of.
Quoted 17 lines
Quoted 3 lines
semanage dontaudit -a
semanage dontaudit -dI like it being a separate command since it really is a global thing but the syntax above seems very confusing. Can we depart from the add/remove paradigm for this one and use something more appropriate, like on/off, enable/disable, audit/dontaudit, or something similar?
Signature · 4 lines
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 2 lines
semanage dontaudit on
semanage dontaudit off
Sounds great to me.
Chad
--
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 110 lines · Chad Sellers
Quoted 108 lines · Daniel J Walsh
Quoted 106 lines · Joshua Brindle
Quoted 82 lines · Daniel J Walsh
Quoted 72 lines · Chad Sellers
Quoted 69 lines · Daniel J Walsh
Quoted 51 lines · Chad Sellers
Quoted 7 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command.
Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyAs I said previously, I've split this patch into the 3 separate patches
(whitespace, equal, modules) for review purposes, as it was too difficult to
get through with the 3 different patches interspersed. Please try to split
up functional patches in the future.This message will apply to the modules patch only.
Quoted 32 lines
policycoreutils/semanage/semanage +0
-2@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
+semanage {module,boolean|login|user|port|interface|node|fcontext|translation}policycoreutils/semanage/semanage +0
-1-{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-Mnetmask]
addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:Quoted 17 lines
Quoted 7 lines
policycoreutils/semanage/semanage +0
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store tomanage
+ --dontaudit Turn on or off dontaudit rulesNeed to specify that this takes an integer argument (1 or 0) here. Also,
need to specify which command this is valid for, which appears to be the
module command. Why is this an option for the module command? It doesn't
seem to have anything to do with a particular module. Should this just be
its own command?Quoted 1 line
I think it should be just for the modules command.
Quoted 9 lines
Care to explain why? As your usage above shows, the module command is for
adding or deleting modules. This functionality has nothing to do with that.
--dontaudit is for specifying globally that dontaudit's should be turned on/off. It's not an option that modifies the behavior of adding or deleting
a module, it's a completely separate thing.Quoted 9 lines
No I don't care to explain why, now that you shot down my idea. :^)
I guess it should be a separate command
What do you think of.
semanage dontaudit -a
semanage dontaudit -dI like it being a separate command since it really is a global thing but the syntax above seems very confusing. Can we depart from the add/remove paradigm for this one and use something more appropriate, like on/off, enable/disable, audit/dontaudit, or something similar?
Signature · 4 lines
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 2 lines
semanage dontaudit on
semanage dontaudit offSounds great to me.
Chad
How about this patch.
policycoreutils/semanage/semanage +8 -0
@@ -54,6 +54,7 @@ semanage fcontext -{a|d|m} [-frst] file_spec semanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean | boolean_file semanage permissive -{d|a} type +semanage dontaudit [ on | off ] Primary Options:
@@ -116,6 +117,7 @@ Object-specific Options (see above): valid_option["node"] += valid_everyone + [ '-M', '--mask', '-t', '--type', '-r', '--range', '-p', '--protocol'] valid_option["fcontext"] = [] valid_option["fcontext"] += valid_everyone + [ '-f', '--ftype', '-s', '--seuser', '-t', '--type', '-r', '--range'] + valid_option["dontaudit"] = [ '-S', '--store' ] valid_option["translation"] = [] valid_option["translation"] += valid_everyone + [ '-T', '--trans' ] valid_option["boolean"] = []
@@ -346,6 +348,12 @@ Object-specific Options (see above): target = cmds[0] + + if object == "dontaudit": + OBJECT = seobject.dontauditClass(store) + OBJECT.toggle(target) + return + if add: if object == "login": OBJECT.add(target, seuser, serange)
policycoreutils/semanage/semanage.8 +4 -0
@@ -21,6 +21,8 @@ semanage \- SELinux Policy Management tool .br .B semanage permissive \-{a|d} type .br +.B semanage dontaudit [ on | off ] +.br .B semanage translation \-{a|d|m} [\-T] level .P
@@ -117,6 +119,8 @@ $ semanage fcontext -a -t httpd_sys_content_t "/web(/.*)?" $ semanage port -a -t http_port_t -p tcp 81 # Change apache to a permissive domain $ semanage permissive -a httpd_t +# Turn off dontaudit rules +$ semanage dontaudit off .fi .SH "AUTHOR"
policycoreutils/semanage/seobject.py +12 -0
@@ -314,6 +314,18 @@ class semanageRecords: self.transaction = False self.commit() +class dontauditClass(semanageRecords): + def __init__(self, store): + semanageRecords.__init__(self, store) + + def toggle(self, dontaudit): + if dontaudit not in [ "on", "off" ]: + raise ValueError(_("dontaudit requires either 'on' or 'off'")) + self.begin() + rc = semanage_set_disable_dontaudit(self.sh, dontaudit == "on") + self.commit() + rc = semanage_reload_policy(self.sh) + class permissiveRecords(semanageRecords): def __init__(self, store): semanageRecords.__init__(self, store)
Quoted 111 lines · Daniel J Walsh
Quoted 110 lines · Chad Sellers
Quoted 108 lines · Daniel J Walsh
Quoted 106 lines · Joshua Brindle
Quoted 82 lines · Daniel J Walsh
Quoted 72 lines · Chad Sellers
Quoted 69 lines · Daniel J Walsh
Quoted 51 lines · Chad Sellers
Quoted 7 lines · Daniel J Walsh
Ok lets try the patch again.
Added equal patch (spelled correctly.)
Beginning to add modules support to consolidate on one management command.
Eventually replace semodule/setsebool with semanage command. Some white space fixing inseobject.pyAs I said previously, I've split this patch into the 3 separate patches
(whitespace, equal, modules) for review purposes, as it was too difficult to
get through with the 3 different patches interspersed. Please try to split
up functional patches in the future.This message will apply to the modules patch only.
Quoted 32 lines
policycoreutils/semanage/semanage +0
-2@@ -44,7 +44,7 @@ if __name__ == '__main__': text = _(""" semanage [ -S store ] -i [ input_file | - ] -semanage {boolean|login|user|port|interface|node|fcontext|translation} -{l|D}[-n]
+semanage {module,boolean|login|user|port|interface|node|fcontext|translation}policycoreutils/semanage/semanage +0
-1-{l|D} [-n] semanage login -{a|d|m} [-sr] login_name | %groupname semanage user -{a|d|m} [-LrRP] selinux_name semanage port -{a|d|m} [-tr] [ -p proto ] port | port_range@@ -53,7 +53,8 @@ semanage node -{a|d|m} [-tr] [ -p protocol ] [-Mnetmask]
addr
semanage fcontext -{a|d|m} [-frst] [-e path ]file_specsemanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean |boolean_filepolicycoreutils/semanage/semanage +2
-1-semanage permissive -{d|a} type +semanage permissive -{a|d} type +semanage module -{a|d|} module Primary Options:Quoted 17 lines
Quoted 7 lines
policycoreutils/semanage/semanage +0
-0@@ -68,6 +69,7 @@ Primary Options: -h, --help Display this message -n, --noheading Do not print heading when listing OBJECTS -S, --store Select and alternate SELinux store tomanage
+ --dontaudit Turn on or off dontaudit rulesNeed to specify that this takes an integer argument (1 or 0) here. Also,
need to specify which command this is valid for, which appears to be the
module command. Why is this an option for the module command? It doesn't
seem to have anything to do with a particular module. Should this just be
its own command?Quoted 1 line
I think it should be just for the modules command.
Quoted 9 lines
Care to explain why? As your usage above shows, the module command is for
adding or deleting modules. This functionality has nothing to do with that.
--dontaudit is for specifying globally that dontaudit's should be turned on/off. It's not an option that modifies the behavior of adding or deleting
a module, it's a completely separate thing.Quoted 9 lines
No I don't care to explain why, now that you shot down my idea. :^)
I guess it should be a separate command
What do you think of.
semanage dontaudit -a
semanage dontaudit -dI like it being a separate command since it really is a global thing but the syntax above seems very confusing. Can we depart from the add/remove paradigm for this one and use something more appropriate, like on/off, enable/disable, audit/dontaudit, or something similar?
Signature · 4 lines
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
Quoted 7 lines
Quoted 2 lines
semanage dontaudit on
semanage dontaudit offSounds great to me.
Chad
How about this patch.
It doesn't actually work, but that's primarily due to a problem in libsemanage, rather than here. libsemanage doesn't notice that the disable_dontaudit flag is set so it does not rebuild the policy. semodule got around this by calling semanage_set_rebuild() explicitly, but libsemanage should really notice that this has changed and rebuild appropriately. I'm sending a separate patch to fix libsemanage.
There are a couple of issues with this as well, which I've highlighted below.
<snip>
Quoted 33 lines
policycoreutils/semanage/semanage.8 +4
-0@@ -21,6 +21,8 @@ semanage \- SELinux Policy Management tool .br .B semanage permissive \-{a|d} type .br +.B semanage dontaudit [ on | off ] +.br .B semanage translation \-{a|d|m} [\-T] level .P@@ -117,6 +119,8 @@ $ semanage fcontext -a -t httpd_sys_content_t "/web(/.*)?" $ semanage port -a -t http_port_t -p tcp 81 # Change apache to a permissive domain $ semanage permissive -a httpd_t +# Turn off dontaudit rules +$ semanage dontaudit off .fi .SH "AUTHOR"policycoreutils/semanage/seobject.py +1
-0@@ -314,6 +314,18 @@ class semanageRecords: self.transaction = False self.commit() +class dontauditClass(semanageRecords):
policycoreutils/semanage/seobject.py class semanageRecords: · line 327
Quoted 10 lines
policycoreutils/semanage/seobject.py +8
-0+ def __init__(self, store): + semanageRecords.__init__(self, store) + + def toggle(self, dontaudit): + if dontaudit not in [ "on", "off" ]: + raise ValueError(_("dontaudit requires either 'on' or 'off'")) + self.begin() + rc = semanage_set_disable_dontaudit(self.sh, dontaudit == "on")
This is the opposite logic of what you put in the man page. The man page says dontaudit off means disable_dontaudit. This does the opposite. I think the man page makes more sense than this.
Also, there is no return code from semanage_set_disable_dontaudit().
policycoreutils/semanage/seobject.py class semanageRecords: · line 327
Quoted 2 lines
policycoreutils/semanage/seobject.py +2
-0+ self.commit() + rc = semanage_reload_policy(self.sh)
You shouldn't call semanage_reload_policy here, as semanage_commit() will do it.
Thanks,
Chad
--
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.
Redone to match man page and remove reload_policy.
policycoreutils/semanage/semanage +8 -0
@@ -54,6 +54,7 @@ semanage fcontext -{a|d|m} [-frst] file_spec semanage translation -{a|d|m} [-T] level semanage boolean -{d|m} [--on|--off|-1|-0] -F boolean | boolean_file semanage permissive -{d|a} type +semanage dontaudit [ on | off ] Primary Options:
@@ -116,6 +117,7 @@ Object-specific Options (see above): valid_option["node"] += valid_everyone + [ '-M', '--mask', '-t', '--type', '-r', '--range', '-p', '--protocol'] valid_option["fcontext"] = [] valid_option["fcontext"] += valid_everyone + [ '-f', '--ftype', '-s', '--seuser', '-t', '--type', '-r', '--range'] + valid_option["dontaudit"] = [ '-S', '--store' ] valid_option["translation"] = [] valid_option["translation"] += valid_everyone + [ '-T', '--trans' ] valid_option["boolean"] = []
@@ -346,6 +348,12 @@ Object-specific Options (see above): target = cmds[0] + + if object == "dontaudit": + OBJECT = seobject.dontauditClass(store) + OBJECT.toggle(target) + return + if add: if object == "login": OBJECT.add(target, seuser, serange)
policycoreutils/semanage/semanage.8 +4 -0
@@ -21,6 +21,8 @@ semanage \- SELinux Policy Management tool .br .B semanage permissive \-{a|d} type .br +.B semanage dontaudit [ on | off ] +.br .B semanage translation \-{a|d|m} [\-T] level .P
@@ -117,6 +119,8 @@ $ semanage fcontext -a -t httpd_sys_content_t "/web(/.*)?" $ semanage port -a -t http_port_t -p tcp 81 # Change apache to a permissive domain $ semanage permissive -a httpd_t +# Turn off dontaudit rules +$ semanage dontaudit off .fi .SH "AUTHOR"
policycoreutils/semanage/seobject.py +11 -0
@@ -314,6 +314,17 @@ class semanageRecords: self.transaction = False self.commit() +class dontauditClass(semanageRecords): + def __init__(self, store): + semanageRecords.__init__(self, store) + + def toggle(self, dontaudit): + if dontaudit not in [ "on", "off" ]: + raise ValueError(_("dontaudit requires either 'on' or 'off'")) + self.begin() + rc = semanage_set_disable_dontaudit(self.sh, dontaudit == "off") + self.commit() + class permissiveRecords(semanageRecords): def __init__(self, store): semanageRecords.__init__(self, store)
Chad Sellers
Acked-byQuoted 1 line · Daniel J Walsh
Redone to match man page and remove
reload_policy.
--
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.