
## <summary>policy for transmission</summary>

########################################
## <summary>
##	Execute transmission_exec_t in the transmission domain.
## </summary>
## <param name="domain">
## <summary>
##	Domain allowed to transition.
## </summary>
## </param>
#
interface(`transmission_domtrans',`
	gen_require(`
		type transmission_t, transmission_exec_t;
	')

	corecmd_search_bin($1)
	domtrans_pattern($1, transmission_exec_t, transmission_t)
')

######################################
## <summary>
##	Execute transmission in the caller domain.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`transmission_exec',`
	gen_require(`
		type transmission_exec_t;
	')

	corecmd_search_bin($1)
	can_exec($1, transmission_exec_t)
')
########################################
## <summary>
##	Read transmission's log files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <rolecap/>
#
interface(`transmission_read_log',`
	gen_require(`
		type transmission_log_t;
	')

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

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

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

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

	logging_search_logs($1)
	manage_dirs_pattern($1, transmission_log_t, transmission_log_t)
	manage_files_pattern($1, transmission_log_t, transmission_log_t)
	manage_lnk_files_pattern($1, transmission_log_t, transmission_log_t)
')

########################################
## <summary>
##	Search transmission lib directories.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`transmission_search_lib',`
	gen_require(`
		type transmission_var_lib_t;
	')

	allow $1 transmission_var_lib_t:dir search_dir_perms;
	files_search_var_lib($1)
')

########################################
## <summary>
##	Read transmission lib files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`transmission_read_lib_files',`
	gen_require(`
		type transmission_var_lib_t;
	')

	files_search_var_lib($1)
	read_files_pattern($1, transmission_var_lib_t, transmission_var_lib_t)
')

########################################
## <summary>
##	Manage transmission lib files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`transmission_manage_lib_files',`
	gen_require(`
		type transmission_var_lib_t;
	')

	files_search_var_lib($1)
	manage_files_pattern($1, transmission_var_lib_t, transmission_var_lib_t)
')

########################################
## <summary>
##	Manage transmission lib directories.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`transmission_manage_lib_dirs',`
	gen_require(`
		type transmission_var_lib_t;
	')

	files_search_var_lib($1)
	manage_dirs_pattern($1, transmission_var_lib_t, transmission_var_lib_t)
')

########################################
## <summary>
##	Read transmission PID files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`transmission_read_pid_files',`
	gen_require(`
		type transmission_var_run_t;
	')

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


########################################
## <summary>
##      Transmission PID files trsansiotions.
## </summary>
## <param name="domain">
##      <summary>
##      Domain allowed access.
##      </summary>
## </param>
#
interface(`transmission_pid_trans',`
        gen_require(`
                type transmission_t;
		type var_run_t;
		type transmission_var_run_t;
		type initrc_t;
        ')

        manage_dirs_pattern(transmission_t, transmission_var_run_t, transmission_var_run_t)
        manage_files_pattern(transmission_t, transmission_var_run_t, transmission_var_run_t)
        manage_lnk_files_pattern(transmission_t, transmission_var_run_t, transmission_var_run_t)
        files_pid_filetrans(transmission_t, transmission_var_run_t, { dir file lnk_file })
        filetrans_pattern(initrc_t, var_run_t, transmission_var_run_t, dir, "transmission")
')

########################################
## <summary>
##	All of the rules required to administrate
##	an transmission environment
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	Role allowed access.
##	</summary>
## </param>
## <rolecap/>
#
interface(`transmission_admin',`
	gen_require(`
		type transmission_t;
		type transmission_log_t;
		type transmission_var_lib_t;
		type transmission_var_run_t;
	')

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

    tunable_policy(`deny_ptrace',`',`
        allow $1 transmission_t:process ptrace;
    ')

	logging_search_logs($1)
	admin_pattern($1, transmission_log_t)

	files_search_var_lib($1)
	admin_pattern($1, transmission_var_lib_t)

	files_search_pids($1)
	admin_pattern($1, transmission_var_run_t)
	optional_policy(`
		systemd_passwd_agent_exec($1)
		systemd_read_fifo_file_passwd_run($1)
	')
')

########################################
## <summary>
##      Bind TCP sockets to the transmission peer port.
## </summary>
## <param name="domain">
##      <summary>
##      Domain allowed access.
##      </summary>
## </param>
## <infoflow type="none"/>
#
interface(`corenet_tcp_bind_transmission_peer_port',`
        gen_require(`
                type transmission_peer_port_t;
        ')

	allow $1 transmission_peer_port_t:tcp_socket name_bind;

')

########################################
## <summary>
##      Bind UDP sockets to the transmission peer port.
## </summary>
## <param name="domain">
##      <summary>
##      Domain allowed access.
##      </summary>
## </param>
## <infoflow type="none"/>
#
interface(`corenet_udp_bind_transmission_peer_port',`
        gen_require(`
                type transmission_peer_port_t;
        ')

	allow $1 transmission_peer_port_t:udp_socket name_bind;

')

########################################
## <summary>
##      Bind TCP sockets to the transmission rpc port.
## </summary>
## <param name="domain">
##      <summary>
##      Domain allowed access.
##      </summary>
## </param>
## <infoflow type="none"/>
#
interface(`corenet_tcp_bind_transmission_rpc_port',`
        gen_require(`
                type transmission_rpc_port_t;
        ')

        allow $1 transmission_rpc_port_t:tcp_socket name_bind;

')
