policy_module(vdagent, 1.1.1)

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

type vdagent_t;
type vdagent_exec_t;
init_daemon_domain(vdagent_t, vdagent_exec_t)

type vdagentd_initrc_exec_t;
init_script_file(vdagentd_initrc_exec_t)

type vdagent_var_run_t;
files_pid_file(vdagent_var_run_t)

type vdagent_log_t;
logging_log_file(vdagent_log_t)

########################################
#
# Local policy
#

dontaudit vdagent_t self:capability sys_admin;
allow vdagent_t self:process signal;

allow vdagent_t self:fifo_file rw_fifo_file_perms;
allow vdagent_t self:unix_stream_socket { accept listen };

manage_dirs_pattern(vdagent_t, vdagent_var_run_t, vdagent_var_run_t)
manage_files_pattern(vdagent_t, vdagent_var_run_t, vdagent_var_run_t)
manage_sock_files_pattern(vdagent_t, vdagent_var_run_t, vdagent_var_run_t)
files_pid_filetrans(vdagent_t, vdagent_var_run_t, { dir file sock_file })

manage_dirs_pattern(vdagent_t, vdagent_log_t, vdagent_log_t)
append_files_pattern(vdagent_t, vdagent_log_t, vdagent_log_t)
create_files_pattern(vdagent_t, vdagent_log_t, vdagent_log_t)
setattr_files_pattern(vdagent_t, vdagent_log_t, vdagent_log_t)
logging_log_filetrans(vdagent_t, vdagent_log_t, file)

kernel_request_load_module(vdagent_t)

dev_rw_input_dev(vdagent_t)
dev_rw_mtrr(vdagent_t)
dev_read_sysfs(vdagent_t)
dev_dontaudit_write_mtrr(vdagent_t)

fs_getattr_cgroup(vdagent_t)
fs_search_cgroup_dirs(vdagent_t)
fs_getattr_tmpfs(vdagent_t)

term_use_virtio_console(vdagent_t)

init_read_state(vdagent_t)

systemd_read_logind_sessions_files(vdagent_t)
systemd_login_read_pid_files(vdagent_t)
systemd_login_watch_session_dirs(vdagent_t)
systemd_dbus_chat_logind(vdagent_t)

logging_send_syslog_msg(vdagent_t)

userdom_read_all_users_state(vdagent_t)

xserver_read_xdm_state(vdagent_t)

optional_policy(`
	dbus_system_bus_client(vdagent_t)

	optional_policy(`
		consolekit_dbus_chat(vdagent_t)
	')
')
