Chris PeBenito 31b7c0
#DESC NSCD - Name service cache daemon cache lookup of user-name
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Author:  Russell Coker <russell@coker.com.au>
Chris PeBenito 31b7c0
# X-Debian-Packages: nscd
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
define(`nscd_socket_domain', `
Chris PeBenito 31b7c0
can_unix_connect($1, nscd_t)
Chris PeBenito 31b7c0
allow $1 nscd_var_run_t:sock_file rw_file_perms;
Chris PeBenito 31b7c0
allow $1 { var_run_t var_t }:dir search;
Chris PeBenito 31b7c0
allow $1 nscd_t:nscd { getpwd getgrp gethost };
Chris PeBenito 31b7c0
dontaudit $1 nscd_t:fd use;
Chris PeBenito 31b7c0
dontaudit $1 nscd_var_run_t:dir { search getattr };
Chris PeBenito 31b7c0
dontaudit $1 nscd_var_run_t:file { getattr read };
Chris PeBenito 31b7c0
dontaudit $1 nscd_t:nscd { shmempwd shmemgrp shmemhost };
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the nscd_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# nscd is both the client program and the daemon.
Chris PeBenito 31b7c0
daemon_domain(nscd, `, userspace_objmgr')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow nscd_t etc_t:file r_file_perms;
Chris PeBenito 31b7c0
allow nscd_t etc_t:lnk_file read;
Chris PeBenito 31b7c0
can_network_client(nscd_t)
Chris PeBenito 31b7c0
allow nscd_t port_type:tcp_socket name_connect;
Chris PeBenito 31b7c0
can_ypbind(nscd_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
file_type_auto_trans(nscd_t, var_run_t, nscd_var_run_t, sock_file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow nscd_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
nscd_socket_domain(nscd_client_domain)
Chris PeBenito 31b7c0
nscd_socket_domain(daemon)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Clients that are allowed to map the database via a fd obtained from nscd.
Chris PeBenito 31b7c0
nscd_socket_domain(nscd_shmem_domain)
Chris PeBenito 31b7c0
allow nscd_shmem_domain nscd_var_run_t:dir r_dir_perms;
Chris PeBenito 31b7c0
allow nscd_shmem_domain nscd_t:nscd { shmempwd shmemgrp shmemhost };
Chris PeBenito 31b7c0
# Receive fd from nscd and map the backing file with read access.
Chris PeBenito 31b7c0
allow nscd_shmem_domain nscd_t:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# For client program operation, invoked from sysadm_t.
Chris PeBenito 31b7c0
# Transition occurs to nscd_t due to direct_sysadm_daemon. 
Chris PeBenito 31b7c0
allow nscd_t self:nscd { admin getstat };
Chris PeBenito 31b7c0
allow nscd_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
read_sysctl(nscd_t)
Chris PeBenito 31b7c0
allow nscd_t self:process { getattr setsched };
Chris PeBenito 31b7c0
allow nscd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 31b7c0
allow nscd_t self:fifo_file { read write };
Chris PeBenito 31b7c0
allow nscd_t self:capability { kill setgid setuid net_bind_service };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for when /etc/passwd has just been updated and has the wrong type
Chris PeBenito 31b7c0
allow nscd_t shadow_t:file getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
dontaudit nscd_t sysadm_home_dir_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`winbind.te', `
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Handle winbind for samba, Might only be needed for targeted policy
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
allow nscd_t winbind_var_run_t:sock_file { read write getattr };
Chris PeBenito 31b7c0
can_unix_connect(nscd_t, winbind_t)
Chris PeBenito 31b7c0
allow nscd_t samba_var_t:dir search;
Chris PeBenito 31b7c0
allow nscd_t winbind_var_run_t:dir { getattr search };
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
r_dir_file(nscd_t, selinux_config_t)
Chris PeBenito 31b7c0
can_getsecurity(nscd_t)
Chris PeBenito 31b7c0
allow nscd_t self:netlink_selinux_socket create_socket_perms;
Chris PeBenito 31b7c0
allow nscd_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito 31b7c0
allow nscd_t tmp_t:dir { search getattr };
Chris PeBenito 31b7c0
allow nscd_t tmp_t:lnk_file read;
Chris PeBenito 31b7c0
allow nscd_t { urandom_device_t random_device_t }:chr_file { getattr read };
Chris PeBenito 31b7c0
log_domain(nscd)
Chris PeBenito 31b7c0
r_dir_file(nscd_t, cert_t)
Chris PeBenito 31b7c0
allow nscd_t tun_tap_device_t:chr_file { read write };
Chris PeBenito 31b7c0
allow nscd_t self:netlink_audit_socket { create_netlink_socket_perms nlmsg_relay };