diff mbox series

[1/4] libsepol: improve policy lookup failure message

Message ID 20240408150802.63941-1-cgoettsche@seltendoof.de (mailing list archive)
State Accepted
Commit fa3a1bcaf3f8
Delegated to: Petr Lautrbach
Headers show
Series [1/4] libsepol: improve policy lookup failure message | expand

Commit Message

Christian Göttsche April 8, 2024, 3:07 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

If a policy version cannot be found include the policy target, and a
module prefix for non kernel policies in the message.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/write.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

James Carter April 22, 2024, 8:48 p.m. UTC | #1
On Mon, Apr 8, 2024 at 11:08 AM Christian Göttsche
<cgoettsche@seltendoof.de> wrote:
>
> From: Christian Göttsche <cgzones@googlemail.com>
>
> If a policy version cannot be found include the policy target, and a
> module prefix for non kernel policies in the message.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

For these four patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsepol/src/write.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libsepol/src/write.c b/libsepol/src/write.c
> index 283d11c8..2fcc1701 100644
> --- a/libsepol/src/write.c
> +++ b/libsepol/src/write.c
> @@ -2252,8 +2252,10 @@ int policydb_write(policydb_t * p, struct policy_file *fp)
>         info = policydb_lookup_compat(p->policyvers, p->policy_type,
>                                         p->target_platform);
>         if (!info) {
> -               ERR(fp->handle, "compatibility lookup failed for policy "
> -                   "version %d", p->policyvers);
> +               ERR(fp->handle, "compatibility lookup failed for %s%s policy version %d",
> +                   p->target_platform == SEPOL_TARGET_SELINUX ? "selinux" : "xen",
> +                   p->policy_type == POLICY_KERN ? "" : " module",
> +                   p->policyvers);
>                 return POLICYDB_ERROR;
>         }
>
> --
> 2.43.0
>
>
James Carter May 2, 2024, 6:03 p.m. UTC | #2
On Mon, Apr 22, 2024 at 4:48 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Apr 8, 2024 at 11:08 AM Christian Göttsche
> <cgoettsche@seltendoof.de> wrote:
> >
> > From: Christian Göttsche <cgzones@googlemail.com>
> >
> > If a policy version cannot be found include the policy target, and a
> > module prefix for non kernel policies in the message.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> For these four patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>

These four patches have been merged.
Thanks,
Jim

> > ---
> >  libsepol/src/write.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/libsepol/src/write.c b/libsepol/src/write.c
> > index 283d11c8..2fcc1701 100644
> > --- a/libsepol/src/write.c
> > +++ b/libsepol/src/write.c
> > @@ -2252,8 +2252,10 @@ int policydb_write(policydb_t * p, struct policy_file *fp)
> >         info = policydb_lookup_compat(p->policyvers, p->policy_type,
> >                                         p->target_platform);
> >         if (!info) {
> > -               ERR(fp->handle, "compatibility lookup failed for policy "
> > -                   "version %d", p->policyvers);
> > +               ERR(fp->handle, "compatibility lookup failed for %s%s policy version %d",
> > +                   p->target_platform == SEPOL_TARGET_SELINUX ? "selinux" : "xen",
> > +                   p->policy_type == POLICY_KERN ? "" : " module",
> > +                   p->policyvers);
> >                 return POLICYDB_ERROR;
> >         }
> >
> > --
> > 2.43.0
> >
> >
diff mbox series

Patch

diff --git a/libsepol/src/write.c b/libsepol/src/write.c
index 283d11c8..2fcc1701 100644
--- a/libsepol/src/write.c
+++ b/libsepol/src/write.c
@@ -2252,8 +2252,10 @@  int policydb_write(policydb_t * p, struct policy_file *fp)
 	info = policydb_lookup_compat(p->policyvers, p->policy_type,
 					p->target_platform);
 	if (!info) {
-		ERR(fp->handle, "compatibility lookup failed for policy "
-		    "version %d", p->policyvers);
+		ERR(fp->handle, "compatibility lookup failed for %s%s policy version %d",
+		    p->target_platform == SEPOL_TARGET_SELINUX ? "selinux" : "xen",
+		    p->policy_type == POLICY_KERN ? "" : " module",
+		    p->policyvers);
 		return POLICYDB_ERROR;
 	}