## <module name="terminal" layer="kernel">
## <summary>Policy for terminals.</summary>
########################################
#
# term_make_pty(type)
#
define(`term_make_pty',`
requires_block_template(`$0'_depend)
allow $1 devpts_t:filesystem associate;
typeattribute $1 ptynode;
')
define(`term_make_pty_depend',`
attribute ptynode;
type devpts_t;
class filesystem associate;
')
########################################
## <interface name="term_make_user_pty">
## <description>
## Transform specified type into a user
## pty type. Interactive ptys will be relabeled
##
## </description>
## <parameter name="userdomain">
## An object type that will applied to a pty.
## </parameter>
## <parameter name="pty_type">
## An object type that will applied to a pty.
## </parameter>
## <infoflow type="none"/>
## </interface>
#
define(`term_make_user_pty',`
requires_block_template(`$0'_depend)
term_make_pty($1)
type_change $1 server_ptynode:chr_file $2;
')
define(`term_make_user_pty_depend',`
attribute server_ptynode;
')
########################################
## <interface name="term_make_interactive_pty">
## <description>
## Transform specified type into an interactive
## pty type. This allows it to be relabeled via
## type change by login programs such as ssh.
## </description>
## <parameter name="object_type">
## An object type that will applied to a pty.
## </parameter>
## <infoflow type="none"/>
## </interface>
#
define(`term_make_interactive_pty',`
requires_block_template(`$0'_depend)
terminal_make_pseudoterminal($1)
typeattribute $1 server_ptynode;
')
define(`terminal_make_service_pseudoterminal_depend',`
attribute server_ptynode;
')
########################################
#
# term_make_tty(domain,type)
#
define(`term_make_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_tmpfs_associate($2)
')
')
define(`term_make_tty_depend',`
attribute ttynode;
type tty_device_t;
')
########################################
#
# term_create_pty(domain,ptytype)
#
define(`term_create_pty',`
requires_block_template(`$0'_depend)
devices_list_device_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;
')
########################################
#
# term_use_all_terminals(domain)
#
define(`term_use_all_terminals',`
requires_block_template(`$0'_depend)
devices_list_device_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_terminals_depend',`
attribute ttynode, ptynode;
type console_device_t, devpts_t, tty_device_t;
class dir r_dir_perms;
class chr_file rw_file_perms;
')
########################################
## <interface name="term_write_console">
## <description>
## Write to the console.
## </description>
## <parameter name="domain">
## The type of the process performing this action.
## </parameter>
## <infoflow type="write" weight="10"/>
## </interface>
#
define(`term_write_console',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 console_device_t:chr_file write;
')
define(`term_use_console_depend',`
type console_device_t;
class chr_file write;
')
########################################
## <interface name="term_use_console">
## <description>
## Read from and write to the console.
## </description>
## <parameter name="domain">
## The type of the process performing this action.
## </parameter>
## <infoflow type="both" weight="10"/>
## </interface>
#
define(`term_use_console',`
requires_block_template(`$0'_depend)
devices_list_device_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;
')
########################################
## <interface name="term_dontaudit_use_console">
## <description>
## Do not audit read from or write to the console.
## </description>
## <parameter name="domain">
## The type of the process performing this action.
## </parameter>
## <infoflow type="both" weight="10"/>
## </interface>
#
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 };
')
########################################
#
# term_setattr_console(domain)
#
define(`term_setattr_console',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 console_device_t:chr_file setattr;
')
define(`term_setattr_console_depend',`
type console_device_t;
class chr_file setattr;
')
########################################
#
# term_list_ptys(domain)
#
define(`term_list_ptys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 devpts_t:dir r_dir_perms;
')
define(`term_list_ptys_depend',`
type devpts_t;
class dir r_dir_perms;
')
########################################
#
# term_dontaudit_list_ptys(domain)
#
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 };
')
########################################
#
# term_use_generic_pty(domain)
#
define(`term_use_generic_pty',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 devpts_t:chr_file { read write };
')
define(`term_use_generic_pty_depend',`
type devpts_t;
class chr_file { read write };
')
########################################
#
# term_dontaudit_use_generic_pty(domain)
#
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 };
')
########################################
#
# term_use_controlling_terminal(domain)
#
define(`term_use_controlling_terminal',`
requires_block_template(`$0'_depend)
devices_list_device_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 };
')
########################################
#
# term_dontaudit_rw_ptmx(domain)
#
define(`term_dontaudit_rw_ptmx',`
requires_block_template(`$0'_depend)
dontaudit $1 ptmx_t:chr_file { getattr read write };
')
define(`term_dontaudit_rw_ptmx_depend',`
type ptmx_t;
class chr_file { getattr read write };
')
########################################
#
# term_getattr_all_ptys(domain)
#
define(`term_getattr_all_ptys',`
requires_block_template(`$0'_depend)
devices_list_device_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;
')
########################################
#
# term_use_all_private_ptys(domain)
#
define(`term_use_all_private_ptys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 devpts_t:dir r_dir_perms;
allow $1 ptynode:chr_file { getattr read write ioctl };
')
define(`term_use_all_private_ptys_depend',`
attribute ptynode;
class dir r_dir_perms;
class chr_file { getattr read write ioctl };
')
########################################
#
# term_dontaudit_use_all_private_ptys(domain)
#
define(`term_dontaudit_use_all_private_ptys',`
requires_block_template(`$0'_depend)
dontaudit $1 ptynode:chr_file { read write };
')
define(`term_dontaudit_use_all_private_ptys_depend',`
attribute ptynode;
class chr_file { read write };
')
########################################
#
# term_gettattr_unallocated_ttys(domain)
#
define(`term_gettattr_unallocated_ttys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 tty_device_t:chr_file getattr;
')
define(`term_gettattr_unallocated_ttys_depend',`
type tty_device_t;
class chr_file getattr;
')
########################################
#
# term_settattr_unallocated_ttys(domain)
#
define(`term_settattr_unallocated_ttys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 tty_device_t:chr_file setattr;
')
define(`term_settattr_unallocated_ttys_depend',`
type tty_device_t;
class chr_file setattr;
')
########################################
#
# term_relabel_unallocated_tty(domain)
#
define(`term_relabel_unallocated_tty',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 tty_device_t:chr_file { relabelfrom relabelto };
')
define(`term_relabel_unallocated_tty_depend',`
type tty_device_t;
class chr_file { relabelfrom relabelto };
')
########################################
#
# term_reset_tty_labels(domain)
#
define(`term_reset_tty_labels',`
requires_block_template(`$0'_depend)
devices_list_device_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 };
')
########################################
## <interface name="term_write_unallocated_tty">
## <description>
## Write to all unallocated ttys. Has a backchannel of
## getting all tty attributes.
## </description>
## <parameter name="domain">
## The type of the process performing this action.
## </parameter>
## <infoflow type="write" weight="10"/>
## </interface>
#
define(`term_write_general_tty',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 tty_device_t:chr_file { getattr write };
')
define(`term_write_general_tty_depend',`
type tty_device_t;
class chr_file { getattr write };
')
########################################
#
# term_use_unallocated_tty(domain)
#
define(`term_use_unallocated_tty',`
requires_block_template(`$0'_depend)
devices_list_device_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 };
')
########################################
#
# term_dontaudit_use_unallocated_tty(domain)
#
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 };
')
########################################
#
# term_getattr_all_private_ttys(domain)
#
define(`term_getattr_all_private_ttys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 ttynode:chr_file getattr;
')
define(`term_getattr_all_private_ttys_depend',`
attribute ttynode;
class chr_file getattr;
')
########################################
#
# term_setattr_all_private_ttys(domain)
#
define(`term_setattr_all_private_ttys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 ttynode:chr_file setattr;
')
define(`term_setattr_all_private_ttys_depend',`
attribute ttynode;
class chr_file setattr;
')
########################################
#
# term_dontaudit_getattr_all_private_ttys(domain)
#
define(`term_dontaudit_getattr_all_private_ttys',`
requires_block_template(`$0'_depend)
dontaudit $1 ttynode:chr_file getattr;
')
define(`term_dontaudit_getattr_all_private_ttys_depend',`
attribute ttynode;
class chr_file getattr;
')
########################################
#
# term_relabel_all_private_ttys(domain)
#
define(`term_relabel_all_private_ttys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 ttynode:chr_file { relabelfrom relabelto };
')
define(`term_relabel_all_private_ttys_depend',`
attribute ttynode;
class chr_file { relabelfrom relabelto };
')
########################################
## <interface name="term_write_all_private_ttys">
## <description>
## Write to all private ttys. Has a backchannel of
## getting all private tty attributes.
## </description>
## <parameter name="domain">
## The type of the process performing this action.
## </parameter>
## <infoflow type="write" weight="10"/>
## </interface>
#
define(`term_write_all_private_ttys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 ttynode:chr_file { getattr write };
')
define(`term_write_all_private_ttys_depend',`
attribute ttynode;
class chr_file { getattr write };
')
########################################
#
# term_use_all_private_ttys(domain)
#
define(`term_use_all_private_ttys',`
requires_block_template(`$0'_depend)
devices_list_device_nodes($1)
allow $1 ttynode:chr_file { getattr read write ioctl };
')
define(`term_use_all_private_ttys_depend',`
attribute ttynode;
class chr_file { getattr read write ioctl };
')
########################################
#
# term_dontaudit_use_all_private_ttys(domain)
#
define(`term_dontaudit_use_all_private_ttys',`
requires_block_template(`$0'_depend)
dontaudit $1 ttynode:chr_file { read write };
')
define(`term_dontaudit_use_all_private_ttys_depend',`
attribute ttynode;
class chr_file { read write };
')
## </module>