diff mbox series

[1/2] Revert "libsepol/tests: rename bool indentifiers"

Message ID 20231204164558.43667-1-lautrbach@redhat.com (mailing list archive)
State Rejected
Delegated to: Petr Lautrbach
Headers show
Series [1/2] Revert "libsepol/tests: rename bool indentifiers" | expand

Commit Message

Petr Lautrbach Dec. 4, 2023, 4:45 p.m. UTC
This reverts commit 893b50c6ce661f3ee339145e76a0bbfa199671c3.

61f21385004 ("libsepol: rename struct member") broke build of SETools:

setools/policyrep.c: In function ‘__pyx_pf_7setools_9policyrep_23ConditionalExprIterator___next__’:
setools/policyrep.c:27857:138: error: ‘cond_expr_t’ {aka ‘struct cond_expr’} has no member named ‘bool’; did you mean ‘boolean’?
27857 |     __pyx_t_3 = __pyx_f_7setools_9policyrep_13SELinuxPolicy_boolean_value_to_datum(__pyx_v_self->__pyx_base.policy, (__pyx_v_self->curr->bool - 1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 336, __pyx_L1_error)
      |                                                                                                                                          ^~~~
      |

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
---
 libsepol/tests/test-linker-cond-map.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

James Carter Dec. 4, 2023, 6:19 p.m. UTC | #1
On Mon, Dec 4, 2023 at 11:46 AM Petr Lautrbach <lautrbach@redhat.com> wrote:
>
> This reverts commit 893b50c6ce661f3ee339145e76a0bbfa199671c3.
>
> 61f21385004 ("libsepol: rename struct member") broke build of SETools:
>
> setools/policyrep.c: In function ‘__pyx_pf_7setools_9policyrep_23ConditionalExprIterator___next__’:
> setools/policyrep.c:27857:138: error: ‘cond_expr_t’ {aka ‘struct cond_expr’} has no member named ‘bool’; did you mean ‘boolean’?
> 27857 |     __pyx_t_3 = __pyx_f_7setools_9policyrep_13SELinuxPolicy_boolean_value_to_datum(__pyx_v_self->__pyx_base.policy, (__pyx_v_self->curr->bool - 1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 336, __pyx_L1_error)
>       |                                                                                                                                          ^~~~
>       |
>
> Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>

Also need to revert 513fc1570c16924080740b23fa34343ef64a90c0
Plus there is a couple of new uses in policy_validate.c and one in
checkpolicy/policy_define.c that need to be corrected.

Thanks,
Jim

> ---
>  libsepol/tests/test-linker-cond-map.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/libsepol/tests/test-linker-cond-map.c b/libsepol/tests/test-linker-cond-map.c
> index 142066669c0c..6ea0e4c2ac6b 100644
> --- a/libsepol/tests/test-linker-cond-map.c
> +++ b/libsepol/tests/test-linker-cond-map.c
> @@ -51,7 +51,7 @@
>   */
>
>  typedef struct test_cond_expr {
> -       const char *boolean;
> +       const char *bool;
>         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].boolean) {
> -                       CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].boolean) == 0);
> +               if (bools[i].bool) {
> +                       CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].bool) == 0);
>                 }
>                 expr = expr->next;
>         }
>  }
>
> -static void test_bool_state(policydb_t * p, const char *boolean, int state)
> +static void test_bool_state(policydb_t * p, const char *bool, int state)
>  {
>         cond_bool_datum_t *b;
>
> -       b = hashtab_search(p->p_bools.table, boolean);
> +       b = hashtab_search(p->p_bools.table, bool);
>         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].boolean = "g_b_bool_1";
> +       bools[0].bool = "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].boolean = "o1_b_bool_1";
> +       bools[0].bool = "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].boolean = "g_m1_bool_1";
> +       bools[0].bool = "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].boolean = "o1_m1_bool_1";
> +       bools[0].bool = "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].boolean = "g_m2_bool_1";
> +       bools[0].bool = "g_m2_bool_1";
>         bools[0].expr_type = COND_BOOL;
> -       bools[1].boolean = "g_m2_bool_2";
> +       bools[1].bool = "g_m2_bool_2";
>         bools[1].expr_type = COND_BOOL;
> -       bools[2].boolean = NULL;
> +       bools[2].bool = NULL;
>         bools[2].expr_type = COND_AND;
>         test_cond_expr_mapping(base, d, bools, 3);
>  }
> --
> 2.41.0
>
>
Christian Göttsche Dec. 4, 2023, 6:24 p.m. UTC | #2
On Mon, 4 Dec 2023 at 19:20, James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Dec 4, 2023 at 11:46 AM Petr Lautrbach <lautrbach@redhat.com> wrote:
> >
> > This reverts commit 893b50c6ce661f3ee339145e76a0bbfa199671c3.
> >
> > 61f21385004 ("libsepol: rename struct member") broke build of SETools:
> >
> > setools/policyrep.c: In function ‘__pyx_pf_7setools_9policyrep_23ConditionalExprIterator___next__’:
> > setools/policyrep.c:27857:138: error: ‘cond_expr_t’ {aka ‘struct cond_expr’} has no member named ‘bool’; did you mean ‘boolean’?
> > 27857 |     __pyx_t_3 = __pyx_f_7setools_9policyrep_13SELinuxPolicy_boolean_value_to_datum(__pyx_v_self->__pyx_base.policy, (__pyx_v_self->curr->bool - 1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 336, __pyx_L1_error)
> >       |                                                                                                                                          ^~~~
> >       |
> >
> > Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
>
> Also need to revert 513fc1570c16924080740b23fa34343ef64a90c0
> Plus there is a couple of new uses in policy_validate.c and one in
> checkpolicy/policy_define.c that need to be corrected.
>
> Thanks,
> Jim

Could you consider https://github.com/SELinuxProject/setools/pull/113
as an alternative?

>
> > ---
> >  libsepol/tests/test-linker-cond-map.c | 24 ++++++++++++------------
> >  1 file changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/libsepol/tests/test-linker-cond-map.c b/libsepol/tests/test-linker-cond-map.c
> > index 142066669c0c..6ea0e4c2ac6b 100644
> > --- a/libsepol/tests/test-linker-cond-map.c
> > +++ b/libsepol/tests/test-linker-cond-map.c
> > @@ -51,7 +51,7 @@
> >   */
> >
> >  typedef struct test_cond_expr {
> > -       const char *boolean;
> > +       const char *bool;
> >         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].boolean) {
> > -                       CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].boolean) == 0);
> > +               if (bools[i].bool) {
> > +                       CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].bool) == 0);
> >                 }
> >                 expr = expr->next;
> >         }
> >  }
> >
> > -static void test_bool_state(policydb_t * p, const char *boolean, int state)
> > +static void test_bool_state(policydb_t * p, const char *bool, int state)
> >  {
> >         cond_bool_datum_t *b;
> >
> > -       b = hashtab_search(p->p_bools.table, boolean);
> > +       b = hashtab_search(p->p_bools.table, bool);
> >         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].boolean = "g_b_bool_1";
> > +       bools[0].bool = "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].boolean = "o1_b_bool_1";
> > +       bools[0].bool = "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].boolean = "g_m1_bool_1";
> > +       bools[0].bool = "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].boolean = "o1_m1_bool_1";
> > +       bools[0].bool = "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].boolean = "g_m2_bool_1";
> > +       bools[0].bool = "g_m2_bool_1";
> >         bools[0].expr_type = COND_BOOL;
> > -       bools[1].boolean = "g_m2_bool_2";
> > +       bools[1].bool = "g_m2_bool_2";
> >         bools[1].expr_type = COND_BOOL;
> > -       bools[2].boolean = NULL;
> > +       bools[2].bool = NULL;
> >         bools[2].expr_type = COND_AND;
> >         test_cond_expr_mapping(base, d, bools, 3);
> >  }
> > --
> > 2.41.0
> >
> >
>
James Carter Dec. 4, 2023, 6:31 p.m. UTC | #3
On Mon, Dec 4, 2023 at 1:24 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> On Mon, 4 Dec 2023 at 19:20, James Carter <jwcart2@gmail.com> wrote:
> >
> > On Mon, Dec 4, 2023 at 11:46 AM Petr Lautrbach <lautrbach@redhat.com> wrote:
> > >
> > > This reverts commit 893b50c6ce661f3ee339145e76a0bbfa199671c3.
> > >
> > > 61f21385004 ("libsepol: rename struct member") broke build of SETools:
> > >
> > > setools/policyrep.c: In function ‘__pyx_pf_7setools_9policyrep_23ConditionalExprIterator___next__’:
> > > setools/policyrep.c:27857:138: error: ‘cond_expr_t’ {aka ‘struct cond_expr’} has no member named ‘bool’; did you mean ‘boolean’?
> > > 27857 |     __pyx_t_3 = __pyx_f_7setools_9policyrep_13SELinuxPolicy_boolean_value_to_datum(__pyx_v_self->__pyx_base.policy, (__pyx_v_self->curr->bool - 1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 336, __pyx_L1_error)
> > >       |                                                                                                                                          ^~~~
> > >       |
> > >
> > > Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
> >
> > Also need to revert 513fc1570c16924080740b23fa34343ef64a90c0
> > Plus there is a couple of new uses in policy_validate.c and one in
> > checkpolicy/policy_define.c that need to be corrected.
> >
> > Thanks,
> > Jim
>
> Could you consider https://github.com/SELinuxProject/setools/pull/113
> as an alternative?
>
Obviously, not reverting would be preferable if at all possible.
Jim

> >
> > > ---
> > >  libsepol/tests/test-linker-cond-map.c | 24 ++++++++++++------------
> > >  1 file changed, 12 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/libsepol/tests/test-linker-cond-map.c b/libsepol/tests/test-linker-cond-map.c
> > > index 142066669c0c..6ea0e4c2ac6b 100644
> > > --- a/libsepol/tests/test-linker-cond-map.c
> > > +++ b/libsepol/tests/test-linker-cond-map.c
> > > @@ -51,7 +51,7 @@
> > >   */
> > >
> > >  typedef struct test_cond_expr {
> > > -       const char *boolean;
> > > +       const char *bool;
> > >         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].boolean) {
> > > -                       CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].boolean) == 0);
> > > +               if (bools[i].bool) {
> > > +                       CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].bool) == 0);
> > >                 }
> > >                 expr = expr->next;
> > >         }
> > >  }
> > >
> > > -static void test_bool_state(policydb_t * p, const char *boolean, int state)
> > > +static void test_bool_state(policydb_t * p, const char *bool, int state)
> > >  {
> > >         cond_bool_datum_t *b;
> > >
> > > -       b = hashtab_search(p->p_bools.table, boolean);
> > > +       b = hashtab_search(p->p_bools.table, bool);
> > >         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].boolean = "g_b_bool_1";
> > > +       bools[0].bool = "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].boolean = "o1_b_bool_1";
> > > +       bools[0].bool = "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].boolean = "g_m1_bool_1";
> > > +       bools[0].bool = "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].boolean = "o1_m1_bool_1";
> > > +       bools[0].bool = "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].boolean = "g_m2_bool_1";
> > > +       bools[0].bool = "g_m2_bool_1";
> > >         bools[0].expr_type = COND_BOOL;
> > > -       bools[1].boolean = "g_m2_bool_2";
> > > +       bools[1].bool = "g_m2_bool_2";
> > >         bools[1].expr_type = COND_BOOL;
> > > -       bools[2].boolean = NULL;
> > > +       bools[2].bool = NULL;
> > >         bools[2].expr_type = COND_AND;
> > >         test_cond_expr_mapping(base, d, bools, 3);
> > >  }
> > > --
> > > 2.41.0
> > >
> > >
> >
Petr Lautrbach Dec. 4, 2023, 6:37 p.m. UTC | #4
Christian Göttsche <cgzones@googlemail.com> writes:

