Skip to contentSkip to conversation

more patches

PATCH Russell Coker 2 participants 2 messages Aug 27, 2002 – Aug 29, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

For user.te I added the following:

# lots of user programs accidentally search /root, and also the admin often
# logs in as UID=0 domain=user_t...
dontaudit unpriv_userdomain sysadm_home_dir_t:dir { getattr search };

# "ps aux" and "ls -l /dev/pts" make too much noise without this dontaudit unpriv_userdomain ptyfile:chr_file getattr;

Without that there's too much noise in the syslog and the admin will tend to ignore it all...

I've attached a patch port.diff to add port contexts to everything else that needs them, and also a patch to mrtg.te.

I've attached a patch triv2.diff which has a few other trivial things, and a patch for postgresql (it still doesn't work but it's a better starting point for other people to work on than the current version).

I've also attached a patch for user macros which mainly improves support for XDM.

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

domains/program/courier.te renamed from tmp/policy/domains/program/courier.te +3 -0
diff -wruN /tmp/policy/domains/program/courier.te policy/domains/program/courier.te
@@ -14,6 +14,8 @@
 type courier_exec_t, file_type, sysadmfile, exec_type;
 type sqwebmail_cron_exec_t, file_type, sysadmfile, exec_type;
 
+type pop_port_t, port_type;
+
 define(`courier_domain', `
 #################################
 #
@@ -76,6 +78,7 @@
 
 courier_domain(tcpd)
 allow courier_tcpd_t self:capability net_bind_service;
+allow courier_tcpd_t pop_port_t:tcp_socket name_bind;
 allow courier_tcpd_t sbin_t:dir search;
 # for TLS
 allow courier_tcpd_t random_device_t:chr_file read;
domains/program/mrtg.te renamed from tmp/policy/domains/program/mrtg.te +5 -7
diff -wruN /tmp/policy/domains/program/mrtg.te policy/domains/program/mrtg.te
@@ -41,10 +41,6 @@
 can_udp_send(snmpd_t, mrtg_t)
 ')
 
-# Use capabilities  should not need kill...
-#allow mrtg_t self:capability { net_raw net_bind_service kill };
-#allow mrtg_t self:process setsched;
-
 allow mrtg_t proc_t:file { read getattr };
 
 allow mrtg_t { var_lock_t var_lib_t }:dir search;
@@ -59,7 +55,9 @@
 allow mrtg_t sysctl_kernel_t:file read;
 
 # for uptime
-dontaudit mrtg_t initrc_var_run_t:file { read write lock };
-dontaudit mrtg_t etc_runtime_t:file { getattr read };
+allow mrtg_t initrc_var_run_t:file read;
+dontaudit mrtg_t initrc_var_run_t:file { write lock };
+allow mrtg_t etc_runtime_t:file { getattr read };
 
-dontaudit mrtg_t sysadm_home_dir_t:dir search;
+# should not need this!
+allow mrtg_t sysadm_home_dir_t:dir { search read };
domains/program/ntpd.te renamed from tmp/policy/domains/program/ntpd.te +2 -0
diff -wruN /tmp/policy/domains/program/ntpd.te policy/domains/program/ntpd.te
@@ -11,6 +11,7 @@
 type var_lib_ntp_t, file_type, sysadmfile;
 type var_log_ntp_t, file_type, sysadmfile, logfile;
 type etc_ntp_t, file_type, sysadmfile;
+type ntp_port_t, port_type;
 
 file_type_auto_trans(ntpd_t, var_log_t, var_log_ntp_t)
 
@@ -31,6 +32,7 @@
 
 # Use the network.
 can_network(ntpd_t)
+allow ntpd_t ntp_port_t:udp_socket name_bind;
 allow ntpd_t domain:packet_socket recvfrom;
 allow ntpd_t self:unix_dgram_socket create_socket_perms;
 allow ntpd_t self:unix_stream_socket create_socket_perms;
domains/program/portmap.te renamed from tmp/policy/domains/program/portmap.te +3 -0
diff -wruN /tmp/policy/domains/program/portmap.te policy/domains/program/portmap.te
@@ -15,6 +15,8 @@
 domain_auto_trans(initrc_t, portmap_exec_t, portmap_t)
 type_transition init_t portmap_exec_t:process portmap_t;
 
+type portmap_port_t, port_type;
+
 type portmap_tmp_t, file_type, sysadmfile, tmpfile;
 file_type_auto_trans(portmap_t, tmp_t, portmap_tmp_t)
 
@@ -23,6 +25,7 @@
 
 # Use the network.
 can_network(portmap_t)
+allow portmap_t portmap_port_t:{ udp_socket tcp_socket } name_bind;
 
 # Send to ypbind, initrc, rpc.statd, xinetd.
 ifdef(`ypbind.te',
domains/program/ssh.te renamed from tmp/policy/domains/program/ssh.te +3 -0
diff -wruN /tmp/policy/domains/program/ssh.te policy/domains/program/ssh.te
@@ -3,6 +3,8 @@
 # Modified by: Russell Coker <[email protected]>
 #
 
+type ssh_port_t, port_type;
+
 define(`sshd_program_domain', `
 type $1, domain, privuser, privrole, privlog, privowner, privfd;
 role system_r types $1;
@@ -48,6 +50,7 @@
 # sshd_key_t is the type of the ssh private key files
 #
 sshd_program_domain(sshd_t)
+allow sshd_t ssh_port_t:tcp_socket name_bind;
 sshd_program_domain(sshd_login_t)
 undefine(`sshd_program_domain')
 type sshd_exec_t, file_type, exec_type, sysadmfile;
domains/program/tftpd.te renamed from tmp/policy/domains/program/tftpd.te +3 -0
diff -wruN /tmp/policy/domains/program/tftpd.te policy/domains/program/tftpd.te
@@ -11,10 +11,13 @@
 #
 daemon_domain(tftpd)
 
+type tftp_port_t, port_type;
+
 domain_auto_trans(inetd_t, tftpd_exec_t, tftpd_t)
 
 # Use the network.
 can_network(tftpd_t)
+allow tftpd_t tftp_port_t:udp_socket name_bind;
 allow tftpd_t self:unix_dgram_socket create_socket_perms;
 allow tftpd_t self:unix_stream_socket create_stream_socket_perms;
 
net_contexts renamed from tmp/policy/net_contexts +23 -2
diff -wruN /tmp/policy/net_contexts policy/net_contexts
@@ -17,13 +17,26 @@
 # protocol number context
 # protocol low-high context
 #
+ifdef(`courier.te', define(`use_pop'))
 ifdef(`ftpd.te', `portcon tcp 21 system_u:object_r:ftp_port_t')
+ifdef(`ssh.te', `portcon tcp 22 system_u:object_r:ssh_port_t')
 ifdef(`inetd.te', `portcon tcp 23 system_u:object_r:telnet_port_t')
 ifdef(`mta.te', `portcon tcp 25 system_u:object_r:smtp_port_t')
 ifdef(`named.te', `portcon udp 53 system_u:object_r:named_port_t
 portcon tcp 53 system_u:object_r:named_port_t')
+ifdef(`tftpd.te', `portcon udp 69  system_u:object_r:tftp_port_t')
 ifdef(`fingerd.te', `portcon tcp 79  system_u:object_r:fingerd_port_t')
 ifdef(`apache.te', `portcon tcp 80  system_u:object_r:http_port_t')
+ifdef(use_pop, `
+portcon tcp 106 system_u:object_r:pop_port_t
+portcon tcp 109 system_u:object_r:pop_port_t
+portcon tcp 110 system_u:object_r:pop_port_t
+')
+ifdef(`portmap.te', `
+portcon udp 111 system_u:object_r:portmap_port_t
+portcon tcp 111 system_u:object_r:portmap_port_t
+')
+ifdef(`ntp.te', `portcon udp 123 system_u:object_r:ntp_port_t')
 ifdef(`samba.te', `
 portcon tcp 137 system_u:object_r:smbd_port_t
 portcon udp 137 system_u:object_r:nmbd_port_t
@@ -32,24 +45,32 @@
 portcon tcp 139 system_u:object_r:smbd_port_t
 portcon udp 139 system_u:object_r:nmbd_port_t
 ')
+ifdef(use_pop, `portcon tcp 143 system_u:object_r:pop_port_t')
 ifdef(`snmpd.te', `
 portcon udp 161 system_u:object_r:snmp_port_t
 portcon udp 162 system_u:object_r:snmp_port_t
 portcon tcp 199 system_u:object_r:snmp_port_t
 ')
+ifdef(use_pop, `portcon tcp 220 system_u:object_r:pop_port_t')
 ifdef(`slapd.te', `portcon tcp 389 system_u:object_r:ldap_port_t')
 ifdef(`rlogind.te', `portcon tcp 513 system_u:object_r:rlogin_port_t')
 ifdef(`rshd.te', `portcon tcp 514 system_u:object_r:rsh_port_t')
 ifdef(`lpd.te', `portcon tcp 515 system_u:object_r:printer_port_t')
 ifdef(`cups.te', `portcon tcp 631 system_u:object_r:ipp_port_t')
-ifdef(`apache.te', `portcon tcp 8080  system_u:object_r:http_cache_port_t',
-`ifdef(`squid.te', `portcon tcp 8080  system_u:object_r:http_cache_port_t')')
+ifdef(use_pop, `
+portcon tcp 993 system_u:object_r:pop_port_t
+portcon tcp 995 system_u:object_r:pop_port_t
+portcon tcp 1109 system_u:object_r:pop_port_t
+')
 ifdef(`radius.te', `portcon udp 1645 system_u:object_r:radius_port_t
 portcon udp 1646 system_u:object_r:radacct_port_t
 portcon udp 1812 system_u:object_r:radius_port_t
 portcon udp 1813 system_u:object_r:radacct_port_t')
 ifdef(`dictd.te', `portcon tcp 2628 system_u:object_r:dict_port_t')
 ifdef(`ircd.te', `portcon tcp 6667 system_u:object_r:ircd_port_t')
+ifdef(`apache.te', define(`use_http_cache'))
+ifdef(`squid.te', define(`use_http_cache'))
+ifdef(use_http_cache, `portcon tcp 8080  system_u:object_r:http_cache_port_t')
 ifdef(`transproxy.te', `portcon tcp 8081 system_u:object_r:transproxy_port_t')
 
 # Network interfaces (default = initial SID 'netif' and 'netmsg')
domains/program/dpkg.te renamed from tmp/policy/domains/program/dpkg.te +1 -0
diff -wruN /tmp/policy/domains/program/dpkg.te policy/domains/program/dpkg.te
@@ -116,6 +116,7 @@
 
 # Inherit and use descriptors from any domain.
 allow { apt_t dpkg_t } privfd:fd use;
+allow { apt_t dpkg_t install_menu_t } devpts_t:dir search;
 allow { apt_t dpkg_t install_menu_t } { sysadm_tty_device_t sysadm_devpts_t }:chr_file rw_file_perms;
 
 allow ifconfig_t dpkg_t:fd use;
domains/program/ipsec.te renamed from tmp/policy/domains/program/ipsec.te +1 -1
diff -wruN /tmp/policy/domains/program/ipsec.te policy/domains/program/ipsec.te
@@ -43,7 +43,7 @@
 allow ipsec_mgmt_t console_device_t:chr_file rw_file_perms;
 allow ipsec_t console_device_t:chr_file rw_file_perms;
 allow ipsec_t init_t:fd use;
-allow ipsec_mgmt_t init_t:fd use;
+allow ipsec_mgmt_t { init_t privfd }:fd use;
 # do we really need this?
 allow ipsec_t initrc_t:fd use;
 allow ipsec_mgmt_t initrc_t:fd use;
domains/program/postgresql.te renamed from tmp/policy/domains/program/postgresql.te +18 -3
diff -wruN /tmp/policy/domains/program/postgresql.te policy/domains/program/postgresql.te
@@ -11,6 +11,13 @@
 #
 daemon_domain(postgresql)
 
+ifdef(`dpkg.te', `
+# gross hack
+domain_auto_trans(dpkg_t, postgresql_exec_t, postgresql_t)
+')
+# a grosser hack
+allow postgresql_t etc_t:file setattr;
+
 dontaudit postgresql_t { sysadm_home_dir_t var_spool_t }:dir search;
 
 allow postgresql_t self:capability { dac_override dac_read_search chown fowner fsetid setuid setgid };
@@ -21,14 +28,22 @@
 
 file_type_auto_trans(postgresql_t, var_log_t, postgresql_log_t)
 
+allow postgresql_t system_crond_script_t:file { getattr read };
+
 tmp_domain(postgresql);
+file_type_auto_trans(postgresql_t, tmpfs_t, postgresql_tmp_t)
+
+can_exec(postgresql_t, dpkg_exec_t)
 
 # Use the network.
 can_network(postgresql_t)
 allow postgresql_t self:fifo_file { getattr read write ioctl };
-allow postgresql_t self:unix_stream_socket create_socket_perms;
+allow postgresql_t self:unix_stream_socket create_stream_socket_perms;
 allow postgresql_t self:unix_dgram_socket create_socket_perms;
-# allow any user domain to connect to the server
+
+allow postgresql_t self:shm rw_shm_perms;
+
+# allow any user domain to connect to the database server
 can_tcp_connect(userdomain, postgresql_t)
 
 allow postgresql_t proc_t:file { getattr read };
@@ -55,7 +70,7 @@
 allow postgresql_t bin_t:lnk_file read;
 allow postgresql_t postgresql_exec_t:lnk_file read;
 
-allow postgresql_t initrc_var_run_t:file { read };
+allow postgresql_t initrc_var_run_t:file { read write lock };
 
 allow postgresql_t self:sem rw_sem_perms;
 
domains/program/pppd.te renamed from tmp/policy/domains/program/pppd.te +1 -0
diff -wruN /tmp/policy/domains/program/pppd.te policy/domains/program/pppd.te
@@ -47,6 +47,7 @@
 
 # Access /dev/ppp.
 allow pppd_t ppp_device_t:chr_file rw_file_perms;
+allow pppd_t devtty_t:chr_file { read write };
 
 allow pppd_t self:unix_dgram_socket create_socket_perms;
 allow pppd_t self:unix_stream_socket create_socket_perms;
domains/program/run_init.te renamed from tmp/policy/domains/program/run_init.te +3 -0
diff -wruN /tmp/policy/domains/program/run_init.te policy/domains/program/run_init.te
@@ -36,6 +36,9 @@
 allow run_init_t sysadm_tty_device_t:chr_file rw_file_perms;
 allow run_init_t sysadm_devpts_t:chr_file rw_file_perms;
 
+# for when it is run from a directory with restrictive perms
+dontaudit run_init_t file_type:dir search;
+
 # for some PAM modules
 dontaudit run_init_t { sysadm_home_dir_t user_home_dir_type }:dir search;
 # for utmp
domains/program/transproxy.te renamed from tmp/policy/domains/program/transproxy.te +1 -2
diff -wruN /tmp/policy/domains/program/transproxy.te policy/domains/program/transproxy.te
@@ -16,12 +16,11 @@
 # Use the network.
 can_network(transproxy_t)
 allow transproxy_t transproxy_port_t:tcp_socket name_bind;
+#allow transproxy_t { sysadm_tty_device_t sysadm_devpts_t }:chr_file { read write };
 
 #allow transproxy_t self:fifo_file { read write };
 allow transproxy_t self:unix_stream_socket create_socket_perms;
 allow transproxy_t self:unix_dgram_socket create_socket_perms;
-# allow any user domain to connect to the server
-can_tcp_connect(userdomain, transproxy_t)
 
 # Use capabilities
 allow transproxy_t self:capability { setgid setuid };
domains/program/xfs.te renamed from tmp/policy/domains/program/xfs.te +1 -0
diff -wruN /tmp/policy/domains/program/xfs.te policy/domains/program/xfs.te
@@ -1,3 +1,4 @@
+#DESC X Font Server
 #
 # Authors:  Stephen Smalley <[email protected]> and Timothy Fraser <[email protected]> (NAI Labs) 
 #
file_contexts/program/sendmail.fc renamed from tmp/policy/file_contexts/program/sendmail.fc +0 -4
diff -wruN /tmp/policy/file_contexts/program/sendmail.fc policy/file_contexts/program/sendmail.fc
@@ -1,9 +1,5 @@
 # sendmail
-/etc/aliases			system_u:object_r:etc_aliases_t
-/etc/aliases.db			system_u:object_r:etc_aliases_t
 /etc/mail(/.*)?			system_u:object_r:etc_mail_t
-/usr/sbin/sendmail		system_u:object_r:sendmail_exec_t
-/usr/sbin/sendmail.sendmail	system_u:object_r:sendmail_exec_t
 /var/spool/mail(/.*)?		system_u:object_r:mail_spool_t
 /var/spool/mqueue(/.*)?		system_u:object_r:mqueue_spool_t
 /var/log/sendmail.st		system_u:object_r:sendmail_var_log_t
macros/user_macros.te renamed from tmp/policy/macros/user_macros.te +21 -4
diff -wruN /tmp/policy/macros/user_macros.te policy/macros/user_macros.te
@@ -199,18 +199,35 @@
 # correctly without it.  Do not audit write denials to utmp.
 dontaudit $1_t initrc_var_run_t:file { read write };
 
-ifdef(`xdm.te',
-`# Connect to the X server run by the X Display Manager.
+# do not audit getattr on tmpfile, otherwise ls -l /tmp fills the logs
+dontaudit $1_t tmpfile:dir_file_class_set getattr;
+
+ifdef(`xdm.te', `
+# Connect to the X server run by the X Display Manager.
 can_unix_connect($1_t, xdm_t)
 allow $1_t xdm_tmp_t:sock_file rw_file_perms;
 allow $1_t xdm_tmp_t:dir r_dir_perms;
-allow $1_t xdm_tmp_t:dir r_dir_perms;
 allow $1_t xdm_xserver_tmp_t:sock_file { read write };
 allow $1_t xdm_xserver_tmp_t:dir search;
+
+# gross hack - should not need this
+file_type_auto_trans(xdm_t, $1_home_dir_t, $1_home_t, file)
 ')
 
 # Access the sound device.
-allow $1_t sound_device_t:chr_file { read write ioctl };
+allow $1_t sound_device_t:chr_file { getattr read write ioctl };
+
+# Allow reading dpkg origins file
+ifdef(`dpkg.te', `
+r_dir_file($1_t, etc_dpkg_t)
+')
+
+ifdef(`ftpd.te', `
+# uncomment the following for FTP access to all home directories
+# or you can just enable FTP access for certain user domains in the ftpd.te
+# file
+#file_type_auto_trans(ftpd_t, $1_home_dir_t, $1_home_t)
+')
 
 ')
 
#1 lore raw

Re: more patches, another small patch

These patches have been merged and are available in the sourceforge CVS tree. I replaced the allow rule granting mrtg_t access to sysadm_home_dir_t with a dontaudit rule. I omitted two changes from postgresql.te: granting the domain setattr permission to etc_t:file and granting the domain write and lock permission to initrc_var_run_t:file.

--
Stephen D. Smalley, NAI Labs
[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.