policy_module(modemmanager)

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

type modemmanager_t;
type modemmanager_exec_t;
init_daemon_domain(modemmanager_t, modemmanager_exec_t)

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

allow modemmanager_t self:capability { net_admin sys_admin sys_tty_config };
allow modemmanager_t self:process { getsched setpgid setsched signal };
allow modemmanager_t self:fifo_file rw_fifo_file_perms;
allow modemmanager_t self:unix_stream_socket { connectto create_stream_socket_perms };
allow modemmanager_t self:netlink_kobject_uevent_socket create_socket_perms;
allow modemmanager_t self:netlink_route_socket { create getattr getopt nlmsg_write read write };
allow modemmanager_t self:qipcrtr_socket { create getattr getopt read write };

# ModemManager  calls mmap(PROT_READ|PROT_WRITE|PROT_EXEC)
allow modemmanager_t self:process execmem;

kernel_read_system_state(modemmanager_t)
kernel_request_load_module(modemmanager_t)

# for qmi/pass_through
dev_create_sysfs_files(modemmanager_t)

dev_getattr_sysfs(modemmanager_t)
dev_read_sysfs(modemmanager_t)
dev_write_sysfs(modemmanager_t)
dev_rw_modem(modemmanager_t)

# for /usr/libexec/qmi-proxy
corecmd_exec_bin(modemmanager_t)

files_read_etc_files(modemmanager_t)

term_use_generic_ptys(modemmanager_t)
term_use_unallocated_ttys(modemmanager_t)

miscfiles_read_localization(modemmanager_t)

logging_send_syslog_msg(modemmanager_t)

optional_policy(`
	dbus_system_domain(modemmanager_t, modemmanager_exec_t)

	optional_policy(`
		devicekit_dbus_chat_power(modemmanager_t)
	')

	optional_policy(`
		networkmanager_dbus_chat(modemmanager_t)
	')

	optional_policy(`
		policykit_dbus_chat(modemmanager_t)
	')
')

optional_policy(`
	systemd_write_inherited_logind_inhibit_pipes(modemmanager_t)
')

optional_policy(`
	udev_manage_runtime_files(modemmanager_t)
')
