All of lore.kernel.org
 help / color / mirror / Atom feed
* This patch fixes the exception handling in libselinux-python bindings
       [not found] <C6A74D22.A99BD%csellers@tresys.com>
@ 2009-08-12 18:34 ` Daniel J Walsh
  2009-09-16 19:18   ` Joshua Brindle
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel J Walsh @ 2009-08-12 18:34 UTC (permalink / raw)
  To: Chad Sellers, SE Linux

[-- Attachment #1: Type: text/plain, Size: 120 bytes --]

What do you think of this one.  Removed excess swig cruft, 

You need to run 

make swigify to generate those changes.


[-- Attachment #2: libselinux-rhat.patch --]
[-- Type: text/plain, Size: 4848 bytes --]

--- nsalibselinux/include/selinux/selinux.h	2009-07-07 15:32:32.000000000 -0400
+++ libselinux-2.0.85/include/selinux/selinux.h	2009-08-12 13:36:34.000000000 -0400
@@ -346,7 +347,7 @@
 	const char *perms[sizeof(access_vector_t) * 8 + 1];
 };
 
-int selinux_set_mapping(struct security_class_mapping *map);
+extern int selinux_set_mapping(struct security_class_mapping *map);
 
 /* Common helpers */
 
@@ -556,17 +557,17 @@
 		     char **r_seuser, char **r_level);
 
 /* Compare two file contexts, return 0 if equivalent. */
-int selinux_file_context_cmp(const security_context_t a,
+extern int selinux_file_context_cmp(const security_context_t a,
 			     const security_context_t b);
 
 /* 
  * Verify the context of the file 'path' against policy.
  * Return 0 if correct. 
  */
-int selinux_file_context_verify(const char *path, mode_t mode);
+extern int selinux_file_context_verify(const char *path, mode_t mode);
 
 /* This function sets the file context on to the system defaults returns 0 on success */
-int selinux_lsetfilecon_default(const char *path);
+extern int selinux_lsetfilecon_default(const char *path);
 
 #ifdef __cplusplus
 }
--- nsalibselinux/src/exception.sh	1969-12-31 19:00:00.000000000 -0500
+++ libselinux-2.0.85/src/exception.sh	2009-08-12 13:44:21.000000000 -0400
@@ -0,0 +1,21 @@
+function except() {
+case $1 in
+    selinux_file_context_cmp) # ignore
+    ;;
+    *)
+echo "
+%exception $1 {
+  \$action 
+  if (result < 0) {
+     PyErr_SetFromErrno(PyExc_OSError);
+     return NULL;
+  }
+}
+"
+;;
+esac
+}
+echo '#include "../include/selinux/selinux.h"' > temp.c
+gcc -c temp.c -aux-info temp.aux 
+for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6 }' temp.aux`; do except $i ; done 
+rm -f temp.c temp.aux temp.o
--- nsalibselinux/src/Makefile	2009-07-14 11:16:03.000000000 -0400
+++ libselinux-2.0.85/src/Makefile	2009-08-12 12:08:08.000000000 -0400
@@ -82,6 +82,9 @@
 	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -ldl -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro
 	ln -sf $@ $(TARGET) 
 
+selinuxswig_exception.i: ../include/selinux/selinux.h
+	sh exception.sh > $@ 
+
 audit2why.lo: audit2why.c
 	$(CC) $(CFLAGS) -I$(PYINC) -fPIC -DSHARED -c -o $@ $<
 
@@ -100,8 +103,8 @@
 $(SWIGRUBYCOUT): $(SWIGRUBYIF)
 	$(SWIGRUBY) $^
 
-swigify: $(SWIGIF)
-	$(SWIG) $^
+swigify: $(SWIGIF) selinuxswig_exception.i
+	$(SWIG) $<
 
 install: all 
 	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
@@ -124,7 +127,7 @@
 	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
 
 clean: 
-	-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
+	-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_exception.i
 
 distclean: clean
 	rm -f $(GENERATED) $(SWIGFILES)
--- nsalibselinux/src/selinuxswig.i	2009-03-12 08:48:48.000000000 -0400
+++ libselinux-2.0.85/src/selinuxswig.i	2009-07-31 08:29:59.000000000 -0400
@@ -4,11 +4,14 @@
 
 %module selinux
 %{
-	#include "selinux/selinux.h"
 	#include "../include/selinux/avc.h"
-	#include "../include/selinux/selinux.h"
-	#include "../include/selinux/get_default_type.h"
+	#include "../include/selinux/av_permissions.h"
+	#include "../include/selinux/context.h"
+	#include "../include/selinux/flask.h"
 	#include "../include/selinux/get_context_list.h"
+	#include "../include/selinux/get_default_type.h"
+	#include "../include/selinux/label.h"
+	#include "../include/selinux/selinux.h"
 %}
 %apply int *OUTPUT { int *enforce };
 %apply int *OUTPUT { size_t * };
@@ -55,8 +58,11 @@
 %ignore avc_netlink_release_fd;
 %ignore avc_netlink_check_nb;
 
-%include "../include/selinux/selinux.h"
 %include "../include/selinux/avc.h"
-%include "../include/selinux/get_default_type.h"
+%include "../include/selinux/av_permissions.h"
+%include "../include/selinux/context.h"
+%include "../include/selinux/flask.h"
 %include "../include/selinux/get_context_list.h"
-
+%include "../include/selinux/get_default_type.h"
+%include "../include/selinux/label.h"
+%include "../include/selinux/selinux.h"
--- nsalibselinux/src/selinuxswig_python.i	2009-03-06 14:41:45.000000000 -0500
+++ libselinux-2.0.85/src/selinuxswig_python.i	2009-07-31 08:29:59.000000000 -0400
@@ -21,6 +21,15 @@
                              map(restorecon, [os.path.join(dirname, fname)
                                               for fname in fnames]), None)
 
+def copytree(src, dest):
+    """ An SELinux-friendly shutil.copytree method """
+    shutil.copytree(src, dest)
+    restorecon(dest, recursive=True)
+
+def install(src, dest):
+    """ An SELinux-friendly shutil.move method """
+    shutil.move(src, dest)
+    restorecon(dest, recursive=True)
 %}
 
 /* security_get_boolean_names() typemap */
@@ -150,4 +159,5 @@
 	free($1);
 }
 
+%include "selinuxswig_exception.i"
 %include "selinuxswig.i"

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-08-12 18:34 ` This patch fixes the exception handling in libselinux-python bindings Daniel J Walsh
@ 2009-09-16 19:18   ` Joshua Brindle
  2009-09-16 19:35     ` Joshua Brindle
  0 siblings, 1 reply; 20+ messages in thread
From: Joshua Brindle @ 2009-09-16 19:18 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: Chad Sellers, SE Linux



Daniel J Walsh wrote:
> What do you think of this one.  Removed excess swig cruft,
>
> You need to run
>
> make swigify to generate those changes.
>

Ok, looking at this now. I don't completely get how it works. I'm trying 
to reproduce what you are doing by hand but nothing comes out of gcc:

[root@localhost src]# echo '#include "../include/selinux/selinux.h"' > 
temp.c
[root@localhost src]# gcc -c temp.c -aux-info temp.aux
[root@localhost src]# ls temp.*
temp.c  temp.o


What is the purpose of the aux-info thing, and why doesn't it work on my 
F11 machine?

also, I'm not sure if the best place for selinuxswig_exception.i is 
swigify or pywrap. In the swigify case it shouldn't be in the clean 
target because if you check out the repo and do make clean; make pywrap 
you'll get an error. (I can make these fixes, I'm just trying to figure 
out how it all works first).


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-09-16 19:18   ` Joshua Brindle
@ 2009-09-16 19:35     ` Joshua Brindle
       [not found]       ` <4AB15164.1020507@redhat.com>
  0 siblings, 1 reply; 20+ messages in thread
From: Joshua Brindle @ 2009-09-16 19:35 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: Chad Sellers, SE Linux



Joshua Brindle wrote:
>
>
> Daniel J Walsh wrote:
>> What do you think of this one. Removed excess swig cruft,
>>
>> You need to run
>>
>> make swigify to generate those changes.
>>
>
> Ok, looking at this now. I don't completely get how it works. I'm trying
> to reproduce what you are doing by hand but nothing comes out of gcc:
>
> [root@localhost src]# echo '#include "../include/selinux/selinux.h"' >
> temp.c
> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
> [root@localhost src]# ls temp.*
> temp.c temp.o
>
>
> What is the purpose of the aux-info thing, and why doesn't it work on my
> F11 machine?
>
> also, I'm not sure if the best place for selinuxswig_exception.i is
> swigify or pywrap. In the swigify case it shouldn't be in the clean
> target because if you check out the repo and do make clean; make pywrap
> you'll get an error. (I can make these fixes, I'm just trying to figure
> out how it all works first).
>

Oh, one more thing, should this be python specific? (E.g, should it be 
named selinuxswig_python_exception.i ?)

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
       [not found]       ` <4AB15164.1020507@redhat.com>
@ 2009-09-24  0:56         ` Joshua Brindle
  2009-09-24 18:16           ` Joshua Brindle
  0 siblings, 1 reply; 20+ messages in thread
From: Joshua Brindle @ 2009-09-24  0:56 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: SE Linux



Daniel J Walsh wrote:
> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
>>
>> Joshua Brindle wrote:
>>>
>>> Daniel J Walsh wrote:
>>>> What do you think of this one. Removed excess swig cruft,
>>>>
>>>> You need to run
>>>>
>>>> make swigify to generate those changes.
>>>>
>>> Ok, looking at this now. I don't completely get how it works. I'm trying
>>> to reproduce what you are doing by hand but nothing comes out of gcc:
>>>
>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
>>> temp.c
>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
>>> [root@localhost src]# ls temp.*
>>> temp.c temp.o
>>>
>>>

I got this "sort of" working locally. It works when I call it directly 
on the header but it leaves a .gch file sitting in the include directory.

Trying to use stdin I get:

[root@localhost src]# gcc -x c-header -c - -aux-info temp.aux < 
../include/selinux/selinux.h
<stdin>:569: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.


Other comments:

The disconnect between swigify and clean targets remains: If make 
swigify builds this, and it is checked in to the tree then make clean 
shouldn't remove it, else it should be in the pywrap target and not 
installed.

I'm not sure what the header re-ordering in selinuxswig.i and the 
copytree/install functions have to do with this patch.

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-09-24  0:56         ` Joshua Brindle
@ 2009-09-24 18:16           ` Joshua Brindle
  2009-09-24 19:19             ` Joshua Brindle
  0 siblings, 1 reply; 20+ messages in thread
From: Joshua Brindle @ 2009-09-24 18:16 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: SE Linux

