selinux-refpolicy/policy/support/misc_macros.spt
Chris PeBenito 78a49b640d Add new mmap permission set and pattern support macros.
Deprecate mmap_file_perms and mmap_files_pattern since they are not fully
informative about their access.  Replace with a full set of permission
set macros for mmap.

Requested for selinux-testsuite usage.
2017-12-13 18:58:34 -05:00

78 lines
1.7 KiB
Cheetah

########################################
#
# Helper macros
#
#
# shiftn(num,list...)
#
# shift the list num times
#
define(`shiftn',`ifelse($1,0,`shift($*)',`shiftn(decr($1),shift(shift($*)))')')
#
# ifndef(expr,true_block,false_block)
#
# m4 does not have this.
#
define(`ifndef',`ifdef(`$1',`$3',`$2')')
#
# __endline__
#
# dummy macro to insert a newline. used for
# errprint, so the close parentheses can be
# indented correctly.
#
define(`__endline__',`
')
########################################
#
# refpolwarn(message)
#
# print a warning message
#
define(`refpolicywarn',`errprint(__program__:__file__:__line__: Warning: `$1'__endline__) ifdef(`m4_werror',`define(`m4_fatal_error')')')
########################################
#
# refpolerr(message)
#
# print an error message.
#
define(`refpolicyerr',`errprint(__program__:__file__:__line__: Error: `$1'__endline__) define(`m4_fatal_error')')
########################################
#
# gen_user(username, prefix, role_set, mls_defaultlevel, mls_range, [mcs_categories])
#
define(`gen_user',`dnl
ifdef(`users_extra',`dnl
ifelse(`$2',,,`user $1 prefix $2;')
',`dnl
user $1 roles { $3 }`'ifdef(`enable_mls', ` level $4 range $5')`'ifdef(`enable_mcs',` level s0 range s0`'ifelse(`$6',,,` - s0:$6')');
')dnl
')
########################################
#
# gen_context(context,mls_sensitivity,[mcs_categories])
#
define(`gen_context',`$1`'ifdef(`enable_mls',`:$2')`'ifdef(`enable_mcs',`:s0`'ifelse(`$3',,,`:$3')')')dnl
########################################
#
# can_exec(domain,executable)
#
define(`can_exec',`allow $1 $2:file { mmap_exec_file_perms ioctl lock execute_no_trans };')
########################################
#
# gen_bool(name,default_value)
#
define(`gen_bool',`
bool $1 dflt_or_overr(`$1'_conf,$2);
')