|
Chris PeBenito |
ca83af |
########################################
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
ca83af |
# Macros for switching between source policy
|
|
Chris PeBenito |
ca83af |
# and loadable policy module support
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
ca83af |
|
|
Chris PeBenito |
ca83af |
##############################
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
ca83af |
# For adding the module statement
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
ca83af |
define(`policy_module',`
|
|
Chris PeBenito |
254bbc |
ifdef(`monolithic_policy',`',`
|
|
Chris PeBenito |
254bbc |
module $1 $2;
|
|
Chris PeBenito |
254bbc |
')
|
|
Chris PeBenito |
ca83af |
')
|
|
Chris PeBenito |
ca83af |
|
|
Chris PeBenito |
ca83af |
##############################
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
fa7bea |
# For use in interfaces, to optionally insert a require block
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
fa7bea |
define(`gen_require',`
|
|
Chris PeBenito |
254bbc |
ifdef(`monolithic_policy',`',`
|
|
Chris PeBenito |
254bbc |
require {
|
|
Chris PeBenito |
254bbc |
$1
|
|
Chris PeBenito |
254bbc |
}
|
|
Chris PeBenito |
254bbc |
')
|
|
Chris PeBenito |
254bbc |
')
|
|
Chris PeBenito |
ca83af |
|
|
Chris PeBenito |
ca83af |
##############################
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
199895 |
# In the future interfaces should be in loadable modules
|
|
Chris PeBenito |
a9ec54 |
#
|
|
Chris PeBenito |
199895 |
# template(name,rules)
|
|
Chris PeBenito |
a9ec54 |
#
|
|
Chris PeBenito |
199895 |
define(`template',`
|
|
Chris PeBenito |
199895 |
`define(`$1',`
|
|
Chris PeBenito |
199895 |
###### begin $1(dollarsstar)
|
|
Chris PeBenito |
a9ec54 |
$2
|
|
Chris PeBenito |
199895 |
###### end $1(dollarsstar)
|
|
Chris PeBenito |
199895 |
'')
|
|
Chris PeBenito |
a9ec54 |
')
|
|
Chris PeBenito |
a9ec54 |
|
|
Chris PeBenito |
199895 |
# helper function, since m4 wont expand macros
|
|
Chris PeBenito |
199895 |
# if a line is a comment (#):
|
|
Chris PeBenito |
199895 |
define(`policy_m4_comment',`dnl
|
|
Chris PeBenito |
199895 |
##### $2 depth: $1
|
|
Chris PeBenito |
199895 |
')dnl
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
199895 |
##############################
|
|
Chris PeBenito |
199895 |
#
|
|
Chris PeBenito |
199895 |
# In the future interfaces should be in loadable modules
|
|
Chris PeBenito |
199895 |
#
|
|
Chris PeBenito |
199895 |
# interface(name,rules)
|
|
Chris PeBenito |
199895 |
#
|
|
Chris PeBenito |
199895 |
define(`interface',`
|
|
Chris PeBenito |
199895 |
`define(`$1',`
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
199895 |
define(`policy_temp',incr(policy_call_depth))
|
|
Chris PeBenito |
199895 |
pushdef(`policy_call_depth',policy_temp)
|
|
Chris PeBenito |
199895 |
undefine(`policy_temp')
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
199895 |
policy_m4_comment(policy_call_depth,begin `$1'(dollarsstar))
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
199895 |
$2
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
199895 |
define(`policy_temp',decr(policy_call_depth))
|
|
Chris PeBenito |
199895 |
pushdef(`policy_call_depth',policy_temp)
|
|
Chris PeBenito |
199895 |
undefine(`policy_temp')
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
199895 |
policy_m4_comment(policy_call_depth,end `$1'(dollarsstar))
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
199895 |
'')
|
|
Chris PeBenito |
199895 |
')
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
199895 |
define(`policy_call_depth',0)
|
|
Chris PeBenito |
199895 |
|
|
Chris PeBenito |
a9ec54 |
##############################
|
|
Chris PeBenito |
a9ec54 |
#
|
|
Chris PeBenito |
ca83af |
# Optional policy handling
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
ca83af |
define(`optional_policy',`
|
|
Chris PeBenito |
254bbc |
ifdef(`monolithic_policy',`
|
|
Chris PeBenito |
e8f005 |
ifdef(`$1',`$2',`$3')
|
|
Chris PeBenito |
254bbc |
',`
|
|
Chris PeBenito |
254bbc |
optional {
|
|
Chris PeBenito |
254bbc |
$2
|
|
Chris PeBenito |
254bbc |
} else {
|
|
Chris PeBenito |
254bbc |
$3
|
|
Chris PeBenito |
254bbc |
}
|
|
Chris PeBenito |
254bbc |
')
|
|
Chris PeBenito |
254bbc |
')
|
|
Chris PeBenito |
ca83af |
|
|
Chris PeBenito |
ca83af |
##############################
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
ddea18 |
# Determine if we should use the default
|
|
Chris PeBenito |
ddea18 |
# tunable value as specified by the policy
|
|
Chris PeBenito |
ddea18 |
# or if the override value should be used
|
|
Chris PeBenito |
ddea18 |
#
|
|
Chris PeBenito |
31908b |
define(`dflt_or_overr',`ifdef(`$1',$1,$2)')
|
|
Chris PeBenito |
ddea18 |
|
|
Chris PeBenito |
ddea18 |
##############################
|
|
Chris PeBenito |
ddea18 |
#
|
|
Chris PeBenito |
ddea18 |
# Tunable declaration
|
|
Chris PeBenito |
ddea18 |
#
|
|
Chris PeBenito |
31908b |
define(`gen_tunable',`
|
|
Chris PeBenito |
ddea18 |
ifdef(`monolithic_policy',`
|
|
Chris PeBenito |
31908b |
bool $1 dflt_or_overr(`$1'_conf,$2);
|
|
Chris PeBenito |
ddea18 |
',`
|
|
Chris PeBenito |
ddea18 |
# loadable module tunable
|
|
Chris PeBenito |
ddea18 |
# declaration will go here
|
|
Chris PeBenito |
ddea18 |
# for $1 $2
|
|
Chris PeBenito |
ddea18 |
')
|
|
Chris PeBenito |
ddea18 |
')
|
|
Chris PeBenito |
ddea18 |
|
|
Chris PeBenito |
ddea18 |
##############################
|
|
Chris PeBenito |
ddea18 |
#
|
|
Chris PeBenito |
ca83af |
# Tunable policy handling
|
|
Chris PeBenito |
ca83af |
#
|
|
Chris PeBenito |
ca83af |
define(`tunable_policy',`
|
|
Chris PeBenito |
254bbc |
ifdef(`monolithic_policy',`
|
|
Chris PeBenito |
254bbc |
if (`$1') {
|
|
Chris PeBenito |
254bbc |
$2
|
|
Chris PeBenito |
254bbc |
} else {
|
|
Chris PeBenito |
254bbc |
$3
|
|
Chris PeBenito |
254bbc |
}
|
|
Chris PeBenito |
254bbc |
',`
|
|
Chris PeBenito |
254bbc |
optional {
|
|
Chris PeBenito |
254bbc |
require { `$1' }
|
|
Chris PeBenito |
254bbc |
$2
|
|
Chris PeBenito |
254bbc |
} else {
|
|
Chris PeBenito |
254bbc |
$3
|
|
Chris PeBenito |
254bbc |
}
|
|
Chris PeBenito |
254bbc |
')
|
|
Chris PeBenito |
254bbc |
')
|