## ## Policy for terminals. ######################################## ## ## ## Transform specified type into a pty type. ## ## ## An object type that will applied to a pty. ## ## # define(`term_pty',` requires_block_template(`$0'_depend) allow $1 devpts_t:filesystem associate; typeattribute $1 ptynode; ') define(`term_pty_depend',` attribute ptynode; type devpts_t; class filesystem associate; ') ######################################## ## ## ## Transform specified type into an user ## pty type. This allows it to be relabeled via ## type change by login programs such as ssh. ## ## ## The type of the user domain associated with ## this pty. ## ## ## An object type that will applied to a pty. ## ## # define(`term_user_pty',` requires_block_template(`$0'_depend) term_pty($1) type_change $1 server_ptynode:chr_file $2; ') define(`term_user_pty_depend',` attribute server_ptynode; ') ######################################## ## ## ## Transform specified type into a tty type. ## ## ## An object type that will applied to a tty. ## ## # define(`term_tty',` requires_block_template(`$0'_depend) typeattribute $2 ttynode; type_change $1 tty_device_t:chr_file $2; # Debian login is from shadow utils and does not allow resetting the perms. # have to fix this! ifdef(`distro_debian',` type_change $1 ttyfile:chr_file $2; ') ifdef(`distro_redhat',` fs_associate_tmpfs($2) ') ') define(`term_tty_depend',` attribute ttynode; type tty_device_t; ') ######################################## ## ## ## Create a pty in the /dev/pts directory. ## ## ## The type of the process creating the pty. ## ## ## The type of the pty. ## ## # define(`term_create_pty',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 ptmx_t:chr_file rw_file_perms; allow $1 devpts_t:dir r_dir_perms; allow $1 devpts_t:filesystem getattr; dontaudit $1 bsdpty_device_t:chr_file { getattr read write }; type_transition $1 devpts_t:chr_file $2; ') define(`term_create_pty_depend',` type ptmx_t, devpts_t; class filesystem getattr; class dir r_dir_perms; class chr_file rw_file_perms; ') ######################################## ## ## ## Read and write the console, all ## ttys and all ptys. ## ## ## The type of the process performing this action. ## ## # define(`term_use_all_terms',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 devpts_t:dir r_dir_perms; allow $1 { console_device_t tty_device_t ttynode ptynode }:chr_file rw_file_perms; ') define(`term_use_all_terms_depend',` attribute ttynode, ptynode; type console_device_t, devpts_t, tty_device_t; class dir r_dir_perms; class chr_file rw_file_perms; ') ######################################## ## ## ## Write to the console. ## ## ## The type of the process performing this action. ## ## # define(`term_write_console',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 console_device_t:chr_file write; ') define(`term_use_console_depend',` type console_device_t; class chr_file write; ') ######################################## ## ## ## Read from and write to the console. ## ## ## The type of the process performing this action. ## ## # define(`term_use_console',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 console_device_t:chr_file rw_file_perms; ') define(`term_use_console_depend',` type console_device_t; class chr_file rw_file_perms; ') ######################################## ## ## ## Do not audit attemtps to read from ## or write to the console. ## ## ## The type of the process performing this action. ## ## # define(`term_dontaudit_use_console',` requires_block_template(`$0'_depend) dontaudit $1 console_device_t:chr_file { read write }; ') define(`term_dontaudit_use_console_depend',` type console_device_t; class chr_file { read write }; ') ######################################## ## ## ## Set the attributes of the console ## device node. ## ## ## The type of the process performing this action. ## ## # define(`term_setattr_console',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 console_device_t:chr_file setattr; ') define(`term_setattr_console_depend',` type console_device_t; class chr_file setattr; ') ######################################## ## ## ## Read the /dev/pts directory to ## list all ptys. ## ## ## The type of the process performing this action. ## ## # define(`term_list_ptys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 devpts_t:dir r_dir_perms; ') define(`term_list_ptys_depend',` type devpts_t; class dir r_dir_perms; ') ######################################## ## ## ## Do not audit attempts to read the ## /dev/pts directory to. ## ## ## The type of the process to not audit. ## ## # define(`term_dontaudit_list_ptys',` requires_block_template(`$0'_depend) dontaudit $1 devpts_t:dir { getattr search read }; ') define(`term_dontaudit_list_ptys_depend',` type devpts_t; class dir { getattr search read }; ') ######################################## ## ## ## Read and write the generic pty ## type. This is generally only used in ## the targeted policy. ## ## ## The type of the process performing this action. ## ## # define(`term_use_generic_pty',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 devpts_t:chr_file { read write }; ') define(`term_use_generic_pty_depend',` type devpts_t; class chr_file { read write }; ') ######################################## ## ## ## Dot not audit attempts to read and ## write the generic pty type. This is ## generally only used in the targeted policy. ## ## ## The type of the process to not audit. ## ## # define(`term_dontaudit_use_generic_pty',` requires_block_template(`$0'_depend) dontaudit $1 devpts_t:chr_file { read write }; ') define(`term_dontaudit_use_generic_pty_depend',` type devpts_t; class chr_file { read write }; ') ######################################## ## ## ## Read and write the controlling ## terminal (/dev/tty). ## ## ## The type of the process performing this action. ## ## # define(`term_use_controlling_term',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 devtty_t:chr_file { getattr read write ioctl }; ') define(`term_use_controlling_terminal_depend',` type devtty_t; class chr_file { getattr read write ioctl }; ') ######################################## ## ## ## Do not audit attempts to read and ## write the pty multiplexor (/dev/ptmx). ## ## ## The type of the process to not audit. ## ## # define(`term_dontaudit_use_ptmx',` requires_block_template(`$0'_depend) dontaudit $1 ptmx_t:chr_file { getattr read write }; ') define(`term_dontaudit_use_ptmx_depend',` type ptmx_t; class chr_file { getattr read write }; ') ######################################## ## ## ## Get the attributes of all user ## pty device nodes. ## ## ## The type of the process performing this action. ## ## # define(`term_getattr_all_user_ptys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 devpts_t:dir r_dir_perms; allow $1 ptynode:chr_file getattr; ') define(`term_getattr_all_ptys_depend',` attribute ptynode; class dir r_dir_perms; class chr_file getattr; ') ######################################## ## ## ## Read and write all user ptys. ## ## ## The type of the process performing this action. ## ## # define(`term_use_all_user_ptys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 devpts_t:dir r_dir_perms; allow $1 ptynode:chr_file { getattr read write ioctl }; ') define(`term_use_all_user_ptys_depend',` attribute ptynode; class dir r_dir_perms; class chr_file { getattr read write ioctl }; ') ######################################## ## ## ## Do not audit attempts to read any ## user ptys. ## ## ## The type of the process to not audit. ## ## # define(`term_dontaudit_use_all_user_ptys',` requires_block_template(`$0'_depend) dontaudit $1 ptynode:chr_file { read write }; ') define(`term_dontaudit_use_all_user_ptys_depend',` attribute ptynode; class chr_file { read write }; ') ######################################## ## ## ## Get the attributes of all unallocated ## tty device nodes. ## ## ## The type of the process performing this action. ## ## # define(`term_getattr_unallocated_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 tty_device_t:chr_file getattr; ') define(`term_getattr_unallocated_ttys_depend',` type tty_device_t; class chr_file getattr; ') ######################################## ## ## ## Set the attributes of all unallocated ## tty device nodes. ## ## ## The type of the process performing this action. ## ## # define(`term_setattr_unallocated_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 tty_device_t:chr_file setattr; ') define(`term_setattr_unallocated_ttys_depend',` type tty_device_t; class chr_file setattr; ') ######################################## ## ## ## Relabel from and to the unallocated ## tty type. ## ## ## The type of the process performing this action. ## ## # define(`term_relabel_unallocated_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 tty_device_t:chr_file { relabelfrom relabelto }; ') define(`term_relabel_unallocated_ttys_depend',` type tty_device_t; class chr_file { relabelfrom relabelto }; ') ######################################## ## ## ## Relabel from all user tty types to ## the unallocated tty type. ## ## ## The type of the process performing this action. ## ## # define(`term_reset_tty_labels',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 ttynode:chr_file relabelfrom; allow $1 tty_device_t:chr_file relabelto; ') define(`term_reset_tty_labels_depend',` attribute ttynode; type tty_device_t; class chr_file { relabelfrom relabelto }; ') ######################################## ## ## ## Write to unallocated ttys. ## ## ## The type of the process performing this action. ## ## # define(`term_write_unallocated_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 tty_device_t:chr_file { getattr write }; ') define(`term_write_unallocated_ttys_depend',` type tty_device_t; class chr_file { getattr write }; ') ######################################## ## ## ## Read and write unallocated ttys. ## ## ## The type of the process performing this action. ## ## # define(`term_use_unallocated_tty',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 tty_device_t:chr_file { getattr read write ioctl }; ') define(`term_use_unallocated_tty_depend',` type tty_device_t; class chr_file { getattr read write ioctl }; ') ######################################## ## ## ## Do not audit attempts to read or ## write unallocated ttys. ## ## ## The type of the process to not audit. ## ## # define(`term_dontaudit_use_unallocated_tty',` requires_block_template(`$0'_depend) dontaudit $1 tty_device_t:chr_file { read write }; ') define(`term_dontaudit_use_unallocated_tty_depend',` type tty_device_t; class chr_file { read write }; ') ######################################## ## ## ## Get the attributes of all user tty ## device nodes. ## ## ## The type of the process performing this action. ## ## # define(`term_getattr_all_user_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 ttynode:chr_file getattr; ') define(`term_getattr_all_user_ttys_depend',` attribute ttynode; class chr_file getattr; ') ######################################## ## ## ## Do not audit attempts to get the ## attributes of any user tty ## device nodes. ## ## ## The type of the process performing this action. ## ## # define(`term_dontaudit_getattr_all_user_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) dontaudit $1 ttynode:chr_file getattr; ') define(`term_dontaudit_getattr_all_user_ttys_depend',` attribute ttynode; class chr_file getattr; ') ######################################## ## ## ## Set the attributes of all user tty ## device nodes. ## ## ## The type of the process performing this action. ## ## # define(`term_setattr_all_user_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 ttynode:chr_file setattr; ') define(`term_setattr_all_user_ttys_depend',` attribute ttynode; class chr_file setattr; ') ######################################## ## ## ## Relabel from and to all user ## user tty device nodes. ## ## ## The type of the process performing this action. ## ## # define(`term_relabel_all_user_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 ttynode:chr_file { relabelfrom relabelto }; ') define(`term_relabel_all_user_ttys_depend',` attribute ttynode; class chr_file { relabelfrom relabelto }; ') ######################################## ## ## ## Write to all user ttys. ## ## ## The type of the process performing this action. ## ## # define(`term_write_all_user_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 ttynode:chr_file { getattr write }; ') define(`term_write_all_user_ttys_depend',` attribute ttynode; class chr_file { getattr write }; ') ######################################## ## ## ## Read and write all user to all user ttys. ## ## ## The type of the process performing this action. ## ## # define(`term_use_all_user_ttys',` requires_block_template(`$0'_depend) dev_list_all_dev_nodes($1) allow $1 ttynode:chr_file { getattr read write ioctl }; ') define(`term_use_all_user_ttys_depend',` attribute ttynode; class chr_file { getattr read write ioctl }; ') ######################################## ## ## ## Do not audit attempts to read or write ## any user ttys. ## ## ## The type of the process performing this action. ## ## # define(`term_dontaudit_use_all_user_ttys',` requires_block_template(`$0'_depend) dontaudit $1 ttynode:chr_file { read write }; ') define(`term_dontaudit_use_all_user_ttys_depend',` attribute ttynode; class chr_file { read write }; ') ##