Joshua Brindle wrote:
>
>
> Daniel J Walsh wrote:
>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
>>>
>>> Joshua Brindle wrote:
>>>>
>>>> Daniel J Walsh wrote:
>>>>> What do you think of this one. Removed excess swig cruft,
>>>>>
>>>>> You need to run
>>>>>
>>>>> make swigify to generate those changes.
>>>>>
>>>> Ok, looking at this now. I don't completely get how it works. I'm
>>>> trying
>>>> to reproduce what you are doing by hand but nothing comes out of gcc:
>>>>
>>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
>>>> temp.c
>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
>>>> [root@localhost src]# ls temp.*
>>>> temp.c temp.o
>>>>
>>>>
>
> I got this "sort of" working locally. It works when I call it directly
> on the header but it leaves a .gch file sitting in the include directory.
>
> Trying to use stdin I get:
>
> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux <
> ../include/selinux/selinux.h
> <stdin>:569: internal compiler error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://bugzilla.redhat.com/bugzilla> for instructions.
>
>
> Other comments:
>
> The disconnect between swigify and clean targets remains: If make
> swigify builds this, and it is checked in to the tree then make clean
> shouldn't remove it, else it should be in the pywrap target and not
> installed.
>
> I'm not sure what the header re-ordering in selinuxswig.i and the
> copytree/install functions have to do with this patch.
>


Applied with this diff on top:

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 928a1df..74b1e6a 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -16,14 +16,14 @@ LIBVERSION = 1

  LIBA=libselinux.a
  TARGET=libselinux.so
-SWIGIF= selinuxswig_python.i
+SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
  SWIGRUBYIF= selinuxswig_ruby.i
  SWIGCOUT= selinuxswig_wrap.c
  SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
  SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
  SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
  SWIGSO=_selinux.so
-SWIGFILES=$(SWIGSO) selinux.py
+SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
  SWIGRUBYSO=_rubyselinux.so
  LIBSO=$(TARGET).$(LIBVERSION)
  AUDIT2WHYSO=audit2why.so
@@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
  $(SWIGRUBYCOUT): $(SWIGRUBYIF)
         $(SWIGRUBY) $^

-swigify: $(SWIGIF) selinuxswig_python_exception.i
+swigify: $(SWIGIF)
         $(SWIG) $<

  install: all
@@ -127,7 +127,7 @@ relabel:
         /sbin/restorecon $(SHLIBDIR)/$(LIBSO)

  clean:
-       -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) 
$(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
+       -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) 
$(TARGET) $(AUDIT2WHYSO) *.o *.lo *~

  distclean: clean
         rm -f $(GENERATED) $(SWIGFILES)
diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh
old mode 100644
new mode 100755
index b2a3799..c3e61a5
--- a/libselinux/src/exception.sh
+++ b/libselinux/src/exception.sh
@@ -15,7 +15,6 @@ echo "
  ;;
  esac
  }
-echo '#include "../include/selinux/selinux.h"' > temp.c
-gcc -c temp.c -aux-info temp.aux
-for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6 
}' temp.aux`; do except $i ; done
-rm -f temp.c temp.aux temp.o
+gcc -x c -c - -aux-info temp.aux < ../include/selinux/selinux.h
+for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except 
$i ; done
+rm -f -- temp.aux -.o

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-09-24 18:16           ` Joshua Brindle
@ 2009-09-24 19:19             ` Joshua Brindle
  2009-09-28 19:07               ` Daniel J Walsh
  0 siblings, 1 reply; 20+ messages in thread
From: Joshua Brindle @ 2009-09-24 19:19 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: SE Linux

Joshua Brindle wrote:
> Joshua Brindle wrote:
>>
>>
>> Daniel J Walsh wrote:
>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
>>>>
>>>> Joshua Brindle wrote:
>>>>>
>>>>> Daniel J Walsh wrote:
>>>>>> What do you think of this one. Removed excess swig cruft,
>>>>>>
>>>>>> You need to run
>>>>>>
>>>>>> make swigify to generate those changes.
>>>>>>
>>>>> Ok, looking at this now. I don't completely get how it works. I'm
>>>>> trying
>>>>> to reproduce what you are doing by hand but nothing comes out of gcc:
>>>>>
>>>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
>>>>> temp.c
>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
>>>>> [root@localhost src]# ls temp.*
>>>>> temp.c temp.o
>>>>>
>>>>>
>>
>> I got this "sort of" working locally. It works when I call it directly
>> on the header but it leaves a .gch file sitting in the include directory.
>>
>> Trying to use stdin I get:
>>
>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux <
>> ../include/selinux/selinux.h
>> <stdin>:569: internal compiler error: Segmentation fault
>> Please submit a full bug report,
>> with preprocessed source if appropriate.
>> See <http://bugzilla.redhat.com/bugzilla> for instructions.
>>
>>
>> Other comments:
>>
>> The disconnect between swigify and clean targets remains: If make
>> swigify builds this, and it is checked in to the tree then make clean
>> shouldn't remove it, else it should be in the pywrap target and not
>> installed.
>>
>> I'm not sure what the header re-ordering in selinuxswig.i and the
>> copytree/install functions have to do with this patch.
>>
>
>
> Applied with this diff on top:
>
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index 928a1df..74b1e6a 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -16,14 +16,14 @@ LIBVERSION = 1
>
> LIBA=libselinux.a
> TARGET=libselinux.so
> -SWIGIF= selinuxswig_python.i
> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
> SWIGRUBYIF= selinuxswig_ruby.i
> SWIGCOUT= selinuxswig_wrap.c
> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
> SWIGSO=_selinux.so
> -SWIGFILES=$(SWIGSO) selinux.py
> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
> SWIGRUBYSO=_rubyselinux.so
> LIBSO=$(TARGET).$(LIBVERSION)
> AUDIT2WHYSO=audit2why.so
> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
> $(SWIGRUBY) $^
>
> -swigify: $(SWIGIF) selinuxswig_python_exception.i
> +swigify: $(SWIGIF)
> $(SWIG) $<
>
> install: all
> @@ -127,7 +127,7 @@ relabel:
> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
>
> clean:
> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
>
> distclean: clean
> rm -f $(GENERATED) $(SWIGFILES)
> diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh
> old mode 100644
> new mode 100755
> index b2a3799..c3e61a5
> --- a/libselinux/src/exception.sh
> +++ b/libselinux/src/exception.sh
> @@ -15,7 +15,6 @@ echo "
> ;;
> esac
> }
> -echo '#include "../include/selinux/selinux.h"' > temp.c
> -gcc -c temp.c -aux-info temp.aux
> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6
> }' temp.aux`; do except $i ; done
> -rm -f temp.c temp.aux temp.o
> +gcc -x c -c - -aux-info temp.aux < ../include/selinux/selinux.h
> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except
> $i ; done
> +rm -f -- temp.aux -.o
>


Merged in libselinux-2.0.87

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-09-24 19:19             ` Joshua Brindle
@ 2009-09-28 19:07               ` Daniel J Walsh
  2009-09-28 20:10                 ` Joshua Brindle
  2010-01-08 15:32                 ` Stephen Smalley
  0 siblings, 2 replies; 20+ messages in thread
From: Daniel J Walsh @ 2009-09-28 19:07 UTC (permalink / raw)
  To: Joshua Brindle; +Cc: SE Linux

On 09/24/2009 03:19 PM, Joshua Brindle wrote:
> Joshua Brindle wrote:
>> Joshua Brindle wrote:
>>>
>>>
>>> Daniel J Walsh wrote:
>>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
>>>>>
>>>>> Joshua Brindle wrote:
>>>>>>
>>>>>> Daniel J Walsh wrote:
>>>>>>> What do you think of this one. Removed excess swig cruft,
>>>>>>>
>>>>>>> You need to run
>>>>>>>
>>>>>>> make swigify to generate those changes.
>>>>>>>
>>>>>> Ok, looking at this now. I don't completely get how it works. I'm
>>>>>> trying
>>>>>> to reproduce what you are doing by hand but nothing comes out of gcc:
>>>>>>
>>>>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
>>>>>> temp.c
>>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
>>>>>> [root@localhost src]# ls temp.*
>>>>>> temp.c temp.o
>>>>>>
>>>>>>
>>>
>>> I got this "sort of" working locally. It works when I call it directly
>>> on the header but it leaves a .gch file sitting in the include
>>> directory.
>>>
>>> Trying to use stdin I get:
>>>
>>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux <
>>> ../include/selinux/selinux.h
>>> <stdin>:569: internal compiler error: Segmentation fault
>>> Please submit a full bug report,
>>> with preprocessed source if appropriate.
>>> See <http://bugzilla.redhat.com/bugzilla> for instructions.
>>>
>>>
>>> Other comments:
>>>
>>> The disconnect between swigify and clean targets remains: If make
>>> swigify builds this, and it is checked in to the tree then make clean
>>> shouldn't remove it, else it should be in the pywrap target and not
>>> installed.
>>>
>>> I'm not sure what the header re-ordering in selinuxswig.i and the
>>> copytree/install functions have to do with this patch.
>>>
>>
>>
>> Applied with this diff on top:
>>
>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>> index 928a1df..74b1e6a 100644
>> --- a/libselinux/src/Makefile
>> +++ b/libselinux/src/Makefile
>> @@ -16,14 +16,14 @@ LIBVERSION = 1
>>
>> LIBA=libselinux.a
>> TARGET=libselinux.so
>> -SWIGIF= selinuxswig_python.i
>> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
>> SWIGRUBYIF= selinuxswig_ruby.i
>> SWIGCOUT= selinuxswig_wrap.c
>> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
>> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
>> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
>> SWIGSO=_selinux.so
>> -SWIGFILES=$(SWIGSO) selinux.py
>> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
>> SWIGRUBYSO=_rubyselinux.so
>> LIBSO=$(TARGET).$(LIBVERSION)
>> AUDIT2WHYSO=audit2why.so
>> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
>> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
>> $(SWIGRUBY) $^
>>
>> -swigify: $(SWIGIF) selinuxswig_python_exception.i
>> +swigify: $(SWIGIF)
>> $(SWIG) $<
>>
>> install: all
>> @@ -127,7 +127,7 @@ relabel:
>> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
>>
>> clean:
>> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
>> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
>>
>> distclean: clean
>> rm -f $(GENERATED) $(SWIGFILES)
>> diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh
>> old mode 100644
>> new mode 100755
>> index b2a3799..c3e61a5
>> --- a/libselinux/src/exception.sh
>> +++ b/libselinux/src/exception.sh
>> @@ -15,7 +15,6 @@ echo "
>> ;;
>> esac
>> }
>> -echo '#include "../include/selinux/selinux.h"' > temp.c
>> -gcc -c temp.c -aux-info temp.aux
>> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6
>> }' temp.aux`; do except $i ; done
>> -rm -f temp.c temp.aux temp.o
>> +gcc -x c -c - -aux-info temp.aux < ../include/selinux/selinux.h
>> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except
>> $i ; done
>> +rm -f -- temp.aux -.o
>>
> 
> 
> Merged in libselinux-2.0.87


