Chris PeBenito 31b7c0
#DESC Amanda - Automated backup program
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# This policy file sets the rigths for amanda client started by inetd_t
Chris PeBenito 31b7c0
# and amrecover 
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# X-Debian-Packages: amanda-common amanda-server
Chris PeBenito 31b7c0
# Depends: inetd.te
Chris PeBenito 31b7c0
# Author     :  Carsten Grohmann <carstengrohmann@gmx.de>
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# License    :  GPL
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# last change:  27. August 2002
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# state      :  complete and tested
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Hints      :
Chris PeBenito 31b7c0
#  - amanda.fc is the appendant file context file
Chris PeBenito 31b7c0
#  - If you use amrecover please extract the files and directories to the
Chris PeBenito 31b7c0
#    directory speficified in amanda.fc as type amanda_recover_dir_t.
Chris PeBenito 31b7c0
#  - The type amanda_user_exec_t is defined to label the files but not used.
Chris PeBenito 31b7c0
#    This configuration works only as an client and a amanda client does not need
Chris PeBenito 31b7c0
#    this programs.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Enhancements/Corrections:
Chris PeBenito 31b7c0
#  - set tighter permissions to /bin/tar instead bin_t 
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##############################################################################
Chris PeBenito 31b7c0
# AMANDA CLIENT DECLARATIONS
Chris PeBenito 31b7c0
##############################################################################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# General declarations
Chris PeBenito 31b7c0
######################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
type amanda_t, domain, privlog, auth, fs_domain, nscd_client_domain;
Chris PeBenito 31b7c0
role system_r types amanda_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for the amanda executables
Chris PeBenito 31b7c0
type amanda_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for the amanda executables started by inetd
Chris PeBenito 31b7c0
type amanda_inetd_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for amanda configurations files
Chris PeBenito 31b7c0
type amanda_config_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for files in /usr/lib/amanda
Chris PeBenito 31b7c0
type amanda_usr_lib_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for all files in /var/lib/amanda
Chris PeBenito 31b7c0
type amanda_var_lib_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for all files in /var/lib/amanda/gnutar-lists/
Chris PeBenito 31b7c0
type amanda_gnutarlists_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for user startable files
Chris PeBenito 31b7c0
type amanda_user_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for same awk and other scripts
Chris PeBenito 31b7c0
type amanda_script_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for the shell configuration files 
Chris PeBenito 31b7c0
type amanda_shellconfig_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
tmp_domain(amanda)
Chris PeBenito 31b7c0
 
