Skip to contentSkip to conversation

Patch to add a "netuser" role and user

PATCH Erich Schubert 2 participants 6 messages Mar 7, 2006 – Mar 13, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,
the following patch adds a "netuser" user and role.
This is pretty much the same to user_u/user_r/user_t except that these users can bind non-privileged tcp ports (like user_u with the user_tcp_server boolean, no ssh port forwarding though)

Maybe this patch (when reviewed) could serve as an example on how to add new user roles?

best regards,
Erich Schubert

Signature · 5 lines
   erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
     This one's tricky. You have to use imaginary numbers, like     //\
                      eleventeen... --- Hobbes                      V_/_
   Jede Frau erwartet von einem Mann, dass er hält, was sie sich
                         von ihm verspricht.
rolemap +1 -0
Index: policy/rolemap
===================================================================
@@ -12,6 +12,7 @@
 	user_r user user_t
 	staff_r staff staff_t
 	sysadm_r sysadm sysadm_t
+	netuser_r netuser netuser_t
 
 	ifdef(`enable_mls',`
 		secadm_r secadm secadm_t
users +1 -0
Index: policy/users
===================================================================
@@ -29,6 +29,7 @@
 gen_user(user_u, user, user_r sysadm_r system_r, s0, s0 - s15:c0.c255, c0.c255)
 ',`
 gen_user(user_u, user, user_r, s0, s0)
+gen_user(netuser_u, netuser, netuser_r, s0, s0)
 gen_user(staff_u, staff, staff_r sysadm_r ifdef(`enable_mls',`secadm_r'), s0, s0 - s15:c0.c255, c0.c255)
 gen_user(sysadm_u, sysadm, sysadm_r, s0, s0 - s15:c0.c255, c0.c255)
 ')
modules/system/userdomain.te +7 -0
Index: policy/modules/system/userdomain.te
===================================================================
@@ -117,12 +117,19 @@
 	admin_user_template(sysadm)
 	unpriv_user_template(staff)
 	unpriv_user_template(user)
+	network_user_template(netuser)
 
 	# user role change rules:
 	# sysadm_r can change to user roles
 	role_change(sysadm, user)
 	role_change(sysadm, staff)
 
+	# netuser is rather flexible
+	role_change(sysadm, netuser)
+	role_change(staff, netuser)
+	role_change(netuser, user)
+	role_change(user, netuser)
+
 	# only staff_r can change to sysadm_r
 	role_change(staff, sysadm)
 
modules/system/userdomain.if +32 -0
Index: policy/modules/system/userdomain.if
===================================================================
@@ -725,6 +725,38 @@
 
 #######################################
 ## <summary>
+##	The template for creating a user with network access.
+## </summary>
+## <desc>
+##	<p>
+##	This template creates a user domain, types, and
+##	rules for the user's tty, pty, home directories,
+##	tmp, and tmpfs files.
+##	</p>
+##	<p>
+##	This differs from the unpriv_user_template by allowing non-privileged network access.
+##	</p>
+## </desc>
+## <param name="userdomain_prefix">
+##	<summary>
+##	The prefix of the user domain (e.g., sysadm
+##	is the prefix for sysadm_t).
+##	</summary>
+## </param>
+#
+template(`network_user_template',`
+	##############################
+	#
+	# Declarations
+	#
+
+	# Inherit rules for ordinary users.
+	unpriv_user_template($1)
+	# like user_tcp_server
+	corenet_tcp_bind_generic_port($1_t)
+')
+#######################################
+## <summary>
 ##	The template for creating an administrative user.
 ## </summary>
 ## <desc>
#1 lore raw
Quoted 9 lines · Erich Schubert

Hi,
the following patch adds a "netuser" user and role.
This is pretty much the same to user_u/user_r/user_t except that these users can bind non-privileged tcp ports (like user_u with the user_tcp_server boolean, no ssh port forwarding though)

Maybe this patch (when reviewed) could serve as an example on how to add new user roles?

The patch is a reasonable example for adding roles, but I'm not sure that it should be added. I can't think of a compelling need for it, especially since its basically user_r with user_tcp_server enabled, as you mention above.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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.
#2 lore raw

Hello Christopher,

Quoted 4 lines

The patch is a reasonable example for adding roles, but I'm not sure that it should be added. I can't think of a compelling need for it, especially since its basically user_r with user_tcp_server enabled, as you mention above.

Except that you might not want to allow user_tcp_server for all users, and with netuser you can give this permission easily to individual users on a per-user basis.

I also had to add:

	sysnet_dns_name_resolve($1_t)
	allow $1_t self:tcp_socket create_stream_socket_perms;
	allow $1_t self:udp_socket create_stream_socket_perms;

so it could actually use the sockets.
Probably missing for user_tcp_server, too. Havn't tested that yet (do tuneables actually work? ssh_sysadm_login doesn't work for me)

best regards,
Erich Schubert

Signature · 11 lines
    erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
  A polar bear is a rectangular bear after a coordinate transform.   //\
       Wenn Leute nicht glauben, dass Mathematik einfach ist,        V_/_
             dann nur deshalb, weil sie nicht begreifen,
         wie kompliziert das Leben ist. --- John von Neumann


--
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.
#3 lore raw
Quoted 8 lines · Erich Schubert
Quoted 4 lines

The patch is a reasonable example for adding roles, but I'm not sure that it should be added. I can't think of a compelling need for it, especially since its basically user_r with user_tcp_server enabled, as you mention above.

Except that you might not want to allow user_tcp_server for all users, and with netuser you can give this permission easily to individual users on a per-user basis.

That is true, but I don't find binding to generic ports to be a compelling reason to add another role to the upstream policy.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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.
#4 lore raw

Hi Christopher,

Quoted 6 lines
Quoted 3 lines

Except that you might not want to allow user_tcp_server for all users, and with netuser you can give this permission easily to individual users on a per-user basis.

That is true, but I don't find binding to generic ports to be a compelling reason to add another role to the upstream policy.

So you want tons of admins to enable user_tcp_server (which apparently currently doesn't give all the needed permissions to fullfil it's promises) when they are running a user tcp service?
E.g. an IRC bouncer? Maybe a "web service"? A custom java app?

I think this role is very interesting to have for admins.

And always remember what the AppArmor people say: that they are easier to use. So why not add things like this role to make SELinux easier to use for certain common situations, too?

best regards,
Erich Schubert

Signature · 11 lines
   erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
            Reality continues to ruin my life --- Calvin            //\
   Die Freunde nennen sich aufrichtig. Die Feinde sind es: Daher    V_/_
     man ihren Tadel zur Selbsterkenntnis benutzen sollte, als
           eine bittere Arznei.  --- Arthur Schopenhauer


--
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.
#5 lore raw
Quoted 11 lines · Erich Schubert

Hi Christopher,

Quoted 6 lines
Quoted 3 lines

Except that you might not want to allow user_tcp_server for all users, and with netuser you can give this permission easily to individual users on a per-user basis.

That is true, but I don't find binding to generic ports to be a compelling reason to add another role to the upstream policy.

So you want tons of admins to enable user_tcp_server (which apparently currently doesn't give all the needed permissions to fullfil it's promises) when they are running a user tcp service?

If the user templates are missing rules, then they need to be fixed.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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.