selinux-policy/refpolicy/policy/modules/kernel/terminal.if

747 lines
16 KiB
Plaintext
Raw Normal View History

## <summary>Policy for terminals.</summary>
2005-04-20 19:07:16 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Transform specified type into a pty type.
## </desc>
## <param name="pty_type">
## An object type that will applied to a pty.
## </param>
#
interface(`term_pty',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ptynode;
type devpts_t;
class filesystem associate;
')
allow $1 devpts_t:filesystem associate;
typeattribute $1 ptynode;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Transform specified type into an user
## pty type. This allows it to be relabeled via
## type change by login programs such as ssh.
## </desc>
## <param name="userdomain">
## The type of the user domain associated with
## this pty.
## </param>
## <param name="object_type">
## An object type that will applied to a pty.
## </param>
#
interface(`term_user_pty',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute server_ptynode;
')
term_pty($2)
type_change $2 server_ptynode:chr_file $1;
')
2005-06-21 21:07:46 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Transform specified type into a pty type
## used by login programs, such as sshd.
## </desc>
## <param name="pty_type">
## An object type that will applied to a pty.
## </param>
2005-06-21 21:07:46 +00:00
#
interface(`term_login_pty',`
2005-06-21 21:07:46 +00:00
gen_require(`
attribute server_ptynode;
')
term_pty($1)
typeattribute $1 server_ptynode;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Transform specified type into a tty type.
## </desc>
## <param name="tty_type">
## An object type that will applied to a tty.
## </param>
#
interface(`term_tty',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
type tty_device_t;
')
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',`
2005-06-16 21:06:29 +00:00
type_change $1 ttynode:chr_file $2;
')
ifdef(`distro_redhat',`
2005-06-09 19:52:50 +00:00
fs_associate_tmpfs($2)
')
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Create a pty in the /dev/pts directory.
## </desc>
## <param name="domain">
## The type of the process creating the pty.
## </param>
## <param name="pty_type">
## The type of the pty.
## </param>
#
interface(`term_create_pty',`
2005-06-16 21:06:29 +00:00
gen_require(`
type bsdpty_device_t, devpts_t, ptmx_t;
class filesystem getattr;
class dir r_dir_perms;
class chr_file rw_file_perms;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
2005-06-08 20:28:45 +00:00
allow $1 ptmx_t:chr_file rw_file_perms;
2005-06-13 16:22:32 +00:00
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;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Read and write the console, all
## ttys and all ptys.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_use_all_terms',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode, ptynode;
type console_device_t, devpts_t, tty_device_t;
class dir r_dir_perms;
class chr_file rw_file_perms;
')
2005-06-13 16:22:32 +00:00
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;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Write to the console.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_write_console',`
2005-06-16 21:06:29 +00:00
gen_require(`
type console_device_t;
class chr_file write;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 console_device_t:chr_file write;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Read from and write to the console.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_use_console',`
2005-06-16 21:06:29 +00:00
gen_require(`
type console_device_t;
class chr_file rw_file_perms;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 console_device_t:chr_file rw_file_perms;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Do not audit attemtps to read from
## or write to the console.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_dontaudit_use_console',`
2005-06-16 21:06:29 +00:00
gen_require(`
type console_device_t;
class chr_file { read write };
')
dontaudit $1 console_device_t:chr_file { read write };
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Set the attributes of the console
## device node.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_setattr_console',`
2005-06-16 21:06:29 +00:00
gen_require(`
type console_device_t;
class chr_file setattr;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 console_device_t:chr_file setattr;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Read the /dev/pts directory to
## list all ptys.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_list_ptys',`
2005-06-16 21:06:29 +00:00
gen_require(`
type devpts_t;
class dir r_dir_perms;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 devpts_t:dir r_dir_perms;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Do not audit attempts to read the
## /dev/pts directory to.
## </desc>
## <param name="domain">
## The type of the process to not audit.
## </param>
#
interface(`term_dontaudit_list_ptys',`
2005-06-16 21:06:29 +00:00
gen_require(`
type devpts_t;
class dir { getattr search read };
')
dontaudit $1 devpts_t:dir { getattr search read };
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Read and write the generic pty
## type. This is generally only used in
## the targeted policy.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_use_generic_pty',`
2005-06-16 21:06:29 +00:00
gen_require(`
type devpts_t;
class chr_file { read write };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 devpts_t:chr_file { read write };
')
2005-04-14 20:18:17 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Dot not audit attempts to read and
## write the generic pty type. This is
## generally only used in the targeted policy.
## </desc>
## <param name="domain">
## The type of the process to not audit.
## </param>
2005-04-14 20:18:17 +00:00
#
interface(`term_dontaudit_use_generic_pty',`
2005-06-16 20:54:18 +00:00
gen_require(`
type devpts_t;
class chr_file { read write };
')
dontaudit $1 devpts_t:chr_file { read write };
2005-04-14 20:18:17 +00:00
')
2005-04-27 21:54:39 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Read and write the controlling
## terminal (/dev/tty).
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-04-27 21:54:39 +00:00
#
interface(`term_use_controlling_term',`
2005-06-16 20:54:18 +00:00
gen_require(`
type devtty_t;
class chr_file { getattr read write ioctl };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 devtty_t:chr_file { getattr read write ioctl };
2005-04-27 21:54:39 +00:00
')
2005-04-28 15:47:50 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Do not audit attempts to read and
## write the pty multiplexor (/dev/ptmx).
## </desc>
## <param name="domain">
## The type of the process to not audit.
## </param>
2005-04-28 15:47:50 +00:00
#
interface(`term_dontaudit_use_ptmx',`
2005-06-16 21:06:29 +00:00
gen_require(`
type ptmx_t;
class chr_file { getattr read write };
')
dontaudit $1 ptmx_t:chr_file { getattr read write };
2005-04-28 15:47:50 +00:00
')
2005-04-14 20:18:17 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Get the attributes of all user
## pty device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-04-14 20:18:17 +00:00
#
interface(`term_getattr_all_user_ptys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ptynode;
class dir r_dir_perms;
class chr_file getattr;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 devpts_t:dir r_dir_perms;
allow $1 ptynode:chr_file getattr;
2005-04-14 20:18:17 +00:00
')
2005-07-15 19:18:55 +00:00
########################################
## <desc>
## Do not audit attempts to get the
## attributes of any user pty
## device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_dontaudit_getattr_all_user_ptys',`
gen_require(`
attribute ptynode;
class chr_file getattr;
')
dev_list_all_dev_nodes($1)
allow $1 devpts_t:dir r_dir_perms;
dontaudit $1 ptynode:chr_file getattr;
')
2005-07-28 20:52:55 +00:00
########################################
## <summary>
## Set the attributes of all user
## pty device nodes.
## </summary>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_setattr_all_user_ptys',`
gen_require(`
attribute ptynode;
class dir r_dir_perms;
class chr_file setattr;
')
dev_list_all_dev_nodes($1)
allow $1 devpts_t:dir r_dir_perms;
allow $1 ptynode:chr_file setattr;
')
########################################
## <summary>
## Relabel to all user ptys.
## </summary>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_relabelto_all_user_ptys',`
gen_require(`
attribute ptynode;
class chr_file relabelto;
')
allow $1 ptynode:chr_file relabelto;
')
2005-05-13 14:37:13 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Read and write all user ptys.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-05-13 14:37:13 +00:00
#
interface(`term_use_all_user_ptys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ptynode;
class dir r_dir_perms;
class chr_file { getattr read write ioctl };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 devpts_t:dir r_dir_perms;
allow $1 ptynode:chr_file { getattr read write ioctl };
2005-05-13 14:37:13 +00:00
')
2005-05-05 17:44:11 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Do not audit attempts to read any
## user ptys.
## </desc>
## <param name="domain">
## The type of the process to not audit.
## </param>
2005-05-05 17:44:11 +00:00
#
interface(`term_dontaudit_use_all_user_ptys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ptynode;
class chr_file { read write };
')
dontaudit $1 ptynode:chr_file { read write };
2005-05-05 17:44:11 +00:00
')
2005-06-21 17:01:45 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Relabel from and to all user
## user pty device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-06-21 17:01:45 +00:00
#
interface(`term_relabel_all_user_ptys',`
2005-06-21 17:01:45 +00:00
gen_require(`
attribute ptynode;
type devpts_t;
2005-06-21 17:01:45 +00:00
class chr_file { relabelfrom relabelto };
')
dev_list_all_dev_nodes($1)
allow $1 devpts_t:dir search;
2005-06-21 17:01:45 +00:00
allow $1 ptynode:chr_file { relabelfrom relabelto };
')
2005-05-13 14:37:13 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Get the attributes of all unallocated
## tty device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-05-13 14:37:13 +00:00
#
interface(`term_getattr_unallocated_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
type tty_device_t;
class chr_file getattr;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 tty_device_t:chr_file getattr;
2005-05-13 14:37:13 +00:00
')
2005-07-18 18:31:49 +00:00
########################################
## <desc>
## Do not audit attempts to get the attributes
## of all unallocated tty device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_dontaudit_getattr_unallocated_ttys',`
gen_require(`
type tty_device_t;
class chr_file getattr;
')
dontaudit $1 tty_device_t:chr_file getattr;
')
2005-05-13 14:37:13 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Set the attributes of all unallocated
## tty device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-05-13 14:37:13 +00:00
#
interface(`term_setattr_unallocated_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
type tty_device_t;
class chr_file setattr;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 tty_device_t:chr_file setattr;
2005-05-13 14:37:13 +00:00
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Relabel from and to the unallocated
## tty type.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_relabel_unallocated_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
type tty_device_t;
class chr_file { relabelfrom relabelto };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 tty_device_t:chr_file { relabelfrom relabelto };
')
2005-04-14 20:18:17 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Relabel from all user tty types to
## the unallocated tty type.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-04-14 20:18:17 +00:00
#
interface(`term_reset_tty_labels',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
type tty_device_t;
class chr_file { relabelfrom relabelto };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 ttynode:chr_file relabelfrom;
allow $1 tty_device_t:chr_file relabelto;
2005-04-14 20:18:17 +00:00
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Write to unallocated ttys.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_write_unallocated_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
type tty_device_t;
class chr_file { getattr write };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 tty_device_t:chr_file { getattr write };
')
2005-04-14 20:18:17 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Read and write unallocated ttys.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_use_unallocated_tty',`
2005-06-16 21:06:29 +00:00
gen_require(`
type tty_device_t;
class chr_file { getattr read write ioctl };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 tty_device_t:chr_file { getattr read write ioctl };
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Do not audit attempts to read or
## write unallocated ttys.
## </desc>
## <param name="domain">
## The type of the process to not audit.
## </param>
#
interface(`term_dontaudit_use_unallocated_tty',`
2005-06-16 21:06:29 +00:00
gen_require(`
type tty_device_t;
class chr_file { read write };
')
dontaudit $1 tty_device_t:chr_file { read write };
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Get the attributes of all user tty
## device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_getattr_all_user_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
class chr_file getattr;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 ttynode:chr_file getattr;
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Do not audit attempts to get the
## attributes of any user tty
## device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_dontaudit_getattr_all_user_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
class chr_file getattr;
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
2005-06-09 19:52:50 +00:00
dontaudit $1 ttynode:chr_file getattr;
')
2005-04-14 20:18:17 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Set the attributes of all user tty
## device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-04-14 20:18:17 +00:00
#
interface(`term_setattr_all_user_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
class chr_file setattr;
')
2005-06-13 17:35:46 +00:00
dev_list_all_dev_nodes($1)
2005-06-09 19:52:50 +00:00
allow $1 ttynode:chr_file setattr;
2005-04-14 20:18:17 +00:00
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Relabel from and to all user
## user tty device nodes.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_relabel_all_user_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
class chr_file { relabelfrom relabelto };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 ttynode:chr_file { relabelfrom relabelto };
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Write to all user ttys.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_write_all_user_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
class chr_file { getattr write };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 ttynode:chr_file { getattr write };
')
2005-04-28 21:41:09 +00:00
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Read and write all user to all user ttys.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
2005-04-28 21:41:09 +00:00
#
interface(`term_use_all_user_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
class chr_file { getattr read write ioctl };
')
2005-06-13 16:22:32 +00:00
dev_list_all_dev_nodes($1)
allow $1 ttynode:chr_file { getattr read write ioctl };
2005-04-28 21:41:09 +00:00
')
########################################
2005-06-23 21:30:57 +00:00
## <desc>
## Do not audit attempts to read or write
## any user ttys.
## </desc>
## <param name="domain">
## The type of the process performing this action.
## </param>
#
interface(`term_dontaudit_use_all_user_ttys',`
2005-06-16 21:06:29 +00:00
gen_require(`
attribute ttynode;
class chr_file { read write };
')
dontaudit $1 ttynode:chr_file { read write };
')