I have VERSION 2.0.86 in git?

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-09-28 19:07               ` Daniel J Walsh
@ 2009-09-28 20:10                 ` Joshua Brindle
  2010-01-08 15:32                 ` Stephen Smalley
  1 sibling, 0 replies; 20+ messages in thread
From: Joshua Brindle @ 2009-09-28 20:10 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: SE Linux



Daniel J Walsh wrote:
> On 09/24/2009 03:19 PM, Joshua Brindle wrote:
>> Joshua Brindle wrote:
>>
>> Merged in libselinux-2.0.87
>
>
> I have VERSION 2.0.86 in git?
>

So it is. Somehow my git got into an anonymous branch and several 
commits weren't pushed. Fixing now.

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-09-28 19:07               ` Daniel J Walsh
  2009-09-28 20:10                 ` Joshua Brindle
@ 2010-01-08 15:32                 ` Stephen Smalley
  2010-01-08 20:06                   ` Stephen Smalley
  1 sibling, 1 reply; 20+ messages in thread
From: Stephen Smalley @ 2010-01-08 15:32 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: Joshua Brindle, SE Linux

On Mon, 2009-09-28 at 15:07 -0400, Daniel J Walsh wrote:
> On 09/24/2009 03:19 PM, Joshua Brindle wrote:
> > Joshua Brindle wrote:
> >> Joshua Brindle wrote:
> >>>
> >>>
> >>> Daniel J Walsh wrote:
> >>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
> >>>>>
> >>>>> Joshua Brindle wrote:
> >>>>>>
> >>>>>> Daniel J Walsh wrote:
> >>>>>>> What do you think of this one. Removed excess swig cruft,
> >>>>>>>
> >>>>>>> You need to run
> >>>>>>>
> >>>>>>> make swigify to generate those changes.
> >>>>>>>
> >>>>>> Ok, looking at this now. I don't completely get how it works. I'm
> >>>>>> trying
> >>>>>> to reproduce what you are doing by hand but nothing comes out of gcc:
> >>>>>>
> >>>>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
> >>>>>> temp.c
> >>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
> >>>>>> [root@localhost src]# ls temp.*
> >>>>>> temp.c temp.o
> >>>>>>
> >>>>>>
> >>>
> >>> I got this "sort of" working locally. It works when I call it directly
> >>> on the header but it leaves a .gch file sitting in the include
> >>> directory.
> >>>
> >>> Trying to use stdin I get:
> >>>
> >>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux <
> >>> ../include/selinux/selinux.h
> >>> <stdin>:569: internal compiler error: Segmentation fault
> >>> Please submit a full bug report,
> >>> with preprocessed source if appropriate.
> >>> See <http://bugzilla.redhat.com/bugzilla> for instructions.
> >>>
> >>>
> >>> Other comments:
> >>>
> >>> The disconnect between swigify and clean targets remains: If make
> >>> swigify builds this, and it is checked in to the tree then make clean
> >>> shouldn't remove it, else it should be in the pywrap target and not
> >>> installed.
> >>>
> >>> I'm not sure what the header re-ordering in selinuxswig.i and the
> >>> copytree/install functions have to do with this patch.
> >>>
> >>
> >>
> >> Applied with this diff on top:
> >>
> >> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> >> index 928a1df..74b1e6a 100644
> >> --- a/libselinux/src/Makefile
> >> +++ b/libselinux/src/Makefile
> >> @@ -16,14 +16,14 @@ LIBVERSION = 1
> >>
> >> LIBA=libselinux.a
> >> TARGET=libselinux.so
> >> -SWIGIF= selinuxswig_python.i
> >> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
> >> SWIGRUBYIF= selinuxswig_ruby.i
> >> SWIGCOUT= selinuxswig_wrap.c
> >> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
> >> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
> >> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
> >> SWIGSO=_selinux.so
> >> -SWIGFILES=$(SWIGSO) selinux.py
> >> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
> >> SWIGRUBYSO=_rubyselinux.so
> >> LIBSO=$(TARGET).$(LIBVERSION)
> >> AUDIT2WHYSO=audit2why.so
> >> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
> >> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
> >> $(SWIGRUBY) $^
> >>
> >> -swigify: $(SWIGIF) selinuxswig_python_exception.i
> >> +swigify: $(SWIGIF)
> >> $(SWIG) $<
> >>
> >> install: all
> >> @@ -127,7 +127,7 @@ relabel:
> >> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
> >>
> >> clean:
> >> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
> >> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
> >> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
> >> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
> >>
> >> distclean: clean
> >> rm -f $(GENERATED) $(SWIGFILES)
> >> diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh
> >> old mode 100644
> >> new mode 100755
> >> index b2a3799..c3e61a5
> >> --- a/libselinux/src/exception.sh
> >> +++ b/libselinux/src/exception.sh
> >> @@ -15,7 +15,6 @@ echo "
> >> ;;
> >> esac
> >> }
> >> -echo '#include "../include/selinux/selinux.h"' > temp.c
> >> -gcc -c temp.c -aux-info temp.aux
> >> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6
> >> }' temp.aux`; do except $i ; done
> >> -rm -f temp.c temp.aux temp.o
> >> +gcc -x c -c - -aux-info temp.aux < ../include/selinux/selinux.h
> >> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except
> >> $i ; done
> >> +rm -f -- temp.aux -.o
> >>
> > 
> > 
> > Merged in libselinux-2.0.87
> 
> 
> I have VERSION 2.0.86 in git?

This seems to break make install-pywrap on the current selinux trunk:
bash exception.sh > selinuxswig_python_exception.i 
swig -Wall -python -o selinuxswig_wrap.c -outdir ./ selinuxswig_python.i selinuxswig_python_exception.i
swig error : Unrecognized option selinuxswig_python.i
Use 'swig -help' for available options.

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2010-01-08 15:32                 ` Stephen Smalley
@ 2010-01-08 20:06                   ` Stephen Smalley
  2010-01-08 20:19                     ` Stephen Smalley
  0 siblings, 1 reply; 20+ messages in thread
From: Stephen Smalley @ 2010-01-08 20:06 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: Joshua Brindle, SE Linux, Caleb Case, Chad Sellers

On Fri, 2010-01-08 at 10:32 -0500, Stephen Smalley wrote:
> On Mon, 2009-09-28 at 15:07 -0400, Daniel J Walsh wrote:
> > On 09/24/2009 03:19 PM, Joshua Brindle wrote:
> > > Joshua Brindle wrote:
> > >> Joshua Brindle wrote:
> > >>>
> > >>>
> > >>> Daniel J Walsh wrote:
> > >>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
> > >>>>>
> > >>>>> Joshua Brindle wrote:
> > >>>>>>
> > >>>>>> Daniel J Walsh wrote:
> > >>>>>>> What do you think of this one. Removed excess swig cruft,
> > >>>>>>>
> > >>>>>>> You need to run
> > >>>>>>>
> > >>>>>>> make swigify to generate those changes.
> > >>>>>>>
> > >>>>>> Ok, looking at this now. I don't completely get how it works. I'm
> > >>>>>> trying
> > >>>>>> to reproduce what you are doing by hand but nothing comes out of gcc:
> > >>>>>>
> > >>>>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
> > >>>>>> temp.c
> > >>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
> > >>>>>> [root@localhost src]# ls temp.*
> > >>>>>> temp.c temp.o
> > >>>>>>
> > >>>>>>
> > >>>
> > >>> I got this "sort of" working locally. It works when I call it directly
> > >>> on the header but it leaves a .gch file sitting in the include
> > >>> directory.
> > >>>
> > >>> Trying to use stdin I get:
> > >>>
> > >>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux <
> > >>> ../include/selinux/selinux.h
> > >>> <stdin>:569: internal compiler error: Segmentation fault
> > >>> Please submit a full bug report,
> > >>> with preprocessed source if appropriate.
> > >>> See <http://bugzilla.redhat.com/bugzilla> for instructions.
> > >>>
> > >>>
> > >>> Other comments:
> > >>>
> > >>> The disconnect between swigify and clean targets remains: If make
> > >>> swigify builds this, and it is checked in to the tree then make clean
> > >>> shouldn't remove it, else it should be in the pywrap target and not
> > >>> installed.
> > >>>
> > >>> I'm not sure what the header re-ordering in selinuxswig.i and the
> > >>> copytree/install functions have to do with this patch.
> > >>>
> > >>
> > >>
> > >> Applied with this diff on top:
> > >>
> > >> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> > >> index 928a1df..74b1e6a 100644
> > >> --- a/libselinux/src/Makefile
> > >> +++ b/libselinux/src/Makefile
> > >> @@ -16,14 +16,14 @@ LIBVERSION = 1
> > >>
> > >> LIBA=libselinux.a
> > >> TARGET=libselinux.so
> > >> -SWIGIF= selinuxswig_python.i
> > >> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
> > >> SWIGRUBYIF= selinuxswig_ruby.i
> > >> SWIGCOUT= selinuxswig_wrap.c
> > >> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
> > >> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
> > >> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
> > >> SWIGSO=_selinux.so
> > >> -SWIGFILES=$(SWIGSO) selinux.py
> > >> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
> > >> SWIGRUBYSO=_rubyselinux.so
> > >> LIBSO=$(TARGET).$(LIBVERSION)
> > >> AUDIT2WHYSO=audit2why.so
> > >> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
> > >> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
> > >> $(SWIGRUBY) $^
> > >>
> > >> -swigify: $(SWIGIF) selinuxswig_python_exception.i
> > >> +swigify: $(SWIGIF)
> > >> $(SWIG) $<
> > >>
> > >> install: all
> > >> @@ -127,7 +127,7 @@ relabel:
> > >> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
> > >>
> > >> clean:
> > >> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
> > >> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
> > >> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
> > >> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
> > >>
> > >> distclean: clean
> > >> rm -f $(GENERATED) $(SWIGFILES)
> > >> diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh
> > >> old mode 100644
> > >> new mode 100755
> > >> index b2a3799..c3e61a5
> > >> --- a/libselinux/src/exception.sh
> > >> +++ b/libselinux/src/exception.sh
> > >> @@ -15,7 +15,6 @@ echo "
> > >> ;;
> > >> esac
> > >> }
> > >> -echo '#include "../include/selinux/selinux.h"' > temp.c
> > >> -gcc -c temp.c -aux-info temp.aux
> > >> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6
> > >> }' temp.aux`; do except $i ; done
> > >> -rm -f temp.c temp.aux temp.o
> > >> +gcc -x c -c - -aux-info temp.aux < ../include/selinux/selinux.h
> > >> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except
> > >> $i ; done
> > >> +rm -f -- temp.aux -.o
> > >>
> > > 
> > > 
> > > Merged in libselinux-2.0.87
> > 
> > 
> > I have VERSION 2.0.86 in git?
> 
> This seems to break make install-pywrap on the current selinux trunk:
> bash exception.sh > selinuxswig_python_exception.i 
> swig -Wall -python -o selinuxswig_wrap.c -outdir ./ selinuxswig_python.i selinuxswig_python_exception.i
> swig error : Unrecognized option selinuxswig_python.i
> Use 'swig -help' for available options.

