Skip to contentSkip to conversation

Patch: Policy for NX server

PATCH Thomas Bleher 2 participants 2 messages Feb 12, 2005 – Mar 15, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

This patch adds policy for the NX server.
The server works like this: a new user nx is added; the users connect to the host via ssh with username nx; the nxserver is started by ssh and connects to the real user via ssh on localhost.
To start nxserver in the correct context I had to add a new role. Only the server is currently protected, not the client or the nxagent. I also haven't tested the more advanced features like remote printing.

Thomas

Signature · 2 lines
http://www.cip.ifi.lmu.de/~bleher/selinux/ - my SELinux pages
GPG-Fingerprint: BC4F BB16 30D6 F253 E3EA  D09E C562 2BAE B2F4 ABE7
domains/program/nx_server.te +62 -0
diff -urN orig/domains/program/nx_server.te mod/domains/program/nx_server.te
@@ -0,0 +1,62 @@
+# DESC NX - NX Server
+#
+# Author: Thomas Bleher <[email protected]>
+#
+# Depends: sshd.te
+#
+
+# Type for the nxserver executable, called from ssh
+type nx_server_exec_t, file_type, sysadmfile, exec_type;
+
+# type of the nxserver; userdomain is needed so sshd can transition
+type nx_server_t, domain, userdomain;
+
+# we need an extra role because nxserver is called from sshd
+role nx_server_r types nx_server_t;
+allow system_r nx_server_r;
+domain_trans(sshd_t, nx_server_exec_t, nx_server_t)
+
+# not really sure if the additional attributes are needed, copied from userdomains
+can_create_pty(nx_server, `, userpty_type, user_tty_type')
+type_change nx_server_t server_pty:chr_file nx_server_devpts_t;
+
+uses_shlib(nx_server_t)
+read_locale(nx_server_t)
+
+tmp_domain(nx_server)
+var_run_domain(nx_server)
+
+# nxserver is a shell script --> call other programs
+can_exec(nx_server_t, { bin_t shell_exec_t })
+allow nx_server_t self:process { fork sigchld };
+allow nx_server_t self:fifo_file { getattr ioctl read write };
+allow nx_server_t bin_t:dir { getattr read search };
+allow nx_server_t bin_t:lnk_file read;
+
+r_dir_file(nx_server_t, proc_t)
+allow nx_server_t { etc_t etc_runtime_t }:file { getattr read };
+
+# we do not actually need this attribute or the types defined here, 
+# but otherwise we cannot call the ssh_domain-macro
+attribute nx_server_file_type;
+type nx_server_home_dir_t alias nx_server_home_t;
+type nx_server_tty_device_t;
+ssh_domain(nx_server)
+
+can_network_client(nx_server_t)
+
+allow nx_server_t devtty_t:chr_file { read write };
+allow nx_server_t sysctl_kernel_t:dir search;
+allow nx_server_t sysctl_kernel_t:file read;
+allow nx_server_t urandom_device_t:chr_file read;
+# for reading the config files; maybe a separate type, 
+# but users need to be able to also read the config
+allow nx_server_t usr_t:file { getattr read };
+
+dontaudit nx_server_t selinux_config_t:dir search;
+
+# clients already have create permissions; the nxclient wants to also have unlink rights
+allow userdomain xdm_tmp_t:sock_file unlink;
+# for a lockfile created by the client process
+allow nx_server_t user_tmpfile:file getattr;
+
file_contexts/program/nx_server.fc +5 -0
diff -urN orig/file_contexts/program/nx_server.fc mod/file_contexts/program/nx_server.fc
@@ -0,0 +1,5 @@
+# nx
+/opt/NX/bin/nxserver		--	system_u:object_r:nx_server_exec_t
+/opt/NX/var(/.*)?			system_u:object_r:nx_server_var_run_t
+/opt/NX/home/nx/\.ssh(/.*)?		system_u:object_r:nx_server_home_ssh_t
+
serviceusers +3 -0
diff -urN orig/serviceusers mod/serviceusers
@@ -4,3 +4,6 @@
 ifdef(`mailman.te', `
 #user mailman roles mailman_r;
 ')
+ifdef(`nx_server.te', `
+user nx roles nx_server_r;
+')
#1 lore raw

Merged.
Serviceusers is no longer being used, but since nx_server is using an actual Unix user, I added the ifdef for user nx to users.

Quoted 10 lines · Thomas Bleher

This patch adds policy for the NX server.
The server works like this: a new user nx is added; the users connect to the host via ssh with username nx; the nxserver is started by ssh and connects to the real user via ssh on localhost.
To start nxserver in the correct context I had to add a new role. Only the server is currently protected, not the client or the nxagent. I also haven't tested the more advanced features like remote printing.

Thomas

Signature · 8 lines
James Carter <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.