Chris PeBenito ab58ad
#DESC SAMBA - SMB file server
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author: Ryan Bergauer (bergauer@rice.edu)
Chris PeBenito ab58ad
# X-Debian-Packages: samba
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Declarations for Samba
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
daemon_domain(smbd, `, auth_chkpwd, nscd_client_domain')
Chris PeBenito ab58ad
daemon_domain(nmbd)
Chris PeBenito ab58ad
type samba_etc_t, file_type, sysadmfile, usercanread;
Chris PeBenito ab58ad
type samba_log_t, file_type, sysadmfile, logfile;
Chris PeBenito ab58ad
type samba_var_t, file_type, sysadmfile;
Chris PeBenito ab58ad
type samba_share_t, file_type, sysadmfile, customizable;
Chris PeBenito ab58ad
type samba_secrets_t, file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for /var/run/samba/messages.tdb
Chris PeBenito ab58ad
allow smbd_t nmbd_var_run_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow smbd_t self:process setrlimit;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# not sure why it needs this
Chris PeBenito ab58ad
tmp_domain(smbd)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow samba to search mnt_t for potential mounted dirs
Chris PeBenito ab58ad
allow smbd_t mnt_t:dir r_dir_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`crond.te', `
Chris PeBenito ab58ad
allow system_crond_t samba_etc_t:file { read getattr lock };
Chris PeBenito ab58ad
allow system_crond_t samba_log_t:file { read getattr lock };
Chris PeBenito ab58ad
#allow system_crond_t samba_secrets_t:file { read getattr lock };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the smbd_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions normally found in every_domain.
Chris PeBenito ab58ad
general_domain_access(smbd_t)
Chris PeBenito ab58ad
general_proc_read_access(smbd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow smbd_t smbd_port_t:tcp_socket name_bind;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities.
Chris PeBenito ab58ad
allow smbd_t self:capability { setgid setuid sys_resource net_bind_service lease dac_override dac_read_search };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use the network.
Chris PeBenito ab58ad
can_network(smbd_t)
Chris PeBenito ab58ad
nsswitch_domain(smbd_t)
Chris PeBenito ab58ad
can_kerberos(smbd_t)
Chris PeBenito ab58ad
allow smbd_t { smbd_port_t ipp_port_t }:tcp_socket name_connect;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow smbd_t urandom_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions for Samba files in /etc/samba
Chris PeBenito ab58ad
# either allow read access to the directory or allow the auto_trans rule to
Chris PeBenito ab58ad
# allow creation of the secrets.tdb file and the MACHINE.SID file
Chris PeBenito ab58ad
#allow smbd_t samba_etc_t:dir { search getattr };
Chris PeBenito ab58ad
file_type_auto_trans(smbd_t, samba_etc_t, samba_secrets_t, file)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow smbd_t { etc_t samba_etc_t etc_runtime_t }:file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions for Samba cache files in /var/cache/samba and /var/lib/samba
Chris PeBenito ab58ad
allow smbd_t var_lib_t:dir search;
Chris PeBenito ab58ad
create_dir_file(smbd_t, samba_var_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Needed for shared printers
Chris PeBenito ab58ad
allow smbd_t var_spool_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions to write log files.
Chris PeBenito ab58ad
allow smbd_t samba_log_t:file { create ra_file_perms };
Chris PeBenito ab58ad
allow smbd_t var_log_t:dir search;
Chris PeBenito ab58ad
allow smbd_t samba_log_t:dir ra_dir_perms;
Chris PeBenito ab58ad
dontaudit smbd_t samba_log_t:dir remove_name;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`hide_broken_symptoms', `
Chris PeBenito ab58ad
dontaudit smbd_t { usbfs_t security_t devpts_t boot_t default_t tmpfs_t }:dir getattr;
Chris PeBenito ab58ad
dontaudit smbd_t devpts_t:dir getattr;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
allow smbd_t fs_t:filesystem quotaget;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow smbd_t usr_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access Samba shares.
Chris PeBenito ab58ad
create_dir_file(smbd_t, samba_share_t)
Chris PeBenito ab58ad
anonymous_domain(smbd)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`logrotate.te', `
Chris PeBenito ab58ad
# the application should be changed
Chris PeBenito ab58ad
can_exec(logrotate_t, samba_log_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the nmbd_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions normally found in every_domain.
Chris PeBenito ab58ad
general_domain_access(nmbd_t)
Chris PeBenito ab58ad
general_proc_read_access(nmbd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow nmbd_t nmbd_port_t:udp_socket name_bind;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities.
Chris PeBenito ab58ad
allow nmbd_t self:capability net_bind_service;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use the network.
Chris PeBenito ab58ad
can_network_server(nmbd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions for Samba files in /etc/samba
Chris PeBenito ab58ad
allow nmbd_t samba_etc_t:file { getattr read };
Chris PeBenito ab58ad
allow nmbd_t samba_etc_t:dir { search getattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions for Samba cache files in /var/cache/samba
Chris PeBenito ab58ad
allow nmbd_t samba_var_t:dir { write remove_name add_name lock getattr search };
Chris PeBenito ab58ad
allow nmbd_t samba_var_t:file { lock unlink create write setattr read getattr rename };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow nmbd_t usr_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Permissions to write log files.
Chris PeBenito ab58ad
allow nmbd_t samba_log_t:file { create ra_file_perms };
Chris PeBenito ab58ad
allow nmbd_t var_log_t:dir search;
Chris PeBenito ab58ad
allow nmbd_t samba_log_t:dir ra_dir_perms;
Chris PeBenito ab58ad
allow nmbd_t etc_t:file { getattr read };
Chris PeBenito ab58ad
ifdef(`cups.te', `
Chris PeBenito ab58ad
allow smbd_t cupsd_rw_etc_t:file { getattr read };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
# Needed for winbindd
Chris PeBenito ab58ad
allow smbd_t { samba_var_t smbd_var_run_t }:sock_file create_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Support Samba sharing of home directories
Chris PeBenito ab58ad
bool samba_enable_home_dirs false;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`mount.te', `
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Domain for running smbmount
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Derive from app. domain. Transition from mount.
Chris PeBenito ab58ad
application_domain(smbmount, `, fs_domain, nscd_client_domain')
Chris PeBenito ab58ad
domain_auto_trans(mount_t, smbmount_exec_t, smbmount_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Capabilities
Chris PeBenito ab58ad
# FIXME: is all of this really necessary?
Chris PeBenito ab58ad
allow smbmount_t self:capability { net_bind_service sys_rawio sys_admin dac_override chown };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access samba config
Chris PeBenito ab58ad
allow smbmount_t samba_etc_t:file r_file_perms;
Chris PeBenito ab58ad
allow smbmount_t samba_etc_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow initrc_t samba_etc_t:file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write samba log
Chris PeBenito ab58ad
allow smbmount_t samba_log_t:file create_file_perms;
Chris PeBenito ab58ad
allow smbmount_t samba_log_t:dir r_dir_perms; 
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Write stuff in var
Chris PeBenito ab58ad
allow smbmount_t var_log_t:dir r_dir_perms;
Chris PeBenito ab58ad
rw_dir_create_file(smbmount_t, samba_var_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access mtab
Chris PeBenito ab58ad
file_type_auto_trans(smbmount_t, etc_t, etc_runtime_t, file)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read nsswitch.conf
Chris PeBenito ab58ad
allow smbmount_t etc_t:file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Networking
Chris PeBenito ab58ad
can_network(smbmount_t)
Chris PeBenito ab58ad
allow smbmount_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ypbind(smbmount_t)
Chris PeBenito ab58ad
allow smbmount_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow smbmount_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow kernel_t smbmount_t:tcp_socket { read write };
Chris PeBenito ab58ad
allow userdomain smbmount_t:tcp_socket write;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Proc
Chris PeBenito ab58ad
# FIXME: is this necessary?
Chris PeBenito ab58ad
r_dir_file(smbmount_t, proc_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Fork smbmnt 
Chris PeBenito ab58ad
allow smbmount_t bin_t:dir r_dir_perms;
Chris PeBenito ab58ad
can_exec(smbmount_t, smbmount_exec_t)
Chris PeBenito ab58ad
allow smbmount_t self:process { fork signal_perms };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Mount 
Chris PeBenito ab58ad
allow smbmount_t cifs_t:filesystem mount_fs_perms;
Chris PeBenito ab58ad
allow smbmount_t cifs_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow smbmount_t mnt_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow smbmount_t mnt_t:dir mounton;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Terminal
Chris PeBenito ab58ad
read_locale(smbmount_t) 
Chris PeBenito ab58ad
access_terminal(smbmount_t, sysadm)
Chris PeBenito ab58ad
allow smbmount_t userdomain:fd use;
Chris PeBenito ab58ad
allow smbmount_t local_login_t:fd use;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
# Derive from app. domain. Transition from mount.
Chris PeBenito ab58ad
application_domain(samba_net, `, nscd_client_domain')
Chris PeBenito ab58ad
role system_r types samba_net_t;
Chris PeBenito ab58ad
in_user_role(samba_net_t)
Chris PeBenito ab58ad
file_type_auto_trans(samba_net_t, samba_etc_t, samba_secrets_t, file)
Chris PeBenito ab58ad
read_locale(samba_net_t) 
Chris PeBenito ab58ad
allow samba_net_t samba_etc_t:file r_file_perms;
Chris PeBenito ab58ad
r_dir_file(samba_net_t, samba_var_t)
Chris PeBenito ab58ad
can_network_udp(samba_net_t)
Chris PeBenito ab58ad
access_terminal(samba_net_t, sysadm)
Chris PeBenito ab58ad
allow samba_net_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow samba_net_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
rw_dir_create_file(samba_net_t, samba_var_t)
Chris PeBenito ab58ad
allow samba_net_t etc_t:file { getattr read };
Chris PeBenito ab58ad
can_network_client(samba_net_t)
Chris PeBenito ab58ad
allow samba_net_t smbd_port_t:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ldap(samba_net_t)
Chris PeBenito ab58ad
can_kerberos(samba_net_t)
Chris PeBenito ab58ad
allow samba_net_t urandom_device_t:chr_file r_file_perms;
Chris PeBenito ab58ad
allow samba_net_t proc_t:dir search;
Chris PeBenito ab58ad
allow samba_net_t proc_t:lnk_file read;
Chris PeBenito ab58ad
allow samba_net_t self:dir search;
Chris PeBenito ab58ad
allow samba_net_t self:file read;
Chris PeBenito ab58ad
allow samba_net_t self:process signal;
Chris PeBenito ab58ad
tmp_domain(samba_net)
Chris PeBenito ab58ad
dontaudit samba_net_t sysadm_home_dir_t:dir search;
Chris PeBenito ab58ad
allow samba_net_t privfd:fd use;