libsepol: rename struct member
PATCH v2 1/6 libsepol: rename struct member
Avoid using the identifier bool to improve support with future C standards. C23 is about to make bool a predefined macro (see N2654).
Since the type cond_expr_t is part of the public API it will break client applications. A quick search of the code in Debian shows only usages in checkpolicy and setools.
Define a new macro signaling the renaming to simplify support of client applications for new and older versions of libsepol.
---
v2:
update version identifier in header to 3.6
--- libsepol/cil/src/cil_binary.c | 6 +++--- libsepol/include/sepol/policydb/conditional.h | 4 +++- libsepol/src/conditional.c | 14 +++++++------- libsepol/src/expand.c | 6 +++--- libsepol/src/kernel_to_cil.c | 2 +- libsepol/src/kernel_to_conf.c | 2 +- libsepol/src/link.c | 6 +++--- libsepol/src/module_to_cil.c | 2 +- libsepol/src/policydb_validate.c | 2 +- libsepol/src/write.c | 2 +- libsepol/tests/debug.c | 2 +- libsepol/tests/test-linker-cond-map.c | 2 +- 12 files changed, 26 insertions(+), 24 deletions(-)
libsepol/cil/src/cil_binary.c +3 -3
@@ -2123,7 +2123,7 @@ static int __cil_cond_item_to_sepol_expr(policydb_t *pdb, struct cil_list_item * *head =cil_malloc (sizeof (cond_expr_t)); (*head)->next =NULL ; (*head)->expr_type =COND_BOOL ; - (*head)->bool = sepol_bool->s.value; + (*head)->boolean = sepol_bool->s.value; *tail = *head; }else if (item->flavor ==CIL_LIST ) {struct cil_list *l = item->data;
@@ -2159,7 +2159,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_listenum cil_flavor cil_op = (enum cil_flavor )(uintptr_t )item->data; op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ;switch (cil_op) {
@@ -2226,7 +2226,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_list goto exit; } op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ; op->expr_type =COND_OR ; t1->next = h2;
libsepol/include/sepol/policydb/conditional.h +3 -1
@@ -54,7 +54,9 @@ typedef struct cond_expr {#define COND_NEQ 7/* bool != bool */ #define COND_LAST COND_NEQuint32_t expr_type; -uint32_t bool; +/* The member `boolean` was renamed from `bool` in version 3.6 */ +#define COND_EXPR_T_RENAME_BOOL_BOOLEAN +uint32_t boolean;struct cond_expr *next; } cond_expr_t;
libsepol/src/conditional.c +7 -7
@@ -125,7 +125,7 @@ int cond_expr_equal(cond_node_t * a, cond_node_t * b)if (cur_a->expr_type != cur_b->expr_type)return 0 ;if (cur_a->expr_type ==COND_BOOL ) { -if (cur_a->bool != cur_b->bool) +if (cur_a->boolean != cur_b->boolean)return 0 ; } cur_a = cur_a->next;
@@ -223,7 +223,7 @@ int cond_evaluate_expr(policydb_t * p, cond_expr_t * expr)if (sp == (COND_EXPR_MAXDEPTH -1 ))return -1 ; sp++; - s[sp] = p->bool_val_to_struct[cur->bool -1 ]->state; + s[sp] = p->bool_val_to_struct[cur->boolean -1 ]->state;break ;case COND_NOT :if (sp <0 )
@@ -279,7 +279,7 @@ cond_expr_t *cond_copy_expr(cond_expr_t * expr)memset (new_expr,0 ,sizeof (cond_expr_t)); new_expr->expr_type = cur->expr_type; - new_expr->bool = cur->bool; + new_expr->boolean = cur->boolean;if (!head) head = new_expr;
@@ -388,10 +388,10 @@ int cond_normalize_expr(policydb_t * p, cond_node_t * cn)switch (e->expr_type) {case COND_BOOL :/* see if we've already seen this bool */ -if (!bool_present (e->bool, cn->bool_ids, cn->nbools)) { +if (!bool_present (e->boolean, cn->bool_ids, cn->nbools)) {/* count em all but only record up to COND_MAX_BOOLS */ if (cn->nbools <COND_MAX_BOOLS ) - cn->bool_ids[cn->nbools++] = e->bool; + cn->bool_ids[cn->nbools++] = e->boolean;else cn->nbools++; }
@@ -737,7 +737,7 @@ static int expr_isvalid(policydb_t * p, cond_expr_t * expr)return 0 ; } -if (expr->bool > p->p_bools.nprim) { +if (expr->boolean > p->p_bools.nprim) {WARN (NULL ,"security: conditional expressions uses unknown bool." );return 0 ; }
@@ -775,7 +775,7 @@ static int cond_read_node(policydb_t * p, cond_node_t * node, void *fp)memset (expr,0 ,sizeof (cond_expr_t)); expr->expr_type =le32_to_cpu (buf[0 ]); - expr->bool =le32_to_cpu (buf[1 ]); + expr->boolean =le32_to_cpu (buf[1 ]);if (!expr_isvalid (p, expr)) {free (expr);
libsepol/src/expand.c +3 -3
@@ -2025,8 +2025,8 @@ static int cond_node_map_bools(expand_state_t * state, cond_node_t * cn) cur = cn->expr;while (cur) { -if (cur->bool) - cur->bool = state->boolmap[cur->bool -1 ]; +if (cur->boolean) + cur->boolean = state->boolmap[cur->boolean -1 ]; cur = cur->next; }
@@ -2899,7 +2899,7 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol) cur_expr = cur_expr->next) {if (cur_expr->expr_type !=COND_BOOL )continue ; - booldatum = pol->bool_val_to_struct[cur_expr->bool -1 ]; + booldatum = pol->bool_val_to_struct[cur_expr->boolean -1 ];if (booldatum->flags &COND_BOOL_FLAGS_TUNABLE ) tmp[tunables++] = booldatum;else
libsepol/src/kernel_to_cil.c +1 -1
@@ -43,7 +43,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;
libsepol/src/kernel_to_conf.c +1 -1
@@ -42,7 +42,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;
libsepol/src/link.c +3 -3
@@ -1524,9 +1524,9 @@ static int copy_cond_list(cond_node_t * list, cond_node_t ** dst,/* expression nodes don't have a bool value of 0 - don't map them */ if (cur_expr->expr_type !=COND_BOOL )continue ; -assert (module->map[SYM_BOOLS ][cur_expr->bool -1 ] !=0 ); - cur_expr->bool = - module->map[SYM_BOOLS ][cur_expr->bool -1 ]; +assert (module->map[SYM_BOOLS ][cur_expr->boolean -1 ] !=0 ); + cur_expr->boolean = + module->map[SYM_BOOLS ][cur_expr->boolean -1 ]; } new_node->nbools = cur->nbools;/* FIXME should COND_MAX_BOOLS be used here? */
libsepol/src/module_to_cil.c +1 -1
@@ -1272,7 +1272,7 @@ static int cond_expr_to_cil(int indent, struct policydb *pdb, struct cond_expr *for (curr = cond_expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { - val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; + val1 = pdb->p_bool_val_to_name[curr->boolean -1 ];// length of boolean + 2 parens + null terminator len =strlen (val1) +2 +1 ; new_val =malloc (len);
libsepol/src/policydb_validate.c +1 -1
@@ -974,7 +974,7 @@ static int validate_cond_expr(sepol_handle_t *handle, const struct cond_expr *exfor (; expr; expr = expr->next) {switch (expr->expr_type) {case COND_BOOL : -if (validate_value (expr->bool, boolean)) +if (validate_value (expr->boolean, boolean)) goto bad;if (depth == (COND_EXPR_MAXDEPTH -1 )) goto bad;
libsepol/src/write.c +1 -1
@@ -834,7 +834,7 @@ static int cond_write_node(policydb_t * p,for (cur_expr = node->expr; cur_expr !=NULL ; cur_expr = cur_expr->next) { items =0 ; buf[items++] =cpu_to_le32 (cur_expr->expr_type); - buf[items++] =cpu_to_le32 (cur_expr->bool); + buf[items++] =cpu_to_le32 (cur_expr->boolean); items2 =put_entry (buf,sizeof (uint32_t ), items, fp);if (items2 != items)return POLICYDB_ERROR ;
libsepol/tests/debug.c +1 -1
@@ -41,7 +41,7 @@ void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp)for (cur = exp; cur !=NULL ; cur = cur->next) {switch (cur->expr_type) {case COND_BOOL : -fprintf (fp,"%s " , p->p_bool_val_to_name[cur->bool -1 ]); +fprintf (fp,"%s " , p->p_bool_val_to_name[cur->boolean -1 ]);break ;case COND_NOT :fprintf (fp,"! " );
libsepol/tests/test-linker-cond-map.c +1 -1
@@ -70,7 +70,7 @@ static void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_CU_ASSERT (expr->expr_type == bools[i].expr_type);if (bools[i].bool) { -CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->bool -1 ], bools[i].bool) ==0 ); +CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->boolean -1 ], bools[i].bool) ==0 ); } expr = expr->next; }
Signature · 1 line
2.40.0
PATCH v2 2/6 checkpolicy: update cond_expr_t struct member name
The previous commit changed the member bool to boolean of the libsepol type cond_expr_t for C23 compatibility.
---
v2:
update commit description
--- checkpolicy/checkpolicy.c | 2 +- checkpolicy/policy_define.c | 2 +- checkpolicy/test/dismod.c | 2 +- checkpolicy/test/dispol.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
checkpolicy/checkpolicy.c +1 -1
@@ -313,7 +313,7 @@ static void display_expr(const cond_expr_t * exp)switch (cur->expr_type) {case COND_BOOL :printf ("%s " , - policydbp->p_bool_val_to_name[cur->bool -1 ]); + policydbp->p_bool_val_to_name[cur->boolean -1 ]);break ;case COND_NOT :printf ("! " );
checkpolicy/policy_define.c +1 -1
@@ -4159,7 +4159,7 @@ cond_expr_t *define_cond_expr(uint32_t expr_type, void *arg1, void *arg2)free (id);return NULL ; } - expr->bool = bool_var->s.value; + expr->boolean = bool_var->s.value;free (id);return expr;default :
checkpolicy/test/dismod.c +1 -1
@@ -404,7 +404,7 @@ static void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp)switch (cur->expr_type) {case COND_BOOL :fprintf (fp,"%s " , - p->p_bool_val_to_name[cur->bool -1 ]); + p->p_bool_val_to_name[cur->boolean -1 ]);break ;case COND_NOT :fprintf (fp,"! " );
checkpolicy/test/dispol.c +1 -1
@@ -197,7 +197,7 @@ static void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp)switch (cur->expr_type) {case COND_BOOL :fprintf (fp,"%s " , - p->p_bool_val_to_name[cur->bool -1 ]); + p->p_bool_val_to_name[cur->boolean -1 ]);break ;case COND_NOT :fprintf (fp,"! " );
Signature · 1 line
2.40.0
PATCH v2 3/6 libsepol/tests: rename bool indentifiers
In reply to Christian GöttscheAvoid using the identifier bool to improve support with future C standards. C23 is about to make bool a predefined macro (see N2654).
--- libsepol/tests/test-linker-cond-map.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
libsepol/tests/test-linker-cond-map.c +12 -12
@@ -51,7 +51,7 @@*/ typedef struct test_cond_expr { -const char *bool; +const char *boolean;uint32_t expr_type; }test_cond_expr_t ;
@@ -69,18 +69,18 @@ static void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_CU_ASSERT_FATAL (expr !=NULL );CU_ASSERT (expr->expr_type == bools[i].expr_type); -if (bools[i].bool) { -CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->boolean -1 ], bools[i].bool) ==0 ); +if (bools[i].boolean) { +CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->boolean -1 ], bools[i].boolean) ==0 ); } expr = expr->next; } } -static void test_bool_state (policydb_t * p,const char *bool,int state) +static void test_bool_state (policydb_t * p,const char *boolean,int state) {cond_bool_datum_t *b; - b =hashtab_search (p->p_bools.table, bool); + b =hashtab_search (p->p_bools.table, boolean);CU_ASSERT_FATAL (b !=NULL );CU_ASSERT (b->state == state); }
@@ -100,7 +100,7 @@ void base_cond_tests(policydb_t * base)test_sym_presence (base,"g_b_bool_1" ,SYM_BOOLS ,SCOPE_DECL , decls,1 );test_bool_state (base,"g_b_bool_1" ,0 );/* conditional expression mapped correctly */ - bools[0 ].bool ="g_b_bool_1" ; + bools[0 ].boolean ="g_b_bool_1" ; bools[0 ].expr_type =COND_BOOL ;test_cond_expr_mapping (base, d, bools,1 );
@@ -110,7 +110,7 @@ void base_cond_tests(policydb_t * base)test_sym_presence (base,"o1_b_bool_1" ,SYM_BOOLS ,SCOPE_DECL , decls,1 );test_bool_state (base,"o1_b_bool_1" ,1 );/* conditional expression mapped correctly */ - bools[0 ].bool ="o1_b_bool_1" ; + bools[0 ].boolean ="o1_b_bool_1" ; bools[0 ].expr_type =COND_BOOL ;test_cond_expr_mapping (base, d, bools,1 );
@@ -128,7 +128,7 @@ void module_cond_tests(policydb_t * base)test_sym_presence (base,"g_m1_bool_1" ,SYM_BOOLS ,SCOPE_DECL , decls,1 );test_bool_state (base,"g_m1_bool_1" ,1 );/* conditional expression mapped correctly */ - bools[0 ].bool ="g_m1_bool_1" ; + bools[0 ].boolean ="g_m1_bool_1" ; bools[0 ].expr_type =COND_BOOL ;test_cond_expr_mapping (base, d, bools,1 );
@@ -138,7 +138,7 @@ void module_cond_tests(policydb_t * base)test_sym_presence (base,"o1_m1_bool_1" ,SYM_BOOLS ,SCOPE_DECL , decls,1 );test_bool_state (base,"o1_m1_bool_1" ,0 );/* conditional expression mapped correctly */ - bools[0 ].bool ="o1_m1_bool_1" ; + bools[0 ].boolean ="o1_m1_bool_1" ; bools[0 ].expr_type =COND_BOOL ;test_cond_expr_mapping (base, d, bools,1 );
@@ -150,11 +150,11 @@ void module_cond_tests(policydb_t * base)test_bool_state (base,"g_m2_bool_1" ,1 );test_bool_state (base,"g_m2_bool_2" ,0 );/* conditional expression mapped correctly */ - bools[0 ].bool ="g_m2_bool_1" ; + bools[0 ].boolean ="g_m2_bool_1" ; bools[0 ].expr_type =COND_BOOL ; - bools[1 ].bool ="g_m2_bool_2" ; + bools[1 ].boolean ="g_m2_bool_2" ; bools[1 ].expr_type =COND_BOOL ; - bools[2 ].bool =NULL ; + bools[2 ].boolean =NULL ; bools[2 ].expr_type =COND_AND ;test_cond_expr_mapping (base, d, bools,3 ); }
Signature · 1 line
2.40.0
PATCH v2 4/6 checkpolicy: rename bool identifiers
In reply to Christian GöttscheAvoid using the identifier bool to improve support with future C standards. C23 is about to make bool a predefined macro (see N2654).
--- checkpolicy/checkpolicy.c | 8 ++++---- checkpolicy/test/dismod.c | 8 ++++---- checkpolicy/test/dispol.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)
checkpolicy/checkpolicy.c +4 -4
@@ -354,14 +354,14 @@ static int display_cond_expressions(void)static int change_bool (const char *name,int state) { -cond_bool_datum_t *bool; +cond_bool_datum_t *boolean; - bool = hashtab_search(policydbp->p_bools.table, name); -if (bool ==NULL ) { + boolean =hashtab_search (policydbp->p_bools.table, name); +if (boolean ==NULL ) {printf ("Could not find bool %s\n" , name);return -1 ; } - bool->state = state; + boolean->state = state;evaluate_conds (policydbp);return 0 ; }
checkpolicy/test/dismod.c +4 -4
@@ -602,14 +602,14 @@ int display_cond_expressions(policydb_t * p, FILE * fp)int change_bool (char *name,int state,policydb_t * p,FILE * fp) { -cond_bool_datum_t *bool; +cond_bool_datum_t *boolean; - bool = hashtab_search(p->p_bools.table, name); -if (bool ==NULL ) { + boolean =hashtab_search (p->p_bools.table, name); +if (boolean ==NULL ) {fprintf (fp,"Could not find bool %s\n" , name);return -1 ; } - bool->state = state; + boolean->state = state;evaluate_conds (p);return 0 ; }
checkpolicy/test/dispol.c +4 -4
@@ -262,14 +262,14 @@ static int display_handle_unknown(policydb_t * p, FILE * out_fp)static int change_bool (char *name,int state,policydb_t * p,FILE * fp) { -cond_bool_datum_t *bool; +cond_bool_datum_t *boolean; - bool = hashtab_search(p->p_bools.table, name); -if (bool ==NULL ) { + boolean =hashtab_search (p->p_bools.table, name); +if (boolean ==NULL ) {fprintf (fp,"Could not find bool %s\n" , name);return -1 ; } - bool->state = state; + boolean->state = state;evaluate_conds (p);return 0 ; }
Signature · 1 line
2.40.0
PATCH v2 5/6 libsepol: rename bool identifiers
In reply to Christian GöttscheAvoid using the identifier bool to improve support with future C standards. C23 is about to make bool a predefined macro (see N2654).
--- libsepol/cil/src/cil_binary.c | 8 ++++---- libsepol/cil/src/cil_policy.c | 12 ++++++------ libsepol/src/expand.c | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-)
libsepol/cil/src/cil_binary.c +4 -4
@@ -4170,13 +4170,13 @@ static int __cil_user_val_array_insert(hashtab_key_t key, hashtab_datum_t datum,static int __cil_bool_val_array_insert (hashtab_key_t key,hashtab_datum_t datum,void *data) {policydb_t *pdb = data; -cond_bool_datum_t *bool = (cond_bool_datum_t *)datum; +cond_bool_datum_t *boolean = (cond_bool_datum_t *)datum; -if (bool->s.value <1 || bool->s.value > pdb->p_bools.nprim) { +if (boolean->s.value <1 || boolean->s.value > pdb->p_bools.nprim) {return -EINVAL ; } - pdb->p_bool_val_to_name[bool->s.value -1 ] = (char *)key; - pdb->bool_val_to_struct[bool->s.value -1 ] = bool; + pdb->p_bool_val_to_name[boolean->s.value -1 ] = (char *)key; + pdb->bool_val_to_struct[boolean->s.value -1 ] = boolean;return 0 ; }
libsepol/cil/src/cil_policy.c +6 -6
@@ -1008,13 +1008,13 @@ static void cil_validatetrans_to_policy(FILE *out, struct cil_db *db, struct cilstatic void cil_bools_to_policy (FILE *out,struct cil_list *bools) {struct cil_list_item *i1; -struct cil_bool *bool; +struct cil_bool *boolean;const char *value;cil_list_for_each (i1, bools) { - bool = i1->data; - value = bool->value ?"true" :"false" ; -fprintf (out,"bool %s %s;\n" , bool->datum.fqn, value); + boolean = i1->data; + value = boolean->value ?"true" :"false" ; +fprintf (out,"bool %s %s;\n" , boolean->datum.fqn, value); } }
@@ -1437,12 +1437,12 @@ static int __cil_te_rules_to_policy_helper(struct cil_tree_node *node, uint32_t *finished =CIL_TREE_SKIP_HEAD ;break ;case CIL_BOOLEANIF : { -struct cil_booleanif *bool = node->data; +struct cil_booleanif *boolean = node->data;struct cil_tree_node *n;struct cil_condblock *cb;fprintf (args->out,"if " ); -cil_cond_expr_to_policy (args->out, bool->datum_expr,CIL_TRUE ); +cil_cond_expr_to_policy (args->out, boolean->datum_expr,CIL_TRUE );fprintf (args->out," {\n" ); n = node->cl_head; cb = n !=NULL ? n->data :NULL ;
libsepol/src/expand.c +6 -6
@@ -1106,11 +1106,11 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum, {int ret;expand_state_t *state; -cond_bool_datum_t *bool, *new_bool; +cond_bool_datum_t *boolean, *new_bool;char *id, *new_id; id = key; - bool = (cond_bool_datum_t *) datum; + boolean = (cond_bool_datum_t *) datum; state = (expand_state_t *) data;if (!is_id_enabled (id, state->base,SYM_BOOLS )) {
@@ -1118,7 +1118,7 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum,return 0 ; } -if (bool->flags &COND_BOOL_FLAGS_TUNABLE ) { +if (boolean->flags &COND_BOOL_FLAGS_TUNABLE ) {/* Skip tunables */ return 0 ; }
@@ -1152,10 +1152,10 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum,return -1 ; } - state->boolmap[bool->s.value -1 ] = new_bool->s.value; + state->boolmap[boolean->s.value -1 ] = new_bool->s.value; - new_bool->state = bool->state; - new_bool->flags = bool->flags; + new_bool->state = boolean->state; + new_bool->flags = boolean->flags;return 0 ; }
Signature · 1 line
2.40.0
PATCH v2 6/6 libsemanage/tests: rename bool identifiers
In reply to Christian GöttscheAvoid using the identifier bool to improve support with future C standards. C23 is about to make bool a predefined macro (see N2654).
--- libsemanage/tests/libsemanage-tests.c | 2 +- libsemanage/tests/test_bool.c | 6 +++--- libsemanage/tests/test_bool.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
libsemanage/tests/libsemanage-tests.c +1 -1
@@ -73,7 +73,7 @@ static bool do_tests(int interactive, int verbose)DECLARE_SUITE (semanage_store);DECLARE_SUITE (semanage_utilities);DECLARE_SUITE (handle); -DECLARE_SUITE (bool); +DECLARE_SUITE (boolean);DECLARE_SUITE (fcontext);DECLARE_SUITE (iface);DECLARE_SUITE (ibendport);
libsemanage/tests/test_bool.c +3 -3
@@ -57,7 +57,7 @@ static void test_bool_list_local(void);extern semanage_handle_t *sh; -int bool_test_init (void ) +int boolean_test_init (void ) {if (create_test_store () <0 ) {fprintf (stderr,"Could not create test store\n" );
@@ -72,7 +72,7 @@ int bool_test_init(void)return 0 ; } -int bool_test_cleanup (void ) +int boolean_test_cleanup (void ) {if (destroy_test_store () <0 ) {fprintf (stderr,"Could not destroy test store\n" );
@@ -82,7 +82,7 @@ int bool_test_cleanup(void)return 0 ; } -int bool_add_tests (CU_pSuite suite) +int boolean_add_tests (CU_pSuite suite) {CU_add_test (suite,"bool_key_create" , test_bool_key_create);CU_add_test (suite,"bool_key_extract" , test_bool_key_extract);
libsemanage/tests/test_bool.h +3 -3
@@ -24,8 +24,8 @@#include <CUnit/Basic.h> #include "semanage/semanage.h" -int bool_test_init (void ); -int bool_test_cleanup (void ); -int bool_add_tests (CU_pSuite suite); +int boolean_test_init (void ); +int boolean_test_cleanup (void ); +int boolean_add_tests (CU_pSuite suite);#endif
Signature · 1 line
2.40.0
Stephen Smalley
maintainerQuoted 7 lines · Christian Göttsche
Avoid using the identifier
boolto improve support with future C standards. C23 is about to makeboola predefined macro (see N2654).Since the type
cond_expr_tis part of the public API it will break client applications. A quick search of the code in Debian shows only usages in checkpolicy and setools.
NB Header files under the sepol/policydb subdirectory are not part of the libsepol shared library API/ABI and thus changes there are not considered to be API/ABI changes. They should only affect users of the static libsepol and there is no warranty for them.
Quoted 266 lines
Define a new macro signaling the renaming to simplify support of client applications for new and older versions of libsepol.
Signed-off-by Christian Göttsche <[email protected]>---
v2:
update version identifier in header to 3.6--- libsepol/cil/src/cil_binary.c | 6 +++--- libsepol/include/sepol/policydb/conditional.h | 4 +++- libsepol/src/conditional.c | 14 +++++++------- libsepol/src/expand.c | 6 +++--- libsepol/src/kernel_to_cil.c | 2 +- libsepol/src/kernel_to_conf.c | 2 +- libsepol/src/link.c | 6 +++--- libsepol/src/module_to_cil.c | 2 +- libsepol/src/policydb_validate.c | 2 +- libsepol/src/write.c | 2 +- libsepol/tests/debug.c | 2 +- libsepol/tests/test-linker-cond-map.c | 2 +- 12 files changed, 26 insertions(+), 24 deletions(-)libsepol/cil/src/cil_binary.c +3
-3@@ -2123,7 +2123,7 @@ static int __cil_cond_item_to_sepol_expr(policydb_t *pdb, struct cil_list_item * *head =cil_malloc (sizeof (cond_expr_t)); (*head)->next =NULL ; (*head)->expr_type =COND_BOOL ; - (*head)->bool = sepol_bool->s.value; + (*head)->boolean = sepol_bool->s.value; *tail = *head; }else if (item->flavor ==CIL_LIST ) {struct cil_list *l = item->data;@@ -2159,7 +2159,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_listenum cil_flavor cil_op = (enum cil_flavor )(uintptr_t )item->data; op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ;switch (cil_op) {@@ -2226,7 +2226,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_list goto exit; } op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ; op->expr_type =COND_OR ; t1->next = h2;libsepol/include/sepol/policydb/conditional.h +3
-1@@ -54,7 +54,9 @@ typedef struct cond_expr {#define COND_NEQ 7/* bool != bool */ #define COND_LAST COND_NEQuint32_t expr_type; -uint32_t bool; +/* The member `boolean` was renamed from `bool` in version 3.6 */ +#define COND_EXPR_T_RENAME_BOOL_BOOLEAN +uint32_t boolean;struct cond_expr *next; } cond_expr_t;libsepol/src/conditional.c +7
-7@@ -125,7 +125,7 @@ int cond_expr_equal(cond_node_t * a, cond_node_t * b)if (cur_a->expr_type != cur_b->expr_type)return 0 ;if (cur_a->expr_type ==COND_BOOL ) { -if (cur_a->bool != cur_b->bool) +if (cur_a->boolean != cur_b->boolean)return 0 ; } cur_a = cur_a->next;@@ -223,7 +223,7 @@ int cond_evaluate_expr(policydb_t * p, cond_expr_t * expr)if (sp == (COND_EXPR_MAXDEPTH -1 ))return -1 ; sp++; - s[sp] = p->bool_val_to_struct[cur->bool -1 ]->state; + s[sp] = p->bool_val_to_struct[cur->boolean -1 ]->state;break ;case COND_NOT :if (sp <0 )@@ -279,7 +279,7 @@ cond_expr_t *cond_copy_expr(cond_expr_t * expr)memset (new_expr,0 ,sizeof (cond_expr_t)); new_expr->expr_type = cur->expr_type; - new_expr->bool = cur->bool; + new_expr->boolean = cur->boolean;if (!head) head = new_expr;@@ -388,10 +388,10 @@ int cond_normalize_expr(policydb_t * p, cond_node_t * cn)switch (e->expr_type) {case COND_BOOL :/* see if we've already seen this bool */ -if (!bool_present (e->bool, cn->bool_ids, cn->nbools)) { +if (!bool_present (e->boolean, cn->bool_ids, cn->nbools)) {/* count em all but only record up to COND_MAX_BOOLS */ if (cn->nbools <COND_MAX_BOOLS ) - cn->bool_ids[cn->nbools++] = e->bool; + cn->bool_ids[cn->nbools++] = e->boolean;else cn->nbools++; }@@ -737,7 +737,7 @@ static int expr_isvalid(policydb_t * p, cond_expr_t * expr)return 0 ; } -if (expr->bool > p->p_bools.nprim) { +if (expr->boolean > p->p_bools.nprim) {WARN (NULL ,"security: conditional expressions uses unknown bool." );return 0 ; }@@ -775,7 +775,7 @@ static int cond_read_node(policydb_t * p, cond_node_t * node, void *fp)memset (expr,0 ,sizeof (cond_expr_t)); expr->expr_type =le32_to_cpu (buf[0 ]); - expr->bool =le32_to_cpu (buf[1 ]); + expr->boolean =le32_to_cpu (buf[1 ]);if (!expr_isvalid (p, expr)) {free (expr);libsepol/src/expand.c +3
-3@@ -2025,8 +2025,8 @@ static int cond_node_map_bools(expand_state_t * state, cond_node_t * cn) cur = cn->expr;while (cur) { -if (cur->bool) - cur->bool = state->boolmap[cur->bool -1 ]; +if (cur->boolean) + cur->boolean = state->boolmap[cur->boolean -1 ]; cur = cur->next; }@@ -2899,7 +2899,7 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol) cur_expr = cur_expr->next) {if (cur_expr->expr_type !=COND_BOOL )continue ; - booldatum = pol->bool_val_to_struct[cur_expr->bool -1 ]; + booldatum = pol->bool_val_to_struct[cur_expr->boolean -1 ];if (booldatum->flags &COND_BOOL_FLAGS_TUNABLE ) tmp[tunables++] = booldatum;else libsepol/src/kernel_to_cil.c +1
-1@@ -43,7 +43,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;libsepol/src/kernel_to_conf.c +1
-1@@ -42,7 +42,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;libsepol/src/link.c +3
-3@@ -1524,9 +1524,9 @@ static int copy_cond_list(cond_node_t * list, cond_node_t ** dst,/* expression nodes don't have a bool value of 0 - don't map them */ if (cur_expr->expr_type !=COND_BOOL )continue ; -assert (module->map[SYM_BOOLS ][cur_expr->bool -1 ] !=0 ); - cur_expr->bool = - module->map[SYM_BOOLS ][cur_expr->bool -1 ]; +assert (module->map[SYM_BOOLS ][cur_expr->boolean -1 ] !=0 ); + cur_expr->boolean = + module->map[SYM_BOOLS ][cur_expr->boolean -1 ]; } new_node->nbools = cur->nbools;/* FIXME should COND_MAX_BOOLS be used here? */ libsepol/src/module_to_cil.c +1
-1@@ -1272,7 +1272,7 @@ static int cond_expr_to_cil(int indent, struct policydb *pdb, struct cond_expr *for (curr = cond_expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { - val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; + val1 = pdb->p_bool_val_to_name[curr->boolean -1 ];// length of boolean + 2 parens + null terminator len =strlen (val1) +2 +1 ; new_val =malloc (len);libsepol/src/policydb_validate.c +1
-1@@ -974,7 +974,7 @@ static int validate_cond_expr(sepol_handle_t *handle, const struct cond_expr *exfor (; expr; expr = expr->next) {switch (expr->expr_type) {case COND_BOOL : -if (validate_value (expr->bool, boolean)) +if (validate_value (expr->boolean, boolean)) goto bad;if (depth == (COND_EXPR_MAXDEPTH -1 )) goto bad;libsepol/src/write.c +1
-1@@ -834,7 +834,7 @@ static int cond_write_node(policydb_t * p,for (cur_expr = node->expr; cur_expr !=NULL ; cur_expr = cur_expr->next) { items =0 ; buf[items++] =cpu_to_le32 (cur_expr->expr_type); - buf[items++] =cpu_to_le32 (cur_expr->bool); + buf[items++] =cpu_to_le32 (cur_expr->boolean); items2 =put_entry (buf,sizeof (uint32_t ), items, fp);if (items2 != items)return POLICYDB_ERROR ;libsepol/tests/debug.c +1
-1@@ -41,7 +41,7 @@ void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp)for (cur = exp; cur !=NULL ; cur = cur->next) {switch (cur->expr_type) {case COND_BOOL : -fprintf (fp,"%s " , p->p_bool_val_to_name[cur->bool -1 ]); +fprintf (fp,"%s " , p->p_bool_val_to_name[cur->boolean -1 ]);break ;case COND_NOT :fprintf (fp,"! " );libsepol/tests/test-linker-cond-map.c +1
-2@@ -70,7 +70,7 @@ static void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_CU_ASSERT (expr->expr_type == bools[i].expr_type);if (bools[i].bool) { -CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->bool -1 ], bools[i].bool) ==0 ); +CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->boolean -1 ], bools[i].bool) ==0 ); } expr = expr->next; } --2.40.0
Quoted 7 lines · Stephen Smalley
Quoted 4 lines · Christian Göttsche
Avoid using the identifier
boolto improve support with future C standards. C23 is about to makeboola predefined macro (see N2654).
Quoted 9 lines
Quoted 3 lines
Since the type
cond_expr_tis part of the public API it will break client applications. A quick search of the code in Debian shows only usages in checkpolicy and setools.NB Header files under the sepol/policydb subdirectory are not part of the libsepol shared library API/ABI and thus changes there are not considered to be API/ABI changes. They should only affect users of the static libsepol and there is no warranty for them.
So should that paragraph be removed or should it say something like:
"While header files under the sepol/policydb subdirectory are not part of the libsepol shared library API/ABI, these changes will break setools."?
Jim
Quoted 266 lines
Quoted 266 lines
Define a new macro signaling the renaming to simplify support of client applications for new and older versions of libsepol.
Signed-off-by Christian Göttsche <[email protected]>---
v2:
update version identifier in header to 3.6--- libsepol/cil/src/cil_binary.c | 6 +++--- libsepol/include/sepol/policydb/conditional.h | 4 +++- libsepol/src/conditional.c | 14 +++++++------- libsepol/src/expand.c | 6 +++--- libsepol/src/kernel_to_cil.c | 2 +- libsepol/src/kernel_to_conf.c | 2 +- libsepol/src/link.c | 6 +++--- libsepol/src/module_to_cil.c | 2 +- libsepol/src/policydb_validate.c | 2 +- libsepol/src/write.c | 2 +- libsepol/tests/debug.c | 2 +- libsepol/tests/test-linker-cond-map.c | 2 +- 12 files changed, 26 insertions(+), 24 deletions(-)libsepol/cil/src/cil_binary.c +3
-3@@ -2123,7 +2123,7 @@ static int __cil_cond_item_to_sepol_expr(policydb_t *pdb, struct cil_list_item * *head =cil_malloc (sizeof (cond_expr_t)); (*head)->next =NULL ; (*head)->expr_type =COND_BOOL ; - (*head)->bool = sepol_bool->s.value; + (*head)->boolean = sepol_bool->s.value; *tail = *head; }else if (item->flavor ==CIL_LIST ) {struct cil_list *l = item->data;@@ -2159,7 +2159,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_listenum cil_flavor cil_op = (enum cil_flavor )(uintptr_t )item->data; op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ;switch (cil_op) {@@ -2226,7 +2226,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_list goto exit; } op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ; op->expr_type =COND_OR ; t1->next = h2;libsepol/include/sepol/policydb/conditional.h +3
-1@@ -54,7 +54,9 @@ typedef struct cond_expr {#define COND_NEQ 7/* bool != bool */ #define COND_LAST COND_NEQuint32_t expr_type; -uint32_t bool; +/* The member `boolean` was renamed from `bool` in version 3.6 */ +#define COND_EXPR_T_RENAME_BOOL_BOOLEAN +uint32_t boolean;struct cond_expr *next; } cond_expr_t;libsepol/src/conditional.c +7
-7@@ -125,7 +125,7 @@ int cond_expr_equal(cond_node_t * a, cond_node_t * b)if (cur_a->expr_type != cur_b->expr_type)return 0 ;if (cur_a->expr_type ==COND_BOOL ) { -if (cur_a->bool != cur_b->bool) +if (cur_a->boolean != cur_b->boolean)return 0 ; } cur_a = cur_a->next;@@ -223,7 +223,7 @@ int cond_evaluate_expr(policydb_t * p, cond_expr_t * expr)if (sp == (COND_EXPR_MAXDEPTH -1 ))return -1 ; sp++; - s[sp] = p->bool_val_to_struct[cur->bool -1 ]->state; + s[sp] = p->bool_val_to_struct[cur->boolean -1 ]->state;break ;case COND_NOT :if (sp <0 )@@ -279,7 +279,7 @@ cond_expr_t *cond_copy_expr(cond_expr_t * expr)memset (new_expr,0 ,sizeof (cond_expr_t)); new_expr->expr_type = cur->expr_type; - new_expr->bool = cur->bool; + new_expr->boolean = cur->boolean;if (!head) head = new_expr;@@ -388,10 +388,10 @@ int cond_normalize_expr(policydb_t * p, cond_node_t * cn)switch (e->expr_type) {case COND_BOOL :/* see if we've already seen this bool */ -if (!bool_present (e->bool, cn->bool_ids, cn->nbools)) { +if (!bool_present (e->boolean, cn->bool_ids, cn->nbools)) {/* count em all but only record up to COND_MAX_BOOLS */ if (cn->nbools <COND_MAX_BOOLS ) - cn->bool_ids[cn->nbools++] = e->bool; + cn->bool_ids[cn->nbools++] = e->boolean;else cn->nbools++; }@@ -737,7 +737,7 @@ static int expr_isvalid(policydb_t * p, cond_expr_t * expr)return 0 ; } -if (expr->bool > p->p_bools.nprim) { +if (expr->boolean > p->p_bools.nprim) {WARN (NULL ,"security: conditional expressions uses unknown bool." );return 0 ; }@@ -775,7 +775,7 @@ static int cond_read_node(policydb_t * p, cond_node_t * node, void *fp)memset (expr,0 ,sizeof (cond_expr_t)); expr->expr_type =le32_to_cpu (buf[0 ]); - expr->bool =le32_to_cpu (buf[1 ]); + expr->boolean =le32_to_cpu (buf[1 ]);if (!expr_isvalid (p, expr)) {free (expr);libsepol/src/expand.c +3
-3@@ -2025,8 +2025,8 @@ static int cond_node_map_bools(expand_state_t * state, cond_node_t * cn) cur = cn->expr;while (cur) { -if (cur->bool) - cur->bool = state->boolmap[cur->bool -1 ]; +if (cur->boolean) + cur->boolean = state->boolmap[cur->boolean -1 ]; cur = cur->next; }@@ -2899,7 +2899,7 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol) cur_expr = cur_expr->next) {if (cur_expr->expr_type !=COND_BOOL )continue ; - booldatum = pol->bool_val_to_struct[cur_expr->bool -1 ]; + booldatum = pol->bool_val_to_struct[cur_expr->boolean -1 ];if (booldatum->flags &COND_BOOL_FLAGS_TUNABLE ) tmp[tunables++] = booldatum;else libsepol/src/kernel_to_cil.c +1
-1@@ -43,7 +43,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;libsepol/src/kernel_to_conf.c +1
-1@@ -42,7 +42,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;libsepol/src/link.c +3
-3@@ -1524,9 +1524,9 @@ static int copy_cond_list(cond_node_t * list, cond_node_t ** dst,/* expression nodes don't have a bool value of 0 - don't map them */ if (cur_expr->expr_type !=COND_BOOL )continue ; -assert (module->map[SYM_BOOLS ][cur_expr->bool -1 ] !=0 ); - cur_expr->bool = - module->map[SYM_BOOLS ][cur_expr->bool -1 ]; +assert (module->map[SYM_BOOLS ][cur_expr->boolean -1 ] !=0 ); + cur_expr->boolean = + module->map[SYM_BOOLS ][cur_expr->boolean -1 ]; } new_node->nbools = cur->nbools;/* FIXME should COND_MAX_BOOLS be used here? */ libsepol/src/module_to_cil.c +1
-1@@ -1272,7 +1272,7 @@ static int cond_expr_to_cil(int indent, struct policydb *pdb, struct cond_expr *for (curr = cond_expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { - val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; + val1 = pdb->p_bool_val_to_name[curr->boolean -1 ];// length of boolean + 2 parens + null terminator len =strlen (val1) +2 +1 ; new_val =malloc (len);libsepol/src/policydb_validate.c +1
-1@@ -974,7 +974,7 @@ static int validate_cond_expr(sepol_handle_t *handle, const struct cond_expr *exfor (; expr; expr = expr->next) {switch (expr->expr_type) {case COND_BOOL : -if (validate_value (expr->bool, boolean)) +if (validate_value (expr->boolean, boolean)) goto bad;if (depth == (COND_EXPR_MAXDEPTH -1 )) goto bad;libsepol/src/write.c +1
-1@@ -834,7 +834,7 @@ static int cond_write_node(policydb_t * p,for (cur_expr = node->expr; cur_expr !=NULL ; cur_expr = cur_expr->next) { items =0 ; buf[items++] =cpu_to_le32 (cur_expr->expr_type); - buf[items++] =cpu_to_le32 (cur_expr->bool); + buf[items++] =cpu_to_le32 (cur_expr->boolean); items2 =put_entry (buf,sizeof (uint32_t ), items, fp);if (items2 != items)return POLICYDB_ERROR ;libsepol/tests/debug.c +1
-1@@ -41,7 +41,7 @@ void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp)for (cur = exp; cur !=NULL ; cur = cur->next) {switch (cur->expr_type) {case COND_BOOL : -fprintf (fp,"%s " , p->p_bool_val_to_name[cur->bool -1 ]); +fprintf (fp,"%s " , p->p_bool_val_to_name[cur->boolean -1 ]);break ;case COND_NOT :fprintf (fp,"! " );libsepol/tests/test-linker-cond-map.c +1
-2@@ -70,7 +70,7 @@ static void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_CU_ASSERT (expr->expr_type == bools[i].expr_type);if (bools[i].bool) { -CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->bool -1 ], bools[i].bool) ==0 ); +CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->boolean -1 ], bools[i].bool) ==0 ); } expr = expr->next; } --2.40.0
Stephen Smalley
maintainerQuoted 20 lines · James Carter
Quoted 7 lines · Stephen Smalley
Quoted 4 lines · Christian Göttsche
Avoid using the identifier
boolto improve support with future C standards. C23 is about to makeboola predefined macro (see N2654).Quoted 9 lines
Quoted 3 lines
Since the type
cond_expr_tis part of the public API it will break client applications. A quick search of the code in Debian shows only usages in checkpolicy and setools.NB Header files under the sepol/policydb subdirectory are not part of the libsepol shared library API/ABI and thus changes there are not considered to be API/ABI changes. They should only affect users of the static libsepol and there is no warranty for them.
Quoted 4 lines
So should that paragraph be removed or should it say something like:
"While header files under the sepol/policydb subdirectory are not part of the libsepol shared library API/ABI, these changes will break setools."?
Is setools using the shared libsepol or the static one?
Also wondering if we have violated the original intent here - I see that #include's of sepol/policydb/policydb.h have crept into public API headers in include/sepol/*.h. That was never supposed to happen. They were only supposed to use the encapsulated sepol/policydb.h that doesn't expose the internals.
Do we have users of the shared library that are now tied to the policydb data structures?
Quoted 22 lines · Stephen Smalley
Quoted 20 lines · James Carter
Quoted 16 lines · Stephen Smalley
Quoted 7 lines · Christian Göttsche
Avoid using the identifier
boolto improve support with future C standards. C23 is about to makeboola predefined macro (see N2654).Since the type
cond_expr_tis part of the public API it will break client applications. A quick search of the code in Debian shows only usages in checkpolicy and setools.NB Header files under the sepol/policydb subdirectory are not part of the libsepol shared library API/ABI and thus changes there are not considered to be API/ABI changes. They should only affect users of the static libsepol and there is no warranty for them.
Quoted 7 lines
Quoted 4 lines
So should that paragraph be removed or should it say something like:
"While header files under the sepol/policydb subdirectory are not part of the libsepol shared library API/ABI, these changes will break setools."?Is setools using the shared libsepol or the static one?
It is python. I know the policyrep part includes sepol/policydb/conditional.h Jim
Quoted 8 lines
Also wondering if we have violated the original intent here - I see that #include's of
sepol/policydb/policydb.hhave crept into public API headers ininclude/sepol/*.h. That was never supposed to happen. They were only supposed to use the encapsulatedsepol/policydb.hthat doesn't expose the internals.Do we have users of the shared library that are now tied to the policydb data structures?
setools was the only thing (that I know of) that broke when we changed how the filename transitions were stored in the policy.
Jim
Quoted 4 lines · Christian Göttsche
Avoid using the identifier
boolto improve support with future C standards. C23 is about to makeboola predefined macro (see N2654).
Quoted 8 lines
Since the type
cond_expr_tis part of the public API it will break client applications. A quick search of the code in Debian shows only usages in checkpolicy and setools.Define a new macro signaling the renaming to simplify support of client applications for new and older versions of libsepol.
Signed-off-by Christian Göttsche <[email protected]>
The code looks fine. I can fix the commit message for patch 1 when I merge it.
Quoted 261 lines
---
v2:
update version identifier in header to 3.6--- libsepol/cil/src/cil_binary.c | 6 +++--- libsepol/include/sepol/policydb/conditional.h | 4 +++- libsepol/src/conditional.c | 14 +++++++------- libsepol/src/expand.c | 6 +++--- libsepol/src/kernel_to_cil.c | 2 +- libsepol/src/kernel_to_conf.c | 2 +- libsepol/src/link.c | 6 +++--- libsepol/src/module_to_cil.c | 2 +- libsepol/src/policydb_validate.c | 2 +- libsepol/src/write.c | 2 +- libsepol/tests/debug.c | 2 +- libsepol/tests/test-linker-cond-map.c | 2 +- 12 files changed, 26 insertions(+), 24 deletions(-)libsepol/cil/src/cil_binary.c +3
-3@@ -2123,7 +2123,7 @@ static int __cil_cond_item_to_sepol_expr(policydb_t *pdb, struct cil_list_item * *head =cil_malloc (sizeof (cond_expr_t)); (*head)->next =NULL ; (*head)->expr_type =COND_BOOL ; - (*head)->bool = sepol_bool->s.value; + (*head)->boolean = sepol_bool->s.value; *tail = *head; }else if (item->flavor ==CIL_LIST ) {struct cil_list *l = item->data;@@ -2159,7 +2159,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_listenum cil_flavor cil_op = (enum cil_flavor )(uintptr_t )item->data; op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ;switch (cil_op) {@@ -2226,7 +2226,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_list goto exit; } op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ; op->expr_type =COND_OR ; t1->next = h2;libsepol/include/sepol/policydb/conditional.h +3
-1@@ -54,7 +54,9 @@ typedef struct cond_expr {#define COND_NEQ 7/* bool != bool */ #define COND_LAST COND_NEQuint32_t expr_type; -uint32_t bool; +/* The member `boolean` was renamed from `bool` in version 3.6 */ +#define COND_EXPR_T_RENAME_BOOL_BOOLEAN +uint32_t boolean;struct cond_expr *next; } cond_expr_t;libsepol/src/conditional.c +7
-7@@ -125,7 +125,7 @@ int cond_expr_equal(cond_node_t * a, cond_node_t * b)if (cur_a->expr_type != cur_b->expr_type)return 0 ;if (cur_a->expr_type ==COND_BOOL ) { -if (cur_a->bool != cur_b->bool) +if (cur_a->boolean != cur_b->boolean)return 0 ; } cur_a = cur_a->next;@@ -223,7 +223,7 @@ int cond_evaluate_expr(policydb_t * p, cond_expr_t * expr)if (sp == (COND_EXPR_MAXDEPTH -1 ))return -1 ; sp++; - s[sp] = p->bool_val_to_struct[cur->bool -1 ]->state; + s[sp] = p->bool_val_to_struct[cur->boolean -1 ]->state;break ;case COND_NOT :if (sp <0 )@@ -279,7 +279,7 @@ cond_expr_t *cond_copy_expr(cond_expr_t * expr)memset (new_expr,0 ,sizeof (cond_expr_t)); new_expr->expr_type = cur->expr_type; - new_expr->bool = cur->bool; + new_expr->boolean = cur->boolean;if (!head) head = new_expr;@@ -388,10 +388,10 @@ int cond_normalize_expr(policydb_t * p, cond_node_t * cn)switch (e->expr_type) {case COND_BOOL :/* see if we've already seen this bool */ -if (!bool_present (e->bool, cn->bool_ids, cn->nbools)) { +if (!bool_present (e->boolean, cn->bool_ids, cn->nbools)) {/* count em all but only record up to COND_MAX_BOOLS */ if (cn->nbools <COND_MAX_BOOLS ) - cn->bool_ids[cn->nbools++] = e->bool; + cn->bool_ids[cn->nbools++] = e->boolean;else cn->nbools++; }@@ -737,7 +737,7 @@ static int expr_isvalid(policydb_t * p, cond_expr_t * expr)return 0 ; } -if (expr->bool > p->p_bools.nprim) { +if (expr->boolean > p->p_bools.nprim) {WARN (NULL ,"security: conditional expressions uses unknown bool." );return 0 ; }@@ -775,7 +775,7 @@ static int cond_read_node(policydb_t * p, cond_node_t * node, void *fp)memset (expr,0 ,sizeof (cond_expr_t)); expr->expr_type =le32_to_cpu (buf[0 ]); - expr->bool =le32_to_cpu (buf[1 ]); + expr->boolean =le32_to_cpu (buf[1 ]);if (!expr_isvalid (p, expr)) {free (expr);libsepol/src/expand.c +3
-3@@ -2025,8 +2025,8 @@ static int cond_node_map_bools(expand_state_t * state, cond_node_t * cn) cur = cn->expr;while (cur) { -if (cur->bool) - cur->bool = state->boolmap[cur->bool -1 ]; +if (cur->boolean) + cur->boolean = state->boolmap[cur->boolean -1 ]; cur = cur->next; }@@ -2899,7 +2899,7 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol) cur_expr = cur_expr->next) {if (cur_expr->expr_type !=COND_BOOL )continue ; - booldatum = pol->bool_val_to_struct[cur_expr->bool -1 ]; + booldatum = pol->bool_val_to_struct[cur_expr->boolean -1 ];if (booldatum->flags &COND_BOOL_FLAGS_TUNABLE ) tmp[tunables++] = booldatum;else libsepol/src/kernel_to_cil.c +1
-1@@ -43,7 +43,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;libsepol/src/kernel_to_conf.c +1
-1@@ -42,7 +42,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;libsepol/src/link.c +3
-3@@ -1524,9 +1524,9 @@ static int copy_cond_list(cond_node_t * list, cond_node_t ** dst,/* expression nodes don't have a bool value of 0 - don't map them */ if (cur_expr->expr_type !=COND_BOOL )continue ; -assert (module->map[SYM_BOOLS ][cur_expr->bool -1 ] !=0 ); - cur_expr->bool = - module->map[SYM_BOOLS ][cur_expr->bool -1 ]; +assert (module->map[SYM_BOOLS ][cur_expr->boolean -1 ] !=0 ); + cur_expr->boolean = + module->map[SYM_BOOLS ][cur_expr->boolean -1 ]; } new_node->nbools = cur->nbools;/* FIXME should COND_MAX_BOOLS be used here? */ libsepol/src/module_to_cil.c +1
-1@@ -1272,7 +1272,7 @@ static int cond_expr_to_cil(int indent, struct policydb *pdb, struct cond_expr *for (curr = cond_expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { - val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; + val1 = pdb->p_bool_val_to_name[curr->boolean -1 ];// length of boolean + 2 parens + null terminator len =strlen (val1) +2 +1 ; new_val =malloc (len);libsepol/src/policydb_validate.c +1
-1@@ -974,7 +974,7 @@ static int validate_cond_expr(sepol_handle_t *handle, const struct cond_expr *exfor (; expr; expr = expr->next) {switch (expr->expr_type) {case COND_BOOL : -if (validate_value (expr->bool, boolean)) +if (validate_value (expr->boolean, boolean)) goto bad;if (depth == (COND_EXPR_MAXDEPTH -1 )) goto bad;libsepol/src/write.c +1
-1@@ -834,7 +834,7 @@ static int cond_write_node(policydb_t * p,for (cur_expr = node->expr; cur_expr !=NULL ; cur_expr = cur_expr->next) { items =0 ; buf[items++] =cpu_to_le32 (cur_expr->expr_type); - buf[items++] =cpu_to_le32 (cur_expr->bool); + buf[items++] =cpu_to_le32 (cur_expr->boolean); items2 =put_entry (buf,sizeof (uint32_t ), items, fp);if (items2 != items)return POLICYDB_ERROR ;libsepol/tests/debug.c +1
-1@@ -41,7 +41,7 @@ void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp)for (cur = exp; cur !=NULL ; cur = cur->next) {switch (cur->expr_type) {case COND_BOOL : -fprintf (fp,"%s " , p->p_bool_val_to_name[cur->bool -1 ]); +fprintf (fp,"%s " , p->p_bool_val_to_name[cur->boolean -1 ]);break ;case COND_NOT :fprintf (fp,"! " );libsepol/tests/test-linker-cond-map.c +1
-2@@ -70,7 +70,7 @@ static void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_CU_ASSERT (expr->expr_type == bools[i].expr_type);if (bools[i].bool) { -CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->bool -1 ], bools[i].bool) ==0 ); +CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->boolean -1 ], bools[i].bool) ==0 ); } expr = expr->next; } --2.40.0
Quoted 11 lines · James Carter
Quoted 8 lines · Christian Göttsche
Avoid using the identifier
boolto improve support with future C standards. C23 is about to makeboola predefined macro (see N2654).Since the type
cond_expr_tis part of the public API it will break client applications. A quick search of the code in Debian shows only usages in checkpolicy and setools.
Quoted 9 lines
Quoted 4 lines
Define a new macro signaling the renaming to simplify support of client applications for new and older versions of libsepol.
Signed-off-by Christian Göttsche <[email protected]>The code looks fine. I can fix the commit message for patch 1 when I merge it.
Acked-by James Carter <[email protected]>
These six patches have been merged.
Thanks,
Jim
Quoted 261 lines
Quoted 261 lines
---
v2:
update version identifier in header to 3.6--- libsepol/cil/src/cil_binary.c | 6 +++--- libsepol/include/sepol/policydb/conditional.h | 4 +++- libsepol/src/conditional.c | 14 +++++++------- libsepol/src/expand.c | 6 +++--- libsepol/src/kernel_to_cil.c | 2 +- libsepol/src/kernel_to_conf.c | 2 +- libsepol/src/link.c | 6 +++--- libsepol/src/module_to_cil.c | 2 +- libsepol/src/policydb_validate.c | 2 +- libsepol/src/write.c | 2 +- libsepol/tests/debug.c | 2 +- libsepol/tests/test-linker-cond-map.c | 2 +- 12 files changed, 26 insertions(+), 24 deletions(-)libsepol/cil/src/cil_binary.c +3
-3@@ -2123,7 +2123,7 @@ static int __cil_cond_item_to_sepol_expr(policydb_t *pdb, struct cil_list_item * *head =cil_malloc (sizeof (cond_expr_t)); (*head)->next =NULL ; (*head)->expr_type =COND_BOOL ; - (*head)->bool = sepol_bool->s.value; + (*head)->boolean = sepol_bool->s.value; *tail = *head; }else if (item->flavor ==CIL_LIST ) {struct cil_list *l = item->data;@@ -2159,7 +2159,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_listenum cil_flavor cil_op = (enum cil_flavor )(uintptr_t )item->data; op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ;switch (cil_op) {@@ -2226,7 +2226,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_list goto exit; } op =cil_malloc (sizeof (*op)); - op->bool =0 ; + op->boolean =0 ; op->next =NULL ; op->expr_type =COND_OR ; t1->next = h2;libsepol/include/sepol/policydb/conditional.h +3
-1@@ -54,7 +54,9 @@ typedef struct cond_expr {#define COND_NEQ 7/* bool != bool */ #define COND_LAST COND_NEQuint32_t expr_type; -uint32_t bool; +/* The member `boolean` was renamed from `bool` in version 3.6 */ +#define COND_EXPR_T_RENAME_BOOL_BOOLEAN +uint32_t boolean;struct cond_expr *next; } cond_expr_t;libsepol/src/conditional.c +7
-7@@ -125,7 +125,7 @@ int cond_expr_equal(cond_node_t * a, cond_node_t * b)if (cur_a->expr_type != cur_b->expr_type)return 0 ;if (cur_a->expr_type ==COND_BOOL ) { -if (cur_a->bool != cur_b->bool) +if (cur_a->boolean != cur_b->boolean)return 0 ; } cur_a = cur_a->next;@@ -223,7 +223,7 @@ int cond_evaluate_expr(policydb_t * p, cond_expr_t * expr)if (sp == (COND_EXPR_MAXDEPTH -1 ))return -1 ; sp++; - s[sp] = p->bool_val_to_struct[cur->bool -1 ]->state; + s[sp] = p->bool_val_to_struct[cur->boolean -1 ]->state;break ;case COND_NOT :if (sp <0 )@@ -279,7 +279,7 @@ cond_expr_t *cond_copy_expr(cond_expr_t * expr)memset (new_expr,0 ,sizeof (cond_expr_t)); new_expr->expr_type = cur->expr_type; - new_expr->bool = cur->bool; + new_expr->boolean = cur->boolean;if (!head) head = new_expr;@@ -388,10 +388,10 @@ int cond_normalize_expr(policydb_t * p, cond_node_t * cn)switch (e->expr_type) {case COND_BOOL :/* see if we've already seen this bool */ -if (!bool_present (e->bool, cn->bool_ids, cn->nbools)) { +if (!bool_present (e->boolean, cn->bool_ids, cn->nbools)) {/* count em all but only record up to COND_MAX_BOOLS */ if (cn->nbools <COND_MAX_BOOLS ) - cn->bool_ids[cn->nbools++] = e->bool; + cn->bool_ids[cn->nbools++] = e->boolean;else cn->nbools++; }@@ -737,7 +737,7 @@ static int expr_isvalid(policydb_t * p, cond_expr_t * expr)return 0 ; } -if (expr->bool > p->p_bools.nprim) { +if (expr->boolean > p->p_bools.nprim) {WARN (NULL ,"security: conditional expressions uses unknown bool." );return 0 ; }@@ -775,7 +775,7 @@ static int cond_read_node(policydb_t * p, cond_node_t * node, void *fp)memset (expr,0 ,sizeof (cond_expr_t)); expr->expr_type =le32_to_cpu (buf[0 ]); - expr->bool =le32_to_cpu (buf[1 ]); + expr->boolean =le32_to_cpu (buf[1 ]);if (!expr_isvalid (p, expr)) {free (expr);libsepol/src/expand.c +3
-3@@ -2025,8 +2025,8 @@ static int cond_node_map_bools(expand_state_t * state, cond_node_t * cn) cur = cn->expr;while (cur) { -if (cur->bool) - cur->bool = state->boolmap[cur->bool -1 ]; +if (cur->boolean) + cur->boolean = state->boolmap[cur->boolean -1 ]; cur = cur->next; }@@ -2899,7 +2899,7 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol) cur_expr = cur_expr->next) {if (cur_expr->expr_type !=COND_BOOL )continue ; - booldatum = pol->bool_val_to_struct[cur_expr->bool -1 ]; + booldatum = pol->bool_val_to_struct[cur_expr->boolean -1 ];if (booldatum->flags &COND_BOOL_FLAGS_TUNABLE ) tmp[tunables++] = booldatum;else libsepol/src/kernel_to_cil.c +1
-1@@ -43,7 +43,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;libsepol/src/kernel_to_conf.c +1
-1@@ -42,7 +42,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr)for (curr = expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { -char *val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; +char *val1 = pdb->p_bool_val_to_name[curr->boolean -1 ]; new_val =create_str ("%s" ,1 , val1); }else {const char *op;libsepol/src/link.c +3
-3@@ -1524,9 +1524,9 @@ static int copy_cond_list(cond_node_t * list, cond_node_t ** dst,/* expression nodes don't have a bool value of 0 - don't map them */ if (cur_expr->expr_type !=COND_BOOL )continue ; -assert (module->map[SYM_BOOLS ][cur_expr->bool -1 ] !=0 ); - cur_expr->bool = - module->map[SYM_BOOLS ][cur_expr->bool -1 ]; +assert (module->map[SYM_BOOLS ][cur_expr->boolean -1 ] !=0 ); + cur_expr->boolean = + module->map[SYM_BOOLS ][cur_expr->boolean -1 ]; } new_node->nbools = cur->nbools;/* FIXME should COND_MAX_BOOLS be used here? */ libsepol/src/module_to_cil.c +1
-1@@ -1272,7 +1272,7 @@ static int cond_expr_to_cil(int indent, struct policydb *pdb, struct cond_expr *for (curr = cond_expr; curr !=NULL ; curr = curr->next) {if (curr->expr_type ==COND_BOOL ) { - val1 = pdb->p_bool_val_to_name[curr->bool -1 ]; + val1 = pdb->p_bool_val_to_name[curr->boolean -1 ];// length of boolean + 2 parens + null terminator len =strlen (val1) +2 +1 ; new_val =malloc (len);libsepol/src/policydb_validate.c +1
-1@@ -974,7 +974,7 @@ static int validate_cond_expr(sepol_handle_t *handle, const struct cond_expr *exfor (; expr; expr = expr->next) {switch (expr->expr_type) {case COND_BOOL : -if (validate_value (expr->bool, boolean)) +if (validate_value (expr->boolean, boolean)) goto bad;if (depth == (COND_EXPR_MAXDEPTH -1 )) goto bad;libsepol/src/write.c +1
-1@@ -834,7 +834,7 @@ static int cond_write_node(policydb_t * p,for (cur_expr = node->expr; cur_expr !=NULL ; cur_expr = cur_expr->next) { items =0 ; buf[items++] =cpu_to_le32 (cur_expr->expr_type); - buf[items++] =cpu_to_le32 (cur_expr->bool); + buf[items++] =cpu_to_le32 (cur_expr->boolean); items2 =put_entry (buf,sizeof (uint32_t ), items, fp);if (items2 != items)return POLICYDB_ERROR ;libsepol/tests/debug.c +1
-1@@ -41,7 +41,7 @@ void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp)for (cur = exp; cur !=NULL ; cur = cur->next) {switch (cur->expr_type) {case COND_BOOL : -fprintf (fp,"%s " , p->p_bool_val_to_name[cur->bool -1 ]); +fprintf (fp,"%s " , p->p_bool_val_to_name[cur->boolean -1 ]);break ;case COND_NOT :fprintf (fp,"! " );libsepol/tests/test-linker-cond-map.c +1
-2@@ -70,7 +70,7 @@ static void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_CU_ASSERT (expr->expr_type == bools[i].expr_type);if (bools[i].bool) { -CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->bool -1 ], bools[i].bool) ==0 ); +CU_ASSERT (strcmp (p->sym_val_to_name[SYM_BOOLS ][expr->boolean -1 ], bools[i].bool) ==0 ); } expr = expr->next; } --2.40.0