checkpolicy policy version warnings
PATCH 1/1 checkpolicy policy version warnings
These patches add a global is_building_modules variable to checkmodule, checkpolicy and the parser. It is used to determine whether a kernel policy is being built so that NETLINK class warnings are only caused when building a kernel policy. This will also be necessary to know whether policycon statements are allowed (for the policy server).
Joshua Brindle
checkmodule.c +3 -1
@@ -49,8 +49,10 @@ static char *txtfile = "policy.conf";static char *binfile ="policy" ;unsigned int policy_type =POLICY_BASE ; -unsigned int policyvers =POLICYDB_VERSION_MAX ; +unsigned int policyvers =MOD_POLICYDB_VERSION_MAX ;unsigned int mlspol =0 ; +/* always set to 0 for checkpolicy, set to 1 for checkmodule */ +unsigned int is_building_modules =1 ;static int read_binary_policy (policydb_t *p,char *file,char *progname) {
checkpolicy.c +3 -0
@@ -103,6 +103,9 @@ static char *binfile = "policy";unsigned int policyvers =POLICYDB_VERSION_MAX ;unsigned int mlspol =0 ; +/* always set to 0 for checkpolicy, set to 1 for checkmodule */ +unsigned int is_building_modules =0 ; +void usage (char *progname) { printf("usage: %s [-b] [-d] [-M] [-c policyvers (%d-%d)] [-o output_file] [input_file]\n",
policy_parse.y +5 -2
@@ -70,6 +70,7 @@ extern unsigned long policydb_lineno; extern unsigned long source_lineno; extern unsigned int policydb_errors; extern unsigned int policyvers; +extern int is_building_modules; extern char yytext[]; extern int yylex(void);
@@ -2006,7 +2007,8 @@ static int define_compute_type_helper(in yyerror(errormsg); goto bad; } - if (policyvers < POLICYDB_VERSION_NLCLASS && + if (!is_building_modules && + policyvers < POLICYDB_VERSION_NLCLASS && (cladatum->value >= SECCLASS_NETLINK_ROUTE_SOCKET && cladatum->value <= SECCLASS_NETLINK_DNRT_SOCKET)) { sprintf(errormsg, "remapping class %s to netlink_socket "
@@ -2270,7 +2272,8 @@ static int define_te_avtab_helper(int wh ret = -1; goto out; } - if (policyvers < POLICYDB_VERSION_NLCLASS && + if (!is_building_modules && + policyvers < POLICYDB_VERSION_NLCLASS && (cladatum->value >= SECCLASS_NETLINK_ROUTE_SOCKET && cladatum->value <= SECCLASS_NETLINK_DNRT_SOCKET)) { sprintf(errormsg, "remapping class %s to netlink_socket "