This btw prevents use of Caleb's patches on Fedora 12.  If I can't build
and install the python modules from the selinux repo, then there is an
undefined dependency from the Fedora libsemanage-python module on the
upstream libsemanage (some symbol introduced in the Fedora patches to
libsemanage) and thus migrate.py is unable to import semanage and
aborts.

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2010-01-08 20:06                   ` Stephen Smalley
@ 2010-01-08 20:19                     ` Stephen Smalley
  2010-01-08 20:40                       ` Daniel J Walsh
  0 siblings, 1 reply; 20+ messages in thread
From: Stephen Smalley @ 2010-01-08 20:19 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: Joshua Brindle, SE Linux, Caleb Case, Chad Sellers

On Fri, 2010-01-08 at 15:06 -0500, Stephen Smalley wrote:
> On Fri, 2010-01-08 at 10:32 -0500, Stephen Smalley wrote:
> > On Mon, 2009-09-28 at 15:07 -0400, Daniel J Walsh wrote:
> > > On 09/24/2009 03:19 PM, Joshua Brindle wrote:
> > > > Joshua Brindle wrote:
> > > >> Joshua Brindle wrote:
> > > >>>
> > > >>>
> > > >>> Daniel J Walsh wrote:
> > > >>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
> > > >>>>>
> > > >>>>> Joshua Brindle wrote:
> > > >>>>>>
> > > >>>>>> Daniel J Walsh wrote:
> > > >>>>>>> What do you think of this one. Removed excess swig cruft,
> > > >>>>>>>
> > > >>>>>>> You need to run
> > > >>>>>>>
> > > >>>>>>> make swigify to generate those changes.
> > > >>>>>>>
> > > >>>>>> Ok, looking at this now. I don't completely get how it works. I'm
> > > >>>>>> trying
> > > >>>>>> to reproduce what you are doing by hand but nothing comes out of gcc:
> > > >>>>>>
> > > >>>>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
> > > >>>>>> temp.c
> > > >>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
> > > >>>>>> [root@localhost src]# ls temp.*
> > > >>>>>> temp.c temp.o
> > > >>>>>>
> > > >>>>>>
> > > >>>
> > > >>> I got this "sort of" working locally. It works when I call it directly
> > > >>> on the header but it leaves a .gch file sitting in the include
> > > >>> directory.
> > > >>>
> > > >>> Trying to use stdin I get:
> > > >>>
> > > >>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux <
> > > >>> ../include/selinux/selinux.h
> > > >>> <stdin>:569: internal compiler error: Segmentation fault
> > > >>> Please submit a full bug report,
> > > >>> with preprocessed source if appropriate.
> > > >>> See <http://bugzilla.redhat.com/bugzilla> for instructions.
> > > >>>
> > > >>>
> > > >>> Other comments:
> > > >>>
> > > >>> The disconnect between swigify and clean targets remains: If make
> > > >>> swigify builds this, and it is checked in to the tree then make clean
> > > >>> shouldn't remove it, else it should be in the pywrap target and not
> > > >>> installed.
> > > >>>
> > > >>> I'm not sure what the header re-ordering in selinuxswig.i and the
> > > >>> copytree/install functions have to do with this patch.
> > > >>>
> > > >>
> > > >>
> > > >> Applied with this diff on top:
> > > >>
> > > >> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> > > >> index 928a1df..74b1e6a 100644
> > > >> --- a/libselinux/src/Makefile
> > > >> +++ b/libselinux/src/Makefile
> > > >> @@ -16,14 +16,14 @@ LIBVERSION = 1
> > > >>
> > > >> LIBA=libselinux.a
> > > >> TARGET=libselinux.so
> > > >> -SWIGIF= selinuxswig_python.i
> > > >> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
> > > >> SWIGRUBYIF= selinuxswig_ruby.i
> > > >> SWIGCOUT= selinuxswig_wrap.c
> > > >> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
> > > >> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
> > > >> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
> > > >> SWIGSO=_selinux.so
> > > >> -SWIGFILES=$(SWIGSO) selinux.py
> > > >> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
> > > >> SWIGRUBYSO=_rubyselinux.so
> > > >> LIBSO=$(TARGET).$(LIBVERSION)
> > > >> AUDIT2WHYSO=audit2why.so
> > > >> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
> > > >> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
> > > >> $(SWIGRUBY) $^
> > > >>
> > > >> -swigify: $(SWIGIF) selinuxswig_python_exception.i
> > > >> +swigify: $(SWIGIF)
> > > >> $(SWIG) $<
> > > >>
> > > >> install: all
> > > >> @@ -127,7 +127,7 @@ relabel:
> > > >> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
> > > >>
> > > >> clean:
> > > >> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
> > > >> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
> > > >> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
> > > >> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
> > > >>
> > > >> distclean: clean
> > > >> rm -f $(GENERATED) $(SWIGFILES)
> > > >> diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh
> > > >> old mode 100644
> > > >> new mode 100755
> > > >> index b2a3799..c3e61a5
> > > >> --- a/libselinux/src/exception.sh
> > > >> +++ b/libselinux/src/exception.sh
> > > >> @@ -15,7 +15,6 @@ echo "
> > > >> ;;
> > > >> esac
> > > >> }
> > > >> -echo '#include "../include/selinux/selinux.h"' > temp.c
> > > >> -gcc -c temp.c -aux-info temp.aux
> > > >> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6
> > > >> }' temp.aux`; do except $i ; done
> > > >> -rm -f temp.c temp.aux temp.o
> > > >> +gcc -x c -c - -aux-info temp.aux < ../include/selinux/selinux.h
> > > >> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except
> > > >> $i ; done
> > > >> +rm -f -- temp.aux -.o
> > > >>
> > > > 
> > > > 
> > > > Merged in libselinux-2.0.87
> > > 
> > > 
> > > I have VERSION 2.0.86 in git?
> > 
> > This seems to break make install-pywrap on the current selinux trunk:
> > bash exception.sh > selinuxswig_python_exception.i 
> > swig -Wall -python -o selinuxswig_wrap.c -outdir ./ selinuxswig_python.i selinuxswig_python_exception.i
> > swig error : Unrecognized option selinuxswig_python.i
> > Use 'swig -help' for available options.
> 
> This btw prevents use of Caleb's patches on Fedora 12.  If I can't build
> and install the python modules from the selinux repo, then there is an
> undefined dependency from the Fedora libsemanage-python module on the
> upstream libsemanage (some symbol introduced in the Fedora patches to
> libsemanage) and thus migrate.py is unable to import semanage and
> aborts.

Hmm...if I make swigify, all is well again.  But something seems wrong
with the Makefile...

