549 lines
15 KiB
Plaintext
549 lines
15 KiB
Plaintext
|
|
policy_module(usermanage,1.0)
|
|
|
|
########################################
|
|
#
|
|
# Declarations
|
|
#
|
|
|
|
type admin_passwd_exec_t;
|
|
files_type(admin_passwd_exec_t)
|
|
|
|
type chfn_t;
|
|
domain_obj_id_change_exempt(chfn_t)
|
|
domain_type(chfn_t)
|
|
role system_r types chfn_t;
|
|
|
|
type chfn_exec_t;
|
|
domain_entry_file(chfn_t,chfn_exec_t)
|
|
|
|
type crack_t;
|
|
domain_type(crack_t)
|
|
role system_r types crack_t;
|
|
|
|
type crack_exec_t;
|
|
domain_entry_file(crack_t,crack_exec_t)
|
|
|
|
type crack_db_t; #, usercanread;
|
|
files_type(crack_db_t)
|
|
|
|
type crack_tmp_t;
|
|
files_tmp_file(crack_tmp_t)
|
|
|
|
type groupadd_t;
|
|
type groupadd_exec_t;
|
|
domain_obj_id_change_exempt(groupadd_t)
|
|
init_system_domain(groupadd_t,groupadd_exec_t)
|
|
role system_r types groupadd_t;
|
|
|
|
type passwd_t;
|
|
domain_obj_id_change_exempt(passwd_t)
|
|
domain_type(passwd_t)
|
|
role system_r types passwd_t;
|
|
|
|
type passwd_exec_t;
|
|
domain_entry_file(passwd_t,passwd_exec_t)
|
|
|
|
type sysadm_passwd_t;
|
|
domain_obj_id_change_exempt(sysadm_passwd_t)
|
|
domain_type(sysadm_passwd_t)
|
|
domain_entry_file(sysadm_passwd_t,admin_passwd_exec_t)
|
|
|
|
type sysadm_passwd_tmp_t;
|
|
files_type(sysadm_passwd_tmp_t)
|
|
|
|
type useradd_t;
|
|
type useradd_exec_t;
|
|
domain_obj_id_change_exempt(useradd_t)
|
|
init_system_domain(useradd_t,useradd_exec_t)
|
|
role system_r types useradd_t;
|
|
|
|
########################################
|
|
#
|
|
# Chfn local policy
|
|
#
|
|
|
|
allow chfn_t self:capability { chown dac_override fsetid setuid setgid sys_resource };
|
|
allow chfn_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execheap execstack };
|
|
allow chfn_t self:process { setrlimit setfscreate };
|
|
allow chfn_t self:fd use;
|
|
allow chfn_t self:fifo_file rw_file_perms;
|
|
allow chfn_t self:shm create_shm_perms;
|
|
allow chfn_t self:sem create_sem_perms;
|
|
allow chfn_t self:msgq create_msgq_perms;
|
|
allow chfn_t self:msg { send receive };
|
|
allow chfn_t self:unix_dgram_socket create_socket_perms;
|
|
allow chfn_t self:unix_stream_socket create_stream_socket_perms;
|
|
allow chfn_t self:unix_dgram_socket sendto;
|
|
allow chfn_t self:unix_stream_socket connectto;
|
|
|
|
kernel_read_system_state(chfn_t)
|
|
kernel_read_kernel_sysctl(chfn_t)
|
|
|
|
selinux_get_fs_mount(chfn_t)
|
|
selinux_validate_context(chfn_t)
|
|
selinux_compute_access_vector(chfn_t)
|
|
selinux_compute_create_context(chfn_t)
|
|
selinux_compute_relabel_context(chfn_t)
|
|
selinux_compute_user_contexts(chfn_t)
|
|
|
|
term_use_all_user_ttys(chfn_t)
|
|
term_use_all_user_ptys(chfn_t)
|
|
|
|
fs_getattr_xattr_fs(chfn_t)
|
|
fs_search_auto_mountpoints(chfn_t)
|
|
|
|
# for SSP
|
|
dev_read_urand(chfn_t)
|
|
|
|
auth_domtrans_chk_passwd(chfn_t)
|
|
auth_dontaudit_read_shadow(chfn_t)
|
|
|
|
# can exec /sbin/unix_chkpwd
|
|
corecmd_search_bin(chfn_t)
|
|
corecmd_search_sbin(chfn_t)
|
|
|
|
domain_use_wide_inherit_fd(chfn_t)
|
|
|
|
files_manage_etc_files(chfn_t)
|
|
files_read_etc_runtime_files(chfn_t)
|
|
files_dontaudit_search_var(chfn_t)
|
|
|
|
# /usr/bin/passwd asks for w access to utmp, but it will operate
|
|
# correctly without it. Do not audit write denials to utmp.
|
|
init_dontaudit_rw_script_pid(chfn_t)
|
|
|
|
libs_use_ld_so(chfn_t)
|
|
libs_use_shared_libs(chfn_t)
|
|
|
|
miscfiles_read_localization(chfn_t)
|
|
|
|
logging_send_syslog_msg(chfn_t)
|
|
|
|
# uses unix_chkpwd for checking passwords
|
|
seutil_dontaudit_search_config(chfn_t)
|
|
|
|
userdom_use_unpriv_users_fd(chfn_t)
|
|
# user generally runs this from their home directory, so do not audit a search
|
|
# on user home dir
|
|
userdom_dontaudit_search_all_users_home(chfn_t)
|
|
|
|
optional_policy(`nis.te',`
|
|
nis_use_ypbind(chfn_t)
|
|
')
|
|
|
|
ifdef(`TODO',`
|
|
ifdef(`gnome-pty-helper.te', `allow chfn_t gphdomain:fd use;')
|
|
|
|
# allow checking if a shell is executable
|
|
allow chfn_t shell_exec_t:file execute;
|
|
') dnl endif TODO
|
|
|
|
########################################
|
|
#
|
|
# Crack local policy
|
|
#
|
|
|
|
allow crack_t self:process { sigkill sigstop signull signal };
|
|
allow crack_t self:fifo_file rw_file_perms;
|
|
|
|
allow crack_t crack_db_t:dir rw_dir_perms;
|
|
allow crack_t crack_db_t:file create_file_perms;
|
|
allow crack_t crack_db_t:lnk_file create_file_perms;
|
|
files_search_var(crack_t)
|
|
|
|
allow crack_t crack_tmp_t:dir create_dir_perms;
|
|
allow crack_t crack_tmp_t:file create_file_perms;
|
|
files_create_tmp_files(crack_t, crack_tmp_t, { file dir })
|
|
|
|
kernel_read_system_state(crack_t)
|
|
|
|
# for SSP
|
|
dev_read_urand(crack_t)
|
|
|
|
fs_getattr_xattr_fs(crack_t)
|
|
|
|
files_read_etc_files(crack_t)
|
|
files_read_etc_runtime_files(crack_t)
|
|
# for dictionaries
|
|
files_read_usr_files(crack_t)
|
|
|
|
corecmd_exec_bin(crack_t)
|
|
|
|
libs_use_ld_so(crack_t)
|
|
libs_use_shared_libs(crack_t)
|
|
|
|
logging_send_syslog_msg(crack_t)
|
|
|
|
userdom_dontaudit_search_sysadm_home_dir(crack_t)
|
|
|
|
optional_policy(`cron.te',`
|
|
cron_system_entry(crack_t,crack_exec_t)
|
|
')
|
|
|
|
########################################
|
|
#
|
|
# Groupadd local policy
|
|
#
|
|
|
|
allow groupadd_t self:capability { dac_override chown kill setuid sys_resource };
|
|
dontaudit groupadd_t self:capability fsetid;
|
|
allow groupadd_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execheap execstack };
|
|
allow groupadd_t self:process { setrlimit setfscreate };
|
|
allow groupadd_t self:fd use;
|
|
allow groupadd_t self:fifo_file rw_file_perms;
|
|
allow groupadd_t self:shm create_shm_perms;
|
|
allow groupadd_t self:sem create_sem_perms;
|
|
allow groupadd_t self:msgq create_msgq_perms;
|
|
allow groupadd_t self:msg { send receive };
|
|
allow groupadd_t self:unix_dgram_socket create_socket_perms;
|
|
allow groupadd_t self:unix_stream_socket create_stream_socket_perms;
|
|
allow groupadd_t self:unix_dgram_socket sendto;
|
|
allow groupadd_t self:unix_stream_socket connectto;
|
|
allow groupadd_t self:netlink_audit_socket { create_socket_perms nlmsg_relay };
|
|
|
|
fs_getattr_xattr_fs(groupadd_t)
|
|
fs_search_auto_mountpoints(groupadd_t)
|
|
|
|
# Allow access to context for shadow file
|
|
selinux_get_fs_mount(groupadd_t)
|
|
selinux_validate_context(groupadd_t)
|
|
selinux_compute_access_vector(groupadd_t)
|
|
selinux_compute_create_context(groupadd_t)
|
|
selinux_compute_relabel_context(groupadd_t)
|
|
selinux_compute_user_contexts(groupadd_t)
|
|
|
|
term_use_all_user_ttys(groupadd_t)
|
|
term_use_all_user_ptys(groupadd_t)
|
|
|
|
init_use_fd(groupadd_t)
|
|
init_read_script_pid(groupadd_t)
|
|
init_dontaudit_write_script_pid(groupadd_t)
|
|
|
|
domain_use_wide_inherit_fd(groupadd_t)
|
|
|
|
files_manage_etc_files(groupadd_t)
|
|
|
|
libs_use_ld_so(groupadd_t)
|
|
libs_use_shared_libs(groupadd_t)
|
|
|
|
# Execute /usr/bin/{passwd,chfn,chsh} and /usr/sbin/{useradd,vipw}.
|
|
corecmd_exec_bin(groupadd_t)
|
|
corecmd_exec_sbin(groupadd_t)
|
|
|
|
logging_send_syslog_msg(groupadd_t)
|
|
|
|
miscfiles_read_localization(groupadd_t)
|
|
|
|
auth_manage_shadow(groupadd_t)
|
|
auth_rw_lastlog(groupadd_t)
|
|
auth_use_nsswitch(groupadd_t)
|
|
|
|
seutil_read_config(groupadd_t)
|
|
|
|
userdom_use_unpriv_users_fd(groupadd_t)
|
|
# for when /root is the cwd
|
|
userdom_dontaudit_search_sysadm_home_dir(groupadd_t)
|
|
|
|
optional_policy(`nis.te',`
|
|
nis_use_ypbind(groupadd_t)
|
|
')
|
|
|
|
optional_policy(`nscd.te',`
|
|
nscd_use_socket(groupadd_t)
|
|
')
|
|
|
|
optional_policy(`rpm.te',`
|
|
rpm_use_fd(groupadd_t)
|
|
rpm_rw_pipe(groupadd_t)
|
|
')
|
|
|
|
ifdef(`TODO',`
|
|
# Update /etc/shadow and /etc/passwd
|
|
allow groupadd_t { etc_t shadow_t }:file { relabelfrom relabelto };
|
|
|
|
# Access terminals.
|
|
ifdef(`gnome-pty-helper.te', `allow groupadd_t gphdomain:fd use;')
|
|
') dnl end TODO
|
|
|
|
########################################
|
|
#
|
|
# Passwd local policy
|
|
#
|
|
|
|
allow passwd_t self:capability { chown dac_override fsetid setuid setgid sys_resource };
|
|
allow passwd_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
|
|
allow passwd_t self:process { setrlimit setfscreate };
|
|
allow passwd_t self:fd use;
|
|
allow passwd_t self:fifo_file rw_file_perms;
|
|
allow passwd_t self:unix_dgram_socket create_socket_perms;
|
|
allow passwd_t self:unix_stream_socket create_stream_socket_perms;
|
|
allow passwd_t self:unix_dgram_socket sendto;
|
|
allow passwd_t self:unix_stream_socket connectto;
|
|
allow passwd_t self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };
|
|
allow passwd_t self:shm create_shm_perms;
|
|
allow passwd_t self:sem create_sem_perms;
|
|
allow passwd_t self:msgq create_msgq_perms;
|
|
allow passwd_t self:msg { send receive };
|
|
|
|
allow passwd_t crack_db_t:dir r_dir_perms;
|
|
allow passwd_t crack_db_t:file r_file_perms;
|
|
|
|
kernel_read_kernel_sysctl(passwd_t)
|
|
|
|
# for SSP
|
|
dev_read_urand(passwd_t)
|
|
|
|
fs_getattr_xattr_fs(passwd_t)
|
|
fs_search_auto_mountpoints(passwd_t)
|
|
|
|
selinux_get_fs_mount(passwd_t)
|
|
selinux_validate_context(passwd_t)
|
|
selinux_compute_access_vector(passwd_t)
|
|
selinux_compute_create_context(passwd_t)
|
|
selinux_compute_relabel_context(passwd_t)
|
|
selinux_compute_user_contexts(passwd_t)
|
|
|
|
auth_manage_shadow(passwd_t)
|
|
|
|
# /usr/bin/passwd asks for w access to utmp, but it will operate
|
|
# correctly without it. Do not audit write denials to utmp.
|
|
init_dontaudit_rw_script_pid(passwd_t)
|
|
|
|
domain_use_wide_inherit_fd(passwd_t)
|
|
|
|
files_read_etc_runtime_files(passwd_t)
|
|
files_manage_etc_files(passwd_t)
|
|
files_search_var(passwd_t)
|
|
files_dontaudit_search_pids(passwd_t)
|
|
|
|
libs_use_ld_so(passwd_t)
|
|
libs_use_shared_libs(passwd_t)
|
|
|
|
logging_send_syslog_msg(passwd_t)
|
|
|
|
miscfiles_read_localization(passwd_t)
|
|
|
|
seutil_dontaudit_search_config(passwd_t)
|
|
|
|
userdom_use_unpriv_users_fd(passwd_t)
|
|
# user generally runs this from their home directory, so do not audit a search
|
|
# on user home dir
|
|
userdom_dontaudit_search_all_users_home(passwd_t)
|
|
|
|
optional_policy(`nis.te',`
|
|
nis_use_ypbind(passwd_t)
|
|
')
|
|
|
|
ifdef(`TODO',`
|
|
# Update /etc/shadow and /etc/passwd
|
|
allow passwd_t { etc_t shadow_t }:file { relabelfrom relabelto };
|
|
|
|
# Inherit and use descriptors from login.
|
|
ifdef(`gnome-pty-helper.te', `allow passwd_t gphdomain:fd use;')
|
|
|
|
# allow checking if a shell is executable
|
|
allow passwd_t shell_exec_t:file execute;
|
|
|
|
# make sure that getcon succeeds
|
|
allow passwd_t userdomain:dir search;
|
|
allow passwd_t userdomain:file read;
|
|
allow passwd_t userdomain:process getattr;
|
|
') dnl endif TODO
|
|
|
|
########################################
|
|
#
|
|
# Password admin local policy
|
|
#
|
|
|
|
allow sysadm_passwd_t self:capability { chown dac_override fsetid setuid setgid sys_resource };
|
|
allow sysadm_passwd_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
|
|
allow sysadm_passwd_t self:process { setrlimit setfscreate };
|
|
allow sysadm_passwd_t self:fd use;
|
|
allow sysadm_passwd_t self:fifo_file rw_file_perms;
|
|
allow sysadm_passwd_t self:unix_dgram_socket create_socket_perms;
|
|
allow sysadm_passwd_t self:unix_stream_socket create_stream_socket_perms;
|
|
allow sysadm_passwd_t self:unix_dgram_socket sendto;
|
|
allow sysadm_passwd_t self:unix_stream_socket connectto;
|
|
allow sysadm_passwd_t self:shm create_shm_perms;
|
|
allow sysadm_passwd_t self:sem create_sem_perms;
|
|
allow sysadm_passwd_t self:msgq create_msgq_perms;
|
|
allow sysadm_passwd_t self:msg { send receive };
|
|
|
|
# allow vipw to create temporary files under /var/tmp/vi.recover
|
|
allow sysadm_passwd_t sysadm_passwd_tmp_t:dir create_dir_perms;
|
|
allow sysadm_passwd_t sysadm_passwd_tmp_t:file create_file_perms;
|
|
files_create_tmp_files(sysadm_passwd_t, sysadm_passwd_tmp_t, { file dir })
|
|
files_search_var(sysadm_passwd_t)
|
|
|
|
kernel_read_kernel_sysctl(sysadm_passwd_t)
|
|
# for /proc/meminfo
|
|
kernel_read_system_state(sysadm_passwd_t)
|
|
|
|
selinux_get_fs_mount(sysadm_passwd_t)
|
|
selinux_validate_context(sysadm_passwd_t)
|
|
selinux_compute_access_vector(sysadm_passwd_t)
|
|
selinux_compute_create_context(sysadm_passwd_t)
|
|
selinux_compute_relabel_context(sysadm_passwd_t)
|
|
selinux_compute_user_contexts(sysadm_passwd_t)
|
|
|
|
# for SSP
|
|
dev_read_urand(sysadm_passwd_t)
|
|
|
|
fs_getattr_xattr_fs(sysadm_passwd_t)
|
|
fs_search_auto_mountpoints(sysadm_passwd_t)
|
|
|
|
term_use_all_user_ttys(sysadm_passwd_t)
|
|
term_use_all_user_ptys(sysadm_passwd_t)
|
|
|
|
auth_manage_shadow(sysadm_passwd_t)
|
|
|
|
# allow vipw to exec the editor
|
|
corecmd_exec_bin(sysadm_passwd_t)
|
|
corecmd_exec_shell(sysadm_passwd_t)
|
|
files_read_usr_files(sysadm_passwd_t)
|
|
|
|
domain_use_wide_inherit_fd(sysadm_passwd_t)
|
|
|
|
files_manage_etc_files(sysadm_passwd_t)
|
|
files_read_etc_runtime_files(sysadm_passwd_t)
|
|
# for nscd lookups
|
|
files_dontaudit_search_pids(sysadm_passwd_t)
|
|
|
|
# /usr/bin/passwd asks for w access to utmp, but it will operate
|
|
# correctly without it. Do not audit write denials to utmp.
|
|
init_dontaudit_rw_script_pid(sysadm_passwd_t)
|
|
|
|
libs_use_ld_so(sysadm_passwd_t)
|
|
libs_use_shared_libs(sysadm_passwd_t)
|
|
|
|
miscfiles_read_localization(sysadm_passwd_t)
|
|
|
|
logging_send_syslog_msg(sysadm_passwd_t)
|
|
|
|
seutil_dontaudit_search_config(sysadm_passwd_t)
|
|
|
|
userdom_use_unpriv_users_fd(sysadm_passwd_t)
|
|
# user generally runs this from their home directory, so do not audit a search
|
|
# on user home dir
|
|
userdom_dontaudit_search_all_users_home(sysadm_passwd_t)
|
|
|
|
optional_policy(`nis.te',`
|
|
nis_use_ypbind(sysadm_passwd_t)
|
|
')
|
|
|
|
ifdef(`TODO',`
|
|
role sysadm_r types sysadm_passwd_t;
|
|
domain_auto_trans(sysadm_t, admin_passwd_exec_t, sysadm_passwd_t)
|
|
|
|
# Inherit and use descriptors from login.
|
|
ifdef(`gnome-pty-helper.te', `allow sysadm_passwd_t gphdomain:fd use;')
|
|
|
|
# allow checking if a shell is executable
|
|
allow sysadm_passwd_t shell_exec_t:file execute;
|
|
|
|
# Update /etc/shadow and /etc/passwd
|
|
allow sysadm_passwd_t { etc_t shadow_t }:file { relabelfrom relabelto };
|
|
|
|
ifdef(`targeted_policy', `
|
|
role system_r types sysadm_passwd_t;
|
|
')
|
|
') dnl endif TODO
|
|
|
|
########################################
|
|
#
|
|
# Useradd local policy
|
|
#
|
|
|
|
allow useradd_t self:capability { dac_override chown kill fowner fsetid setuid sys_resource };
|
|
allow useradd_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
|
|
allow useradd_t self:process setfscreate;
|
|
allow useradd_t self:fd use;
|
|
allow useradd_t self:fifo_file rw_file_perms;
|
|
allow useradd_t self:shm create_shm_perms;
|
|
allow useradd_t self:sem create_sem_perms;
|
|
allow useradd_t self:msgq create_msgq_perms;
|
|
allow useradd_t self:msg { send receive };
|
|
allow useradd_t self:unix_dgram_socket create_socket_perms;
|
|
allow useradd_t self:unix_stream_socket create_stream_socket_perms;
|
|
allow useradd_t self:unix_dgram_socket sendto;
|
|
allow useradd_t self:unix_stream_socket connectto;
|
|
allow useradd_t self:netlink_audit_socket { create_socket_perms nlmsg_relay };
|
|
|
|
# Allow access to context for shadow file
|
|
selinux_get_fs_mount(useradd_t)
|
|
selinux_validate_context(useradd_t)
|
|
selinux_compute_access_vector(useradd_t)
|
|
selinux_compute_create_context(useradd_t)
|
|
selinux_compute_relabel_context(useradd_t)
|
|
selinux_compute_user_contexts(useradd_t)
|
|
# for getting the number of groups
|
|
kernel_read_kernel_sysctl(useradd_t)
|
|
|
|
fs_search_auto_mountpoints(useradd_t)
|
|
fs_getattr_xattr_fs(useradd_t)
|
|
|
|
term_use_all_user_ttys(useradd_t)
|
|
term_use_all_user_ptys(useradd_t)
|
|
|
|
auth_manage_shadow(useradd_t)
|
|
auth_rw_lastlog(useradd_t)
|
|
auth_use_nsswitch(useradd_t)
|
|
|
|
corecmd_exec_shell(useradd_t)
|
|
# Execute /usr/bin/{passwd,chfn,chsh} and /usr/sbin/{useradd,vipw}.
|
|
corecmd_exec_bin(useradd_t)
|
|
corecmd_exec_sbin(useradd_t)
|
|
|
|
domain_use_wide_inherit_fd(useradd_t)
|
|
|
|
files_manage_etc_files(useradd_t)
|
|
files_search_var_lib(useradd_t)
|
|
|
|
init_use_fd(useradd_t)
|
|
init_rw_script_pid(useradd_t)
|
|
|
|
libs_use_ld_so(useradd_t)
|
|
libs_use_shared_libs(useradd_t)
|
|
|
|
logging_send_syslog_msg(useradd_t)
|
|
|
|
miscfiles_read_localization(useradd_t)
|
|
|
|
seutil_read_config(useradd_t)
|
|
seutil_read_file_contexts(useradd_t)
|
|
|
|
userdom_use_unpriv_users_fd(useradd_t)
|
|
# for when /root is the cwd
|
|
userdom_dontaudit_search_sysadm_home_dir(useradd_t)
|
|
# Add/remove user home directories
|
|
userdom_create_user_home_dir(useradd_t)
|
|
userdom_manage_user_home_dir(useradd_t)
|
|
userdom_create_user_home(useradd_t,notdevfile_class_set)
|
|
|
|
mta_manage_spool(useradd_t)
|
|
|
|
optional_policy(`nis.te',`
|
|
nis_use_ypbind(useradd_t)
|
|
')
|
|
|
|
optional_policy(`nscd.te',`
|
|
nscd_use_socket(useradd_t)
|
|
')
|
|
|
|
optional_policy(`rpm.te',`
|
|
rpm_use_fd(useradd_t)
|
|
rpm_rw_pipe(useradd_t)
|
|
')
|
|
|
|
ifdef(`TODO',`
|
|
# Update /etc/shadow and /etc/passwd
|
|
allow useradd_t { etc_t shadow_t }:file { relabelfrom relabelto };
|
|
|
|
# Access terminals.
|
|
ifdef(`gnome-pty-helper.te', `allow useradd_t gphdomain:fd use;')
|
|
|
|
# /var/mail is a link to /var/spool/mail
|
|
allow useradd_t mail_spool_t:lnk_file read;
|
|
') dnl end TODO
|