Chris PeBenito 31b7c0
# type for /etc/amandates
Chris PeBenito 31b7c0
type amanda_amandates_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for /etc/dumpdates
Chris PeBenito 31b7c0
type amanda_dumpdates_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for amanda data
Chris PeBenito 31b7c0
type amanda_data_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Domain transitions
Chris PeBenito 31b7c0
####################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
domain_auto_trans(inetd_t, amanda_inetd_exec_t, amanda_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##################
Chris PeBenito 31b7c0
# File permissions
Chris PeBenito 31b7c0
##################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# configuration files -> read only
Chris PeBenito 31b7c0
allow amanda_t amanda_config_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to amanda_amandates_t
Chris PeBenito 31b7c0
allow amanda_t amanda_amandates_t:file { getattr lock read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to amanda_dumpdates_t
Chris PeBenito 31b7c0
allow amanda_t amanda_dumpdates_t:file { getattr lock read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to amandas data structure
Chris PeBenito 31b7c0
allow amanda_t amanda_data_t:dir { read search write };
Chris PeBenito 31b7c0
allow amanda_t amanda_data_t:file { read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to proc_t
Chris PeBenito 31b7c0
allow amanda_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to etc_t and similar
Chris PeBenito 31b7c0
allow amanda_t etc_t:file { getattr read };
Chris PeBenito 31b7c0
allow amanda_t etc_runtime_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to amanda_gnutarlists_t (/var/lib/amanda/gnutar-lists)
Chris PeBenito 31b7c0
rw_dir_create_file(amanda_t, amanda_gnutarlists_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to device_t and similar
Chris PeBenito 31b7c0
allow amanda_t devtty_t:chr_file { read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to fs_t
Chris PeBenito 31b7c0
allow amanda_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to sysctl_kernel_t ( proc/sys/kernel/* )
Chris PeBenito 31b7c0
read_sysctl(amanda_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#####################
Chris PeBenito 31b7c0
# process permissions
Chris PeBenito 31b7c0
#####################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow to use shared libs
Chris PeBenito 31b7c0
uses_shlib(amanda_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow to execute a amanda executable file
Chris PeBenito 31b7c0
allow amanda_t amanda_exec_t:file { execute execute_no_trans getattr read };	
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow to run a shell
Chris PeBenito 31b7c0
allow amanda_t shell_exec_t:file { execute execute_no_trans getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to bin_t (tar)
Chris PeBenito 31b7c0
allow amanda_t bin_t:file { execute execute_no_trans };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow amanda_t self:capability { chown dac_override setuid };
Chris PeBenito 31b7c0
allow amanda_t self:process { fork sigchld setpgid signal };
Chris PeBenito 31b7c0
allow amanda_t self:dir search;
Chris PeBenito 31b7c0
allow amanda_t self:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
###################################
Chris PeBenito 31b7c0
# Network and process communication
Chris PeBenito 31b7c0
###################################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
can_network_server(amanda_t);
Chris PeBenito 31b7c0
can_ypbind(amanda_t);
Chris PeBenito 31b7c0
can_exec(amanda_t, sbin_t);
Chris PeBenito 31b7c0
	
Chris PeBenito 31b7c0
allow amanda_t self:fifo_file { getattr read write ioctl lock };
Chris PeBenito 31b7c0
allow amanda_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow amanda_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########################
Chris PeBenito 31b7c0
# Communication with inetd
Chris PeBenito 31b7c0
##########################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow amanda_t inetd_t:udp_socket { read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
###################
Chris PeBenito 31b7c0
# inetd permissions
Chris PeBenito 31b7c0
###################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow inetd_t amanda_usr_lib_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
########################
Chris PeBenito 31b7c0
# Access to to save data
Chris PeBenito 31b7c0
########################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to user_home_t
Chris PeBenito 31b7c0
allow amanda_t user_home_type:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##############################################################################
Chris PeBenito 31b7c0
# AMANDA RECOVER DECLARATIONS
Chris PeBenito 31b7c0
##############################################################################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# General declarations
Chris PeBenito 31b7c0
######################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for amrecover
Chris PeBenito 31b7c0
type amanda_recover_t, domain;
Chris PeBenito 31b7c0
role sysadm_r types amanda_recover_t;
Chris PeBenito 31b7c0
role system_r types amanda_recover_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# exec types for amrecover 
Chris PeBenito 31b7c0
type amanda_recover_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# type for recover files ( restored data )
Chris PeBenito 31b7c0
type amanda_recover_dir_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
file_type_auto_trans(amanda_recover_t, sysadm_home_dir_t, amanda_recover_dir_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# domain transsition
Chris PeBenito 31b7c0
domain_auto_trans(sysadm_t, amanda_recover_exec_t, amanda_recover_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# file type auto trans to write debug messages
Chris PeBenito 31b7c0
file_type_auto_trans(amanda_recover_t, tmp_t, amanda_tmp_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# amanda recover process permissions
Chris PeBenito 31b7c0
####################################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
uses_shlib(amanda_recover_t)
Chris PeBenito 31b7c0
allow amanda_recover_t self:process { fork sigkill sigstop sigchld signal };
Chris PeBenito 31b7c0
allow amanda_recover_t self:capability { fowner fsetid kill setgid setuid chown dac_override net_bind_service };
Chris PeBenito 31b7c0
can_exec(amanda_recover_t, shell_exec_t)
Chris PeBenito 31b7c0
allow amanda_recover_t privfd:fd use;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# amrecover network and process communication
Chris PeBenito 31b7c0
#############################################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
can_network(amanda_recover_t);
Chris PeBenito 31b7c0
allow amanda_recover_t amanda_port_t:tcp_socket name_connect;
Chris PeBenito 31b7c0
can_ypbind(amanda_recover_t);
Chris PeBenito 31b7c0
read_locale(amanda_recover_t);
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow amanda_recover_t self:fifo_file { getattr ioctl read write };
Chris PeBenito 31b7c0
allow amanda_recover_t self:unix_stream_socket { connect create read write };
Chris PeBenito 31b7c0
allow amanda_recover_t var_log_t:dir search;
Chris PeBenito 31b7c0
rw_dir_create_file(amanda_recover_t, amanda_log_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# amrecover file permissions
Chris PeBenito 31b7c0
############################
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to etc_t and similar
Chris PeBenito 31b7c0
allow amanda_recover_t etc_t:dir search;
Chris PeBenito 31b7c0
allow amanda_recover_t etc_t:file { getattr read };
Chris PeBenito 31b7c0
allow amanda_recover_t etc_runtime_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to amanda_recover_dir_t
Chris PeBenito 31b7c0
allow amanda_recover_t amanda_recover_dir_t:dir { add_name remove_name search write };
Chris PeBenito 31b7c0
allow amanda_recover_t amanda_recover_dir_t:file { append create getattr setattr unlink };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to var_t and var_run_t
Chris PeBenito 31b7c0
allow amanda_recover_t var_t:dir search;
Chris PeBenito 31b7c0
allow amanda_recover_t var_run_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to proc_t
Chris PeBenito 31b7c0
allow amanda_recover_t proc_t:dir search;
Chris PeBenito 31b7c0
allow amanda_recover_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to sysctl_kernel_t
Chris PeBenito 31b7c0
read_sysctl(amanda_recover_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to dev_t and similar
Chris PeBenito 31b7c0
allow amanda_recover_t device_t:dir search;
Chris PeBenito 31b7c0
allow amanda_recover_t devtty_t:chr_file { read write };
Chris PeBenito 31b7c0
allow amanda_recover_t null_device_t:chr_file { getattr write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to bin_t
Chris PeBenito 31b7c0
allow amanda_recover_t bin_t:file { execute execute_no_trans };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to sysadm_home_t and sysadm_home_dir_t to start amrecover 
Chris PeBenito 31b7c0
# in the sysadm home directory
Chris PeBenito 31b7c0
allow amanda_recover_t { sysadm_home_dir_t sysadm_home_t }:dir { search getattr };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to use sysadm_tty_device_t (/dev/tty?)
Chris PeBenito 31b7c0
allow amanda_recover_t sysadm_tty_device_t:chr_file { getattr ioctl read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# access to amanda_tmp_t and tmp_t
Chris PeBenito 31b7c0
allow amanda_recover_t amanda_tmp_t:dir { add_name remove_name search write };
Chris PeBenito 31b7c0
allow amanda_recover_t amanda_tmp_t:file { append create getattr setattr unlink };
Chris PeBenito 31b7c0
allow amanda_recover_t tmp_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
#  Rules to allow amanda to be run as a service in xinetd
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
allow inetd_t amanda_port_t:{ tcp_socket udp_socket } name_bind;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#amanda needs to look at fs_type directories to decide whether it should backup
Chris PeBenito 31b7c0
allow amanda_t { fs_type file_type }:dir {getattr read search };
Chris PeBenito 31b7c0
allow amanda_t file_type:{ lnk_file file chr_file blk_file } {getattr read };
Chris PeBenito 31b7c0
allow amanda_t device_type:{ blk_file chr_file } getattr;
Chris PeBenito 31b7c0
allow amanda_t fixed_disk_device_t:blk_file read;
Chris PeBenito 31b7c0
domain_auto_trans(amanda_t, fsadm_exec_t, fsadm_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow amanda_t file_type:sock_file getattr;
Chris PeBenito 31b7c0
logdir_domain(amanda)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
dontaudit amanda_t proc_t:lnk_file read;
Chris PeBenito 31b7c0
dontaudit amanda_t unlabeled_t:file getattr;
Chris PeBenito 31b7c0
#amanda wants to check attributes on fifo_files
Chris PeBenito 31b7c0
allow amanda_t file_type:fifo_file getattr;