| divert(-1) |
| |
| define(`fatal_error', `errprint(`m4: '__file__: __line__`: fatal error: $*')m4exit(1)') |
| define(`assert_define_visible', `ifelse($1()$1, `$1()$1', `fatal_error(`definition $1 is not visible in policy')', ``'')') |
| define(`assert_api_level_format', ` |
| ifelse(regexp(`$1', `^[0-9][0-9][0-9][0-9]04$'), 0, , ` |
| fatal_error(`Invalid API level format: $1. Expected YYYY04, e.g., 202604.') |
| ') |
| ') |
| |
| |
| #################################### |
| # is_flag_enabled(flag, rules) |
| # SELinux rules which apply only if given feature is turned on |
| define(`is_flag_enabled', ` |
| assert_define_visible(`target_flag_$1') |
| ifelse(target_flag_$1, `true', `$2') |
| ') |
| |
| #################################### |
| # is_flag_disabled(flag, rules) |
| # SELinux rules which apply only if given feature is turned off |
| define(`is_flag_disabled', ` |
| assert_define_visible(`target_flag_$1') |
| ifelse(target_flag_$1, `true', , `$2') |
| ') |
| |
| #################################### |
| # starting_at_board_api(api_level, rules_if_api_level) |
| # |
| # This macro conditionally exposes SELinux rules ensuring they are available |
| # only when the board API level is at or above the specified 'api_level'. |
| define(`starting_at_board_api', ` |
| assert_define_visible(`target_board_api_level') |
| assert_api_level_format(`$1') |
| ifelse(eval(target_board_api_level >= $1), 1, `$2') |
| ') |
| |
| #################################### |
| # until_board_api(api_level, rules_if_lower_api_level) |
| # |
| # This macro conditionally exposes SELinux rules ensuring they are available |
| # only when the board API level is below the specified 'api_level'. |
| define(`until_board_api', ` |
| assert_define_visible(`target_board_api_level') |
| assert_api_level_format(`$1') |
| ifelse(eval(target_board_api_level < $1), 1, `$2') |
| ') |
| |
| divert(0) |