policy_module(oav, 1.10.0)

########################################
#
# Declarations
#

attribute_role oav_update_roles;

type oav_update_t;
type oav_update_exec_t;
application_domain(oav_update_t, oav_update_exec_t)
role oav_update_roles types oav_update_t;

type oav_update_etc_t;
files_config_file(oav_update_etc_t)

type oav_update_var_lib_t;
files_type(oav_update_var_lib_t)

type scannerdaemon_t;
type scannerdaemon_exec_t;
init_daemon_domain(scannerdaemon_t, scannerdaemon_exec_t)

type scannerdaemon_etc_t;
files_config_file(scannerdaemon_etc_t)

type scannerdaemon_log_t;
logging_log_file(scannerdaemon_log_t)

type scannerdaemon_var_run_t;
files_pid_file(scannerdaemon_var_run_t)

########################################
#
# Update local policy
#

allow oav_update_t self:tcp_socket create_stream_socket_perms;
allow oav_update_t self:udp_socket create_socket_perms;

allow oav_update_t oav_update_etc_t:dir list_dir_perms;
allow oav_update_t oav_update_etc_t:file read_file_perms;

manage_dirs_pattern(oav_update_t, oav_update_var_lib_t, oav_update_var_lib_t)
manage_files_pattern(oav_update_t, oav_update_var_lib_t, oav_update_var_lib_t)
read_lnk_files_pattern(oav_update_t, oav_update_var_lib_t, oav_update_var_lib_t)

corecmd_exec_all_executables(oav_update_t)

files_exec_etc_files(oav_update_t)

libs_exec_ld_so(oav_update_t)
libs_exec_lib_files(oav_update_t)

logging_send_syslog_msg(oav_update_t)

sysnet_read_config(oav_update_t)

userdom_use_user_terminals(oav_update_t)

optional_policy(`
	cron_system_entry(oav_update_t, oav_update_exec_t)
')

########################################
#
# Scannerdaemon local policy
#

dontaudit scannerdaemon_t self:capability sys_tty_config;
allow scannerdaemon_t self:process signal_perms;
allow scannerdaemon_t self:fifo_file rw_fifo_file_perms;
allow scannerdaemon_t self:tcp_socket create_stream_socket_perms;
allow scannerdaemon_t self:udp_socket create_socket_perms;

allow scannerdaemon_t oav_update_var_lib_t:dir list_dir_perms;
allow scannerdaemon_t oav_update_var_lib_t:file read_file_perms;

allow scannerdaemon_t scannerdaemon_etc_t:file read_file_perms;

allow scannerdaemon_t scannerdaemon_log_t:file manage_file_perms;
logging_log_filetrans(scannerdaemon_t, scannerdaemon_log_t, file)

manage_files_pattern(scannerdaemon_t, scannerdaemon_var_run_t, scannerdaemon_var_run_t)
files_pid_filetrans(scannerdaemon_t, scannerdaemon_var_run_t, file)

kernel_read_system_state(scannerdaemon_t)
kernel_read_kernel_sysctls(scannerdaemon_t)

corecmd_exec_all_executables(scannerdaemon_t)

dev_read_sysfs(scannerdaemon_t)

domain_use_interactive_fds(scannerdaemon_t)

files_exec_etc_files(scannerdaemon_t)
files_read_etc_runtime_files(scannerdaemon_t)
files_search_var_lib(scannerdaemon_t)

fs_getattr_all_fs(scannerdaemon_t)
fs_search_auto_mountpoints(scannerdaemon_t)

auth_dontaudit_read_shadow(scannerdaemon_t)

libs_exec_ld_so(scannerdaemon_t)
libs_exec_lib_files(scannerdaemon_t)

logging_send_syslog_msg(scannerdaemon_t)

miscfiles_read_localization(scannerdaemon_t)

sysnet_read_config(scannerdaemon_t)

userdom_dontaudit_use_unpriv_user_fds(scannerdaemon_t)
userdom_dontaudit_search_user_home_dirs(scannerdaemon_t)

optional_policy(`
	seutil_sigchld_newrole(scannerdaemon_t)
')

optional_policy(`
	udev_read_db(scannerdaemon_t)
')
