policycoreutils semanage for nodes
PATCH 1/1 policycoreutils semanage for nodes
Hi all,
Since libsemanage support node context management and semanage command for policycoreutils does not, I thought that was a good idea to implement this.
This patch provide all that semanage command needs to manage nodes context. (including a man page updated)
However I know that SECMARK mechanism largely obsoletes the use of netif and node contexts going forward, but I did this patch because I was missing the node management at semanage command.
Thanks,
Rodrigo Vivi.
(vivijim at #selinux)
semanage/semanage +25 -4
@@ -41,6 +41,7 @@ semanage user -{a|d|m} [-LrRP] selinux_name\n\ semanage port -{a|d|m} [-tr] [ -p protocol ] port | port_range\n\ semanage interface -{a|d|m} [-tr] interface_spec\n\ +semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask] addr\n\ semanage fcontext -{a|d|m} [-frst] file_spec\n\ semanage translation -{a|d|m} [-T] level\n\n\ \
@@ -65,7 +66,8 @@ -l (symbolic link) \n\ -p (named pipe) \n\n\ \ - -p, --proto Port protocol (tcp or udp)\n\ + -p, --protocol Port protocol (tcp or udp)\n\ + -M, --mask Netmask\n\ -P, --prefix Prefix for home directory labeling\n\ -L, --level Default SELinux Level (MLS/MCS Systems only)\n\ -R, --roles SELinux Roles (ex: "sysadm_r staff_r")\n\
@@ -94,7 +96,9 @@ valid_option["port"] = [] valid_option["port"] += valid_everyone + [ '-t', '--type', '-r', '--range', '-p', '--protocol' ] valid_option["interface"] = [] - valid_option["interface"] += valid_everyone + [ '-t', '--type', '-r', '--range'] + valid_option["interface"] += valid_everyone + [ '-t', '--type', '-r', '--range'] + 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["translation"] = []
@@ -110,6 +114,7 @@ serange = "" port = "" proto = "" + mask = "" selevel = "" setype = "" ftype = ""
@@ -134,7 +139,7 @@ args = sys.argv[2:] gopts, cmds = getopt.getopt(args, - 'adf:lhmnp:s:R:L:r:t:T:P:', + 'adf:lhmnp:s:R:L:r:t:T:P:M:', ['add', 'delete', 'ftype=',
@@ -149,7 +154,8 @@ 'roles=', 'type=', 'trans=', - 'prefix=' + 'prefix=', + 'mask=' ]) for o, a in gopts: if o not in option_dict[object]:
@@ -194,6 +200,9 @@ if o == "-p" or o == '--proto': proto = a + if o == "-M" or o == '--mask': + mask = a + if o == "-P" or o == '--prefix': prefix = a
@@ -220,6 +229,9 @@ if object == "interface": OBJECT = seobject.interfaceRecords() + + if object == "node": + OBJECT = seobject.nodeRecords() if object == "fcontext": OBJECT = seobject.fcontextRecords()
@@ -257,6 +269,9 @@ if object == "interface": OBJECT.add(target, serange, setype) + if object == "node": + OBJECT.add(target, mask, proto, serange, setype) + if object == "fcontext": OBJECT.add(target, setype, ftype, serange, seuser) sys.exit(0);
@@ -278,6 +293,9 @@ if object == "interface": OBJECT.modify(target, serange, setype) + if object == "node": + OBJECT.modify(target, mask, proto, serange, setype) + if object == "fcontext": OBJECT.modify(target, setype, ftype, serange, seuser)
@@ -290,6 +308,9 @@ elif object == "fcontext": OBJECT.delete(target, ftype) + elif object == "node": + OBJECT.delete(target, mask, proto) + else: OBJECT.delete(target)
semanage/semanage.8 +5 -1
@@ -3,7 +3,7 @@ semanage \- SELinux Policy Management tool .SH "SYNOPSIS" -.B semanage {login|user|port|interface|fcontext|translation} \-l [\-n] +.B semanage {login|user|port|interface|node|fcontext|translation} \-l [\-n] .br .B semanage login \-{a|d|m} [\-sr] login_name .br
@@ -13,6 +13,8 @@ .br .B semanage interface \-{a|d|m} [\-tr] interface_spec .br +.B semanage node \-{a|d|m} [\-tr] [-M netmask] [-p protocol] address +.br .B semanage fcontext \-{a|d|m} [\-frst] file_spec .br .B semanage translation \-{a|d|m} [\-T] level
@@ -93,6 +95,8 @@ $ semanage fcontext -a -t httpd_sys_content_t '/web(/.*)?' # Allow Apache to listen on port 81 $ semanage port -a -t http_port_t -p tcp 81 +# Add node context to 192.168.0.1 / 255.255.255.0 +$ semanage node -a -M 255.255.255.0 -t compat_ipv4_node_t 192.168.0.1 .fi .SH "AUTHOR"
semanage/seobject.py +209 -0
218 lines not on this page · raw message
Quoted 5 lines · Rodrigo Vivi
Hi all,
Since libsemanage support node context management and semanage command for policycoreutils does not, I thought that was a good idea to implement this.
Quoted 7 lines
This patch provide all that semanage command needs to manage nodes context. (including a man page updated)
However I know that SECMARK mechanism largely obsoletes the use of netif and node contexts going forward, but I did this patch because I was missing the node management at semanage command.
I think that netif and node will be around for a while and node in particular is useful for bind(2).
Quoted 20 lines
Thanks,
Rodrigo Vivi.
(vivijim at #selinux)diff -ruN policycoreutils-1.30.26/semanage/semanage policycoreutils-dev/semanage/semanage
--- policycoreutils-1.30.26/semanage/semanage 2006-08-12
09:21:39.000000000 -0300
+++ policycoreutils-dev/semanage/semanage 2006-09-03
05:05:41.000000000 -0300semanage/semanage +1
-0@@ -41,6 +41,7 @@ semanage user -{a|d|m} [-LrRP] selinux_name\n\ semanage port -{a|d|m} [-tr] [ -p protocol ] port | port_range\n\ semanage interface -{a|d|m} [-tr] interface_spec\n\ +semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask] addr\n\ semanage fcontext -{a|d|m} [-frst] file_spec\n\ semanage translation -{a|d|m} [-T] level\n\n\ \
semanage/semanage line 69
Quoted 5 lines
semanage/semanage +1
-1@@ -65,7 +66,8 @@ -l (symbolic link) \n\ -p (named pipe) \n\n\ \ - -p, --proto Port protocol (tcp or udp)\n\ + -p, --protocol Port protocol (tcp or udp)\n\
Did you mean to make this change? It doesn't appear in the argument parsing below. Additionally, I don't think that it is a good idea to change the arguments at this point even if they are better.
Otherwise this looks good - thanks for also making the manpage change. If you are OK with the change above being dropped I don't think there is a reason to resubmit.
Acked-by Karl MacMillan <[email protected]>
--
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 · Rodrigo Vivi
Hi all,
Since libsemanage support node context management and semanage command for policycoreutils does not, I thought that was a good idea to implement this.
This patch provide all that semanage command needs to manage nodes context. (including a man page updated)
Quoted 8 lines
However I know that SECMARK mechanism largely obsoletes the use of
netif and node contexts going forward, but I did this patch because I was missing the node management at semanage command.Thanks,
Rodrigo Vivi.
(vivijim at #selinux)
In addition to the comments below, I tried this patch out and while it indeed added the nodecon it didn't seem to have a net effect on the system. This is probably because of ordering issues which IIRC is why we never had this support to begin with.
semanage/semanage line 45
Quoted 11 lines
------------------------------------------------------------------------
diff -ruN policycoreutils-1.30.26/semanage/semanage policycoreutils-dev/semanage/semanage
semanage/semanage +1
-0@@ -41,6 +41,7 @@ semanage user -{a|d|m} [-LrRP] selinux_name\n\ semanage port -{a|d|m} [-tr] [ -p protocol ] port | port_range\n\ semanage interface -{a|d|m} [-tr] interface_spec\n\ +semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask] addr\n\
what does [ -p protocol ] mean for node? nodecon's don't have protocols
You also didn't add node to the line above these:
semanage {login|user|port|interface|fcontext|translation} -l [-n]
semanage/semanage line 70
Quoted 10 lines
semanage/semanage +0
-0semanage fcontext -{a|d|m} [-frst] file_spec\n\ semanage translation -{a|d|m} [-T] level\n\n\\
semanage/semanage +1
-1@@ -65,7 +66,8 @@ -l (symbolic link) \n\ -p (named pipe) \n\n\ \ - -p, --proto Port protocol (tcp or udp)\n\ + -p, --protocol Port protocol (tcp or udp)\n\
why change this?
semanage/semanage line 102
Quoted 13 lines
semanage/semanage +1
-0+ -M, --mask Netmask\n\ -P, --prefix Prefix for home directory labeling\n\ -L, --level Default SELinux Level (MLS/MCS Systems only)\n\semanage/semanage +3
-1-R, --roles SELinux Roles (ex: "sysadm_r staff_r")\n\@@ -94,7 +96,9 @@ valid_option["port"] = [] valid_option["port"] += valid_everyone + [ '-t', '--type', '-r', '--range', '-p', '--protocol' ] valid_option["interface"] = [] - valid_option["interface"] += valid_everyone + [ '-t', '--type', '-r', '--range'] + valid_option["interface"] += valid_everyone + [ '-t', '--type', '-r', '--range'] + valid_option["node"] = [] + valid_option["node"] += valid_everyone + [ '-M', '--mask', '-t', '--type', '-r', '--range', '-p', '--protocol' ]
I don't think protocol is valid for everyone
Quoted 3 lines
semanage/semanage +0
-0valid_option["fcontext"] = [] valid_option["fcontext"] += valid_everyone + [ '-f', '--ftype', '-s', '--seuser', '-t', '--type', '-r', '--range']
<snip>
semanage/semanage
Quoted 11 lines
semanage/semanage +9
-0valid_option["translation"] = [] + def list(self, heading = 1): + if heading: + print "%-50s %s\n" % ("SELinux Addr", "Context") + ddict = self.get_all() + keys = ddict.keys() + keys.sort() + if is_mls_enabled: + for k in keys: + print "%-50s %s:%s:%s:%s " % (k,ddict[k][0], ddict[k][1],ddict[k][2], translate(ddict[k][3],
I don't think ddict[k][3] is what you think it is..
Quoted 10 lines
False))
semanage/semanage +4
-0+ else: + for k in keys: + print "%-50s %s:%s:%s " % (k,ddict[k][0], ddict[k][1],ddict[k][2]) + class fcontextRecords(semanageRecords): def __init__(self):
semanage/semanage line 1491
Quoted 5 lines
semanage/semanage +2
-0@@ -1280,3 +1487,5 @@ for k in keys: if ddict[k]: print "%-50s %-18s " % (k[0], ddict[k][0]) + +
whitespace?
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 18 lines · Joshua Brindle
Quoted 8 lines · Rodrigo Vivi
Hi all,
Since libsemanage support node context management and semanage command for policycoreutils does not, I thought that was a good idea to implement this.
This patch provide all that semanage command needs to manage nodes context. (including a man page updated)
Quoted 9 lines
However I know that SECMARK mechanism largely obsoletes the use of netif and node contexts going forward, but I did this patch because I was missing the node management at semanage command.
Thanks,
Rodrigo Vivi.
(vivijim at #selinux)
Quoted 5 lines
In addition to the comments below, I tried this patch out and while it indeed added the nodecon it didn't seem to have a net effect on the system. This is probably because of ordering issues which IIRC is why we never had this support to begin with.
How is this different from the port sorting problem? For a simple example pre-pending the local modifications should have the desired effect, so this sounds like a general semanage bug to me.
Karl
--
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 20 lines · Karl MacMillan
Quoted 18 lines · Joshua Brindle
Quoted 16 lines · Rodrigo Vivi
Hi all,
Since libsemanage support node context management and semanage command for policycoreutils does not, I thought that was a good idea to implement this.
This patch provide all that semanage command needs to manage nodes context. (including a man page updated)
However I know that SECMARK mechanism largely obsoletes the use of
netif and node contexts going forward, but I did this patch because I was missing the node management at semanage command.Thanks,
Rodrigo Vivi.
(vivijim at #selinux)
Quoted 9 lines
Quoted 3 lines
In addition to the comments below, I tried this patch out and while it indeed added the nodecon it didn't seem to have a net effect on the system. This is probably because of ordering issues which IIRC is why we never had this support to begin with.
How is this different from the port sorting problem? For a simple example pre-pending the local modifications should have the desired effect, so this sounds like a general semanage bug to me.
Which wasn't fixed in this patch and so shouldn't be merged
--
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 · Joshua Brindle
Quoted 29 lines · Karl MacMillan
Quoted 26 lines · Joshua Brindle
Quoted 8 lines · Rodrigo Vivi
Hi all,
Since libsemanage support node context management and semanage command for policycoreutils does not, I thought that was a good idea to implement this.
This patch provide all that semanage command needs to manage nodes context. (including a man page updated)
Quoted 10 lines
However I know that SECMARK mechanism largely obsoletes the use of netif and node contexts going forward, but I did this patch because I was missing the node management at semanage command.
Thanks,
Rodrigo Vivi.
(vivijim at #selinux)In addition to the comments below, I tried this patch out and while it indeed added the nodecon it didn't seem to have a net effect on the system. This is probably because of ordering issues which IIRC is why we never had this support to begin with.
Quoted 6 lines
Quoted 5 lines
How is this different from the port sorting problem? For a simple example pre-pending the local modifications should have the desired effect, so this sounds like a general semanage bug to me.
Which wasn't fixed in this patch and so shouldn't be merged
Rodrigo - are you interested in trying to get to the bottom of this? Otherwise, please file a bug [1] and attach your existing patch.
Thanks,
Karl
[1] http://sourceforge.net/tracker/?group_id=21266&atid=121266
--
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.
Hi all,
first of all I'm submitting a new version of this patch that contains some changes related to the comments that you've sent me:
Review
Quoted 2 lines
(quoted diff) +1
-1- -p, --proto Port protocol (tcp or udp)\n\ + -p, --protocol Port protocol (tcp or udp)\n\
This were a mistake. Actually what I believe that is really need to change is that:
- valid_option["port"] += valid_everyone +
[ '-t', '--type', '-r', '--range', '-p', '--protocol' ]
+ valid_option["port"] += valid_everyone +
[ '-t', '--type', '-r', '--range', '-p', '--proto' ]
Quoted 1 line
what does [ -p protocol ] mean for node? nodecon's don't have protocols
For node protocol must be ipv4 or ipv6. Actually libsemanage consider 0 as ipv4 and 1 as ipv6.
Now i did some changes in manpage and in usage string that explain this.
Quoted 2 lines
You also didn't add node to the line above these:
semanage {login|user|port|interface|fcontext|translation} -l [-n]
done.
Quoted 2 lines
ddict[k][1],ddict[k][2], translate(ddict[k][3], I don't think ddict[k][3] is what you think it is..
I didn't understand your point. In get_all() I add the mls context as the field 3.
Quoted 1 line
whitespace?
removed. sorry.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
In addition to the comments below, I tried this patch out and while it indeed added the nodecon it didn't seem to have a net effect on the system. This is probably because of ordering issues which IIRC is why we never had this support to begin with.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
How is this different from the port sorting problem? For a simple example pre-pending the local modifications should have the desired effect, so this sounds like a general semanage bug to me.
Which wasn't fixed in this patch and so shouldn't be merged
Rodrigo - are you interested in trying to get to the bottom of this? Otherwise, please file a bug [1] and attach your existing patch.
Yes, I'm very interested in trying to get to the bottom of this. I'm not sure if I have sufficient experience for that but I can try. And need your help.
So, I coded this patch for node based on interface one and I was sure that for interface it was working. But I had tried only in permissive mode. Today I tested in enforcing mode and I'm not sure even if for interface semanage is working.
because I could send a message from a process in SystemHigh through a tun interface in SystemLow and a node in SystemLow too.
How is the best way to test this ?
How did you do to test this ?
How can I debug this to see why this is not working ?
Thanks for your help and patience.
semanage/semanage +27 -6
@@ -36,11 +36,12 @@ def usage(message = ""): print _('\ -semanage {login|user|port|interface|fcontext|translation} -l [-n] \n\ +semanage {login|user|port|interface|node|fcontext|translation} -l [-n] \n\ semanage login -{a|d|m} [-sr] login_name\n\ semanage user -{a|d|m} [-LrRP] selinux_name\n\ semanage port -{a|d|m} [-tr] [ -p protocol ] port | port_range\n\ semanage interface -{a|d|m} [-tr] interface_spec\n\ +semanage node -{a|d|m} [-tr] [ -p protocol ] [-M netmask] addr\n\ semanage fcontext -{a|d|m} [-frst] file_spec\n\ semanage translation -{a|d|m} [-T] level\n\n\ \
@@ -65,7 +66,8 @@ -l (symbolic link) \n\ -p (named pipe) \n\n\ \ - -p, --proto Port protocol (tcp or udp)\n\ + -p, --proto Protocol {tcp|udp} for Port or {ipv4|ipv6} for Node\n\ + -M, --mask Node Netmask\n\ -P, --prefix Prefix for home directory labeling\n\ -L, --level Default SELinux Level (MLS/MCS Systems only)\n\ -R, --roles SELinux Roles (ex: "sysadm_r staff_r")\n\
@@ -92,9 +94,11 @@ valid_option["user"] = [] valid_option["user"] += valid_everyone + [ '-L', '--level', '-r', '--range', '-R', '--roles', '-P', '--prefix' ] valid_option["port"] = [] - valid_option["port"] += valid_everyone + [ '-t', '--type', '-r', '--range', '-p', '--protocol' ] + valid_option["port"] += valid_everyone + [ '-t', '--type', '-r', '--range', '-p', '--proto' ] valid_option["interface"] = [] - valid_option["interface"] += valid_everyone + [ '-t', '--type', '-r', '--range'] + valid_option["interface"] += valid_everyone + [ '-t', '--type', '-r', '--range'] + valid_option["node"] = [] + valid_option["node"] += valid_everyone + [ '-M', '--mask', '-t', '--type', '-r', '--range', '-p', '--proto' ] valid_option["fcontext"] = [] valid_option["fcontext"] += valid_everyone + [ '-f', '--ftype', '-s', '--seuser', '-t', '--type', '-r', '--range'] valid_option["translation"] = []
@@ -110,6 +114,7 @@ serange = "" port = "" proto = "" + mask = "" selevel = "" setype = "" ftype = ""
@@ -134,7 +139,7 @@ args = sys.argv[2:] gopts, cmds = getopt.getopt(args, - 'adf:lhmnp:s:R:L:r:t:T:P:', + 'adf:lhmnp:s:R:L:r:t:T:P:M:', ['add', 'delete', 'ftype=',
@@ -149,7 +154,8 @@ 'roles=', 'type=', 'trans=', - 'prefix=' + 'prefix=', + 'mask=' ]) for o, a in gopts: if o not in option_dict[object]:
@@ -194,6 +200,9 @@ if o == "-p" or o == '--proto': proto = a + if o == "-M" or o == '--mask': + mask = a + if o == "-P" or o == '--prefix': prefix = a
@@ -220,6 +229,9 @@ if object == "interface": OBJECT = seobject.interfaceRecords() + + if object == "node": + OBJECT = seobject.nodeRecords() if object == "fcontext": OBJECT = seobject.fcontextRecords()
@@ -257,6 +269,9 @@ if object == "interface": OBJECT.add(target, serange, setype) + if object == "node": + OBJECT.add(target, mask, proto, serange, setype) + if object == "fcontext": OBJECT.add(target, setype, ftype, serange, seuser) sys.exit(0);
@@ -278,6 +293,9 @@ if object == "interface": OBJECT.modify(target, serange, setype) + if object == "node": + OBJECT.modify(target, mask, proto, serange, setype) + if object == "fcontext": OBJECT.modify(target, setype, ftype, serange, seuser)
@@ -290,6 +308,9 @@ elif object == "fcontext": OBJECT.delete(target, ftype) + elif object == "node": + OBJECT.delete(target, mask, proto) + else: OBJECT.delete(target)
semanage/semanage.8 +6 -2
@@ -3,7 +3,7 @@ semanage \- SELinux Policy Management tool .SH "SYNOPSIS" -.B semanage {login|user|port|interface|fcontext|translation} \-l [\-n] +.B semanage {login|user|port|interface|node|fcontext|translation} \-l [\-n] .br .B semanage login \-{a|d|m} [\-sr] login_name .br
@@ -13,6 +13,8 @@ .br .B semanage interface \-{a|d|m} [\-tr] interface_spec .br +.B semanage node \-{a|d|m} [\-tr] [-M netmask] [-p protocol] address +.br .B semanage fcontext \-{a|d|m} [\-frst] file_spec .br .B semanage translation \-{a|d|m} [\-T] level
@@ -63,7 +65,7 @@ Do not print heading when listing OBJECTS. .TP .I \-p, \-\-proto -Protocol for the specified port (tcp|udp). +Protocol for the specified port (tcp|udp) or for the specified node (ipv4|ipv6), ipv4 Default. .TP .I \-r, \-\-range MLS/MCS Security Range (MLS/MCS Systems only)
@@ -93,6 +95,8 @@ $ semanage fcontext -a -t httpd_sys_content_t '/web(/.*)?' # Allow Apache to listen on port 81 $ semanage port -a -t http_port_t -p tcp 81 +# Add node context to 192.168.0.1 / 255.255.255.0 +$ semanage node -a -M 255.255.255.0 -p ipv4 -t compat_ipv4_node_t 192.168.0.1 .fi .SH "AUTHOR"
semanage/seobject.py +212 -0
219 lines not on this page · raw message