## <summary>nut - Network UPS Tools </summary>

#######################################
## <summary>
##  Creates types and rules for a basic
##  Network UPS Tools systemd daemon domain.
## </summary>
## <param name="prefix">
##  <summary>
##  Prefix for the domain.
##  </summary>
## </param>
#
template(`nut_domain_template',`
	gen_require(`
		attribute nut_domain;
	')

	type nut_$1_t, nut_domain;
	type nut_$1_exec_t;
	init_daemon_domain(nut_$1_t, nut_$1_exec_t)

	type nut_$1_tmp_t;
	files_tmp_file(nut_$1_tmp_t)

	manage_dirs_pattern(nut_$1_t, nut_$1_tmp_t, nut_$1_tmp_t)
	manage_files_pattern(nut_$1_t, nut_$1_tmp_t, nut_$1_tmp_t)
	manage_lnk_files_pattern(nut_$1_t, nut_$1_tmp_t, nut_$1_tmp_t)
	files_tmp_filetrans(nut_$1_t, nut_$1_tmp_t, { lnk_file file dir })
	fs_tmpfs_filetrans(nut_$1_t, nut_$1_tmp_t, { lnk_file file dir })

    auth_use_nsswitch(nut_$1_t)

    logging_send_syslog_msg(nut_$1_t)

')

#######################################
## <summary>
##  Execute swift server in the swift domain.
## </summary>
## <param name="domain">
##  <summary>
##  Domain allowed to transition.
##  </summary>
## </param>
#
interface(`nut_systemctl',`
    gen_require(`
        type nut_t;
        type nut_unit_file_t;
    ')

	systemd_exec_systemctl($1)
	init_reload_services($1)
    allow $1 nut_unit_file_t:file read_file_perms;
    allow $1 nut_unit_file_t:service manage_service_perms;

    ps_process_pattern($1, nut_t)
')
