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