-- 
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2010-01-08 20:19                     ` Stephen Smalley
@ 2010-01-08 20:40                       ` Daniel J Walsh
  2010-01-08 20:52                         ` Joshua Brindle
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel J Walsh @ 2010-01-08 20:40 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: Joshua Brindle, SE Linux, Caleb Case, Chad Sellers

On 01/08/2010 03:19 PM, Stephen Smalley wrote:
> On Fri, 2010-01-08 at 15:06 -0500, Stephen Smalley wrote:
>> On Fri, 2010-01-08 at 10:32 -0500, Stephen Smalley wrote:
>>> On Mon, 2009-09-28 at 15:07 -0400, Daniel J Walsh wrote:
>>>> On 09/24/2009 03:19 PM, Joshua Brindle wrote:
>>>>> Joshua Brindle wrote:
>>>>>> Joshua Brindle wrote:
>>>>>>>
>>>>>>>
>>>>>>> Daniel J Walsh wrote:
>>>>>>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
>>>>>>>>>
>>>>>>>>> Joshua Brindle wrote:
>>>>>>>>>>
>>>>>>>>>> Daniel J Walsh wrote:
>>>>>>>>>>> What do you think of this one. Removed excess swig cruft,
>>>>>>>>>>>
>>>>>>>>>>> You need to run
>>>>>>>>>>>
>>>>>>>>>>> make swigify to generate those changes.
>>>>>>>>>>>
>>>>>>>>>> Ok, looking at this now. I don't completely get how it works. I'm
>>>>>>>>>> trying
>>>>>>>>>> to reproduce what you are doing by hand but nothing comes out of gcc:
>>>>>>>>>>
>>>>>>>>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
>>>>>>>>>> temp.c
>>>>>>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
>>>>>>>>>> [root@localhost src]# ls temp.*
>>>>>>>>>> temp.c temp.o
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>
>>>>>>> I got this "sort of" working locally. It works when I call it directly
>>>>>>> on the header but it leaves a .gch file sitting in the include
>>>>>>> directory.
>>>>>>>
>>>>>>> Trying to use stdin I get:
>>>>>>>
>>>>>>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux <
>>>>>>> ../include/selinux/selinux.h
>>>>>>> <stdin>:569: internal compiler error: Segmentation fault
>>>>>>> Please submit a full bug report,
>>>>>>> with preprocessed source if appropriate.
>>>>>>> See <http://bugzilla.redhat.com/bugzilla> for instructions.
>>>>>>>
>>>>>>>
>>>>>>> Other comments:
>>>>>>>
>>>>>>> The disconnect between swigify and clean targets remains: If make
>>>>>>> swigify builds this, and it is checked in to the tree then make clean
>>>>>>> shouldn't remove it, else it should be in the pywrap target and not
>>>>>>> installed.
>>>>>>>
>>>>>>> I'm not sure what the header re-ordering in selinuxswig.i and the
>>>>>>> copytree/install functions have to do with this patch.
>>>>>>>
>>>>>>
>>>>>>
>>>>>> Applied with this diff on top:
>>>>>>
>>>>>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>>>>>> index 928a1df..74b1e6a 100644
>>>>>> --- a/libselinux/src/Makefile
>>>>>> +++ b/libselinux/src/Makefile
>>>>>> @@ -16,14 +16,14 @@ LIBVERSION = 1
>>>>>>
>>>>>> LIBA=libselinux.a
>>>>>> TARGET=libselinux.so
>>>>>> -SWIGIF= selinuxswig_python.i
>>>>>> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
>>>>>> SWIGRUBYIF= selinuxswig_ruby.i
>>>>>> SWIGCOUT= selinuxswig_wrap.c
>>>>>> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
>>>>>> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
>>>>>> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
>>>>>> SWIGSO=_selinux.so
>>>>>> -SWIGFILES=$(SWIGSO) selinux.py
>>>>>> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
>>>>>> SWIGRUBYSO=_rubyselinux.so
>>>>>> LIBSO=$(TARGET).$(LIBVERSION)
>>>>>> AUDIT2WHYSO=audit2why.so
>>>>>> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
>>>>>> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
>>>>>> $(SWIGRUBY) $^
>>>>>>
>>>>>> -swigify: $(SWIGIF) selinuxswig_python_exception.i
>>>>>> +swigify: $(SWIGIF)
>>>>>> $(SWIG) $<
>>>>>>
>>>>>> install: all
>>>>>> @@ -127,7 +127,7 @@ relabel:
>>>>>> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
>>>>>>
>>>>>> clean:
>>>>>> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>>>>>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
>>>>>> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>>>>>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
>>>>>>
>>>>>> distclean: clean
>>>>>> rm -f $(GENERATED) $(SWIGFILES)
>>>>>> diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh
>>>>>> old mode 100644
>>>>>> new mode 100755
>>>>>> index b2a3799..c3e61a5
>>>>>> --- a/libselinux/src/exception.sh
>>>>>> +++ b/libselinux/src/exception.sh
>>>>>> @@ -15,7 +15,6 @@ echo "
>>>>>> ;;
>>>>>> esac
>>>>>> }
>>>>>> -echo '#include "../include/selinux/selinux.h"' > temp.c
>>>>>> -gcc -c temp.c -aux-info temp.aux
>>>>>> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6
>>>>>> }' temp.aux`; do except $i ; done
>>>>>> -rm -f temp.c temp.aux temp.o
>>>>>> +gcc -x c -c - -aux-info temp.aux < ../include/selinux/selinux.h
>>>>>> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except
>>>>>> $i ; done
>>>>>> +rm -f -- temp.aux -.o
>>>>>>
>>>>>
>>>>>
>>>>> Merged in libselinux-2.0.87
>>>>
>>>>
>>>> I have VERSION 2.0.86 in git?
>>>
>>> This seems to break make install-pywrap on the current selinux trunk:
>>> bash exception.sh > selinuxswig_python_exception.i 
>>> swig -Wall -python -o selinuxswig_wrap.c -outdir ./ selinuxswig_python.i selinuxswig_python_exception.i
>>> swig error : Unrecognized option selinuxswig_python.i
>>> Use 'swig -help' for available options.
>>
>> This btw prevents use of Caleb's patches on Fedora 12.  If I can't build
>> and install the python modules from the selinux repo, then there is an
>> undefined dependency from the Fedora libsemanage-python module on the
>> upstream libsemanage (some symbol introduced in the Fedora patches to
>> libsemanage) and thus migrate.py is unable to import semanage and
>> aborts.
> 
> Hmm...if I make swigify, all is well again.  But something seems wrong
> with the Makefile...
> 
Lets stop carrying the patch for swigified c and py file from the package and force you to have to run make swigify in the build procedure.



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2010-01-08 20:40                       ` Daniel J Walsh
@ 2010-01-08 20:52                         ` Joshua Brindle
  2010-02-08 21:10                           ` Caleb Case
  0 siblings, 1 reply; 20+ messages in thread
From: Joshua Brindle @ 2010-01-08 20:52 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: Stephen Smalley, SE Linux, Caleb Case, Chad Sellers

Daniel J Walsh wrote:
> On 01/08/2010 03:19 PM, Stephen Smalley wrote:
>> On Fri, 2010-01-08 at 15:06 -0500, Stephen Smalley wrote:
>>> On Fri, 2010-01-08 at 10:32 -0500, Stephen Smalley wrote:
>>>> On Mon, 2009-09-28 at 15:07 -0400, Daniel J Walsh wrote:
>>>>> On 09/24/2009 03:19 PM, Joshua Brindle wrote:
>>>>>> Joshua Brindle wrote:
>>>>>>> Joshua Brindle wrote:
>>>>>>>>
>>>>>>>> Daniel J Walsh wrote:
>>>>>>>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
>>>>>>>>>> Joshua Brindle wrote:
>>>>>>>>>>> Daniel J Walsh wrote:
>>>>>>>>>>>> What do you think of this one. Removed excess swig cruft,
>>>>>>>>>>>>
>>>>>>>>>>>> You need to run
>>>>>>>>>>>>
>>>>>>>>>>>> make swigify to generate those changes.
>>>>>>>>>>>>
>>>>>>>>>>> Ok, looking at this now. I don't completely get how it works. I'm
>>>>>>>>>>> trying
>>>>>>>>>>> to reproduce what you are doing by hand but nothing comes out of gcc:
>>>>>>>>>>>
>>>>>>>>>>> [root@localhost src]# echo '#include "../include/selinux/selinux.h"'>
>>>>>>>>>>> temp.c
>>>>>>>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
>>>>>>>>>>> [root@localhost src]# ls temp.*
>>>>>>>>>>> temp.c temp.o
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>> I got this "sort of" working locally. It works when I call it directly
>>>>>>>> on the header but it leaves a .gch file sitting in the include
>>>>>>>> directory.
>>>>>>>>
>>>>>>>> Trying to use stdin I get:
>>>>>>>>
>>>>>>>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux<
>>>>>>>> ../include/selinux/selinux.h
>>>>>>>> <stdin>:569: internal compiler error: Segmentation fault
>>>>>>>> Please submit a full bug report,
>>>>>>>> with preprocessed source if appropriate.
>>>>>>>> See<http://bugzilla.redhat.com/bugzilla>  for instructions.
>>>>>>>>
>>>>>>>>
>>>>>>>> Other comments:
>>>>>>>>
>>>>>>>> The disconnect between swigify and clean targets remains: If make
>>>>>>>> swigify builds this, and it is checked in to the tree then make clean
>>>>>>>> shouldn't remove it, else it should be in the pywrap target and not
>>>>>>>> installed.
>>>>>>>>
>>>>>>>> I'm not sure what the header re-ordering in selinuxswig.i and the
>>>>>>>> copytree/install functions have to do with this patch.
>>>>>>>>
>>>>>>>
>>>>>>> Applied with this diff on top:
>>>>>>>
>>>>>>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>>>>>>> index 928a1df..74b1e6a 100644
>>>>>>> --- a/libselinux/src/Makefile
>>>>>>> +++ b/libselinux/src/Makefile
>>>>>>> @@ -16,14 +16,14 @@ LIBVERSION = 1
>>>>>>>
>>>>>>> LIBA=libselinux.a
>>>>>>> TARGET=libselinux.so
>>>>>>> -SWIGIF= selinuxswig_python.i
>>>>>>> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
>>>>>>> SWIGRUBYIF= selinuxswig_ruby.i
>>>>>>> SWIGCOUT= selinuxswig_wrap.c
>>>>>>> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
>>>>>>> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
>>>>>>> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
>>>>>>> SWIGSO=_selinux.so
>>>>>>> -SWIGFILES=$(SWIGSO) selinux.py
>>>>>>> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
>>>>>>> SWIGRUBYSO=_rubyselinux.so
>>>>>>> LIBSO=$(TARGET).$(LIBVERSION)
>>>>>>> AUDIT2WHYSO=audit2why.so
>>>>>>> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
>>>>>>> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
>>>>>>> $(SWIGRUBY) $^
>>>>>>>
>>>>>>> -swigify: $(SWIGIF) selinuxswig_python_exception.i
>>>>>>> +swigify: $(SWIGIF)
>>>>>>> $(SWIG) $<
>>>>>>>
>>>>>>> install: all
>>>>>>> @@ -127,7 +127,7 @@ relabel:
>>>>>>> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
>>>>>>>
>>>>>>> clean:
>>>>>>> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>>>>>>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
>>>>>>> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>>>>>>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
>>>>>>>
>>>>>>> distclean: clean
>>>>>>> rm -f $(GENERATED) $(SWIGFILES)
>>>>>>> diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh
>>>>>>> old mode 100644
>>>>>>> new mode 100755
>>>>>>> index b2a3799..c3e61a5
>>>>>>> --- a/libselinux/src/exception.sh
>>>>>>> +++ b/libselinux/src/exception.sh
>>>>>>> @@ -15,7 +15,6 @@ echo "
>>>>>>> ;;
>>>>>>> esac
>>>>>>> }
>>>>>>> -echo '#include "../include/selinux/selinux.h"'>  temp.c
>>>>>>> -gcc -c temp.c -aux-info temp.aux
>>>>>>> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ { print $6
>>>>>>> }' temp.aux`; do except $i ; done
>>>>>>> -rm -f temp.c temp.aux temp.o
>>>>>>> +gcc -x c -c - -aux-info temp.aux<  ../include/selinux/selinux.h
>>>>>>> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except
>>>>>>> $i ; done
>>>>>>> +rm -f -- temp.aux -.o
>>>>>>>
>>>>>>
>>>>>> Merged in libselinux-2.0.87
>>>>>
>>>>> I have VERSION 2.0.86 in git?
>>>> This seems to break make install-pywrap on the current selinux trunk:
>>>> bash exception.sh>  selinuxswig_python_exception.i
>>>> swig -Wall -python -o selinuxswig_wrap.c -outdir ./ selinuxswig_python.i selinuxswig_python_exception.i
>>>> swig error : Unrecognized option selinuxswig_python.i
>>>> Use 'swig -help' for available options.
>>> This btw prevents use of Caleb's patches on Fedora 12.  If I can't build
>>> and install the python modules from the selinux repo, then there is an
>>> undefined dependency from the Fedora libsemanage-python module on the
>>> upstream libsemanage (some symbol introduced in the Fedora patches to
>>> libsemanage) and thus migrate.py is unable to import semanage and
>>> aborts.
>> Hmm...if I make swigify, all is well again.  But something seems wrong
>> with the Makefile...
>>
> Lets stop carrying the patch for swigified c and py file from the package and force you to have to run make swigify in the build procedure.
>

