## <summary>The SMS Server Tools are made to send and receive short messages through GSM modems. It supports easy file interfaces and it can run external programs for automatic actions.</summary>

########################################
## <summary>
##	Execute smsd in the smsd domin.
## </summary>
## <param name="domain">
## <summary>
##	Domain allowed to transition.
## </summary>
## </param>
#
interface(`smsd_domtrans',`
	gen_require(`
		type smsd_t, smsd_exec_t;
	')

	corecmd_search_bin($1)
	domtrans_pattern($1, smsd_exec_t, smsd_t)
')

########################################
## <summary>
##	Execute smsd server in the smsd domain.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_initrc_domtrans',`
	gen_require(`
		type smsd_initrc_exec_t;
	')

	init_labeled_script_domtrans($1, smsd_initrc_exec_t)
')

########################################
## <summary>
##	Read smsd's log files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_read_log',`
	gen_require(`
		type smsd_log_t;
	')

	logging_search_logs($1)
	read_files_pattern($1, smsd_log_t, smsd_log_t)
')

########################################
## <summary>
##	Append to smsd log files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_append_log',`
	gen_require(`
		type smsd_log_t;
	')

	logging_search_logs($1)
	append_files_pattern($1, smsd_log_t, smsd_log_t)
')

########################################
## <summary>
##	Manage smsd log files
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_manage_log',`
	gen_require(`
		type smsd_log_t;
	')

	logging_search_logs($1)
	manage_dirs_pattern($1, smsd_log_t, smsd_log_t)
	manage_files_pattern($1, smsd_log_t, smsd_log_t)
	manage_lnk_files_pattern($1, smsd_log_t, smsd_log_t)
')
########################################
## <summary>
##	Read smsd PID files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_read_pid_files',`
	gen_require(`
		type smsd_var_run_t;
	')

	files_search_pids($1)
	read_files_pattern($1, smsd_var_run_t, smsd_var_run_t)
')

########################################
## <summary>
##	Search smsd spool directories.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_search_spool',`
	gen_require(`
		type smsd_spool_t;
	')

	allow $1 smsd_spool_t:dir search_dir_perms;
	files_search_spool($1)
')

########################################
## <summary>
##	Read smsd spool files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_read_spool_files',`
	gen_require(`
		type smsd_spool_t;
	')

	files_search_spool($1)
	read_files_pattern($1, smsd_spool_t, smsd_spool_t)
')

########################################
## <summary>
##	Manage smsd spool files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_manage_spool_files',`
	gen_require(`
		type smsd_spool_t;
	')

	files_search_spool($1)
	manage_files_pattern($1, smsd_spool_t, smsd_spool_t)
')

########################################
## <summary>
##	Manage smsd spool dirs.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`smsd_manage_spool_dirs',`
	gen_require(`
		type smsd_spool_t;
	')

	files_search_spool($1)
	manage_dirs_pattern($1, smsd_spool_t, smsd_spool_t)
')

########################################
## <summary>
##	All of the rules required to administrate
##	an smsd environment
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	Role allowed access.
##	</summary>
## </param>
## <rolecap/>
#
interface(`smsd_admin',`
	gen_require(`
		type smsd_t;
		type smsd_initrc_exec_t;
		type smsd_log_t;
		type smsd_var_run_t;
		type smsd_spool_t;
	')

	allow $1 smsd_t:process { ptrace signal_perms };
	ps_process_pattern($1, smsd_t)

	smsd_initrc_domtrans($1)
	domain_system_change_exemption($1)
	role_transition $2 smsd_initrc_exec_t system_r;
	allow $2 system_r;

	logging_search_logs($1)
	admin_pattern($1, smsd_log_t)

	files_search_pids($1)
	admin_pattern($1, smsd_var_run_t)

	files_search_spool($1)
	admin_pattern($1, smsd_spool_t)

	optional_policy(`
		systemd_passwd_agent_exec($1)
		systemd_read_fifo_file_passwd_run($1)
	')
')
