|
Chris PeBenito |
ab58ad |
#DESC Passwd - Password utilities
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Authors: Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser
|
|
Chris PeBenito |
ab58ad |
# X-Debian-Packages: passwd
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Rules for the passwd_t domain.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`base_passwd_domain', `
|
|
Chris PeBenito |
ab58ad |
type $1_t, domain, privlog, $2;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for SSP
|
|
Chris PeBenito |
ab58ad |
allow $1_t urandom_device_t:chr_file read;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t self:process setrlimit;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
general_domain_access($1_t);
|
|
Chris PeBenito |
ab58ad |
uses_shlib($1_t);
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Inherit and use descriptors from login.
|
|
Chris PeBenito |
ab58ad |
allow $1_t privfd:fd use;
|
|
Chris PeBenito |
ab58ad |
ifdef(`gnome-pty-helper.te', `allow $1_t gphdomain:fd use;')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
read_locale($1_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t fs_t:filesystem getattr;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# allow checking if a shell is executable
|
|
Chris PeBenito |
ab58ad |
allow $1_t shell_exec_t:file execute;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Obtain contexts
|
|
Chris PeBenito |
ab58ad |
can_getsecurity($1_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t etc_t:file create_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# read /etc/mtab
|
|
Chris PeBenito |
ab58ad |
allow $1_t etc_runtime_t:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Allow etc_t symlinks for /etc/alternatives on Debian.
|
|
Chris PeBenito |
ab58ad |
allow $1_t etc_t:lnk_file read;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Use capabilities.
|
|
Chris PeBenito |
ab58ad |
allow $1_t self:capability { chown dac_override fsetid setuid setgid sys_resource };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# Access terminals.
|
|
Chris PeBenito |
ab58ad |
allow $1_t { ttyfile ptyfile }:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow $1_t devtty_t:chr_file rw_file_perms;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t devpts_t:dir getattr;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# /usr/bin/passwd asks for w access to utmp, but it will operate
|
|
Chris PeBenito |
ab58ad |
# correctly without it. Do not audit write denials to utmp.
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t initrc_var_run_t:file { read write };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# user generally runs this from their home directory, so do not audit a search
|
|
Chris PeBenito |
ab58ad |
# on user home dir
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t { user_home_dir_type user_home_type }:dir search;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# When the wrong current passwd is entered, passwd, for some reason,
|
|
Chris PeBenito |
ab58ad |
# attempts to access /proc and /dev, but handles failure appropriately. So
|
|
Chris PeBenito |
ab58ad |
# do not audit those denials.
|
|
Chris PeBenito |
ab58ad |
dontaudit $1_t { proc_t device_t }:dir { search read };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow $1_t device_t:dir getattr;
|
|
Chris PeBenito |
ab58ad |
read_sysctl($1_t)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
#################################
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
# Rules for the passwd_t domain.
|
|
Chris PeBenito |
ab58ad |
#
|
|
Chris PeBenito |
ab58ad |
define(`passwd_domain', `
|
|
Chris PeBenito |
ab58ad |
base_passwd_domain($1, `auth_write, privowner')
|
|
Chris PeBenito |
ab58ad |
# Update /etc/shadow and /etc/passwd
|
|
Chris PeBenito |
ab58ad |
file_type_auto_trans($1_t, etc_t, shadow_t, file)
|
|
Chris PeBenito |
ab58ad |
allow $1_t { etc_t shadow_t }:file { relabelfrom relabelto };
|
|
Chris PeBenito |
ab58ad |
can_setfscreate($1_t)
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
passwd_domain(passwd)
|
|
Chris PeBenito |
ab58ad |
passwd_domain(sysadm_passwd)
|
|
Chris PeBenito |
ab58ad |
base_passwd_domain(chfn, `auth_chkpwd, etc_writer, privowner')
|
|
Chris PeBenito |
ab58ad |
can_setfscreate(chfn_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# can exec /sbin/unix_chkpwd
|
|
Chris PeBenito |
ab58ad |
allow chfn_t { bin_t sbin_t }:dir search;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# uses unix_chkpwd for checking passwords
|
|
Chris PeBenito |
ab58ad |
dontaudit chfn_t shadow_t:file read;
|
|
Chris PeBenito |
ab58ad |
allow chfn_t etc_t:dir rw_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow chfn_t etc_t:file create_file_perms;
|
|
Chris PeBenito |
ab58ad |
allow chfn_t proc_t:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
allow chfn_t self:file write;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
in_user_role(passwd_t)
|
|
Chris PeBenito |
ab58ad |
in_user_role(chfn_t)
|
|
Chris PeBenito |
ab58ad |
role sysadm_r types passwd_t;
|
|
Chris PeBenito |
ab58ad |
role sysadm_r types sysadm_passwd_t;
|
|
Chris PeBenito |
ab58ad |
role sysadm_r types chfn_t;
|
|
Chris PeBenito |
ab58ad |
role system_r types passwd_t;
|
|
Chris PeBenito |
ab58ad |
role system_r types chfn_t;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
type admin_passwd_exec_t, file_type, sysadmfile;
|
|
Chris PeBenito |
ab58ad |
type passwd_exec_t, file_type, sysadmfile, exec_type;
|
|
Chris PeBenito |
ab58ad |
type chfn_exec_t, file_type, sysadmfile, exec_type;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans({ userdomain ifdef(`firstboot.te', `firstboot_t') }, passwd_exec_t, passwd_t)
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans({ userdomain ifdef(`firstboot.te', `firstboot_t') }, chfn_exec_t, chfn_t)
|
|
Chris PeBenito |
ab58ad |
domain_auto_trans(sysadm_t, admin_passwd_exec_t, sysadm_passwd_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
dontaudit chfn_t var_t:dir search;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifdef(`crack.te', `
|
|
Chris PeBenito |
ab58ad |
allow passwd_t var_t:dir search;
|
|
Chris PeBenito |
ab58ad |
dontaudit passwd_t var_run_t:dir search;
|
|
Chris PeBenito |
ab58ad |
allow passwd_t crack_db_t:dir r_dir_perms;
|
|
Chris PeBenito |
ab58ad |
allow passwd_t crack_db_t:file r_file_perms;
|
|
Chris PeBenito |
ab58ad |
', `
|
|
Chris PeBenito |
ab58ad |
dontaudit passwd_t var_t:dir search;
|
|
Chris PeBenito |
ab58ad |
')
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# allow vipw to exec the editor
|
|
Chris PeBenito |
ab58ad |
allow sysadm_passwd_t { root_t bin_t sbin_t }:dir search;
|
|
Chris PeBenito |
ab58ad |
allow sysadm_passwd_t bin_t:lnk_file read;
|
|
Chris PeBenito |
ab58ad |
can_exec(sysadm_passwd_t, { shell_exec_t bin_t })
|
|
Chris PeBenito |
ab58ad |
r_dir_file(sysadm_passwd_t, usr_t)
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# allow vipw to create temporary files under /var/tmp/vi.recover
|
|
Chris PeBenito |
ab58ad |
allow sysadm_passwd_t var_t:dir search;
|
|
Chris PeBenito |
ab58ad |
tmp_domain(sysadm_passwd)
|
|
Chris PeBenito |
ab58ad |
# for vipw - vi looks in the root home directory for config
|
|
Chris PeBenito |
ab58ad |
dontaudit sysadm_passwd_t sysadm_home_dir_t:dir { getattr search };
|
|
Chris PeBenito |
ab58ad |
# for /etc/alternatives/vi
|
|
Chris PeBenito |
ab58ad |
allow sysadm_passwd_t etc_t:lnk_file read;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for nscd lookups
|
|
Chris PeBenito |
ab58ad |
dontaudit sysadm_passwd_t var_run_t:dir search;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# for /proc/meminfo
|
|
Chris PeBenito |
ab58ad |
allow sysadm_passwd_t proc_t:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
dontaudit { chfn_t passwd_t sysadm_passwd_t } selinux_config_t:dir search;
|
|
Chris PeBenito |
ab58ad |
dontaudit sysadm_passwd_t devpts_t:dir search;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
# make sure that getcon succeeds
|
|
Chris PeBenito |
ab58ad |
allow passwd_t userdomain:dir search;
|
|
Chris PeBenito |
ab58ad |
allow passwd_t userdomain:file { getattr read };
|
|
Chris PeBenito |
ab58ad |
allow passwd_t userdomain:process getattr;
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
allow passwd_t self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };
|
|
Chris PeBenito |
ab58ad |
|
|
Chris PeBenito |
ab58ad |
ifdef(`targeted_policy', `
|
|
Chris PeBenito |
ab58ad |
role system_r types sysadm_passwd_t;
|
|
Chris PeBenito |
ab58ad |
')
|