I am fine with that, having an outdated swig wrapper has caused much 
more pain than having to have swig installed will.


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2010-01-08 20:52                         ` Joshua Brindle
@ 2010-02-08 21:10                           ` Caleb Case
  2010-03-06 23:23                             ` Joshua Brindle
  0 siblings, 1 reply; 20+ messages in thread
From: Caleb Case @ 2010-02-08 21:10 UTC (permalink / raw)
  To: Joshua Brindle; +Cc: Daniel J Walsh, Stephen Smalley, SE Linux, Chad Sellers

On Fri, Jan 8, 2010 at 3:52 PM, Joshua Brindle <method@manicmethod.com> wrote:
> Daniel J Walsh wrote:
>>
>> On 01/08/2010 03:19 PM, Stephen Smalley wrote:
>>>
>>> On Fri, 2010-01-08 at 15:06 -0500, Stephen Smalley wrote:
>>>>
>>>> On Fri, 2010-01-08 at 10:32 -0500, Stephen Smalley wrote:
>>>>>
>>>>> On Mon, 2009-09-28 at 15:07 -0400, Daniel J Walsh wrote:
>>>>>>
>>>>>> On 09/24/2009 03:19 PM, Joshua Brindle wrote:
>>>>>>>
>>>>>>> Joshua Brindle wrote:
>>>>>>>>
>>>>>>>> Joshua Brindle wrote:
>>>>>>>>>
>>>>>>>>> Daniel J Walsh wrote:
>>>>>>>>>>
>>>>>>>>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
>>>>>>>>>>>
>>>>>>>>>>> Joshua Brindle wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Daniel J Walsh wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> What do you think of this one. Removed excess swig cruft,
>>>>>>>>>>>>>
>>>>>>>>>>>>> You need to run
>>>>>>>>>>>>>
>>>>>>>>>>>>> make swigify to generate those changes.
>>>>>>>>>>>>>
>>>>>>>>>>>> Ok, looking at this now. I don't completely get how it works.
>>>>>>>>>>>> I'm
>>>>>>>>>>>> trying
>>>>>>>>>>>> to reproduce what you are doing by hand but nothing comes out of
>>>>>>>>>>>> gcc:
>>>>>>>>>>>>
>>>>>>>>>>>> [root@localhost src]# echo '#include
>>>>>>>>>>>> "../include/selinux/selinux.h"'>
>>>>>>>>>>>> temp.c
>>>>>>>>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
>>>>>>>>>>>> [root@localhost src]# ls temp.*
>>>>>>>>>>>> temp.c temp.o
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>> I got this "sort of" working locally. It works when I call it
>>>>>>>>> directly
>>>>>>>>> on the header but it leaves a .gch file sitting in the include
>>>>>>>>> directory.
>>>>>>>>>
>>>>>>>>> Trying to use stdin I get:
>>>>>>>>>
>>>>>>>>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux<
>>>>>>>>> ../include/selinux/selinux.h
>>>>>>>>> <stdin>:569: internal compiler error: Segmentation fault
>>>>>>>>> Please submit a full bug report,
>>>>>>>>> with preprocessed source if appropriate.
>>>>>>>>> See<http://bugzilla.redhat.com/bugzilla>  for instructions.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Other comments:
>>>>>>>>>
>>>>>>>>> The disconnect between swigify and clean targets remains: If make
>>>>>>>>> swigify builds this, and it is checked in to the tree then make
>>>>>>>>> clean
>>>>>>>>> shouldn't remove it, else it should be in the pywrap target and not
>>>>>>>>> installed.
>>>>>>>>>
>>>>>>>>> I'm not sure what the header re-ordering in selinuxswig.i and the
>>>>>>>>> copytree/install functions have to do with this patch.
>>>>>>>>>
>>>>>>>>
>>>>>>>> Applied with this diff on top:
>>>>>>>>
>>>>>>>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>>>>>>>> index 928a1df..74b1e6a 100644
>>>>>>>> --- a/libselinux/src/Makefile
>>>>>>>> +++ b/libselinux/src/Makefile
>>>>>>>> @@ -16,14 +16,14 @@ LIBVERSION = 1
>>>>>>>>
>>>>>>>> LIBA=libselinux.a
>>>>>>>> TARGET=libselinux.so
>>>>>>>> -SWIGIF= selinuxswig_python.i
>>>>>>>> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
>>>>>>>> SWIGRUBYIF= selinuxswig_ruby.i
>>>>>>>> SWIGCOUT= selinuxswig_wrap.c
>>>>>>>> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
>>>>>>>> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
>>>>>>>> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
>>>>>>>> SWIGSO=_selinux.so
>>>>>>>> -SWIGFILES=$(SWIGSO) selinux.py
>>>>>>>> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
>>>>>>>> SWIGRUBYSO=_rubyselinux.so
>>>>>>>> LIBSO=$(TARGET).$(LIBVERSION)
>>>>>>>> AUDIT2WHYSO=audit2why.so
>>>>>>>> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
>>>>>>>> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
>>>>>>>> $(SWIGRUBY) $^
>>>>>>>>
>>>>>>>> -swigify: $(SWIGIF) selinuxswig_python_exception.i
>>>>>>>> +swigify: $(SWIGIF)
>>>>>>>> $(SWIG) $<
>>>>>>>>
>>>>>>>> install: all
>>>>>>>> @@ -127,7 +127,7 @@ relabel:
>>>>>>>> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
>>>>>>>>
>>>>>>>> clean:
>>>>>>>> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>>>>>>>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
>>>>>>>> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>>>>>>>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
>>>>>>>>
>>>>>>>> distclean: clean
>>>>>>>> rm -f $(GENERATED) $(SWIGFILES)
>>>>>>>> diff --git a/libselinux/src/exception.sh
>>>>>>>> b/libselinux/src/exception.sh
>>>>>>>> old mode 100644
>>>>>>>> new mode 100755
>>>>>>>> index b2a3799..c3e61a5
>>>>>>>> --- a/libselinux/src/exception.sh
>>>>>>>> +++ b/libselinux/src/exception.sh
>>>>>>>> @@ -15,7 +15,6 @@ echo "
>>>>>>>> ;;
>>>>>>>> esac
>>>>>>>> }
>>>>>>>> -echo '#include "../include/selinux/selinux.h"'>  temp.c
>>>>>>>> -gcc -c temp.c -aux-info temp.aux
>>>>>>>> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ {
>>>>>>>> print $6
>>>>>>>> }' temp.aux`; do except $i ; done
>>>>>>>> -rm -f temp.c temp.aux temp.o
>>>>>>>> +gcc -x c -c - -aux-info temp.aux<  ../include/selinux/selinux.h
>>>>>>>> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do
>>>>>>>> except
>>>>>>>> $i ; done
>>>>>>>> +rm -f -- temp.aux -.o
>>>>>>>>
>>>>>>>
>>>>>>> Merged in libselinux-2.0.87
>>>>>>
>>>>>> I have VERSION 2.0.86 in git?
>>>>>
>>>>> This seems to break make install-pywrap on the current selinux trunk:
>>>>> bash exception.sh>  selinuxswig_python_exception.i
>>>>> swig -Wall -python -o selinuxswig_wrap.c -outdir ./
>>>>> selinuxswig_python.i selinuxswig_python_exception.i
>>>>> swig error : Unrecognized option selinuxswig_python.i
>>>>> Use 'swig -help' for available options.
>>>>
>>>> This btw prevents use of Caleb's patches on Fedora 12.  If I can't build
>>>> and install the python modules from the selinux repo, then there is an
>>>> undefined dependency from the Fedora libsemanage-python module on the
>>>> upstream libsemanage (some symbol introduced in the Fedora patches to
>>>> libsemanage) and thus migrate.py is unable to import semanage and
>>>> aborts.
>>>
>>> Hmm...if I make swigify, all is well again.  But something seems wrong
>>> with the Makefile...

The make targets swigify and make install-pywrap should do the same
things during their swig step, however they don't. It appears that make
swigify does not include the second target to swig
(selinuxswig_python_exception.i), but install-pywrap does. On the other
hand, swig also does not accept multiple .i files so install-pywrap
fails.

As a result the exception wrappers are not installed.

[make swigify]

[ccase@fc12 libselinux]$ make distclean
<snip>
[ccase@fc12 libselinux]$ make swigify
<snip>
make -C src swigify
make[1]: Entering directory
`/home/ccase/projects/git/selinux-upstream/libselinux/src'
bash exception.sh > selinuxswig_python_exception.i
swig -Wall -python -o selinuxswig_wrap.c -outdir ./ selinuxswig_python.i
../include/selinux/avc.h:410: Warning(302): Identifier
'avc_cache_stats' redefined (ignored),
../include/selinux/avc.h:390: Warning(302): previous definition of
'avc_cache_stats'.
../include/selinux/selinux.h:142: Warning(451): Setting a const char *
variable may leak memory.
../include/selinux/selinux.h:345: Warning(451): Setting a const char *
variable may leak memory.
make[1]: Leaving directory
`/home/ccase/projects/git/selinux-upstream/libselinux/src'

[make install-pywrap]

