<div>In the example below with the foo_user_t, my understanding is that after the new type is created, it should be assigned to a role, and then the role assigned to a user. </div>
<div> </div>
<div>The problem I am seeing is that after I assign the new role to the user, id -Z still shows the defualt unconfined_r role assigned.</div>
<p>Details:</p>
<p>// labeled the network interfaces<br>semanage interface –a –t netif_t –r s0:c4 eth0<br>semanage interface –a –t netif_t –r s0:c5 eth1</p>
<p>// created a new type</p>
<p>module netIfControl 1.0;</p>
<p>require { <br> # allow icmp as part of tcp<br> class netif { tcp_send tcp_recv };<br> type netif_t<br>};</p>
<p># define a new type<br>type user_1_t;</p>
<p># define a new role and assign the type to it<br># later assign the new role to the user using semanage</p>
<p>role accessNetworkInterface_r types user_1_t;</p>
<p># define what the type is permitted to do<br>allow user_1_t netif_t:netif { tcp_send tcp_recv };</p>
<p>// compile, package and load module<br>checkmodule -M -m -o netIfControl.mod netIfCntrol.te<br>semodule_package -o netIfControl.pp -m netIfControl.mod<br>semodule -i netIfControl.pp</p>
<p>// no errors reported</p>
<p>// Create a new SeLinux user and assign to the networkInterface_r role</p>
<p>semanage user -a -L s0 -r S0:c5 -R networkInterface_r -P user networkInterface _u</p>
<p>// Map the new SELinux user to a Linux user</p>
<p>semanage login -m -s networkInterface_u -r s0:c5 user_1</p>
<p>// Login via ssh as user_1<br>id -Z<br>user:u system_r:unconfined_t:s0</p>
<p><br><br> </p>
<div class="gmail_quote">On Mon, Aug 24, 2009 at 3:58 PM, Paul Moore <span dir="ltr"><<a href="mailto:paul.moore@hp.com">paul.moore@hp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="h5">On Sunday 23 August 2009 09:51:26 pm James Morris wrote:<br>> On Fri, 21 Aug 2009, Jason Shaw wrote:<br>> > In FC-11, under the targeted policy, is it possible to label an ethernet<br>> > interface (such as eth0, eth1) with a specific MCS category?<br>
> ><br>> > Example:<br>> > 1) Use semanage to assign user1 to s0:c5<br>> > 3) Assign eth0 to s0:c4 (Can this be done?)<br>> > 4) Assign eth1 to s0:c5<br>> ><br>> > Desired result: if user1 tries to ping -I eth1 <ip_address> the ping<br>
> > command will work (as both eth1 and user1 have category c5). If user1<br>> > tries to ping -I eth0 <ip_address>, the ping command will not work<br>> > (category mismatch between user and eth1).<br>
><br>> It should be possible to do this via iptables and SECMARK.<br>><br>> i.e. match all packets on ethN and label with the MCS category then use<br>> the SELinux packet flow policy rules.<br>><br>> I haven't looked at this stuff for a while, so cc'ing Paul Moore, who<br>
> maintains the code.<br><br></div></div>[NOTE: I'm not currently subscribed to fedora-selinux-list, feel free to fwd]<br><br>Hi Jason,<br><br>Using your example as a guide, there are actually two ways to accomplish what<br>
you want to do.  The first approach James already mentioned: Secmark.  The<br>second approach uses the network ingress/egress controls.  The best choice for<br>your particular case is going to likely depend on whatever other SELinux<br>
network access controls you have in place and which administration mechanism<br>you prefer ... however, here is a quick overview of what is involved for both.<br><br> * Secmark<br>  - Establish a iptables rules marking the outbound packets<br>
       # iptables -t mangle -A OUTPUT -o eth0 -j SECMARK \<br>      --selctx system_u:object_r:foo_packet_t:s0:c4<br>       # iptables -t mangle -A OUTPUT -o eth1 -j SECMARK \<br>      --selctx system_u:object_r:foo_packet_t:s0:c5<br>
  - Ensure you have the right SELinux policy in place<br>       allow foo_user_t foo_packet_t:packet { send };<br><br> * Ingress/Egress Controls<br>  - Label the interfaces<br>       # semanage interface -a -t netif_t -r s0:c4 eth0<br>
       # semanage interface -a -t netif_t -r s0:c5 eth1<br>  - Ensure you have the right SELinux policy in place<br>       allow foo_user_t netif_t:netif { egress };<br><br>The examples above are pretty simple but they should get you going in the<br>
right direction - if you have any questions don't hesitate to ask.<br><font color="#888888"><br>--<br>paul moore<br>linux @ hp<br></font></blockquote></div><br>