diff mbox series

libselinux/restorecon: Include <selinux/label.h>

Message ID 20240726160725.1598159-1-vmojzis@redhat.com (mailing list archive)
State Accepted
Headers show
Series libselinux/restorecon: Include <selinux/label.h> | expand

Commit Message

Vit Mojzis July 26, 2024, 3:59 p.m. UTC
restorecon.h uses types defined in label.h, so it needs to include
label.h (or code using restorecon.h also needs to include label.h,
which is not practical).

Fixes:
  $ make DESTDIR=~/obj install > make.out
In file included from semanage_store.c:39:
/home/sdsmall/obj/usr/include/selinux/restorecon.h:137:52: error:
‘struct selabel_handle’ declared inside parameter list will not be
visible outside of this definition or declaration [-Werror]
  137 | extern void selinux_restorecon_set_sehandle(struct
selabel_handle *hndl);
      |                                                    ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:111: semanage_store.o] Error 1
make[1]: *** [Makefile:15: install] Error 2
make: *** [Makefile:40: install] Error 1

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
---
Sorry, did not notice the error since for some reason fedora-rawhide
build with the patch was successful:
https://copr.fedorainfracloud.org/coprs/vmojzis/userspace_test/build/7789598/
But I managed to reporoduce it on a fresh system with the command you
provided.
I assume you meant label.h instead of handle.h.

 libselinux/include/selinux/restorecon.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Stephen Smalley July 26, 2024, 5:24 p.m. UTC | #1
On Fri, Jul 26, 2024 at 12:10 PM Vit Mojzis <vmojzis@redhat.com> wrote:
>
> restorecon.h uses types defined in label.h, so it needs to include
> label.h (or code using restorecon.h also needs to include label.h,
> which is not practical).
>
> Fixes:
>   $ make DESTDIR=~/obj install > make.out
> In file included from semanage_store.c:39:
> /home/sdsmall/obj/usr/include/selinux/restorecon.h:137:52: error:
> ‘struct selabel_handle’ declared inside parameter list will not be
> visible outside of this definition or declaration [-Werror]
>   137 | extern void selinux_restorecon_set_sehandle(struct
> selabel_handle *hndl);
>       |                                                    ^~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[2]: *** [Makefile:111: semanage_store.o] Error 1
> make[1]: *** [Makefile:15: install] Error 2
> make: *** [Makefile:40: install] Error 1
>
> Signed-off-by: Vit Mojzis <vmojzis@redhat.com>

Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>

> ---
> Sorry, did not notice the error since for some reason fedora-rawhide
> build with the patch was successful:
> https://copr.fedorainfracloud.org/coprs/vmojzis/userspace_test/build/7789598/
> But I managed to reporoduce it on a fresh system with the command you
> provided.
> I assume you meant label.h instead of handle.h.

Correct, thanks. Probably not a fatal error in the default build.

>  libselinux/include/selinux/restorecon.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libselinux/include/selinux/restorecon.h b/libselinux/include/selinux/restorecon.h
> index b10fe684..5be6542c 100644
> --- a/libselinux/include/selinux/restorecon.h
> +++ b/libselinux/include/selinux/restorecon.h
> @@ -1,6 +1,8 @@
>  #ifndef _RESTORECON_H_
>  #define _RESTORECON_H_
>
> +#include <selinux/label.h>
> +
>  #include <sys/types.h>
>  #include <stddef.h>
>  #include <stdarg.h>
> --
> 2.43.0
>
>
Stephen Smalley July 29, 2024, 11:57 a.m. UTC | #2
On Fri, Jul 26, 2024 at 1:24 PM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
>
> On Fri, Jul 26, 2024 at 12:10 PM Vit Mojzis <vmojzis@redhat.com> wrote:
> >
> > restorecon.h uses types defined in label.h, so it needs to include
> > label.h (or code using restorecon.h also needs to include label.h,
> > which is not practical).
> >
> > Fixes:
> >   $ make DESTDIR=~/obj install > make.out
> > In file included from semanage_store.c:39:
> > /home/sdsmall/obj/usr/include/selinux/restorecon.h:137:52: error:
> > ‘struct selabel_handle’ declared inside parameter list will not be
> > visible outside of this definition or declaration [-Werror]
> >   137 | extern void selinux_restorecon_set_sehandle(struct
> > selabel_handle *hndl);
> >       |                                                    ^~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> > make[2]: *** [Makefile:111: semanage_store.o] Error 1
> > make[1]: *** [Makefile:15: install] Error 2
> > make: *** [Makefile:40: install] Error 1
> >
> > Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
>
> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>

This patch has been applied to main.
diff mbox series

Patch

diff --git a/libselinux/include/selinux/restorecon.h b/libselinux/include/selinux/restorecon.h
index b10fe684..5be6542c 100644
--- a/libselinux/include/selinux/restorecon.h
+++ b/libselinux/include/selinux/restorecon.h
@@ -1,6 +1,8 @@ 
 #ifndef _RESTORECON_H_
 #define _RESTORECON_H_
 
+#include <selinux/label.h>
+
 #include <sys/types.h>
 #include <stddef.h>
 #include <stdarg.h>