Skip to contentSkip to conversation

run_init

PATCH Russell Coker 2 participants 4 messages Oct 26, 2002 – Oct 29, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

I have attached the source to a modified version of run_init that runs another process (in initrc_t) to actually run the daemon.

initrc_t is allowed to write to the sysadm terminal, and I've changed my policy to allow all daemons rw_file_perms access to initrc_devpts_t.

I've gone through the policy for all the daemons and removed any instances (even commented ones) of direct daemon access to the administrator terminal.

I also noticed a minor error related to devfs pty's. I have now made the pty allocation macro include filesystem getattr access. I would have done that before if I knew it was the openpty() library call that was doing it.

I have attached the policy patch to this message. Steve, I encourage you to apply this patch to the CVS now. It does what you want the policy to do. We can probably have a discussion about the best way of implementing the openpty() code (and my code at the moment is a bit messy). But regardless of how we might decide to change it, it'll at most require something like a 2 line policy patch.

Also the policy patch applies on top of my previous patch.

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

Only in /tmp/policy/domains: admin

domains/program/apache.te renamed from tmp/policy/domains/program/apache.te +2 -13
diff -ru /tmp/policy/domains/program/apache.te ./domains/program/apache.te
@@ -365,17 +365,6 @@
 allow httpd_t httpd_user_script_rw_t:file r_file_perms;
 allow httpd_t httpd_user_script_rw_t:dir r_dir_perms;
 
-########################################
-# When the admin starts the server, the server wants to acess
-# the TTY or PTY associated with the session. The httpd appears
-# to run correctly without this permission, so the permission
-# are commented out here. If you decide that access is needed,
-# then uncomment, but be aware that this will grant httpd access
-# to all sysadm_r TTYs and PTYs.
-##################################################
-#allow httpd_t admin_tty_type:chr_file write;
-dontaudit httpd_t admin_tty_type:chr_file { read write };
-
 ###########################
 # Allow httpd to receive messages from the network card
 ########################################
@@ -399,12 +388,12 @@
 #################################################
 # Allow the httpd_t to read the web servers config files
 ###################################################
