2005-06-02 14:31:31 +00:00
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Macros for switching between source policy
|
|
|
|
# and loadable policy module support
|
|
|
|
#
|
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# For adding the module statement
|
|
|
|
#
|
|
|
|
define(`policy_module',`
|
2006-06-12 17:27:15 +00:00
|
|
|
ifndef(`self_contained_policy',`
|
2005-06-07 18:45:47 +00:00
|
|
|
module $1 $2;
|
2005-08-22 17:07:17 +00:00
|
|
|
|
2005-10-19 14:36:04 +00:00
|
|
|
require {
|
|
|
|
role system_r;
|
|
|
|
all_kernel_class_perms
|
2006-10-04 17:25:34 +00:00
|
|
|
|
|
|
|
ifdef(`enable_mcs',`
|
2007-08-20 15:15:03 +00:00
|
|
|
decl_sens(0,0)
|
|
|
|
decl_cats(0,decr(mcs_num_cats))
|
2006-10-04 17:25:34 +00:00
|
|
|
')
|
|
|
|
|
|
|
|
ifdef(`enable_mls',`
|
2007-08-20 15:15:03 +00:00
|
|
|
decl_sens(0,decr(mls_num_sens))
|
|
|
|
decl_cats(0,decr(mls_num_cats))
|
2006-10-04 17:25:34 +00:00
|
|
|
')
|
2005-10-19 14:36:04 +00:00
|
|
|
}
|
2005-08-22 20:18:42 +00:00
|
|
|
')
|
2005-06-02 14:31:31 +00:00
|
|
|
')
|
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
2005-06-13 20:47:04 +00:00
|
|
|
# For use in interfaces, to optionally insert a require block
|
2005-06-02 14:31:31 +00:00
|
|
|
#
|
2005-06-13 20:47:04 +00:00
|
|
|
define(`gen_require',`
|
2006-03-23 21:07:57 +00:00
|
|
|
ifdef(`self_contained_policy',`
|
|
|
|
ifdef(`__in_optional_policy',`
|
|
|
|
require {
|
|
|
|
$1
|
|
|
|
} # end require
|
|
|
|
')
|
|
|
|
',`
|
2005-06-07 18:45:47 +00:00
|
|
|
require {
|
|
|
|
$1
|
2006-03-23 21:07:57 +00:00
|
|
|
} # end require
|
2005-06-07 18:45:47 +00:00
|
|
|
')
|
|
|
|
')
|
2005-06-02 14:31:31 +00:00
|
|
|
|
2005-12-05 16:43:28 +00:00
|
|
|
# helper function, since m4 wont expand macros
|
|
|
|
# if a line is a comment (#):
|
|
|
|
define(`policy_m4_comment',`
|
|
|
|
##### $2 depth: $1
|
|
|
|
')dnl
|
|
|
|
|
2005-06-08 13:11:47 +00:00
|
|
|
##############################
|
|
|
|
#
|
2005-06-22 19:21:31 +00:00
|
|
|
# In the future interfaces should be in loadable modules
|
2005-06-08 13:11:47 +00:00
|
|
|
#
|
2005-06-22 19:21:31 +00:00
|
|
|
# template(name,rules)
|
2005-06-08 13:11:47 +00:00
|
|
|
#
|
2005-12-05 16:43:28 +00:00
|
|
|
define(`template',` dnl
|
2006-07-25 17:27:00 +00:00
|
|
|
ifdef(`$1',`refpolicyerr(`duplicate definition of $1(). Original definition on '$1.) define(`__if_error')',`define(`$1',__line__)') dnl
|
2005-12-05 16:43:28 +00:00
|
|
|
`define(`$1',` dnl
|
2008-04-18 12:57:01 +00:00
|
|
|
pushdef(`policy_call_depth',incr(policy_call_depth)) dnl
|
2005-12-05 16:43:28 +00:00
|
|
|
policy_m4_comment(policy_call_depth,begin `$1'(dollarsstar)) dnl
|
|
|
|
$2 dnl
|
2008-04-18 12:57:01 +00:00
|
|
|
popdef(`policy_call_depth') dnl
|
2005-12-05 16:43:28 +00:00
|
|
|
policy_m4_comment(policy_call_depth,end `$1'(dollarsstar)) dnl
|
2005-06-22 19:21:31 +00:00
|
|
|
'')
|
2005-06-08 13:11:47 +00:00
|
|
|
')
|
|
|
|
|
2005-06-22 19:21:31 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# In the future interfaces should be in loadable modules
|
|
|
|
#
|
|
|
|
# interface(name,rules)
|
|
|
|
#
|
2005-12-05 16:43:28 +00:00
|
|
|
define(`interface',` dnl
|
2006-07-25 17:27:00 +00:00
|
|
|
ifdef(`$1',`refpolicyerr(`duplicate definition of $1(). Original definition on '$1.) define(`__if_error')',`define(`$1',__line__)') dnl
|
2005-12-05 16:43:28 +00:00
|
|
|
`define(`$1',` dnl
|
2008-04-18 12:57:01 +00:00
|
|
|
pushdef(`policy_call_depth',incr(policy_call_depth)) dnl
|
2005-12-05 16:43:28 +00:00
|
|
|
policy_m4_comment(policy_call_depth,begin `$1'(dollarsstar)) dnl
|
2005-06-22 19:21:31 +00:00
|
|
|
$2
|
2008-04-18 12:57:01 +00:00
|
|
|
popdef(`policy_call_depth') dnl
|
2005-12-05 16:43:28 +00:00
|
|
|
policy_m4_comment(policy_call_depth,end `$1'(dollarsstar)) dnl
|
2005-06-22 19:21:31 +00:00
|
|
|
'')
|
|
|
|
')
|
|
|
|
|
|
|
|
define(`policy_call_depth',0)
|
|
|
|
|
2005-06-02 14:31:31 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Optional policy handling
|
|
|
|
#
|
|
|
|
define(`optional_policy',`
|
2011-10-14 14:22:16 +00:00
|
|
|
optional {`'pushdef(`__in_optional_policy')
|
|
|
|
$1
|
|
|
|
ifelse(`$2',`',`',`} else {
|
|
|
|
$2
|
|
|
|
')}`'popdef(`__in_optional_policy')`'ifndef(`__in_optional_policy',` # end optional')
|
2005-06-07 18:45:47 +00:00
|
|
|
')
|
2005-06-02 14:31:31 +00:00
|
|
|
|
2005-06-07 22:26:39 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Determine if we should use the default
|
|
|
|
# tunable value as specified by the policy
|
|
|
|
# or if the override value should be used
|
|
|
|
#
|
2005-06-13 20:27:32 +00:00
|
|
|
define(`dflt_or_overr',`ifdef(`$1',$1,$2)')
|
2005-06-07 22:26:39 +00:00
|
|
|
|
2005-09-21 20:01:40 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Extract booleans out of an expression.
|
|
|
|
# This needs to be reworked so expressions
|
|
|
|
# with parentheses can work.
|
|
|
|
|
2007-03-30 12:43:15 +00:00
|
|
|
define(`declare_required_symbols',`
|
2005-09-21 20:01:40 +00:00
|
|
|
ifelse(regexp($1, `\w'), -1, `', `dnl
|
|
|
|
bool regexp($1, `\(\w+\)', `\1');
|
2007-03-30 12:43:15 +00:00
|
|
|
declare_required_symbols(regexp($1, `\w+\(.*\)', `\1'))dnl
|
2005-09-21 20:01:40 +00:00
|
|
|
') dnl
|
|
|
|
')
|
|
|
|
|
2005-06-07 22:26:39 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Tunable declaration
|
|
|
|
#
|
2005-06-13 20:27:32 +00:00
|
|
|
define(`gen_tunable',`
|
2007-03-30 12:43:15 +00:00
|
|
|
bool $1 dflt_or_overr(`$1'_conf,$2);
|
2005-06-07 22:26:39 +00:00
|
|
|
')
|
|
|
|
|
2005-06-02 14:31:31 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Tunable policy handling
|
|
|
|
#
|
|
|
|
define(`tunable_policy',`
|
2007-03-30 12:43:15 +00:00
|
|
|
gen_require(`
|
|
|
|
declare_required_symbols(`$1')
|
2005-08-24 20:00:10 +00:00
|
|
|
')
|
2007-03-30 12:43:15 +00:00
|
|
|
if (`$1') {
|
|
|
|
$2
|
|
|
|
ifelse(`$3',`',`',`} else {
|
|
|
|
$3
|
|
|
|
')}
|
2005-06-07 18:45:47 +00:00
|
|
|
')
|