Skip to contentSkip to conversation

policy patches

PATCH Russell Coker 1 participant 1 message Apr 26, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

makefile.diff is a Makefile patch for jfs and jffs2. jffs2 is probably redundant, but does no harm (and it's good to demonstrate that a large number of file systems are supported).

global.diff is a patch to global_macros.te. This contains some things that are relied on by later patches. It allows can_exec_any() to read symlinks in /etc because in Debian /usr/bin has many symlinks to symlinks in /etc for the case where several packages can provide the same program. Also it removes every_domain(), which will break some other policy. I've got patches for all the other domains, I'll post them here shortly.

passwd.diff makes two separate domains for changing password, one for the user that's just for "spasswd", and the other for the administrator that allows everything that's needed for svipw etc. Also it merges useradd.te and groupadd.te into the same file with macros and removes every_domain() from chkpwd_macros.te .

simple.diff contains a bunch of small changes that aren't particularly noteworthy.

Signature · 4 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page
Makefile renamed from tmp/policy/Makefile +2 -2
diff -ru /tmp/policy/Makefile ./Makefile
@@ -103,10 +104,10 @@
 	cat domains/*.te domains/misc/*.te domains/program/*.te > $@
 
 relabel:  $(FC) $(SETFILES)
-	$(SETFILES) $(FC) `mount | awk '/(ext[23]|reiserfs)/{print $$3}'`
+	$(SETFILES) $(FC) `mount | awk '/(ext[23]|reiserfs|jfs|jffs2)/{print $$3}'`
 
 reset:  $(FC) $(SETFILES)
-	$(SETFILES) -R $(FC) `mount | awk '/(ext[23]|reiserfs)/{print $$3}'`
+	$(SETFILES) -R $(FC) `mount | awk '/(ext[23]|reiserfs|jfs|jffs2)/{print $$3}'`
 
 $(FC): $(FCFILES) file_contexts/program 
 	cat $(FCFILES) > $@
macros/global_macros.te renamed from tmp/policy/macros/global_macros.te +49 -74

221 lines not on this page · raw message

assert.te renamed from tmp/policy/assert.te +5 -3
diff -ru /tmp/policy/assert.te ./assert.te
@@ -111,9 +111,11 @@
 # entrypoint type and can only execute the dynamic loader
 # and the ordinary passwd program without a transition to another domain.
 #
-ifdef(`passwd.te',
-`neverallow passwd_t ~{ admin_passwd_exec_t passwd_exec_t }:file entrypoint;
-neverallow passwd_t ~{ bin_t sbin_t shell_exec_t ld_so_t passwd_real_exec_t }:file execute_no_trans;')
+ifdef(`passwd.te', `
+neverallow passwd_t ~{ passwd_exec_t }:file entrypoint;
+neverallow sysadm_passwd_t ~{ admin_passwd_exec_t }:file entrypoint;
+neverallow { passwd_t sysadm_passwd_t } ~{ bin_t sbin_t shell_exec_t ld_so_t passwd_real_exec_t }:file execute_no_trans;
+')
 
 #
 # Verify that only the admin domains and initrc_t have avc_toggle.
domains/program/groupadd.te renamed from tmp/policy/domains/program/groupadd.te +0 -60

60 lines not on this page · raw message

domains/program/passwd.te renamed from tmp/policy/domains/program/passwd.te +57 -40

125 lines not on this page · raw message

file_contexts/program/groupadd.fc renamed from tmp/policy/file_contexts/program/groupadd.fc +0 -10
diff -ru /tmp/policy/file_contexts/program/groupadd.fc ./file_contexts/program/groupadd.fc
@@ -1,10 +0,0 @@
-# groupadd
-/usr/local/selinux/bin/sgroupadd	system_u:object_r:groupadd_exec_t
-/usr/local/selinux/bin/sgroupdel	system_u:object_r:groupadd_exec_t
-/usr/local/selinux/bin/sgroupmod	system_u:object_r:groupadd_exec_t
-/usr/local/selinux/bin/sgpasswd		system_u:object_r:groupadd_exec_t
-/usr/bin/sgroupmod		system_u:object_r:groupadd_exec_t
-/usr/bin/sgroupadd               system_u:object_r:groupadd_exec_t
-/usr/bin/sgroupdel               system_u:object_r:groupadd_exec_t
-/usr/bin/sgpasswd               system_u:object_r:groupadd_exec_t
-
file_contexts/program/passwd.fc renamed from tmp/policy/file_contexts/program/passwd.fc +2 -0
diff -ru /tmp/policy/file_contexts/program/passwd.fc ./file_contexts/program/passwd.fc
@@ -3,10 +3,12 @@
 /usr/local/selinux/bin/schsh	system_u:object_r:passwd_exec_t
 /usr/local/selinux/bin/schfn	system_u:object_r:passwd_exec_t
 /usr/local/selinux/bin/svipw    system_u:object_r:admin_passwd_exec_t
+/usr/local/selinux/bin/svigr	system_u:object_r:admin_passwd_exec_t
 /usr/local/selinux/bin/sadminpasswd system_u:object_r:admin_passwd_exec_t
 /usr/bin/spasswd		system_u:object_r:passwd_exec_t
 /usr/bin/passwd			system_u:object_r:passwd_real_exec_t
 /usr/bin/schsh			system_u:object_r:passwd_exec_t
 /usr/bin/schfn			system_u:object_r:passwd_exec_t
 /usr/bin/svipw                 system_u:object_r:admin_passwd_exec_t
+/usr/bin/svigr			system_u:object_r:admin_passwd_exec_t
 /usr/bin/sadminpasswd          system_u:object_r:admin_passwd_exec_t
file_contexts/program/useradd.fc renamed from tmp/policy/file_contexts/program/useradd.fc +10 -0
diff -ru /tmp/policy/file_contexts/program/useradd.fc ./file_contexts/program/useradd.fc
@@ -5,3 +5,13 @@
 /usr/bin/susermod		system_u:object_r:useradd_exec_t
 /usr/bin/suseradd               system_u:object_r:useradd_exec_t
 /usr/bin/suserdel               system_u:object_r:useradd_exec_t
+# groupadd
+/usr/local/selinux/bin/sgroupadd	system_u:object_r:groupadd_exec_t
+/usr/local/selinux/bin/sgroupdel	system_u:object_r:groupadd_exec_t
+/usr/local/selinux/bin/sgroupmod	system_u:object_r:groupadd_exec_t
+/usr/local/selinux/bin/sgpasswd		system_u:object_r:groupadd_exec_t
+/usr/bin/sgroupmod		system_u:object_r:groupadd_exec_t
+/usr/bin/sgroupadd               system_u:object_r:groupadd_exec_t
+/usr/bin/sgroupdel               system_u:object_r:groupadd_exec_t
+/usr/bin/sgpasswd               system_u:object_r:groupadd_exec_t
+
macros/program/chkpwd_macros.te renamed from tmp/policy/macros/program/chkpwd_macros.te +3 -2
diff -ru /tmp/policy/macros/program/chkpwd_macros.te ./macros/program/chkpwd_macros.te
@@ -23,8 +23,9 @@
 # The user role is authorized for this domain.
 role $1_r types $1_chkpwd_t;
 
-# This domain is granted permissions common to most domains (includes can_net)
-every_domain($1_chkpwd_t)
+uses_shlib($1_chkpwd_t)
+allow $1_chkpwd_t self:unix_dgram_socket create_socket_perms;
+r_dir_file($1_chkpwd_t, locale_t)
 
 # Use capabilities.
 allow $1_chkpwd_t self:capability setuid;
domains/program/klogd.te renamed from tmp/policy/domains/program/klogd.te +7 -19
diff -ru /tmp/policy/domains/program/klogd.te ./domains/program/klogd.te
@@ -7,47 +7,35 @@
 #
 # Rules for the klogd_t domain.
 #
-type klogd_t, domain, privlog, privmem;
-role system_r types klogd_t;
-uses_shlib(klogd_t)
-type klogd_exec_t, file_type, sysadmfile, exec_type;
-domain_auto_trans(initrc_t, klogd_exec_t, klogd_t)
-allow klogd_t self:process { fork signal };
-
-type klogd_tmp_t, file_type, sysadmfile, tmpfile;
-file_type_auto_trans(klogd_t, tmp_t, klogd_tmp_t)
-allow klogd_t var_t:dir r_dir_perms;
-type klogd_var_run_t, file_type, sysadmfile, pidfile;
-file_type_auto_trans(klogd_t, var_run_t, klogd_var_run_t)
+daemon_domain(klogd, `, privmem')
+
+tmp_domain(klogd)
 allow klogd_t proc_t:dir r_dir_perms;
 allow klogd_t proc_t:lnk_file r_file_perms;
+allow klogd_t proc_t:file { getattr read };
 allow klogd_t self:dir r_dir_perms;
 allow klogd_t self:lnk_file r_file_perms;
 
 # read /etc/nsswitch.conf
+allow klogd_t etc_t:lnk_file read;
 allow klogd_t etc_t:file r_file_perms;
 
 # read localization information
 allow klogd_t locale_t:dir r_dir_perms;
 allow klogd_t locale_t:{file lnk_file} r_file_perms;
 
+allow klogd_t etc_runtime_t:file { getattr read };
+
 # Create unix sockets
 allow klogd_t self:unix_dgram_socket create_socket_perms;
 
 # Use the sys_admin and sys_rawio capabilities.
 allow klogd_t klogd_t:capability { sys_admin sys_rawio };
 
-# Inherit and use descriptors from init.
-allow klogd_t init_t:fd use;
-
 # Read /proc/kmsg and /dev/mem.
-allow klogd_t device_t:dir r_dir_perms;
 allow klogd_t proc_kmsg_t:file r_file_perms;
 allow klogd_t memory_device_t:chr_file r_file_perms;
 
-# Write to the console.
-allow klogd_t { initrc_devpts_t console_device_t }:chr_file rw_file_perms;
-
 # Control syslog and console logging
 allow klogd_t kernel_t:system { syslog_mod syslog_console };
 
domains/program/syslogd.te renamed from tmp/policy/domains/program/syslogd.te +10 -15
diff -ru /tmp/policy/domains/program/syslogd.te ./domains/program/syslogd.te
@@ -12,31 +12,22 @@
 # devlog_t is the type of the Unix domain socket created 
 # by syslogd.
 #
-type syslogd_t, domain;
-role system_r types syslogd_t;
-uses_shlib(syslogd_t)
-type syslogd_exec_t, file_type, sysadmfile, exec_type;
-domain_auto_trans(initrc_t, syslogd_exec_t, syslogd_t)
+daemon_domain(syslogd)
+
+# can_network is for the UDP socket
+can_network(syslogd_t)
+
 type devlog_t, file_type, sysadmfile;
-allow syslogd_t self:process { fork signal };
 
 # if something can log to syslog they should be able to log to the console
 allow privlog console_device_t:chr_file { ioctl read write getattr };
 
-type syslogd_tmp_t, file_type, sysadmfile, tmpfile;
-file_type_auto_trans(syslogd_t, tmp_t, syslogd_tmp_t)
-type syslogd_var_run_t, file_type, sysadmfile, pidfile;
-file_type_auto_trans(syslogd_t, var_run_t, syslogd_var_run_t, file)
-allow syslogd_t var_t:dir r_dir_perms;
+tmp_domain(syslogd)
 
 # read files in /etc
 allow syslogd_t etc_t:file r_file_perms;
 allow syslogd_t resolv_conf_t:{ file lnk_file } r_file_perms;
 
-# read localization information
-allow syslogd_t locale_t:dir r_dir_perms;
-allow syslogd_t locale_t:{file lnk_file} r_file_perms;
-
 # Use capabilities.
 allow syslogd_t syslogd_t:capability { net_bind_service dac_override };
 
@@ -65,3 +56,7 @@
 
 # Write to the cron log.
 allow syslogd_t cron_log_t:file rw_file_perms;
+
+ifdef(`logrotate.te', `
+allow logrotate_t syslogd_exec_t:file r_file_perms;
+')
file_contexts/program/fsadm.fc renamed from tmp/policy/file_contexts/program/fsadm.fc +2 -0
diff -ru /tmp/policy/file_contexts/program/fsadm.fc ./file_contexts/program/fsadm.fc
@@ -6,6 +6,7 @@
 /sbin/mkreiserfs		system_u:object_r:fsadm_exec_t
 /sbin/resize.*fs		system_u:object_r:fsadm_exec_t
 /sbin/e2label			system_u:object_r:fsadm_exec_t
+/sbin/findfs			system_u:object_r:fsadm_exec_t
 /sbin/mkfs			system_u:object_r:fsadm_exec_t
 /sbin/mke2fs			system_u:object_r:fsadm_exec_t
 /sbin/mkswap			system_u:object_r:fsadm_exec_t
@@ -22,6 +23,7 @@
 /sbin/mkraid			system_u:object_r:fsadm_exec_t
 /sbin/blockdev			system_u:object_r:fsadm_exec_t
 /sbin/losetup			system_u:object_r:fsadm_exec_t
+/sbin/jfs_.*			system_u:object_r:fsadm_exec_t
 /usr/sbin/updfstab		system_u:object_r:fsadm_exec_t
 /usr/sbin/smart(d|ctl)		system_u:object_r:fsadm_exec_t
 /sbin/lvmiopversion		system_u:object_r:fsadm_exec_t
file_contexts/program/postfix.fc renamed from tmp/policy/file_contexts/program/postfix.fc +1 -1
diff -ru /tmp/policy/file_contexts/program/postfix.fc ./file_contexts/program/postfix.fc
@@ -24,7 +24,7 @@
 /usr/sbin/postmap		system_u:object_r:postfix_master_exec_t
 /usr/sbin/postqueue		system_u:object_r:postfix_postqueue_exec_t
 /usr/sbin/postsuper		system_u:object_r:postfix_master_exec_t
-/usr/sbin/rmail			system_u:object_r:postfix_master_exec_t
+/usr/sbin/rmail			system_u:object_r:sendmail_exec_t
 /var/spool/postfix(/[^/]+)?	system_u:object_r:postfix_spool_t
 /var/spool/postfix/active(/.*)?	system_u:object_r:postfix_spool_t
 /var/spool/postfix/hold(/.*)?	system_u:object_r:postfix_spool_t
file_contexts/program/syslogd.fc renamed from tmp/policy/file_contexts/program/syslogd.fc +0 -1
diff -ru /tmp/policy/file_contexts/program/syslogd.fc ./file_contexts/program/syslogd.fc
@@ -5,5 +5,4 @@
 /sbin/syslog-ng			system_u:object_r:syslogd_exec_t
 /dev/log			system_u:object_r:devlog_t
 /var/run/log			system_u:object_r:devlog_t
-/var/run/klogd\.pid		system_u:object_r:klogd_var_run_t
 /var/run/syslogd\.pid		system_u:object_r:syslogd_var_run_t
macros/program/crontab_macros.te renamed from tmp/policy/macros/program/crontab_macros.te +12 -4
diff -ru /tmp/policy/macros/program/crontab_macros.te ./macros/program/crontab_macros.te
@@ -27,8 +27,11 @@
 # The user role is authorized for this domain.
 role $1_r types $1_crontab_t;
 
-# This domain is granted permissions common to most domains (including can_net)
-every_domain($1_crontab_t)
+uses_shlib($1_crontab_t)
+allow $1_crontab_t etc_t:file { getattr read };
+allow $1_crontab_t self:unix_stream_socket create_socket_perms;
+allow $1_crontab_t self:unix_dgram_socket create_socket_perms;
+r_dir_file($1_crontab_t, locale_t)
 
 # Use capabilities
 allow $1_crontab_t $1_crontab_t:capability { setuid setgid chown };
@@ -40,7 +43,9 @@
 type $1_cron_spool_t, file_type, sysadmfile;
 # Use the type when creating files in /var/spool/cron.
 allow sysadm_crontab_t $1_cron_spool_t:file { getattr read };
+allow $1_crontab_t var_spool_t:dir search;
 file_type_auto_trans($1_crontab_t, cron_spool_t, $1_cron_spool_t)
+allow $1_crontab_t self:process { fork signal_perms };
 ifdef(`fcron.te', `
 allow crond_t $1_cron_spool_t:file create_file_perms;
 # fcron wants an instant update of a crontab change for the administrator
@@ -57,7 +62,9 @@
 allow crond_t $1_cron_spool_t:file r_file_perms;
 
 # Run helper programs as $1_t
-domain_auto_trans($1_crontab_t, { bin_t sbin_t exec_type }, $1_t)
+allow $1_crontab_t { bin_t sbin_t }:dir search;
+allow $1_crontab_t bin_t:lnk_file read;
+domain_auto_trans_read($1_crontab_t, { bin_t sbin_t shell_exec_t }, $1_t)
 
 # Read user crontabs 
 allow $1_crontab_t { $1_home_t $1_home_dir_t }:dir r_dir_perms;  
@@ -69,10 +76,11 @@
 allow $1_crontab_t cron_log_t:file { append };
 
 # Access terminals.
+allow $1_crontab_t device_t:dir search;
 allow $1_crontab_t $1_tty_device_t:chr_file rw_file_perms;
 allow $1_crontab_t $1_devpts_t:chr_file rw_file_perms;
 
 # Inherit and use descriptors from gnome-pty-helper.
 ifdef(`gnome-pty-helper.te', `allow $1_crontab_t $1_gph_t:fd use;')
-
+allow $1_crontab_t privfd:fd use;
 ')
macros/program/gpg_macros.te renamed from tmp/policy/macros/program/gpg_macros.te +1 -1
diff -ru /tmp/policy/macros/program/gpg_macros.te ./macros/program/gpg_macros.te
@@ -80,6 +80,6 @@
 allow $1_gpg_t { etc_t usr_t }:dir r_dir_perms;
 allow $1_gpg_t fs_t:filesystem getattr;
 allow $1_gpg_t usr_t:file r_file_perms;
-allow $1_gpg_t etc_t:lnk_file r_file_perms;
+r_dir_file($1_gpg_t, locale_t)
 allow $1_t $1_gpg_secret_t:dir rw_dir_perms;
 ')
macros/program/gph_macros.te renamed from tmp/policy/macros/program/gph_macros.te +1 -1
diff -ru /tmp/policy/macros/program/gph_macros.te ./macros/program/gph_macros.te
@@ -34,7 +34,7 @@
 role $1_r types $1_gph_t;
 
 # This domain is granted permissions common to most domains.
-every_domain($1_gph_t)
+uses_shlib($1_gph_t)
 
 # Use capabilities.
 allow $1_gph_t $1_gph_t:capability { setuid setgid fsetid };
macros/program/irc_macros.te renamed from tmp/policy/macros/program/irc_macros.te +2 -4
diff -ru /tmp/policy/macros/program/irc_macros.te ./macros/program/irc_macros.te
@@ -36,9 +36,7 @@
 role $1_r types $1_irc_t;
 
 # Inherit and use descriptors from gnome-pty-helper.
-ifdef(`gnome-pty-helper.te',
-`allow $1_irc_t $1_gph_t:fd use;
-allow $1_t $1_gph_t:fd use;')
+ifdef(`gnome-pty-helper.te', `allow $1_irc_t $1_gph_t:fd use;')
 
 # Inherit and use descriptors from newrole.
 ifdef(`newrole.te', `allow $1_irc_t newrole_t:fd use;')
@@ -53,7 +51,7 @@
 
 uses_shlib($1_irc_t)
 allow $1_irc_t { etc_t resolv_conf_t }:file { read getattr };
-allow $1_irc_t etc_t:lnk_file read;
+r_dir_file($1_irc_t, locale_t)
 allow $1_irc_t fs_t:filesystem getattr;
 allow $1_irc_t var_t:dir search;
 allow $1_irc_t devpts_t:dir { getattr read search };
macros/program/run_program_macros.te renamed from tmp/policy/macros/program/run_program_macros.te +13 -2
diff -ru /tmp/policy/macros/program/run_program_macros.te ./macros/program/run_program_macros.te
@@ -29,6 +29,9 @@
 allow run_$3_t initrc_var_run_t:file rw_file_perms;
 allow run_$3_t admin_tty_type:chr_file rw_file_perms;
 
+dontaudit run_$3_t devpts_t:dir { getattr read };
+dontaudit run_$3_t device_t:dir read;
+
 # often the administrator runs such programs from a directory that is owned
 # by a different user or has restrictive SE permissions, do not want to audit
 # the failed access to the current directory
@@ -39,6 +42,14 @@
 
 domain_trans(run_$3_t, $4, $5)
 
-# hmm, do we REALLY need this?
-every_domain(run_$3_t)
+allow run_$3_t privfd:fd use;
+uses_shlib(run_$3_t)
+allow run_$3_t security_t:security { sid_to_context context_to_sid };
+allow run_$3_t self:unix_stream_socket create_socket_perms;
+allow run_$3_t self:unix_dgram_socket create_socket_perms;
+allow run_$3_t etc_t:file { getattr read };
+r_dir_file(run_$3_t, locale_t)
+allow run_$3_t fs_t:filesystem getattr;
+allow run_$3_t { bin_t sbin_t }:dir search;
+dontaudit run_$3_t { proc_t device_t }:dir { getattr search };
 ')
macros/program/sendmail_macros.te renamed from tmp/policy/macros/program/sendmail_macros.te +0 -3
diff -ru /tmp/policy/macros/program/sendmail_macros.te ./macros/program/sendmail_macros.te
@@ -25,9 +25,6 @@
 # Use this type when creating files in /tmp.
 file_type_auto_trans($1_mail_t, tmp_t, $1_mail_tmp_t)
 
-# Update /etc/mail/statistics.
-allow $1_mail_t etc_mail_t:file rw_file_perms;
-
 # Write to /var/spool/mail and /var/spool/mqueue.
 allow $1_mail_t mail_spool_t:dir rw_dir_perms;
 allow $1_mail_t mail_spool_t:file create_file_perms;
macros/program/ssh_macros.te renamed from tmp/policy/macros/program/ssh_macros.te +3 -0
diff -ru /tmp/policy/macros/program/ssh_macros.te ./macros/program/ssh_macros.te
@@ -111,6 +111,9 @@
 r_dir_file(sshd_t, $1_home_ssh_t)
 rw_dir_create_file($1_t, $1_home_ssh_t)
 
+# for /bin/sh used to execute xauth
+dontaudit $1_ssh_t proc_t:dir search;
+
 # Inherit and use descriptors from gnome-pty-helper.
 ifdef(`gnome-pty-helper.te', `allow $1_ssh_t $1_gph_t:fd use;')
 
macros/program/xserver_macros.te renamed from tmp/policy/macros/program/xserver_macros.te +2 -0
diff -ru /tmp/policy/macros/program/xserver_macros.te ./macros/program/xserver_macros.te
@@ -128,6 +128,8 @@
 allow $1_t $1_xserver_tmpfs_t:file rw_file_perms;
 ')
 
+r_dir_file($1_xserver_t, locale_t)
+
 # David Wheeler says he needs the following permission
 # for his X server.  Something is wrong here - the shared
 # memory pseudo file should be labeled $1_tmpfs_t and handled