-allow httpd_t httpd_config_t:file r_file_perms;
-allow httpd_t httpd_config_t:dir r_dir_perms;
+r_dir_file(httpd_t, httpd_config_t)
 # allow logrotate to read the config files for restart
 ifdef(`logrotate.te', `
 r_dir_file(logrotate_t, httpd_config_t)
 ')
+r_dir_file(initrc_t, httpd_config_t)
 ##################################################
 
 ##################################################
domains/program/courier.te renamed from tmp/policy/domains/program/courier.te +0 -3
diff -ru /tmp/policy/domains/program/courier.te ./domains/program/courier.te
@@ -112,9 +112,6 @@
 # for calendaring
 courier_domain(pcp)
 
-# courier pcpd will not start (from an admin shell) without this!
-#allow courier_pcp_t admin_tty_type:chr_file { read write };
-
 allow courier_pcp_t self:capability { setuid setgid };
 allow courier_pcp_t random_device_t:chr_file r_file_perms;
 
domains/program/devfsd.te renamed from tmp/policy/domains/program/devfsd.te +0 -1
diff -ru /tmp/policy/domains/program/devfsd.te ./domains/program/devfsd.te
@@ -19,7 +19,6 @@
 allow devfsd_t proc_t:dir r_dir_perms;
 allow devfsd_t { etc_t etc_runtime_t proc_t }:file r_file_perms;
 allow devfsd_t devtty_t:chr_file rw_file_perms;
-#allow devfsd_t admin_tty_type:chr_file { read write };
 
 # Run /sbin/modprobe
 allow devfsd_t sbin_t:dir r_dir_perms;
domains/program/dpkg.te renamed from tmp/policy/domains/program/dpkg.te +4 -0
diff -ru /tmp/policy/domains/program/dpkg.te ./domains/program/dpkg.te
@@ -109,6 +109,10 @@
 # daemons are started in the correct context
 domain_auto_trans(dpkg_t, etc_t, initrc_t)
 
+# allow dpkg to run open_init_pty
+can_create_other_pty(dpkg, initrc)
+can_exec(dpkg_t, initrc_exec_t)
+
 ifdef(`bootloader.te',
 `domain_auto_trans(dpkg_t, bootloader_exec_t, bootloader_t)')
 
domains/program/initrc.te renamed from tmp/policy/domains/program/initrc.te +4 -1
diff -ru /tmp/policy/domains/program/initrc.te ./domains/program/initrc.te
@@ -19,6 +19,9 @@
 every_domain(initrc_t)
 type initrc_exec_t, file_type, sysadmfile, exec_type;
 
+# Can create ptys for open_init_pty
+can_create_pty(initrc)
+
 type initrc_tmp_t, file_type, sysadmfile, tmpfile;
 file_type_auto_trans(initrc_t, tmp_t, initrc_tmp_t)
 
@@ -227,4 +230,4 @@
 #
 # Rules for the run_init_t domain.
 #
-run_program(sysadm_t, sysadm_r, init, etc_t, initrc_t)
+run_program(sysadm_t, sysadm_r, init, initrc_exec_t, initrc_t)
domains/program/ircd.te renamed from tmp/policy/domains/program/ircd.te +0 -2
diff -ru /tmp/policy/domains/program/ircd.te ./domains/program/ircd.te
@@ -21,8 +21,6 @@
 type var_lib_ircd_t, sysadmfile, file_type;
 file_type_auto_trans(ircd_t, var_lib_t, var_lib_ircd_t)
 
-#allow ircd_t admin_tty_type:chr_file rw_file_perms;
-
 # Use the network.
 can_network(ircd_t)
 #allow ircd_t self:fifo_file { read write };
domains/program/named.te renamed from tmp/policy/domains/program/named.te +0 -3
diff -ru /tmp/policy/domains/program/named.te ./domains/program/named.te
@@ -17,9 +17,6 @@
 type ndc_t, domain, privlog;
 role sysadm_r types ndc_t;
 
-# named will not start (from an admin shell) without this!
-#allow named_t admin_tty_type:chr_file { read write };
-
 can_exec(named_t, named_exec_t)
 allow named_t sbin_t:dir search;
 
domains/program/postfix.te renamed from tmp/policy/domains/program/postfix.te +0 -2
diff -ru /tmp/policy/domains/program/postfix.te ./domains/program/postfix.te
@@ -90,8 +90,6 @@
 create_dir_file(postfix_master_t, postfix_spool_flush_t)
 allow postfix_master_t random_device_t:chr_file { read getattr };
 allow postfix_master_t postfix_prng_t:file rw_file_perms;
-# should not need read, getattr does not matter
-allow postfix_master_t admin_tty_type:chr_file { getattr read write };
 
 # allow access to deferred queue
 allow postfix_master_t postfix_spool_t:dir create_dir_perms;
domains/program/postgresql.te renamed from tmp/policy/domains/program/postgresql.te +0 -3
diff -ru /tmp/policy/domains/program/postgresql.te ./domains/program/postgresql.te
@@ -11,9 +11,6 @@
 #
 daemon_domain(postgresql)
 
-# postgresql will not start (from an admin shell) without this!
-#allow postgresql_t admin_tty_type:chr_file { read write };
-
 ifdef(`dpkg.te', `
 # gross hack
 domain_auto_trans(dpkg_t, postgresql_exec_t, postgresql_t)
domains/program/radvd.te renamed from tmp/policy/domains/program/radvd.te +0 -2
diff -ru /tmp/policy/domains/program/radvd.te ./domains/program/radvd.te
@@ -14,8 +14,6 @@
 allow radvd_t self:{ rawip_socket unix_dgram_socket } rw_socket_perms;
 allow radvd_t self:{ rawip_socket } recvfrom;
 
-#allow radvd_t admin_tty_type:chr_file { read write };
-
 allow radvd_t self:capability { net_raw };
 allow radvd_t self:{ unix_dgram_socket rawip_socket } create;
 allow radvd_t self:unix_stream_socket create_socket_perms;
domains/program/rlogind.te renamed from tmp/policy/domains/program/rlogind.te +0 -4
diff -ru /tmp/policy/domains/program/rlogind.te ./domains/program/rlogind.te
@@ -45,7 +45,3 @@
 
 # Modify /var/log/wtmp.
 allow rlogind_t wtmp_t:file rw_file_perms;
-
-ifdef(`devfsd.te', `
-allow rlogind_t device_t:filesystem getattr;
-')
domains/program/slapd.te renamed from tmp/policy/domains/program/slapd.te +0 -3
diff -ru /tmp/policy/domains/program/slapd.te ./domains/program/slapd.te
@@ -18,9 +18,6 @@
 type slapd_db_t, file_type, sysadmfile;
 type slapd_replog_t, file_type, sysadmfile;
 
-# slapd will not start (from an admin shell) without this!
-#allow slapd_t admin_tty_type:chr_file { read write };
-
 tmp_domain(slapd)
 
 # Use the network.
domains/program/ssh.te renamed from tmp/policy/domains/program/ssh.te +0 -7
diff -ru /tmp/policy/domains/program/ssh.te ./domains/program/ssh.te
@@ -36,10 +36,6 @@
 # Determine the set of legal user SIDs that can be reached.
 allow $1 security_t:security get_user_sids;
 
-ifdef(`devfsd.te', `
-allow $1 device_t:filesystem getattr;
-')
-
 ')dnl end sshd_program_domain
 
 #################################
@@ -69,9 +65,6 @@
 # Inherit and use descriptors from init.
 allow sshd_t init_t:fd use;
 
-# for startup error messages
-#allow sshd_t admin_tty_type:chr_file { read write };
-
 # Can create ptys
 can_create_pty(sshd)
 
domains/program/transproxy.te renamed from tmp/policy/domains/program/transproxy.te +0 -1
diff -ru /tmp/policy/domains/program/transproxy.te ./domains/program/transproxy.te
@@ -16,7 +16,6 @@
 # Use the network.
 can_network(transproxy_t)
 allow transproxy_t transproxy_port_t:tcp_socket name_bind;
-#allow transproxy_t admin_tty_type:chr_file { read write };
 
 #allow transproxy_t self:fifo_file { read write };
 allow transproxy_t self:unix_stream_socket create_socket_perms;
file_contexts/program/initrc.fc renamed from tmp/policy/file_contexts/program/initrc.fc +1 -0
diff -ru /tmp/policy/file_contexts/program/initrc.fc ./file_contexts/program/initrc.fc
@@ -9,3 +9,4 @@
 # run_init
 /usr/local/selinux/sbin/run_init	system_u:object_r:run_init_exec_t
 /usr/sbin/run_init		system_u:object_r:run_init_exec_t
+/usr/sbin/open_init_pty		system_u:object_r:initrc_exec_t
macros/global_macros.te renamed from tmp/policy/macros/global_macros.te +11 -0
diff -ru /tmp/policy/macros/global_macros.te ./macros/global_macros.te
@@ -530,6 +530,11 @@
 
 # Read and write my pty files.
 allow $1_t $1_devpts_t:chr_file { setattr rw_file_perms };
+
+ifdef(`devfsd.te', `
+allow $1_t device_t:filesystem getattr;
+')
+
 ')
 
 
@@ -549,6 +554,11 @@
 
 # Read and write pty files.
 allow $1_t $2_devpts_t:chr_file { setattr rw_file_perms };
+
+ifdef(`devfsd.te', `
+allow $1_t device_t:filesystem getattr;
+')
+
 ')
 
 
@@ -930,6 +940,7 @@
 allow $1_t device_t:dir { getattr search };
 allow $1_t null_device_t:chr_file rw_file_perms;
 allow $1_t console_device_t:chr_file rw_file_perms;
+allow $1_t initrc_devpts_t:chr_file rw_file_perms;
 ')dnl
 
 define(`daemon_domain', `
macros/user_macros.te renamed from tmp/policy/macros/user_macros.te +0 -4
diff -ru /tmp/policy/macros/user_macros.te ./macros/user_macros.te
@@ -40,10 +40,6 @@
 # Bind to a Unix domain socket in /tmp.
 allow $1_t $1_tmp_t:unix_stream_socket name_bind;
 
-ifdef(`devfsd.te', `
-allow $1_t device_t:filesystem getattr;
-')
-
 # Type for tty devices.
 type $1_tty_device_t, file_type, sysadmfile, ttyfile;
 # Access ttys.
#1 lore raw
Quoted 8 lines · Russell Coker

I have attached the policy patch to this message. Steve, I encourage you to apply this patch to the CVS now. It does what you want the policy to do. We can probably have a discussion about the best way of implementing the openpty() code (and my code at the moment is a bit messy). But regardless of how we might decide to change it, it'll at most require something like a 2 line policy patch.

Also the policy patch applies on top of my previous patch.

I've merged the policy patch but I have not yet merged the modified run_init program (no harm caused by the policy changes) pending further review. It might be preferable to not change SIDs until you execute the init script from open_init_pty (i.e. run_init does a normal exec of open_init_pty or open_init_pty is directly folded into run_init), and have the pty labeled run_init_devpts_t. That would make it clearer that you are only granting the daemons the ability to access a pty created by run_init, not any arbitrary pty that happens to be created by an initrc_t process.

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

#2 lore raw
Quoted 6 lines · Stephen Smalley

I've merged the policy patch but I have not yet merged the modified run_init program (no harm caused by the policy changes) pending further review. It might be preferable to not change SIDs until you execute the init script from open_init_pty (i.e. run_init does a normal exec of open_init_pty or open_init_pty is directly folded into run_init), and have the pty labeled run_init_devpts_t.

I've attached the latest open_init_pty that I'm using. I decided to use this when I realised that I need input so I can also use run_init for running the Debian package management tools (and for some of the lamer daemons). I also need basic terminal control (^C etc). So that means quite a bit more coding than I did for my first cut of open_init_pty.

So because of this I decided to use a program that already exists to open pseudo-tty's and run programs - expect!

We can always change this decision later if we want. But at the moment I've got better things to do than write what is basically a cut-down version of expect.

So with this current setup we are forced to have two programs, run_init and the program to open the pty.

As for your point about not using initrc_t for this, that would be easy to do and is worth doing. We can easily change this with sed later on, if you'd like to pick a name and run sed on the policy tree that would be fine. I'm not going to do this right now as I've got a bunch of little niggly issues with the current policy (when you make a change of this scale lots of little things will need to be changed). I'll probably be tweaking this for another few weeks, but that will not be greatly impacted by any such name change you make.

I have attached two patches to this message, one for pty issues and one for a bunch of other little things.

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

#!/usr/bin/expect

eval spawn -noecho $argv
interact

domains/program/bootloader.te renamed from tmp/policy/domains/program/bootloader.te +1 -2
diff -ru /tmp/policy/domains/program/bootloader.te policy/domains/program/bootloader.te
@@ -78,8 +78,7 @@
 allow bootloader_t etc_runtime_t:file r_file_perms;
 
 allow bootloader_t devtty_t:chr_file rw_file_perms;
-allow bootloader_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow bootloader_t sysadm_devpts_t:chr_file rw_file_perms;
+allow bootloader_t admin_tty_type:chr_file rw_file_perms;
 
 ifdef(`dpkg.te', `
 # for making an initrd
domains/program/cardmgr.te renamed from tmp/policy/domains/program/cardmgr.te +3 -4
diff -ru /tmp/policy/domains/program/cardmgr.te policy/domains/program/cardmgr.te
@@ -26,16 +26,15 @@
 # for /etc/resolv.conf
 file_type_auto_trans(cardmgr_t, etc_t, resolv_conf_t)
 
-# allow cardmgr to write to the sysadm terminal (otherwise it will not start)
-allow cardmgr_t { sysadm_tty_device_t sysadm_devpts_t }:chr_file { read write };
+allow cardmgr_t initrc_devpts_t:chr_file { read write };
 
 # Create pid file and temporary block and character device nodes
 type cardmgr_var_run_t, file_type, sysadmfile, pidfile;
 file_type_auto_trans(cardmgr_t, { var_run_t device_t }, cardmgr_var_run_t, { blk_file chr_file file })
 
-# Create stab file.
+# Create stab file and device nodes.
 type cardmgr_var_lib_t, file_type, sysadmfile;
-file_type_auto_trans(cardmgr_t, var_lib_t, cardmgr_var_lib_t)
+file_type_auto_trans(cardmgr_t, var_lib_t, cardmgr_var_lib_t, { blk_file chr_file file })
 
 # Create device files in /tmp.
 type cardmgr_dev_t, file_type, sysadmfile, tmpfile;
domains/program/checkpolicy.te renamed from tmp/policy/domains/program/checkpolicy.te +1 -2
diff -ru /tmp/policy/domains/program/checkpolicy.te policy/domains/program/checkpolicy.te
@@ -44,8 +44,7 @@
 `allow checkpolicy_t sshd_devpts_t:dir r_dir_perms;')
 
 # Other access
-allow checkpolicy_t sysadm_tty_device_t:chr_file { read write ioctl getattr };
-allow checkpolicy_t sysadm_devpts_t:chr_file { read write ioctl getattr };
+allow checkpolicy_t admin_tty_type:chr_file { read write ioctl getattr };
 uses_shlib(checkpolicy_t)
 allow checkpolicy_t self:capability dac_override;
 
domains/program/dpkg.te renamed from tmp/policy/domains/program/dpkg.te +6 -8
diff -ru /tmp/policy/domains/program/dpkg.te policy/domains/program/dpkg.te
@@ -109,10 +109,6 @@
 # daemons are started in the correct context
 domain_auto_trans(dpkg_t, etc_t, initrc_t)
 
-# allow dpkg to run open_init_pty
-can_create_other_pty(dpkg, initrc)
-can_exec(dpkg_t, initrc_exec_t)
-
 ifdef(`bootloader.te',
 `domain_auto_trans(dpkg_t, bootloader_exec_t, bootloader_t)')
 
@@ -134,9 +130,9 @@
 can_exec(sysadm_t, etc_dpkg_t)
 
 # Inherit and use descriptors from any domain.
-allow { apt_t dpkg_t } privfd:fd use;
+allow { apt_t dpkg_t install_menu_t } initrc_t: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 { apt_t dpkg_t install_menu_t } initrc_devpts_t:chr_file rw_file_perms;
 
 allow ifconfig_t dpkg_t:fd use;
 allow ifconfig_t dpkg_t:fifo_file { read write };
@@ -271,5 +267,7 @@
 #
 # Rules for the run_deb_t domain.
 #
-run_program(sysadm_t, sysadm_r, deb, dpkg_exec_t, dpkg_t)
-domain_trans(run_deb_t, apt_exec_t, apt_t)
+#run_program(sysadm_t, sysadm_r, deb, dpkg_exec_t, dpkg_t)
+#domain_trans(run_deb_t, apt_exec_t, apt_t)
+domain_auto_trans(initrc_t, dpkg_exec_t, dpkg_t)
+domain_auto_trans(initrc_t, apt_exec_t, apt_t)
domains/program/fsadm.te renamed from tmp/policy/domains/program/fsadm.te +1 -2
diff -ru /tmp/policy/domains/program/fsadm.te policy/domains/program/fsadm.te
@@ -63,6 +63,5 @@
 can_exec_any(fsadm_t)
 
 # Access terminals.
-allow fsadm_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow fsadm_t sysadm_devpts_t:chr_file rw_file_perms;
+allow fsadm_t admin_tty_type:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow fsadm_t sysadm_gph_t:fd use;')
domains/program/ifconfig.te renamed from tmp/policy/domains/program/ifconfig.te +1 -2
diff -ru /tmp/policy/domains/program/ifconfig.te policy/domains/program/ifconfig.te
@@ -32,6 +32,5 @@
 allow ifconfig_t pump_t:fd use;')
 
 # Access terminals.
-allow ifconfig_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow ifconfig_t sysadm_devpts_t:chr_file rw_file_perms;
+allow ifconfig_t { initrc_devpts_t admin_tty_type }:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow ifconfig_t sysadm_gph_t:fd use;')
domains/program/initrc.te renamed from tmp/policy/domains/program/initrc.te +1 -2
diff -ru /tmp/policy/domains/program/initrc.te policy/domains/program/initrc.te
@@ -180,8 +180,7 @@
 # Allow access to the sysadm TTYs. Note that this will give access to the 
 # TTYs to any process in the initrc_t domain. Therefore, daemons and such
 # started from init should be placed in their own domain.
-allow initrc_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow initrc_t sysadm_devpts_t:chr_file rw_file_perms;
+allow initrc_t admin_tty_type:chr_file rw_file_perms;
 
 # Access sound device and files.
 allow initrc_t sound_device_t:chr_file { setattr ioctl read write };
domains/program/ipchains.te renamed from tmp/policy/domains/program/ipchains.te +1 -2
diff -ru /tmp/policy/domains/program/ipchains.te policy/domains/program/ipchains.te
@@ -31,6 +31,5 @@
 allow ipchains_t ipchains_t:rawip_socket create_socket_perms;
 
 # Access terminals.
-allow ipchains_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow ipchains_t sysadm_devpts_t:chr_file rw_file_perms;
+allow ipchains_t admin_tty_type:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow ipchains_t sysadm_gph_t:fd use;')
domains/program/ipsec.te renamed from tmp/policy/domains/program/ipsec.te +3 -3
diff -ru /tmp/policy/domains/program/ipsec.te policy/domains/program/ipsec.te
@@ -195,11 +196,11 @@
 allow ipsec_mgmt_t ipsec_mgmt_t:udp_socket { create ioctl };
 
 #When running ipsec auto --up <conname>
-allow ipsec_t self:process fork;
+allow ipsec_t self:process { fork sigchld };
 allow ipsec_t self:fifo_file { read getattr };
 
 # ideally it would not need this.  It wants to write to /root/.rnd
 file_type_auto_trans(ipsec_mgmt_t, sysadm_home_dir_t, sysadm_home_t, file)
 
-allow ipsec_mgmt_t { sysadm_tty_device_t sysadm_devpts_t }:chr_file { getattr read write ioctl };
-allow ipsec_t { sysadm_tty_device_t sysadm_devpts_t }:chr_file { getattr read write };
+allow ipsec_mgmt_t { initrc_devpts_t admin_tty_type }:chr_file { getattr read write ioctl };
+allow ipsec_t initrc_devpts_t:chr_file { getattr read write };
domains/program/klogd.te renamed from tmp/policy/domains/program/klogd.te +1 -1
diff -ru /tmp/policy/domains/program/klogd.te policy/domains/program/klogd.te
@@ -29,7 +29,7 @@
 allow klogd_t memory_device_t:chr_file r_file_perms;
 
 # Write to the console.
-allow klogd_t console_device_t:chr_file rw_file_perms;
+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/ldconfig.te renamed from tmp/policy/domains/program/ldconfig.te +1 -1
diff -ru /tmp/policy/domains/program/ldconfig.te policy/domains/program/ldconfig.te
@@ -14,7 +14,7 @@
 
 domain_auto_trans({ sysadm_t initrc_t ifdef(`dpkg.te', `dpkg_t') }, ldconfig_exec_t, ldconfig_t)
 dontaudit ldconfig_t device_t:dir search;
-allow ldconfig_t admin_tty_type:chr_file rw_file_perms;
+allow ldconfig_t { initrc_devpts_t admin_tty_type }:chr_file rw_file_perms;
 allow ldconfig_t privfd:fd use;
 
 uses_shlib(ldconfig_t)
domains/program/load_policy.te renamed from tmp/policy/domains/program/load_policy.te +2 -5
diff -ru /tmp/policy/domains/program/load_policy.te policy/domains/program/load_policy.te
@@ -41,14 +41,11 @@
 
 # Read the devpts root directory (needed?)  
 allow load_policy_t devpts_t:dir r_dir_perms;
-ifdef(`sshd.te',
-`allow load_policy_t sshd_devpts_t:dir r_dir_perms;')
 
 # Other access
-allow load_policy_t sysadm_tty_device_t:chr_file { read write ioctl getattr };
-allow load_policy_t sysadm_devpts_t:chr_file { read write ioctl getattr };
+allow load_policy_t { initrc_devpts_t admin_tty_type }:chr_file { read write ioctl getattr };
 uses_shlib(load_policy_t)
 allow load_policy_t self:capability dac_override;
 
-allow load_policy_t privfd:fd use;
+allow load_policy_t { initrc_t privfd }:fd use;
 
domains/program/logrotate.te renamed from tmp/policy/domains/program/logrotate.te +1 -2
diff -ru /tmp/policy/domains/program/logrotate.te policy/domains/program/logrotate.te
@@ -72,8 +72,7 @@
 allow logrotate_t var_spool_t:file { rename create setattr unlink };
 
 # Access terminals.
-allow logrotate_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow logrotate_t sysadm_devpts_t:chr_file rw_file_perms;
+allow logrotate_t admin_tty_type:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow logrotate_t sysadm_gph_t:fd use;')
 
 # for /var/backups on Debian
domains/program/modutil.te renamed from tmp/policy/domains/program/modutil.te +3 -4
diff -ru /tmp/policy/domains/program/modutil.te policy/domains/program/modutil.te
@@ -38,8 +38,7 @@
 allow depmod_t modules_object_t:{ file lnk_file } r_file_perms;
 
 # Access terminals.
-allow depmod_t { console_device_t sysadm_tty_device_t }:chr_file rw_file_perms;
-allow depmod_t sysadm_devpts_t:chr_file rw_file_perms;
+allow depmod_t { console_device_t initrc_devpts_t admin_tty_type }:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow depmod_t sysadm_gph_t:fd use;')
 
 # Read System.map from home directories.
@@ -93,7 +92,7 @@
 allow insmod_t ipsec_t:process signal;')
 
 # Access terminals.
-allow insmod_t { sysadm_tty_device_t sysadm_devpts_t }:chr_file rw_file_perms;
+allow insmod_t { initrc_devpts_t admin_tty_type }:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow insmod_t sysadm_gph_t:fd use;')
 
 uses_shlib(insmod_t)
@@ -114,7 +113,7 @@
 
 allow update_modules_t device_t:dir search;
 allow update_modules_t { console_device_t devtty_t }:chr_file rw_file_perms;
-allow update_modules_t { sysadm_tty_device_t sysadm_devpts_t }:chr_file rw_file_perms;
+allow update_modules_t { initrc_devpts_t admin_tty_type }:chr_file rw_file_perms;
 
 dontaudit update_modules_t sysadm_home_dir_t:dir search;
 
domains/program/netutils.te renamed from tmp/policy/domains/program/netutils.te +1 -2
diff -ru /tmp/policy/domains/program/netutils.te policy/domains/program/netutils.te
@@ -29,8 +29,7 @@
 allow netutils_t self:packet_socket create_socket_perms;
 
 # Access terminals.
-allow netutils_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow netutils_t sysadm_devpts_t:chr_file rw_file_perms;
+allow netutils_t admin_tty_type:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow netutils_t sysadm_gph_t:fd use;')
 
 
domains/program/ping.te renamed from tmp/policy/domains/program/ping.te +1 -2
diff -ru /tmp/policy/domains/program/ping.te policy/domains/program/ping.te
@@ -30,7 +30,6 @@
 allow ping_t ping_t:capability { net_raw setuid };
 
 # Access the terminal.
-allow ping_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow ping_t sysadm_devpts_t:chr_file rw_file_perms;
+allow ping_t admin_tty_type:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow ping_t sysadm_gph_t:fd use;')
 
domains/program/quota.te renamed from tmp/policy/domains/program/quota.te +2 -0
diff -ru /tmp/policy/domains/program/quota.te policy/domains/program/quota.te
@@ -28,3 +29,5 @@
 allow quota_t fixed_disk_device_t:blk_file getattr;
 allow quota_t boot_t:dir r_dir_perms;
 allow quota_t sysctl_t:dir search;
+
+allow quota_t initrc_devpts_t:chr_file rw_file_perms;
domains/program/setfiles.te renamed from tmp/policy/domains/program/setfiles.te +2 -2
diff -ru /tmp/policy/domains/program/setfiles.te policy/domains/program/setfiles.te
@@ -14,8 +14,8 @@
 role system_r types setfiles_t;
 role sysadm_r types setfiles_t;
 
-allow setfiles_t sysadm_tty_device_t:chr_file { read write ioctl };
-allow setfiles_t sysadm_devpts_t:chr_file { read write ioctl };
+allow setfiles_t initrc_devpts_t:chr_file { read write ioctl };
+allow setfiles_t admin_tty_type:chr_file { read write ioctl };
 
 domain_auto_trans({ initrc_t sysadm_t }, setfiles_exec_t, setfiles_t)
 allow setfiles_t init_t:fd use;
domains/program/snmpd.te renamed from tmp/policy/domains/program/snmpd.te +0 -3
diff -ru /tmp/policy/domains/program/snmpd.te policy/domains/program/snmpd.te
@@ -14,9 +14,6 @@
 
 can_network(snmpd_t)
 
-dontaudit snmpd_t { sysadm_tty_device_t sysadm_devpts_t }:chr_file { read write };
-
-
 type snmp_port_t, port_type;
 allow snmpd_t snmp_port_t:{ udp_socket tcp_socket } name_bind;
 
domains/program/syslogd.te renamed from tmp/policy/domains/program/syslogd.te +1 -1
diff -ru /tmp/policy/domains/program/syslogd.te policy/domains/program/syslogd.te
@@ -32,7 +32,7 @@
 
 # Inherit and use descriptors from init.
 allow syslogd_t init_t:fd use;
-allow syslogd_t console_device_t:chr_file { read write };
+allow syslogd_t { initrc_devpts_t console_device_t }:chr_file { read write };
 
 # Modify/create log files.
 create_append_log_file(syslogd_t, var_log_t)
domains/program/traceroute.te renamed from tmp/policy/domains/program/traceroute.te +1 -2
diff -ru /tmp/policy/domains/program/traceroute.te policy/domains/program/traceroute.te
@@ -30,7 +32,6 @@
 allow traceroute_t any_socket_t:rawip_socket sendto;
 
 # Access the terminal.
-allow traceroute_t sysadm_tty_device_t:chr_file rw_file_perms;
-allow traceroute_t sysadm_devpts_t:chr_file rw_file_perms;
+allow traceroute_t admin_tty_type:chr_file rw_file_perms;
 ifdef(`gnome-pty-helper.te', `allow traceroute_t sysadm_gph_t:fd use;')
 
file_contexts/program/dpkg.fc renamed from tmp/policy/file_contexts/program/dpkg.fc +1 -2
diff -ru /tmp/policy/file_contexts/program/dpkg.fc policy/file_contexts/program/dpkg.fc
@@ -29,6 +29,5 @@
 /etc/dpkg/.*			system_u:object_r:etc_dpkg_t
 /etc/menu-methods/.*		system_u:object_r:install_menu_exec_t
 /etc/kde2/.*\.sh		system_u:object_r:install_menu_exec_t
-# run_deb
-/usr/sbin/se_dpkg		system_u:object_r:run_deb_exec_t
+/usr/share/console/getkmapchoice.pl system_u:object_r:bin_t
 /var/run/update-menus.pid	system_u:object_r:install_menu_var_run_t
macros/program/chroot_macros.te renamed from tmp/policy/macros/program/chroot_macros.te +1 -1
diff -ru /tmp/policy/macros/program/chroot_macros.te policy/macros/program/chroot_macros.te
@@ -7,7 +7,7 @@
 
 ifelse(`$1', `initrc', `
 define(`chroot_role', `system_r')
-define(`chroot_tty_device', `{ console_device_t sysadm_devpts_t sysadm_tty_device_t }')
+define(`chroot_tty_device', `{ console_device_t admin_tty_type }')
 define(`chroot_mount_domain', `mount_t')
 define(`chroot_fd_use', `{ privfd init_t }')
 ', `
macros/program/run_program_macros.te renamed from tmp/policy/macros/program/run_program_macros.te +1 -1
diff -ru /tmp/policy/macros/program/run_program_macros.te policy/macros/program/run_program_macros.te
@@ -27,7 +27,7 @@
 
 # for utmp
 allow run_$3_t initrc_var_run_t:file rw_file_perms;
-allow run_$3_t { sysadm_devpts_t sysadm_tty_device_t }:chr_file rw_file_perms;
+allow run_$3_t admin_tty_type:chr_file rw_file_perms;
 
 # 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
domains/program/fingerd.te renamed from tmp/policy/domains/program/fingerd.te +4 -0
diff -ru /tmp/policy/domains/program/fingerd.te policy/domains/program/fingerd.te
@@ -76,3 +76,7 @@
 allow fingerd_t ptyfile:chr_file getattr;
 
 allow fingerd_t proc_t:file { read getattr };
+
+# for date command
+allow fingerd_t sysctl_kernel_t:dir search;
+allow fingerd_t sysctl_kernel_t:file { read getattr };
domains/program/ftpd.te renamed from tmp/policy/domains/program/ftpd.te +2 -0
diff -ru /tmp/policy/domains/program/ftpd.te policy/domains/program/ftpd.te
@@ -18,6 +18,8 @@
 ifdef(`inetd.te', `domain_auto_trans(inetd_t, ftpd_exec_t, ftpd_t)')
 ifdef(`tcpd.te', `domain_auto_trans(tcpd_t, ftpd_exec_t, ftpd_t)')
 
+ifdef(`crond.te', `system_crond_entry(ftpd_exec_t, ftpd_t)')
+
 # Inherit and use descriptors from inetd.
 allow ftpd_t inetd_t:fd use;
 
domains/program/ipsec.te renamed from tmp/policy/domains/program/ipsec.te +1 -0
diff -ru /tmp/policy/domains/program/ipsec.te policy/domains/program/ipsec.te
@@ -69,6 +69,7 @@
 allow ipsec_mgmt_t ipsec_mgmt_exec_t:lnk_file read;
 can_exec(ipsec_mgmt_t, shell_exec_t)
 can_exec(ipsec_t, shell_exec_t)
+can_exec(ipsec_t, ipsec_mgmt_exec_t)
 can_exec(ipsec_mgmt_t, ifconfig_exec_t)
 
 # now for a icky part...
domains/program/mysqld.te renamed from tmp/policy/domains/program/mysqld.te +1 -1
diff -ru /tmp/policy/domains/program/mysqld.te policy/domains/program/mysqld.te
@@ -37,7 +37,7 @@
 allow mysqld_t var_lib_t:dir search;
 
 # read config files
-r_dir_file(mysqld_t, etc_mysqld_t)
+r_dir_file({ mysqld_t initrc_t }, etc_mysqld_t)
 allow mysqld_t { etc_t resolv_conf_t etc_runtime_t }:{ file lnk_file } { read getattr };
 
 allow mysqld_t etc_t:dir search;
domains/program/named.te renamed from tmp/policy/domains/program/named.te +1 -0
diff -ru /tmp/policy/domains/program/named.te policy/domains/program/named.te
@@ -101,6 +101,7 @@
 allow ndc_t privfd:fd use;
 # seems to need read as well for some reason
 allow ndc_t admin_tty_type:chr_file { getattr read write };
+allow ndc_t fs_t:filesystem getattr;
 
 # Read sysctl kernel variables.
 allow ndc_t sysctl_t:dir r_dir_perms;
domains/program/postfix.te renamed from tmp/policy/domains/program/postfix.te +1 -0
diff -ru /tmp/policy/domains/program/postfix.te policy/domains/program/postfix.te
@@ -177,6 +177,7 @@
 postfix_user_domain(postqueue)
 allow postfix_postqueue_t postfix_public_t:dir search;
 allow postfix_postqueue_t postfix_public_t:fifo_file getattr;
+allow postfix_postqueue_t self:udp_socket create;
 allow postfix_master_t postfix_postqueue_exec_t:file getattr;
 
 # to write the mailq output, it really should not need read access!
domains/program/quota.te renamed from tmp/policy/domains/program/quota.te +1 -0
diff -ru /tmp/policy/domains/program/quota.te policy/domains/program/quota.te
@@ -20,6 +20,7 @@
 
 # for /quota.*
 allow quota_t quota_db_t:file { read write };
+dontaudit unpriv_userdomain quota_db_t:file getattr;
 
 # Read /etc/mtab.
 allow quota_t etc_runtime_t:file { read getattr };
domains/program/syslogd.te renamed from tmp/policy/domains/program/syslogd.te +1 -1
diff -ru /tmp/policy/domains/program/syslogd.te policy/domains/program/syslogd.te
@@ -32,7 +32,7 @@
 
 # Inherit and use descriptors from init.
 allow syslogd_t init_t:fd use;
-allow syslogd_t console_device_t:chr_file { read write };
+allow syslogd_t { initrc_devpts_t console_device_t }:chr_file { read write };
 
 # Modify/create log files.
 create_append_log_file(syslogd_t, var_log_t)
domains/program/traceroute.te renamed from tmp/policy/domains/program/traceroute.te +2 -0
diff -ru /tmp/policy/domains/program/traceroute.te policy/domains/program/traceroute.te
@@ -20,6 +20,8 @@
 domain_auto_trans(initrc_t, traceroute_exec_t, traceroute_t)
 domain_auto_trans(sysadm_t, traceroute_exec_t, traceroute_t)
 
+allow traceroute_t icmp_socket_t:rawip_socket recvfrom;
+
 # Let traceroute create raw ICMP packets.
 #allow traceroute_t traceroute_t:rawip_socket { create bind setopt getopt write read };
 
file_contexts/program/ftpd.fc renamed from tmp/policy/file_contexts/program/ftpd.fc +2 -0
diff -ru /tmp/policy/file_contexts/program/ftpd.fc policy/file_contexts/program/ftpd.fc
@@ -7,3 +7,5 @@
 /var/run/proftpd/proftpd-inetd	system_u:object_r:ftpd_var_run_t
 /var/log/muddleftpd.log.*	system_u:object_r:xferlog_t
 /var/log/xferlog.*		system_u:object_r:xferlog_t
+/var/log/xferreport.*		system_u:object_r:xferlog_t
+/etc/cron.monthly/proftpd	system_u:object_r:ftpd_exec_t
file_contexts/program/quota.fc renamed from tmp/policy/file_contexts/program/quota.fc +1 -1
diff -ru /tmp/policy/file_contexts/program/quota.fc policy/file_contexts/program/quota.fc
@@ -1,4 +1,4 @@
 # quota system
 /var/lib/quota(/.*)?		system_u:object_r:quota_flag_t
 /sbin/quota(check|on)		system_u:object_r:quota_exec_t
-/quota.(user|group)		system_u:object_r:quota_db_t
+/(|home/|var/)quota.(user|group) system_u:object_r:quota_db_t
macros/program/gpg_macros.te renamed from tmp/policy/macros/program/gpg_macros.te +2 -1
diff -ru /tmp/policy/macros/program/gpg_macros.te policy/macros/program/gpg_macros.te
@@ -57,7 +57,8 @@
 
 uses_shlib($1_gpg_t)
 
-allow $1_gpg_t home_root_t:dir search;
+# should not need read access...
+allow $1_gpg_t home_root_t:dir { read search };
 
 # use $1_gpg_secret_t for files it creates
 # NB we are doing the type transition for directory creation only!
#3 lore raw
Quoted 2 lines · Russell Coker

I have attached two patches to this message, one for pty issues and one for a bunch of other little things.

Ok, merged. I also added the open_init_pty script and merged the run_init patch with appropriate adjustments.

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