Message ID | 20241211161417.126236-1-jwcart2@gmail.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Petr Lautrbach |
Headers | show |
Series | [1/9] Revert "libselinux/utils: drop reachable assert in sefcontext_compile" | expand |
It looks like Christian was able to fix the problem, so ignore these. Jim On Wed, Dec 11, 2024 at 11:14 AM James Carter <jwcart2@gmail.com> wrote: > > This reverts commit f50abe2a3aad0716a0711cfcc07f934f4a9d2b02. > > Needed to revert commit 92306daf5219e73f6e8bc9fc7699399457999bcd > "libselinux: rework selabel_file(5) database", which broke Android > file_context matching. > > Signed-off-by: James Carter <jwcart2@gmail.com> > --- > libselinux/utils/sefcontext_compile.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/libselinux/utils/sefcontext_compile.c b/libselinux/utils/sefcontext_compile.c > index b4445a1f..5d7ab301 100644 > --- a/libselinux/utils/sefcontext_compile.c > +++ b/libselinux/utils/sefcontext_compile.c > @@ -188,9 +188,6 @@ static int write_sidtab(FILE *bin_file, const struct sidtab *stab) > if (len != 1) > return -1; > > - if (stab->nel == 0) > - return 0; > - > /* sort entries by id */ > sids = calloc(stab->nel, sizeof(*sids)); > if (!sids) > @@ -206,6 +203,8 @@ static int write_sidtab(FILE *bin_file, const struct sidtab *stab) > } > assert(index == stab->nel); > qsort(sids, stab->nel, sizeof(struct security_id), security_id_compare); > + assert(sids[0].id == 1); > + assert(sids[stab->nel - 1].id == stab->nel); > > /* write raw contexts sorted by id */ > for (uint32_t i = 0; i < stab->nel; i++) { > -- > 2.47.1 >
diff --git a/libselinux/utils/sefcontext_compile.c b/libselinux/utils/sefcontext_compile.c index b4445a1f..5d7ab301 100644 --- a/libselinux/utils/sefcontext_compile.c +++ b/libselinux/utils/sefcontext_compile.c @@ -188,9 +188,6 @@ static int write_sidtab(FILE *bin_file, const struct sidtab *stab) if (len != 1) return -1; - if (stab->nel == 0) - return 0; - /* sort entries by id */ sids = calloc(stab->nel, sizeof(*sids)); if (!sids) @@ -206,6 +203,8 @@ static int write_sidtab(FILE *bin_file, const struct sidtab *stab) } assert(index == stab->nel); qsort(sids, stab->nel, sizeof(struct security_id), security_id_compare); + assert(sids[0].id == 1); + assert(sids[stab->nel - 1].id == stab->nel); /* write raw contexts sorted by id */ for (uint32_t i = 0; i < stab->nel; i++) {
This reverts commit f50abe2a3aad0716a0711cfcc07f934f4a9d2b02. Needed to revert commit 92306daf5219e73f6e8bc9fc7699399457999bcd "libselinux: rework selabel_file(5) database", which broke Android file_context matching. Signed-off-by: James Carter <jwcart2@gmail.com> --- libselinux/utils/sefcontext_compile.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)