Skip to contentSkip to conversation

libselinux, libsemanage: remove *swig_python_exception.i if its creation failed

PATCH Applied Nicolas Iooss 3 participants 5 messages Nov 5, 2016 – Nov 8, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux, libsemanage: remove *swig_python_exception.i if its creation failed

When compiling libselinux with CC=clang, "make pywrap" reports the following message:

bash exception.sh > selinuxswig_python_exception.i clang-3.9: error: no such file or directory: 'temp.aux'
awk: fatal: cannot open file `temp.aux' for reading (No such file or directory)

This does not make the build fail as exception.sh returns an "OK" status. Use "bash -e" with this script to make it return an error value.

In order not to keep an empty selinuxswig_python_exception.i file after a build fails (which would make a second run of "make pywrap" incorrectly succeed), remove the file when exception.sh fails.

As libsemanage uses the same code to build semanageswig_python_exception.i, modify its Makefile too.

By the way, on Linux clang does not seem to currently support -aux-info so it cannot be used to craft selinuxswig_python_exception.i.

---
 libselinux/src/Makefile  | 2 +-
 libsemanage/src/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
libselinux/src/Makefile +1 -1
index b92fe1c8f5f9..24946cee8a01 100644
@@ -140,7 +140,7 @@ $(LIBPC): $(LIBPC).in ../VERSION
 	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
 
 selinuxswig_python_exception.i: ../include/selinux/selinux.h
-	bash exception.sh > $@ 
+	bash -e exception.sh > $@ || (rm -f $@ ; false)
 
 $(AUDIT2WHYLOBJ): audit2why.c
 	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
libsemanage/src/Makefile +1 -1
index 55e3f469b0ba..cd29a8abf5ab 100644
@@ -98,7 +98,7 @@ $(LIBPC): $(LIBPC).in ../VERSION
 	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
 
 semanageswig_python_exception.i: ../include/semanage/semanage.h
-	bash exception.sh > $@
+	bash -e exception.sh > $@ || (rm -f $@ ; false)
 
 conf-scan.c: conf-scan.l conf-parse.h
 	$(LEX) $(LFLAGS) -t $< > $@
Signature · 1 line
2.10.2
#1 lore raw
Quoted 15 lines · Nicolas Iooss

When compiling libselinux with CC=clang, "make pywrap" reports the following message:

bash exception.sh > selinuxswig_python_exception.i clang-3.9: error: no such file or directory: 'temp.aux'
awk: fatal: cannot open file `temp.aux' for reading (No such file or directory)

This does not make the build fail as exception.sh returns an "OK" status. Use "bash -e" with this script to make it return an error value.

In order not to keep an empty selinuxswig_python_exception.i file after a build fails (which would make a second run of "make pywrap" incorrectly succeed), remove the file when exception.sh fails.

Quoted 5 lines

As libsemanage uses the same code to build semanageswig_python_exception.i, modify its Makefile too.

By the way, on Linux clang does not seem to currently support -aux-info so it cannot be used to craft selinuxswig_python_exception.i.

Thanks, applied all three. Maybe we need to just always set CC to gcc in exception.sh?

Quoted 34 lines
---
 libselinux/src/Makefile  | 2 +-
 libsemanage/src/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
libselinux/src/Makefile +1 -1
index b92fe1c8f5f9..24946cee8a01 100644
@@ -140,7 +140,7 @@ $(LIBPC): $(LIBPC).in ../VERSION
 	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
 
 selinuxswig_python_exception.i: ../include/selinux/selinux.h
-	bash exception.sh > $@ 
+	bash -e exception.sh > $@ || (rm -f $@ ; false)
 
 $(AUDIT2WHYLOBJ): audit2why.c
 	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
libsemanage/src/Makefile +1 -1
index 55e3f469b0ba..cd29a8abf5ab 100644
@@ -98,7 +98,7 @@ $(LIBPC): $(LIBPC).in ../VERSION
 	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
 
 semanageswig_python_exception.i: ../include/semanage/semanage.h
-	bash exception.sh > $@
+	bash -e exception.sh > $@ || (rm -f $@ ; false)
 
 conf-scan.c: conf-scan.l conf-parse.h
 	$(LEX) $(LFLAGS) -t $< > $@
#2 lore raw
Quoted 10 lines · Stephen Smalley
Quoted 8 lines · Nicolas Iooss

When compiling libselinux with CC=clang, "make pywrap" reports the following message:

bash exception.sh > selinuxswig_python_exception.i clang-3.9: error: no such file or directory: 'temp.aux'
awk: fatal: cannot open file `temp.aux' for reading (No such file or directory)

Quoted 5 lines
Quoted 5 lines

This does not make the build fail as exception.sh returns an "OK" status. Use "bash -e" with this script to make it return an error value.

In order not to keep an empty selinuxswig_python_exception.i file after a build fails (which would make a second run of "make pywrap"

incorrectly

Quoted 11 lines
Quoted 7 lines

succeed), remove the file when exception.sh fails.

As libsemanage uses the same code to build semanageswig_python_exception.i, modify its Makefile too.

By the way, on Linux clang does not seem to currently support -aux-info so it cannot be used to craft selinuxswig_python_exception.i.

Thanks, applied all three. Maybe we need to just always set CC to gcc in exception.sh?

What if you don't have GCC? We should support CC consistently and not set it under the hood IMHO.

Quoted 7 lines
Quoted 7 lines
---
 libselinux/src/Makefile  | 2 +-
 libsemanage/src/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines

libselinux/src/Makefile $(LIBPC): $(LIBPC).in ../VERSION · line 140

Quoted 6 lines
libselinux/src/Makefile +0 -0
index b92fe1c8f5f9..24946cee8a01 100644
@@ -140,7 +140,7 @@ $(LIBPC): $(LIBPC).in ../VERSION
      sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):;

s:@includedir@:$(INCLUDEDIR):' < $< > $@

Quoted 7 lines

libselinux/src/Makefile $(LIBPC): $(LIBPC).in ../VERSION

Quoted 7 lines
libselinux/src/Makefile +1 -1
 selinuxswig_python_exception.i: ../include/selinux/selinux.h
-     bash exception.sh > $@
+     bash -e exception.sh > $@ || (rm -f $@ ; false)
 
 $(AUDIT2WHYLOBJ): audit2why.c
      $(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c

-o $@ $<

Quoted 6 lines

libsemanage/src/Makefile $(LIBPC): $(LIBPC).in ../VERSION · line 98

Quoted 6 lines
libsemanage/src/Makefile +0 -0
index 55e3f469b0ba..cd29a8abf5ab 100644
@@ -98,7 +98,7 @@ $(LIBPC): $(LIBPC).in ../VERSION
      sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):;

s:@includedir@:$(INCLUDEDIR):' < $< > $@

Quoted 9 lines

libsemanage/src/Makefile $(LIBPC): $(LIBPC).in ../VERSION

Quoted 8 lines
libsemanage/src/Makefile +1 -1
 semanageswig_python_exception.i: ../include/semanage/semanage.h
-     bash exception.sh > $@
+     bash -e exception.sh > $@ || (rm -f $@ ; false)
 
 conf-scan.c: conf-scan.l conf-parse.h
      $(LEX) $(LFLAGS) -t $< > $@
 
Quoted 5 lines

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to

[email protected].

#3 lore raw
Quoted 26 lines · William Roberts
Quoted 10 lines · On Nov 7, 2016 13:03, "Stephen Smalley" <[email protected]…
Quoted 8 lines · Nicolas Iooss

When compiling libselinux with CC=clang, "make pywrap" reports the following message:

bash exception.sh > selinuxswig_python_exception.i clang-3.9: error: no such file or directory: 'temp.aux'
awk: fatal: cannot open file `temp.aux' for reading (No such file or directory)

Quoted 5 lines
Quoted 5 lines

This does not make the build fail as exception.sh returns an "OK" status. Use "bash -e" with this script to make it return an error value.

In order not to keep an empty selinuxswig_python_exception.i file after a build fails (which would make a second run of "make pywrap"

incorrectly

Quoted 8 lines
Quoted 7 lines

succeed), remove the file when exception.sh fails.

As libsemanage uses the same code to build semanageswig_python_exception.i, modify its Makefile too.

By the way, on Linux clang does not seem to currently support -aux-info so it cannot be used to craft selinuxswig_python_exception.i.

Quoted 6 lines
Quoted 3 lines

Thanks, applied all three. Maybe we need to just always set CC to gcc in exception.sh?

What if you don't have GCC? We should support CC consistently and not set it under the hood IMHO.

There are also valid scenarios where exception.sh works without CC being gcc, for example when cross-compiling with CC=arm-....-gcc, or building with wrappers like CC=musl-gcc, etc.
What about using gcc as a fallback if $CC did not work? i.e. something like this in exception.sh:

if ! ${CC:-gcc} -x c -c -I../include - -aux-info .... ; then

    # clang does not support -aux-info so fall back to gcc
    gcc -x c -c -I../include - -aux-info ....
fi

Nicolas

#4 lore raw
Quoted 40 lines · Nicolas Iooss
Quoted 26 lines · William Roberts
Quoted 10 lines · On Nov 7, 2016 13:03, "Stephen Smalley" <[email protected]…
Quoted 8 lines · Nicolas Iooss

When compiling libselinux with CC=clang, "make pywrap" reports the following message:

bash exception.sh > selinuxswig_python_exception.i clang-3.9: error: no such file or directory: 'temp.aux'
awk: fatal: cannot open file `temp.aux' for reading (No such file or directory)

Quoted 5 lines
Quoted 5 lines

This does not make the build fail as exception.sh returns an "OK" status. Use "bash -e" with this script to make it return an error value.

In order not to keep an empty selinuxswig_python_exception.i file after a build fails (which would make a second run of "make pywrap"

incorrectly

Quoted 8 lines
Quoted 7 lines

succeed), remove the file when exception.sh fails.

As libsemanage uses the same code to build semanageswig_python_exception.i, modify its Makefile too.

By the way, on Linux clang does not seem to currently support -aux-info so it cannot be used to craft selinuxswig_python_exception.i.

Quoted 6 lines
Quoted 3 lines

Thanks, applied all three. Maybe we need to just always set CC to gcc in exception.sh?

What if you don't have GCC? We should support CC consistently and not set it under the hood IMHO.

There are also valid scenarios where exception.sh works without CC being gcc, for example when cross-compiling with CC=arm-....-gcc, or building with wrappers like CC=musl-gcc, etc.
What about using gcc as a fallback if $CC did not work? i.e. something like this in exception.sh:

Quoted 6 lines

if ! ${CC:-gcc} -x c -c -I../include - -aux-info .... ; then

    # clang does not support -aux-info so fall back to gcc
    gcc -x c -c -I../include - -aux-info ....
fi

Nicolas

Looking at exception.sh it appears that it takes in selinux.h and produces custom
exception handlers for the swig interface.

We could potentially do this without -aux-info and just write the swig interface by hand.