[ccase@fc12 libselinux]$ make distclean
<snip>
[ccase@fc12 libselinux]$ make install-pywrap
<snip>
bash exception.sh > selinuxswig_python_exception.i
swig -Wall -python -o selinuxswig_wrap.c -outdir ./
selinuxswig_python.i selinuxswig_python_exception.i
swig error : Unrecognized option selinuxswig_python.i
Use 'swig -help' for available options.
make[1]: *** [selinuxswig_wrap.c] Error 1
make[1]: Leaving directory
`/home/ccase/projects/git/selinux-upstream/libselinux/src'
make: *** [install-pywrap] Error 2

Caleb


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2010-02-08 21:10                           ` Caleb Case
@ 2010-03-06 23:23                             ` Joshua Brindle
  0 siblings, 0 replies; 20+ messages in thread
From: Joshua Brindle @ 2010-03-06 23:23 UTC (permalink / raw)
  To: Caleb Case; +Cc: Daniel J Walsh, Stephen Smalley, SE Linux, Chad Sellers



Caleb Case wrote:
> On Fri, Jan 8, 2010 at 3:52 PM, Joshua Brindle<method@manicmethod.com>  wrote:
>> Daniel J Walsh wrote:
>>> On 01/08/2010 03:19 PM, Stephen Smalley wrote:
>>>> On Fri, 2010-01-08 at 15:06 -0500, Stephen Smalley wrote:
>>>>> On Fri, 2010-01-08 at 10:32 -0500, Stephen Smalley wrote:
>>>>>> On Mon, 2009-09-28 at 15:07 -0400, Daniel J Walsh wrote:
>>>>>>> On 09/24/2009 03:19 PM, Joshua Brindle wrote:
>>>>>>>> Joshua Brindle wrote:
>>>>>>>>> Joshua Brindle wrote:
>>>>>>>>>> Daniel J Walsh wrote:
>>>>>>>>>>> On 09/16/2009 03:35 PM, Joshua Brindle wrote:
>>>>>>>>>>>> Joshua Brindle wrote:
>>>>>>>>>>>>> Daniel J Walsh wrote:
>>>>>>>>>>>>>> What do you think of this one. Removed excess swig cruft,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> You need to run
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> make swigify to generate those changes.
>>>>>>>>>>>>>>
>>>>>>>>>>>>> Ok, looking at this now. I don't completely get how it works.
>>>>>>>>>>>>> I'm
>>>>>>>>>>>>> trying
>>>>>>>>>>>>> to reproduce what you are doing by hand but nothing comes out of
>>>>>>>>>>>>> gcc:
>>>>>>>>>>>>>
>>>>>>>>>>>>> [root@localhost src]# echo '#include
>>>>>>>>>>>>> "../include/selinux/selinux.h"'>
>>>>>>>>>>>>> temp.c
>>>>>>>>>>>>> [root@localhost src]# gcc -c temp.c -aux-info temp.aux
>>>>>>>>>>>>> [root@localhost src]# ls temp.*
>>>>>>>>>>>>> temp.c temp.o
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>> I got this "sort of" working locally. It works when I call it
>>>>>>>>>> directly
>>>>>>>>>> on the header but it leaves a .gch file sitting in the include
>>>>>>>>>> directory.
>>>>>>>>>>
>>>>>>>>>> Trying to use stdin I get:
>>>>>>>>>>
>>>>>>>>>> [root@localhost src]# gcc -x c-header -c - -aux-info temp.aux<
>>>>>>>>>> ../include/selinux/selinux.h
>>>>>>>>>> <stdin>:569: internal compiler error: Segmentation fault
>>>>>>>>>> Please submit a full bug report,
>>>>>>>>>> with preprocessed source if appropriate.
>>>>>>>>>> See<http://bugzilla.redhat.com/bugzilla>    for instructions.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Other comments:
>>>>>>>>>>
>>>>>>>>>> The disconnect between swigify and clean targets remains: If make
>>>>>>>>>> swigify builds this, and it is checked in to the tree then make
>>>>>>>>>> clean
>>>>>>>>>> shouldn't remove it, else it should be in the pywrap target and not
>>>>>>>>>> installed.
>>>>>>>>>>
>>>>>>>>>> I'm not sure what the header re-ordering in selinuxswig.i and the
>>>>>>>>>> copytree/install functions have to do with this patch.
>>>>>>>>>>
>>>>>>>>> Applied with this diff on top:
>>>>>>>>>
>>>>>>>>> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>>>>>>>>> index 928a1df..74b1e6a 100644
>>>>>>>>> --- a/libselinux/src/Makefile
>>>>>>>>> +++ b/libselinux/src/Makefile
>>>>>>>>> @@ -16,14 +16,14 @@ LIBVERSION = 1
>>>>>>>>>
>>>>>>>>> LIBA=libselinux.a
>>>>>>>>> TARGET=libselinux.so
>>>>>>>>> -SWIGIF= selinuxswig_python.i
>>>>>>>>> +SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
>>>>>>>>> SWIGRUBYIF= selinuxswig_ruby.i
>>>>>>>>> SWIGCOUT= selinuxswig_wrap.c
>>>>>>>>> SWIGRUBYCOUT= selinuxswig_ruby_wrap.c
>>>>>>>>> SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
>>>>>>>>> SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
>>>>>>>>> SWIGSO=_selinux.so
>>>>>>>>> -SWIGFILES=$(SWIGSO) selinux.py
>>>>>>>>> +SWIGFILES=$(SWIGSO) selinux.py selinuxswig_python_exception.i
>>>>>>>>> SWIGRUBYSO=_rubyselinux.so
>>>>>>>>> LIBSO=$(TARGET).$(LIBVERSION)
>>>>>>>>> AUDIT2WHYSO=audit2why.so
>>>>>>>>> @@ -103,7 +103,7 @@ $(SWIGCOUT): $(SWIGIF)
>>>>>>>>> $(SWIGRUBYCOUT): $(SWIGRUBYIF)
>>>>>>>>> $(SWIGRUBY) $^
>>>>>>>>>
>>>>>>>>> -swigify: $(SWIGIF) selinuxswig_python_exception.i
>>>>>>>>> +swigify: $(SWIGIF)
>>>>>>>>> $(SWIG) $<
>>>>>>>>>
>>>>>>>>> install: all
>>>>>>>>> @@ -127,7 +127,7 @@ relabel:
>>>>>>>>> /sbin/restorecon $(SHLIBDIR)/$(LIBSO)
>>>>>>>>>
>>>>>>>>> clean:
>>>>>>>>> - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>>>>>>>>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_python_exception.i
>>>>>>>>> + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO)
>>>>>>>>> $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
>>>>>>>>>
>>>>>>>>> distclean: clean
>>>>>>>>> rm -f $(GENERATED) $(SWIGFILES)
>>>>>>>>> diff --git a/libselinux/src/exception.sh
>>>>>>>>> b/libselinux/src/exception.sh
>>>>>>>>> old mode 100644
>>>>>>>>> new mode 100755
>>>>>>>>> index b2a3799..c3e61a5
>>>>>>>>> --- a/libselinux/src/exception.sh
>>>>>>>>> +++ b/libselinux/src/exception.sh
>>>>>>>>> @@ -15,7 +15,6 @@ echo "
>>>>>>>>> ;;
>>>>>>>>> esac
>>>>>>>>> }
>>>>>>>>> -echo '#include "../include/selinux/selinux.h"'>    temp.c
>>>>>>>>> -gcc -c temp.c -aux-info temp.aux
>>>>>>>>> -for i in `awk '/..\/include\/selinux\/selinux.h.*extern int/ {
>>>>>>>>> print $6
>>>>>>>>> }' temp.aux`; do except $i ; done
>>>>>>>>> -rm -f temp.c temp.aux temp.o
>>>>>>>>> +gcc -x c -c - -aux-info temp.aux<    ../include/selinux/selinux.h
>>>>>>>>> +for i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do
>>>>>>>>> except
>>>>>>>>> $i ; done
>>>>>>>>> +rm -f -- temp.aux -.o
>>>>>>>>>
>>>>>>>> Merged in libselinux-2.0.87
>>>>>>> I have VERSION 2.0.86 in git?
>>>>>> This seems to break make install-pywrap on the current selinux trunk:
>>>>>> bash exception.sh>    selinuxswig_python_exception.i
>>>>>> swig -Wall -python -o selinuxswig_wrap.c -outdir ./
>>>>>> selinuxswig_python.i selinuxswig_python_exception.i
>>>>>> swig error : Unrecognized option selinuxswig_python.i
>>>>>> Use 'swig -help' for available options.
>>>>> This btw prevents use of Caleb's patches on Fedora 12.  If I can't build
>>>>> and install the python modules from the selinux repo, then there is an
>>>>> undefined dependency from the Fedora libsemanage-python module on the
>>>>> upstream libsemanage (some symbol introduced in the Fedora patches to
>>>>> libsemanage) and thus migrate.py is unable to import semanage and
>>>>> aborts.
>>>> Hmm...if I make swigify, all is well again.  But something seems wrong
>>>> with the Makefile...
>
> The make targets swigify and make install-pywrap should do the same
> things during their swig step, however they don't. It appears that make
> swigify does not include the second target to swig
> (selinuxswig_python_exception.i), but install-pywrap does. On the other
> hand, swig also does not accept multiple .i files so install-pywrap
> fails.
>
> As a result the exception wrappers are not installed.
>
> [make swigify]
>
> [ccase@fc12 libselinux]$ make distclean
> <snip>
> [ccase@fc12 libselinux]$ make swigify
> <snip>
> make -C src swigify
> make[1]: Entering directory
> `/home/ccase/projects/git/selinux-upstream/libselinux/src'
> bash exception.sh>  selinuxswig_python_exception.i
> swig -Wall -python -o selinuxswig_wrap.c -outdir ./ selinuxswig_python.i
> ../include/selinux/avc.h:410: Warning(302): Identifier
> 'avc_cache_stats' redefined (ignored),
> ../include/selinux/avc.h:390: Warning(302): previous definition of
> 'avc_cache_stats'.
> ../include/selinux/selinux.h:142: Warning(451): Setting a const char *
> variable may leak memory.
> ../include/selinux/selinux.h:345: Warning(451): Setting a const char *
> variable may leak memory.
> make[1]: Leaving directory
> `/home/ccase/projects/git/selinux-upstream/libselinux/src'
>
> [make install-pywrap]
>
> [ccase@fc12 libselinux]$ make distclean
> <snip>
> [ccase@fc12 libselinux]$ make install-pywrap
> <snip>
> bash exception.sh>  selinuxswig_python_exception.i
> swig -Wall -python -o selinuxswig_wrap.c -outdir ./
> selinuxswig_python.i selinuxswig_python_exception.i
> swig error : Unrecognized option selinuxswig_python.i
> Use 'swig -help' for available options.
> make[1]: *** [selinuxswig_wrap.c] Error 1
> make[1]: Leaving directory
> `/home/ccase/projects/git/selinux-upstream/libselinux/src'
> make: *** [install-pywrap] Error 2
>

I'm not sure why, make swigify and make install-pywrap both work here 
(F12) swig-1.3.40-5

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-06-18 14:23     ` Joshua Brindle
@ 2009-06-18 19:41       ` Daniel J Walsh
  0 siblings, 0 replies; 20+ messages in thread
From: Daniel J Walsh @ 2009-06-18 19:41 UTC (permalink / raw)
  To: Joshua Brindle; +Cc: Chad Sellers, SE Linux

On 06/18/2009 10:23 AM, Joshua Brindle wrote:
> Daniel J Walsh wrote:
>> On 05/19/2009 12:16 PM, Chad Sellers wrote:
>>> On 5/18/09 2:10 PM, "Daniel J Walsh"<dwalsh@redhat.com> wrote:
>>>
>>>> Basically we need to search for all interfaces that return an int and
>>>> set those up as python exception handlers.
>>>
>>> I presume this supercedes the patch submitted on March 4 titled
>>> "Patch to
>>> python bindings" which used a single generic exception handler. Is that
>>> correct? Why the switch from a generic exception handler to a shell
>>> script
>>> to generate lots of specific exception handlers?
>>>
>>> Thanks,
>>> Chad
>>>
>>>
>>> --
>>> This message was distributed to subscribers of the selinux mailing list.
>>> If you no longer wish to subscribe, send mail to
>>> majordomo@tycho.nsa.gov with
>>> the words "unsubscribe selinux" without quotes as the message.
>> Yes, that patch caused certain interfaces to not work if they did not
>> return int.
>>
>
> This doesn't strike me as the best way to handle it. Assuming all
> functions that return an int returns it as a return code is a little
> overzealous. For example selinux_file_context_cmp() returns 1, 0, -1 for
> comparison. It is only not included in the exception.sh output by
> accident it appears (it is defined as int selinux_file_context_cmp(...)
> rather than extern int.
>
I am willing to accept better ideas.  Admittedly this is a hack, but I 
have not seen a bug since implementing.  I guess we should tell python 
when we have exceptions to the rule, like selinux_file_context_cmp

> Which brings up the next point, there are a handful of functions in
> selinux.h that don't have extern which means exception handlers aren't
> made for them.
>
> --
> This message was distributed to subscribers of the selinux mailing list.
> If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov
> with
> the words "unsubscribe selinux" without quotes as the message.


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-05-19 17:35   ` Daniel J Walsh
@ 2009-06-18 14:23     ` Joshua Brindle
  2009-06-18 19:41       ` Daniel J Walsh
  0 siblings, 1 reply; 20+ messages in thread
