Chris PeBenito ab58ad
#DESC Login - Local/remote login utilities
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser  
Chris PeBenito ab58ad
# Macroised by Russell Coker <russell@coker.com.au>
Chris PeBenito ab58ad
# X-Debian-Packages: login
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
# Rules for the local_login_t domain
Chris PeBenito ab58ad
# and the remote_login_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# $1 is the name of the domain (local or remote)
Chris PeBenito ab58ad
define(`login_domain', `
Chris PeBenito ab58ad
type $1_login_t, domain, privuser, privrole, privlog, auth_chkpwd, privowner, privfd, nscd_client_domain, mlsfilewrite, mlsprocsetsl, mlsfileupgrade, mlsfiledowngrade;
Chris PeBenito ab58ad
role system_r types $1_login_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
dontaudit $1_login_t shadow_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
general_domain_access($1_login_t);
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read system information files in /proc.
Chris PeBenito ab58ad
r_dir_file($1_login_t, proc_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
base_file_read_access($1_login_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read directories and files with the readable_t type.
Chris PeBenito ab58ad
# This type is a general type for "world"-readable files.
Chris PeBenito ab58ad
allow $1_login_t readable_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_login_t readable_t:notdevfile_class_set r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read /var, /var/spool
Chris PeBenito ab58ad
allow $1_login_t { var_t var_spool_t }:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for when /var/mail is a sym-link
Chris PeBenito ab58ad
allow $1_login_t var_t:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read /etc.
Chris PeBenito ab58ad
r_dir_file($1_login_t, etc_t)
Chris PeBenito ab58ad
allow $1_login_t etc_runtime_t:{ file lnk_file } r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
read_locale($1_login_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for SSP/ProPolice
Chris PeBenito ab58ad
allow $1_login_t urandom_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read executable types.
Chris PeBenito ab58ad
allow $1_login_t exec_type:{ file lnk_file } r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read /dev directories and any symbolic links.
Chris PeBenito ab58ad
allow $1_login_t device_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_login_t device_t:lnk_file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
uses_shlib($1_login_t);
Chris PeBenito ab58ad
Chris PeBenito ab58ad
tmp_domain($1_login)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`pam.te', `
Chris PeBenito ab58ad
can_exec($1_login_t, pam_exec_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`pamconsole.te', `
Chris PeBenito ab58ad
rw_dir_create_file($1_login_t, pam_var_console_t)
Chris PeBenito ab58ad
domain_auto_trans($1_login_t, pam_console_exec_t, pam_console_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`alsa.te', `
Chris PeBenito ab58ad
domain_auto_trans($1_login_t, alsa_exec_t, alsa_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities
Chris PeBenito ab58ad
allow $1_login_t self:capability { dac_override chown fowner fsetid kill setgid setuid net_bind_service sys_nice sys_resource sys_tty_config };
Chris PeBenito ab58ad
allow $1_login_t self:process setrlimit;
Chris PeBenito ab58ad
dontaudit $1_login_t sysfs_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Set exec context.
Chris PeBenito ab58ad
can_setexec($1_login_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_login_t autofs_t:dir { search read getattr };
Chris PeBenito ab58ad
allow $1_login_t mnt_t:dir r_dir_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
if (use_nfs_home_dirs) {
Chris PeBenito ab58ad
r_dir_file($1_login_t, nfs_t)
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
Chris PeBenito ab58ad
if (use_samba_home_dirs) {
Chris PeBenito ab58ad
r_dir_file($1_login_t, cifs_t)
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Login can polyinstantiate
Chris PeBenito ab58ad
polyinstantiater($1_login_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# FIXME: what is this for?
Chris PeBenito ab58ad
ifdef(`xdm.te', `
Chris PeBenito ab58ad
allow xdm_t $1_login_t:process signull;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`crack.te', `
Chris PeBenito ab58ad
allow $1_login_t crack_db_t:file r_file_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permit login to search the user home directories.
Chris PeBenito ab58ad
allow $1_login_t home_root_t:dir search;
Chris PeBenito ab58ad
allow $1_login_t home_dir_type:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write to /var/run/utmp.
Chris PeBenito ab58ad
allow $1_login_t var_run_t:dir search;
Chris PeBenito ab58ad
allow $1_login_t initrc_var_run_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write to /var/log/wtmp.
Chris PeBenito ab58ad
allow $1_login_t var_log_t:dir search;
Chris PeBenito ab58ad
allow $1_login_t wtmp_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write to /var/log/lastlog.
Chris PeBenito ab58ad
allow $1_login_t lastlog_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write to /var/log/btmp
Chris PeBenito ab58ad
allow $1_login_t faillog_t:file { lock append read write };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Search for mail spool file.
Chris PeBenito ab58ad
allow $1_login_t mail_spool_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_login_t mail_spool_t:file getattr;
Chris PeBenito ab58ad
allow $1_login_t mail_spool_t:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Get security policy decisions.
Chris PeBenito ab58ad
can_getsecurity($1_login_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# allow read access to default_contexts in /etc/security
Chris PeBenito ab58ad
allow $1_login_t default_context_t:file r_file_perms;
Chris PeBenito ab58ad
allow $1_login_t default_context_t:dir search;
Chris PeBenito ab58ad
r_dir_file($1_login_t, selinux_config_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_login_t mouse_device_t:chr_file { getattr setattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`targeted_policy',`
Chris PeBenito ab58ad
unconfined_domain($1_login_t)
Chris PeBenito ab58ad
domain_auto_trans($1_login_t, shell_exec_t, unconfined_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')dnl end login_domain macro
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the local_login_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# local_login_t is the domain of a login process 
Chris PeBenito ab58ad
# spawned by getty.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# remote_login_t is the domain of a login process 
Chris PeBenito ab58ad
# spawned by rlogind.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# login_exec_t is the type of the login program
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
type login_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
login_domain(local)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# But also permit other user domains to be entered by login.
Chris PeBenito ab58ad
login_spawn_domain(local_login, userdomain)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Do not audit denied attempts to access devices.
Chris PeBenito ab58ad
dontaudit local_login_t fixed_disk_device_t:blk_file { getattr setattr };
Chris PeBenito ab58ad
dontaudit local_login_t removable_device_t:blk_file { getattr setattr };
Chris PeBenito ab58ad
dontaudit local_login_t device_t:{ chr_file blk_file lnk_file } { getattr setattr };
Chris PeBenito ab58ad
dontaudit local_login_t misc_device_t:{ chr_file blk_file } { getattr setattr };
Chris PeBenito ab58ad
dontaudit local_login_t framebuf_device_t:chr_file { getattr setattr read };
Chris PeBenito ab58ad
dontaudit local_login_t apm_bios_t:chr_file { getattr setattr };
Chris PeBenito ab58ad
dontaudit local_login_t v4l_device_t:chr_file { getattr setattr read };
Chris PeBenito ab58ad
dontaudit local_login_t removable_device_t:chr_file { getattr setattr };
Chris PeBenito ab58ad
dontaudit local_login_t scanner_device_t:chr_file { getattr setattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Do not audit denied attempts to access /mnt.
Chris PeBenito ab58ad
dontaudit local_login_t mnt_t:dir r_dir_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Create lock file.
Chris PeBenito ab58ad
lock_domain(local_login)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read and write ttys.
Chris PeBenito ab58ad
allow local_login_t tty_device_t:chr_file { setattr rw_file_perms };
Chris PeBenito ab58ad
allow local_login_t ttyfile:chr_file { setattr rw_file_perms };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Relabel ttys.
Chris PeBenito ab58ad
allow local_login_t tty_device_t:chr_file { getattr relabelfrom relabelto };
Chris PeBenito ab58ad
allow local_login_t ttyfile:chr_file { getattr relabelfrom relabelto };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`gpm.te',
Chris PeBenito ab58ad
`allow local_login_t gpmctl_t:sock_file { getattr setattr };')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow setting of attributes on sound devices.
Chris PeBenito ab58ad
allow local_login_t sound_device_t:chr_file { getattr setattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow setting of attributes on power management devices.
Chris PeBenito ab58ad
allow local_login_t power_device_t:chr_file { getattr setattr };
Chris PeBenito ab58ad
dontaudit local_login_t init_t:fd use;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the remote_login_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
login_domain(remote)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Only permit unprivileged user domains to be entered via rlogin,
Chris PeBenito ab58ad
# since very weak authentication is used.
Chris PeBenito ab58ad
login_spawn_domain(remote_login, unpriv_userdomain)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow remote_login_t userpty_type:chr_file { setattr write };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use the pty created by rlogind.
Chris PeBenito ab58ad
ifdef(`rlogind.te', `
Chris PeBenito ab58ad
can_access_pty(remote_login_t, rlogind)
Chris PeBenito ab58ad
# Relabel ptys created by rlogind.
Chris PeBenito ab58ad
allow remote_login_t rlogind_devpts_t:chr_file { setattr relabelfrom relabelto };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use the pty created by telnetd.
Chris PeBenito ab58ad
ifdef(`telnetd.te', `
Chris PeBenito ab58ad
can_access_pty(remote_login_t, telnetd)
Chris PeBenito ab58ad
# Relabel ptys created by telnetd.
Chris PeBenito ab58ad
allow remote_login_t telnetd_devpts_t:chr_file { setattr relabelfrom relabelto };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow remote_login_t ptyfile:chr_file { getattr relabelfrom relabelto ioctl };
Chris PeBenito ab58ad
allow remote_login_t fs_t:filesystem { getattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow remote login to resolve host names (passed in via the -h switch)
Chris PeBenito ab58ad
can_resolve(remote_login_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`use_mcs', `
Chris PeBenito ab58ad
ifdef(`getty.te', `
Chris PeBenito ab58ad
range_transition getty_t login_exec_t s0 - s0:c0.c255;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
')