diff mbox series

[RFC,v2,15/27] libselinux/utils: use correct type for backend argument

Message ID 20230814132025.45364-16-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit e28f6a8a15ee
Delegated to: Petr Lautrbach
Headers show
Series libselinux: rework selabel_file(5) database | expand

Commit Message

Christian Göttsche Aug. 14, 2023, 1:20 p.m. UTC
selabel_open(3) expects the backend to be of type unsigned int.

Also initialize with a macro flag instead raw 0.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/utils/selabel_digest.c | 3 ++-
 libselinux/utils/selabel_lookup.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

James Carter Oct. 5, 2023, 3:49 p.m. UTC | #1
On Mon, Aug 14, 2023 at 9:42 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> selabel_open(3) expects the backend to be of type unsigned int.
>
> Also initialize with a macro flag instead raw 0.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libselinux/utils/selabel_digest.c | 3 ++-
>  libselinux/utils/selabel_lookup.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libselinux/utils/selabel_digest.c b/libselinux/utils/selabel_digest.c
> index 6a8313a2..bf22b472 100644
> --- a/libselinux/utils/selabel_digest.c
> +++ b/libselinux/utils/selabel_digest.c
> @@ -59,7 +59,8 @@ static int run_check_digest(char *cmd, char *selabel_digest)
>
>  int main(int argc, char **argv)
>  {
> -       int backend = 0, rc, opt, validate = 0;
> +       unsigned int backend = SELABEL_CTX_FILE;
> +       int rc, opt, validate = 0;
>         char *baseonly = NULL, *file = NULL, *digest = (char *)1;
>         char **specfiles = NULL;
>         unsigned char *sha1_digest = NULL;
> diff --git a/libselinux/utils/selabel_lookup.c b/libselinux/utils/selabel_lookup.c
> index 112ffda1..5dc32548 100644
> --- a/libselinux/utils/selabel_lookup.c
> +++ b/libselinux/utils/selabel_lookup.c
> @@ -32,7 +32,8 @@ static __attribute__ ((__noreturn__)) void usage(const char *progname)
>
>  int main(int argc, char **argv)
>  {
> -       int raw = 0, type = 0, backend = 0, rc, opt;
> +       int raw = 0, type = 0, rc, opt;
> +       unsigned int backend = SELABEL_CTX_FILE;
>         char *validate = NULL, *key = NULL, *context = NULL, *file = NULL;
>
>         struct selabel_handle *hnd;
> --
> 2.40.1
>
James Carter Oct. 12, 2023, 5:55 p.m. UTC | #2
On Thu, Oct 5, 2023 at 11:49 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Aug 14, 2023 at 9:42 AM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > selabel_open(3) expects the backend to be of type unsigned int.
> >
> > Also initialize with a macro flag instead raw 0.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim

> > ---
> >  libselinux/utils/selabel_digest.c | 3 ++-
> >  libselinux/utils/selabel_lookup.c | 3 ++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/libselinux/utils/selabel_digest.c b/libselinux/utils/selabel_digest.c
> > index 6a8313a2..bf22b472 100644
> > --- a/libselinux/utils/selabel_digest.c
> > +++ b/libselinux/utils/selabel_digest.c
> > @@ -59,7 +59,8 @@ static int run_check_digest(char *cmd, char *selabel_digest)
> >
> >  int main(int argc, char **argv)
> >  {
> > -       int backend = 0, rc, opt, validate = 0;
> > +       unsigned int backend = SELABEL_CTX_FILE;
> > +       int rc, opt, validate = 0;
> >         char *baseonly = NULL, *file = NULL, *digest = (char *)1;
> >         char **specfiles = NULL;
> >         unsigned char *sha1_digest = NULL;
> > diff --git a/libselinux/utils/selabel_lookup.c b/libselinux/utils/selabel_lookup.c
> > index 112ffda1..5dc32548 100644
> > --- a/libselinux/utils/selabel_lookup.c
> > +++ b/libselinux/utils/selabel_lookup.c
> > @@ -32,7 +32,8 @@ static __attribute__ ((__noreturn__)) void usage(const char *progname)
> >
> >  int main(int argc, char **argv)
> >  {
> > -       int raw = 0, type = 0, backend = 0, rc, opt;
> > +       int raw = 0, type = 0, rc, opt;
> > +       unsigned int backend = SELABEL_CTX_FILE;
> >         char *validate = NULL, *key = NULL, *context = NULL, *file = NULL;
> >
> >         struct selabel_handle *hnd;
> > --
> > 2.40.1
> >
diff mbox series

Patch

diff --git a/libselinux/utils/selabel_digest.c b/libselinux/utils/selabel_digest.c
index 6a8313a2..bf22b472 100644
--- a/libselinux/utils/selabel_digest.c
+++ b/libselinux/utils/selabel_digest.c
@@ -59,7 +59,8 @@  static int run_check_digest(char *cmd, char *selabel_digest)
 
 int main(int argc, char **argv)
 {
-	int backend = 0, rc, opt, validate = 0;
+	unsigned int backend = SELABEL_CTX_FILE;
+	int rc, opt, validate = 0;
 	char *baseonly = NULL, *file = NULL, *digest = (char *)1;
 	char **specfiles = NULL;
 	unsigned char *sha1_digest = NULL;
diff --git a/libselinux/utils/selabel_lookup.c b/libselinux/utils/selabel_lookup.c
index 112ffda1..5dc32548 100644
--- a/libselinux/utils/selabel_lookup.c
+++ b/libselinux/utils/selabel_lookup.c
@@ -32,7 +32,8 @@  static __attribute__ ((__noreturn__)) void usage(const char *progname)
 
 int main(int argc, char **argv)
 {
-	int raw = 0, type = 0, backend = 0, rc, opt;
+	int raw = 0, type = 0, rc, opt;
+	unsigned int backend = SELABEL_CTX_FILE;
 	char *validate = NULL, *key = NULL, *context = NULL, *file = NULL;
 
 	struct selabel_handle *hnd;