From: Joshua Brindle @ 2009-06-18 14:23 UTC (permalink / raw)
  To: Daniel J Walsh; +Cc: Chad Sellers, SE Linux

Daniel J Walsh wrote:
> On 05/19/2009 12:16 PM, Chad Sellers wrote:
>> On 5/18/09 2:10 PM, "Daniel J Walsh"<dwalsh@redhat.com> wrote:
>>
>>> Basically we need to search for all interfaces that return an int and
>>> set those up as python exception handlers.
>>
>> I presume this supercedes the patch submitted on March 4 titled "Patch to
>> python bindings" which used a single generic exception handler. Is that
>> correct? Why the switch from a generic exception handler to a shell
>> script
>> to generate lots of specific exception handlers?
>>
>> Thanks,
>> Chad
>>
>>
>> --
>> This message was distributed to subscribers of the selinux mailing list.
>> If you no longer wish to subscribe, send mail to
>> majordomo@tycho.nsa.gov with
>> the words "unsubscribe selinux" without quotes as the message.
> Yes, that patch caused certain interfaces to not work if they did not
> return int.
>

This doesn't strike me as the best way to handle it. Assuming all functions that 
return an int returns it as a return code is a little overzealous. For example 
selinux_file_context_cmp() returns 1, 0, -1 for comparison. It is only not 
included in the exception.sh output by accident it appears (it is defined as int 
selinux_file_context_cmp(...) rather than extern int.

Which brings up the next point, there are a handful of functions in selinux.h 
that don't have extern which means exception handlers aren't made for them.

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-05-19 16:16 ` Chad Sellers
@ 2009-05-19 17:35   ` Daniel J Walsh
  2009-06-18 14:23     ` Joshua Brindle
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel J Walsh @ 2009-05-19 17:35 UTC (permalink / raw)
  To: Chad Sellers; +Cc: SE Linux

On 05/19/2009 12:16 PM, Chad Sellers wrote:
> On 5/18/09 2:10 PM, "Daniel J Walsh"<dwalsh@redhat.com>  wrote:
>
>> Basically we need to search for all interfaces that return an int and
>> set those up as python exception handlers.
>
> I presume this supercedes the patch submitted on March 4 titled "Patch to
> python bindings" which used a single generic exception handler. Is that
> correct? Why the switch from a generic exception handler to a shell script
> to generate lots of specific exception handlers?
>
> Thanks,
> Chad
>
>
> --
> This message was distributed to subscribers of the selinux mailing list.
> If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
> the words "unsubscribe selinux" without quotes as the message.
Yes, that patch caused certain interfaces to not work if they did not 
return int.

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: This patch fixes the exception handling in libselinux-python bindings
  2009-05-18 18:10 Daniel J Walsh
@ 2009-05-19 16:16 ` Chad Sellers
  2009-05-19 17:35   ` Daniel J Walsh
  0 siblings, 1 reply; 20+ messages in thread
From: Chad Sellers @ 2009-05-19 16:16 UTC (permalink / raw)
  To: Daniel J Walsh, SE Linux

On 5/18/09 2:10 PM, "Daniel J Walsh" <dwalsh@redhat.com> wrote:

> Basically we need to search for all interfaces that return an int and
> set those up as python exception handlers.

I presume this supercedes the patch submitted on March 4 titled "Patch to
python bindings" which used a single generic exception handler. Is that
correct? Why the switch from a generic exception handler to a shell script
to generate lots of specific exception handlers?

Thanks,
Chad 


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* This patch fixes the exception handling in libselinux-python bindings
@ 2009-05-18 18:10 Daniel J Walsh
  2009-05-19 16:16 ` Chad Sellers
  0 siblings, 1 reply; 20+ messages in thread
From: Daniel J Walsh @ 2009-05-18 18:10 UTC (permalink / raw)
  To: SE Linux

[-- Attachment #1: Type: text/plain, Size: 114 bytes --]

Basically we need to search for all interfaces that return an int and 
set those up as python exception handlers.

[-- Attachment #2: libselinux_python_exception.patch --]
[-- Type: text/plain, Size: 3514 bytes --]

--- nsalibselinux/src/selinuxswig.i	2009-03-12 08:48:48.000000000 -0400
+++ libselinux-2.0.81/src/selinuxswig.i	2009-05-18 14:04:07.000000000 -0400
@@ -4,11 +4,14 @@
 
 %module selinux
 %{
-	#include "selinux/selinux.h"
 	#include "../include/selinux/avc.h"
-	#include "../include/selinux/selinux.h"
-	#include "../include/selinux/get_default_type.h"
+	#include "../include/selinux/av_permissions.h"
+	#include "../include/selinux/context.h"
+	#include "../include/selinux/flask.h"
 	#include "../include/selinux/get_context_list.h"
+	#include "../include/selinux/get_default_type.h"
+	#include "../include/selinux/label.h"
+	#include "../include/selinux/selinux.h"
 %}
 %apply int *OUTPUT { int *enforce };
 %apply int *OUTPUT { size_t * };
@@ -55,8 +58,11 @@
 %ignore avc_netlink_release_fd;
 %ignore avc_netlink_check_nb;
 
-%include "../include/selinux/selinux.h"
 %include "../include/selinux/avc.h"
-%include "../include/selinux/get_default_type.h"
+%include "../include/selinux/av_permissions.h"
+%include "../include/selinux/context.h"
+%include "../include/selinux/flask.h"
 %include "../include/selinux/get_context_list.h"
-
+%include "../include/selinux/get_default_type.h"
+%include "../include/selinux/label.h"
+%include "../include/selinux/selinux.h"
--- nsalibselinux/src/Makefile	2009-03-06 14:41:45.000000000 -0500
+++ libselinux-2.0.81/src/Makefile	2009-05-18 14:04:07.000000000 -0400
@@ -82,6 +82,9 @@
 	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -ldl -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro
 	ln -sf $@ $(TARGET) 
 
+selinuxswig_exception.i: ../include/selinux/selinux.h
+	sh exception.sh > $@ 
+
 audit2why.lo: audit2why.c
 	$(CC) $(CFLAGS) -I$(PYINC) -fPIC -DSHARED -c -o $@ $<
 
@@ -100,8 +103,8 @@
 $(SWIGRUBYCOUT): $(SWIGRUBYIF)
 	$(SWIGRUBY) $^
 
-swigify: $(SWIGIF)
-	$(SWIG) $^
+swigify: $(SWIGIF) selinuxswig_exception.i
+	$(SWIG) $<
 
 install: all 
 	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
@@ -124,7 +127,7 @@
 	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
 
 clean: 
-	-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
+	-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~ selinuxswig_exception.i
 
 distclean: clean
 	rm -f $(GENERATED) $(SWIGFILES)
--- nsalibselinux/src/exception.sh	1969-12-31 19:00:00.000000000 -0500
+++ libselinux-2.0.81/src/exception.sh	2009-05-18 14:04:07.000000000 -0400
@@ -0,0 +1,12 @@
+function except() {
+echo "
+%exception $1 {
+  \$action 
+  if (result < 0) {
+     PyErr_SetFromErrno(PyExc_OSError);
+     return NULL;
+  }
+}
+"
+}
+for i in `grep "extern *int" ../include/selinux/selinux.h | awk '{ print $3 }' | cut -d '(' -f 1`; do except $i ; done 
--- nsalibselinux/src/selinuxswig_python.i	2009-03-06 14:41:45.000000000 -0500
+++ libselinux-2.0.81/src/selinuxswig_python.i	2009-05-18 14:04:07.000000000 -0400
@@ -21,6 +21,15 @@
                              map(restorecon, [os.path.join(dirname, fname)
                                               for fname in fnames]), None)
 
+def copytree(src, dest):
+    """ An SELinux-friendly shutil.copytree method """
+    shutil.copytree(src, dest)
+    restorecon(dest, recursive=True)
+
+def install(src, dest):
+    """ An SELinux-friendly shutil.move method """
+    shutil.move(src, dest)
+    restorecon(dest, recursive=True)
 %}
 
 /* security_get_boolean_names() typemap */
@@ -150,4 +159,5 @@
 	free($1);
 }
 
+%include "selinuxswig_exception.i"
 %include "selinuxswig.i"

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-03-06 23:23 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <C6A74D22.A99BD%csellers@tresys.com>
2009-08-12 18:34 ` This patch fixes the exception handling in libselinux-python bindings Daniel J Walsh
2009-09-16 19:18   ` Joshua Brindle
2009-09-16 19:35     ` Joshua Brindle
     [not found]       ` <4AB15164.1020507@redhat.com>
2009-09-24  0:56         ` Joshua Brindle
2009-09-24 18:16           ` Joshua Brindle
2009-09-24 19:19             ` Joshua Brindle
2009-09-28 19:07               ` Daniel J Walsh
2009-09-28 20:10                 ` Joshua Brindle
2010-01-08 15:32                 ` Stephen Smalley
2010-01-08 20:06                   ` Stephen Smalley
2010-01-08 20:19                     ` Stephen Smalley
2010-01-08 20:40                       ` Daniel J Walsh
2010-01-08 20:52                         ` Joshua Brindle
2010-02-08 21:10                           ` Caleb Case
2010-03-06 23:23                             ` Joshua Brindle
2009-05-18 18:10 Daniel J Walsh
2009-05-19 16:16 ` Chad Sellers
2009-05-19 17:35   ` Daniel J Walsh
2009-06-18 14:23     ` Joshua Brindle
2009-06-18 19:41       ` Daniel J Walsh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.