2005-10-21 13:11:17 +00:00
|
|
|
#
|
|
|
|
# shiftn(num,list...)
|
|
|
|
#
|
|
|
|
# shift the list num times
|
|
|
|
#
|
|
|
|
define(`shiftn',`ifelse($1,0,`shift($*)',`shiftn(decr($1),shift(shift($*)))')')
|
|
|
|
|
2010-04-13 15:06:02 +00:00
|
|
|
#
|
|
|
|
# range_start(num)
|
|
|
|
#
|
|
|
|
# return the low port in a range.
|
|
|
|
#
|
|
|
|
# range_start(600) returns "600"
|
|
|
|
# range_start(1200-1600) returns "1200"
|
|
|
|
#
|
|
|
|
define(`range_start',`ifelse(-1,index(`$1', `-'),$1,substr($1,0,index(`$1', `-')))')
|
|
|
|
|
2006-09-29 17:37:57 +00:00
|
|
|
#
|
|
|
|
# build_option(option_name,true,[false])
|
|
|
|
#
|
|
|
|
# makes an ifdef. hacky quoting changes because with
|
|
|
|
# regular quoting, the macros in $2 and $3 will not be expanded
|
|
|
|
#
|
|
|
|
define(`build_option',`dnl
|
|
|
|
changequote([,])dnl
|
|
|
|
[ifdef(`$1',`]
|
|
|
|
changequote(`,')dnl
|
|
|
|
$2
|
|
|
|
changequote([,])dnl
|
|
|
|
[',`]
|
|
|
|
changequote(`,')dnl
|
|
|
|
$3
|
|
|
|
changequote([,])dnl
|
|
|
|
[')]
|
|
|
|
changequote(`,')dnl
|
|
|
|
')
|
|
|
|
|
2005-07-22 14:00:38 +00:00
|
|
|
define(`declare_netifs',`dnl
|
2005-10-06 19:33:06 +00:00
|
|
|
netifcon $2 gen_context(system_u:object_r:$1,$3) gen_context(system_u:object_r:unlabeled_t,$3)
|
2005-07-22 14:00:38 +00:00
|
|
|
ifelse(`$4',`',`',`declare_netifs($1,shiftn(3,$*))')dnl
|
|
|
|
')
|
|
|
|
|
2005-06-08 21:46:39 +00:00
|
|
|
#
|
2005-07-22 14:00:38 +00:00
|
|
|
# network_interface(if_name,linux_interface,mls_sensitivity)
|
2005-06-08 21:46:39 +00:00
|
|
|
#
|
|
|
|
define(`network_interface',`
|
2020-08-11 13:48:27 +00:00
|
|
|
gen_require(``type unlabeled_t;'') #selint-disable:S-001
|
2019-09-11 00:52:54 +00:00
|
|
|
type $1_netif_t, netif_type;
|
2005-07-22 14:00:38 +00:00
|
|
|
declare_netifs($1_netif_t,shift($*))
|
2005-06-08 21:46:39 +00:00
|
|
|
')
|
|
|
|
|
2009-01-15 20:31:06 +00:00
|
|
|
define(`network_interface_controlled',`
|
|
|
|
ifdef(`__network_enabled_declared__',`',`
|
|
|
|
## <desc>
|
|
|
|
## <p>
|
|
|
|
## Enable network traffic on all controlled interfaces.
|
|
|
|
## </p>
|
|
|
|
## </desc>
|
|
|
|
gen_bool(network_enabled, true)
|
|
|
|
define(`__network_enabled_declared__')
|
|
|
|
')
|
2020-08-11 13:48:27 +00:00
|
|
|
gen_require(``type unlabeled_t;'') #selint-disable:S-001
|
2019-09-11 00:52:54 +00:00
|
|
|
type $1_netif_t, netif_type;
|
2009-01-15 20:31:06 +00:00
|
|
|
declare_netifs($1_netif_t,shift($*))
|
|
|
|
')
|
|
|
|
|
2006-01-16 18:48:57 +00:00
|
|
|
define(`declare_nodes',`dnl
|
|
|
|
nodecon $3 $4 gen_context(system_u:object_r:$1,$2)
|
|
|
|
ifelse(`$5',`',`',`declare_nodes($1,shiftn(4,$*))')dnl
|
|
|
|
')
|
|
|
|
|
2005-06-08 21:46:39 +00:00
|
|
|
#
|
2006-01-16 18:48:57 +00:00
|
|
|
# network_node(node_name,mls_sensitivity,address,netmask[, mls_sensitivity,address,netmask, [...]])
|
2005-06-08 21:46:39 +00:00
|
|
|
#
|
|
|
|
define(`network_node',`
|
2019-09-11 00:52:54 +00:00
|
|
|
type $1_node_t, node_type;
|
2006-01-16 18:48:57 +00:00
|
|
|
declare_nodes($1_node_t,shift($*))
|
2005-06-08 21:46:39 +00:00
|
|
|
')
|
|
|
|
|
2011-10-04 19:31:08 +00:00
|
|
|
define(`declare_portcons',`dnl
|
2005-10-06 19:33:06 +00:00
|
|
|
portcon $2 $3 gen_context(system_u:object_r:$1,$4)
|
2011-10-04 19:31:08 +00:00
|
|
|
ifelse(`$5',`',`',`declare_portcons($1,shiftn(4,$*))')dnl
|
|
|
|
')
|
|
|
|
|
|
|
|
define(`add_port_attribute',`dnl
|
|
|
|
ifelse(eval(range_start($2) < 1024),1,`typeattribute $1 reserved_port_type;',`typeattribute $1 unreserved_port_type;')
|
|
|
|
')
|
|
|
|
|
|
|
|
# bindresvport in glibc starts searching for reserved ports at 512
|
|
|
|
define(`add_rpc_attribute',`dnl
|
|
|
|
ifelse(eval(range_start($3) >= 512 && range_start($3) < 1024),1,`typeattribute $1 rpc_port_type;
|
|
|
|
',`ifelse(`$5',`',`',`add_rpc_attribute($1,shiftn(4,$*))')')dnl
|
2005-06-08 21:46:39 +00:00
|
|
|
')
|
|
|
|
|
|
|
|
#
|
|
|
|
# network_port(port_name,protocol portnum mls_sensitivity [,protocol portnum mls_sensitivity[,...]])
|
|
|
|
#
|
|
|
|
define(`network_port',`
|
2011-08-26 13:03:25 +00:00
|
|
|
type $1_port_t, port_type, defined_port_type;
|
2006-05-26 13:49:13 +00:00
|
|
|
type $1_client_packet_t, packet_type, client_packet_type;
|
|
|
|
type $1_server_packet_t, packet_type, server_packet_type;
|
2011-10-04 19:31:08 +00:00
|
|
|
ifelse(`$2',`',`',`add_port_attribute($1_port_t,$3)')dnl
|
|
|
|
ifelse(`$2',`',`',`add_rpc_attribute($1_port_t,shift($*))')dnl
|
|
|
|
ifelse(`$2',`',`',`declare_portcons($1_port_t,shift($*))')dnl
|
2005-06-08 21:46:39 +00:00
|
|
|
')
|
2006-05-23 18:31:02 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# network_packet(packet_name)
|
|
|
|
#
|
|
|
|
define(`network_packet',`
|
2006-05-26 13:49:13 +00:00
|
|
|
type $1_client_packet_t, packet_type, client_packet_type;
|
|
|
|
type $1_server_packet_t, packet_type, server_packet_type;
|
2006-05-23 18:31:02 +00:00
|
|
|
')
|
2017-05-24 14:14:59 +00:00
|
|
|
|
2020-04-19 12:22:26 +00:00
|
|
|
#
|
|
|
|
# network_packet_simple(packet_name)
|
|
|
|
#
|
|
|
|
define(`network_packet_simple',`
|
|
|
|
type $1_packet_t, packet_type;
|
|
|
|
')
|
|
|
|
|
2017-05-24 14:14:59 +00:00
|
|
|
define(`declare_ibpkeycons',`dnl
|
|
|
|
ibpkeycon $2 $3 gen_context(system_u:object_r:$1,$4)
|
|
|
|
ifelse(`$5',`',`',`declare_ibpkeycons($1,shiftn(4,$*))')dnl
|
|
|
|
')
|
|
|
|
|
|
|
|
#
|
|
|
|
# ib_pkey(nam, subnet_prefix, pkey_num, mls_sensitivity [,subnet_prefix, pkey_num, mls_sensitivity[,...]])
|
|
|
|
#
|
|
|
|
define(`ib_pkey',`
|
|
|
|
type $1_ibpkey_t, ibpkey_type;
|
|
|
|
ifelse(`$2',`',`',`declare_ibpkeycons($1_ibpkey_t,shift($*))')dnl
|
|
|
|
')
|
|
|
|
|
|
|
|
define(`declare_ibendportcons',`dnl
|
|
|
|
ibendportcon $2 $3 gen_context(system_u:object_r:$1,$4)
|
|
|
|
ifelse(`$5',`',`',`declare_ibendportcons($1,shiftn(4,$*))')dnl
|
|
|
|
')
|
|
|
|
|
|
|
|
#
|
|
|
|
# ib_endport (name, dev_name, port_num, mls_sensitivity [, dev_name, port_num mls_sensitivity[,...]])
|
|
|
|
#
|
|
|
|
define(`ib_endport',`
|
|
|
|
type $1_ibendport_t, ibendport_type;
|
|
|
|
ifelse(`$2',`',`',`declare_ibendportcons($1_ibendport_t,shift($*))')dnl
|
|
|
|
')
|