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',`
|
2005-06-07 18:45:47 +00:00
|
|
|
ifdef(`monolithic_policy',`',`
|
|
|
|
module $1 $2;
|
2005-08-22 17:07:17 +00:00
|
|
|
|
2005-08-22 20:18:42 +00:00
|
|
|
require { all_kernel_class_perms }
|
|
|
|
')
|
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',`
|
2005-06-07 18:45:47 +00:00
|
|
|
ifdef(`monolithic_policy',`',`
|
|
|
|
require {
|
|
|
|
$1
|
|
|
|
}
|
|
|
|
')
|
|
|
|
')
|
2005-06-02 14:31: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
|
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-06-22 19:21:31 +00:00
|
|
|
define(`template',`
|
|
|
|
`define(`$1',`
|
2005-07-12 20:33:42 +00:00
|
|
|
##### begin $1(dollarsstar)
|
2005-06-08 13:11:47 +00:00
|
|
|
$2
|
2005-07-12 20:33:42 +00:00
|
|
|
##### end $1(dollarsstar)
|
2005-06-22 19:21:31 +00:00
|
|
|
'')
|
2005-06-08 13:11:47 +00:00
|
|
|
')
|
|
|
|
|
2005-06-22 19:21:31 +00:00
|
|
|
# helper function, since m4 wont expand macros
|
|
|
|
# if a line is a comment (#):
|
|
|
|
define(`policy_m4_comment',`dnl
|
|
|
|
##### $2 depth: $1
|
|
|
|
')dnl
|
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# In the future interfaces should be in loadable modules
|
|
|
|
#
|
|
|
|
# interface(name,rules)
|
|
|
|
#
|
|
|
|
define(`interface',`
|
|
|
|
`define(`$1',`
|
|
|
|
|
|
|
|
define(`policy_temp',incr(policy_call_depth))
|
|
|
|
pushdef(`policy_call_depth',policy_temp)
|
|
|
|
undefine(`policy_temp')
|
|
|
|
|
|
|
|
policy_m4_comment(policy_call_depth,begin `$1'(dollarsstar))
|
|
|
|
|
|
|
|
$2
|
|
|
|
|
|
|
|
define(`policy_temp',decr(policy_call_depth))
|
|
|
|
pushdef(`policy_call_depth',policy_temp)
|
|
|
|
undefine(`policy_temp')
|
|
|
|
|
|
|
|
policy_m4_comment(policy_call_depth,end `$1'(dollarsstar))
|
|
|
|
|
|
|
|
'')
|
|
|
|
')
|
|
|
|
|
|
|
|
define(`policy_call_depth',0)
|
|
|
|
|
2005-06-02 14:31:31 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Optional policy handling
|
|
|
|
#
|
|
|
|
define(`optional_policy',`
|
2005-06-07 18:45:47 +00:00
|
|
|
ifdef(`monolithic_policy',`
|
2005-07-05 20:54:12 +00:00
|
|
|
ifdef(`$1',`$2',`$3')
|
2005-06-07 18:45:47 +00:00
|
|
|
',`
|
|
|
|
optional {
|
|
|
|
$2
|
2005-08-18 21:27:20 +00:00
|
|
|
ifelse(`$3',`',`',`
|
2005-06-07 18:45:47 +00:00
|
|
|
} else {
|
|
|
|
$3
|
2005-08-18 21:27:20 +00:00
|
|
|
')
|
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
|
|
|
|
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Tunable declaration
|
|
|
|
#
|
2005-08-24 18:30:47 +00:00
|
|
|
# cjp: modular policy commented out
|
|
|
|
# until loadable modules support tunables.
|
2005-06-13 20:27:32 +00:00
|
|
|
define(`gen_tunable',`
|
2005-08-24 18:30:47 +00:00
|
|
|
# ifdef(`monolithic_policy',`
|
2005-06-13 20:27:32 +00:00
|
|
|
bool $1 dflt_or_overr(`$1'_conf,$2);
|
2005-08-24 18:30:47 +00:00
|
|
|
# ',`
|
|
|
|
# # loadable module tunable
|
|
|
|
# # declaration will go here
|
|
|
|
# # for $1 $2
|
|
|
|
# ')
|
2005-06-07 22:26:39 +00:00
|
|
|
')
|
|
|
|
|
2005-06-02 14:31:31 +00:00
|
|
|
##############################
|
|
|
|
#
|
|
|
|
# Tunable policy handling
|
|
|
|
#
|
2005-08-24 18:30:47 +00:00
|
|
|
# cjp: modular policy commented out
|
|
|
|
# until loadable modules support tunables.
|
2005-06-02 14:31:31 +00:00
|
|
|
define(`tunable_policy',`
|
2005-08-24 18:30:47 +00:00
|
|
|
# ifdef(`monolithic_policy',`
|
2005-06-07 18:45:47 +00:00
|
|
|
if (`$1') {
|
|
|
|
$2
|
|
|
|
} else {
|
|
|
|
$3
|
|
|
|
}
|
2005-08-24 18:30:47 +00:00
|
|
|
# ',`
|
|
|
|
# optional {
|
|
|
|
# require { `$1' }
|
|
|
|
# $2
|
|
|
|
# ifelse(`$3',`',`',`
|
|
|
|
# } else {
|
|
|
|
# $3
|
|
|
|
# ')
|
|
|
|
# }
|
|
|
|
# ')
|
2005-06-07 18:45:47 +00:00
|
|
|
')
|