> On Mon, 4 Dec 2023 at 19:20, James Carter <jwcart2@gmail.com> wrote:
>>
>> On Mon, Dec 4, 2023 at 11:46 AM Petr Lautrbach <lautrbach@redhat.com> wrote:
>> >
>> > This reverts commit 893b50c6ce661f3ee339145e76a0bbfa199671c3.
>> >
>> > 61f21385004 ("libsepol: rename struct member") broke build of SETools:
>> >
>> > setools/policyrep.c: In function ‘__pyx_pf_7setools_9policyrep_23ConditionalExprIterator___next__’:
>> > setools/policyrep.c:27857:138: error: ‘cond_expr_t’ {aka ‘struct cond_expr’} has no member named ‘bool’; did you mean ‘boolean’?
>> > 27857 |     __pyx_t_3 = __pyx_f_7setools_9policyrep_13SELinuxPolicy_boolean_value_to_datum(__pyx_v_self->__pyx_base.policy, (__pyx_v_self->curr->bool - 1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 336, __pyx_L1_error)
>> >       |                                                                                                                                          ^~~~
>> >       |
>> >
>> > Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
>>
>> Also need to revert 513fc1570c16924080740b23fa34343ef64a90c0
>> Plus there is a couple of new uses in policy_validate.c and one in
>> checkpolicy/policy_define.c that need to be corrected.
>>
>> Thanks,
>> Jim
>
> Could you consider https://github.com/SELinuxProject/setools/pull/113
> as an alternative?

Nice, thanks!

I need to test it, but it looks good.

For me, this is better solution than reverting all the patches.

But we need to release SETools together with SELinux userspace 3.6.

Chris, is it feasible to release SETools with the proposed change on
this Wednesday or a week later?

Petr



>>
>> > ---
>> >  libsepol/tests/test-linker-cond-map.c | 24 ++++++++++++------------
>> >  1 file changed, 12 insertions(+), 12 deletions(-)
>> >
>> > diff --git a/libsepol/tests/test-linker-cond-map.c b/libsepol/tests/test-linker-cond-map.c
>> > index 142066669c0c..6ea0e4c2ac6b 100644
>> > --- a/libsepol/tests/test-linker-cond-map.c
>> > +++ b/libsepol/tests/test-linker-cond-map.c
>> > @@ -51,7 +51,7 @@
>> >   */
>> >
>> >  typedef struct test_cond_expr {
>> > -       const char *boolean;
>> > +       const char *bool;
>> >         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].boolean) {
>> > -                       CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].boolean) == 0);
>> > +               if (bools[i].bool) {
>> > +                       CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].bool) == 0);
>> >                 }
>> >                 expr = expr->next;
>> >         }
>> >  }
>> >
>> > -static void test_bool_state(policydb_t * p, const char *boolean, int state)
>> > +static void test_bool_state(policydb_t * p, const char *bool, int state)
>> >  {
>> >         cond_bool_datum_t *b;
>> >
>> > -       b = hashtab_search(p->p_bools.table, boolean);
>> > +       b = hashtab_search(p->p_bools.table, bool);
>> >         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].boolean = "g_b_bool_1";
>> > +       bools[0].bool = "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].boolean = "o1_b_bool_1";
>> > +       bools[0].bool = "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].boolean = "g_m1_bool_1";
>> > +       bools[0].bool = "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].boolean = "o1_m1_bool_1";
>> > +       bools[0].bool = "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].boolean = "g_m2_bool_1";
>> > +       bools[0].bool = "g_m2_bool_1";
>> >         bools[0].expr_type = COND_BOOL;
>> > -       bools[1].boolean = "g_m2_bool_2";
>> > +       bools[1].bool = "g_m2_bool_2";
>> >         bools[1].expr_type = COND_BOOL;
>> > -       bools[2].boolean = NULL;
>> > +       bools[2].bool = NULL;
>> >         bools[2].expr_type = COND_AND;
>> >         test_cond_expr_mapping(base, d, bools, 3);
>> >  }
>> > --
>> > 2.41.0
>> >
>> >
>>
Chris PeBenito Dec. 6, 2023, 1:43 p.m. UTC | #5
On 12/4/2023 1:37 PM, Petr Lautrbach wrote:
> Christian Göttsche <cgzones@googlemail.com> writes:
> 
>> On Mon, 4 Dec 2023 at 19:20, James Carter <jwcart2@gmail.com> wrote:
>>>
>>> On Mon, Dec 4, 2023 at 11:46 AM Petr Lautrbach <lautrbach@redhat.com> wrote:
>>>>
>>>> This reverts commit 893b50c6ce661f3ee339145e76a0bbfa199671c3.
>>>>
>>>> 61f21385004 ("libsepol: rename struct member") broke build of SETools:
>>>>
>>>> setools/policyrep.c: In function ‘__pyx_pf_7setools_9policyrep_23ConditionalExprIterator___next__’:
>>>> setools/policyrep.c:27857:138: error: ‘cond_expr_t’ {aka ‘struct cond_expr’} has no member named ‘bool’; did you mean ‘boolean’?
>>>> 27857 |     __pyx_t_3 = __pyx_f_7setools_9policyrep_13SELinuxPolicy_boolean_value_to_datum(__pyx_v_self->__pyx_base.policy, (__pyx_v_self->curr->bool - 1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 336, __pyx_L1_error)
>>>>        |                                                                                                                                          ^~~~
>>>>        |
>>>>
>>>> Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
>>>
>>> Also need to revert 513fc1570c16924080740b23fa34343ef64a90c0
>>> Plus there is a couple of new uses in policy_validate.c and one in
>>> checkpolicy/policy_define.c that need to be corrected.
>>>
>>> Thanks,
>>> Jim
>>
>> Could you consider https://github.com/SELinuxProject/setools/pull/113
>> as an alternative?
> 
> Nice, thanks!
> 
> I need to test it, but it looks good.
> 
> For me, this is better solution than reverting all the patches.
> 
> But we need to release SETools together with SELinux userspace 3.6.
> 
> Chris, is it feasible to release SETools with the proposed change on
> this Wednesday or a week later?

Yes, that can be done.
diff mbox series

Patch

diff --git a/libsepol/tests/test-linker-cond-map.c b/libsepol/tests/test-linker-cond-map.c
index 142066669c0c..6ea0e4c2ac6b 100644
--- a/libsepol/tests/test-linker-cond-map.c
+++ b/libsepol/tests/test-linker-cond-map.c
@@ -51,7 +51,7 @@ 
  */
 
 typedef struct test_cond_expr {
-	const char *boolean;
+	const char *bool;
 	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].boolean) {
-			CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].boolean) == 0);
+		if (bools[i].bool) {
+			CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].bool) == 0);
 		}
 		expr = expr->next;
 	}
 }
 
-static void test_bool_state(policydb_t * p, const char *boolean, int state)
+static void test_bool_state(policydb_t * p, const char *bool, int state)
 {
 	cond_bool_datum_t *b;
 
-	b = hashtab_search(p->p_bools.table, boolean);
+	b = hashtab_search(p->p_bools.table, bool);
 	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].boolean = "g_b_bool_1";
+	bools[0].bool = "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].boolean = "o1_b_bool_1";
+	bools[0].bool = "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].boolean = "g_m1_bool_1";
+	bools[0].bool = "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].boolean = "o1_m1_bool_1";
+	bools[0].bool = "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].boolean = "g_m2_bool_1";
+	bools[0].bool = "g_m2_bool_1";
 	bools[0].expr_type = COND_BOOL;
-	bools[1].boolean = "g_m2_bool_2";
+	bools[1].bool = "g_m2_bool_2";
 	bools[1].expr_type = COND_BOOL;
-	bools[2].boolean = NULL;
+	bools[2].bool = NULL;
 	bools[2].expr_type = COND_AND;
 	test_cond_expr_mapping(base, d, bools, 3);
 }