Swigify libselinux
Signature · 1 line
--
src/Makefile +32 -6
@@ -3,25 +3,41 @@ LIBDIR ?= $(PREFIX)/lib SHLIBDIR ?= $(DESTDIR)/lib INCLUDEDIR ?= $(PREFIX)/include +PYINC ?= /usr/include/python2.4 +PYLIB ?= /usr/lib/python2.4 +PYLIBVER ?= python2.4 +PYTHONLIBDIR ?= $(LIBDIR)/python2.4 LIBVERSION = 1 - LIBA=libselinux.a TARGET=libselinux.so +SWIGIF= selinuxswig.i +SWIGCOUT= selinuxswig_wrap.c +SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT)) +SWIGSO=_selinux.so +SWIGFILES=$(SWIGSO) selinux.py LIBSO=$(TARGET).$(LIBVERSION) -OBJS= $(patsubst %.c,%.o,$(wildcard *.c)) -LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c)) +OBJS= $(patsubst %.c,%.o,$(filter-out $(SWIGCOUT),$(wildcard *.c))) +LOBJS= $(patsubst %.c,%.lo,$(filter-out $(SWIGCOUT),$(wildcard *.c))) CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 RANLIB=ranlib -all: $(LIBA) $(LIBSO) +SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./ + +all: $(LIBA) $(LIBSO) $(SWIGSO) $(LIBA): $(OBJS) $(AR) rcs $@ $^ $(RANLIB) $@ +$(SWIGLOBJ): $(SWIGCOUT) + $(CC) $(CFLAGS) -I$(PYINC) -fpic -DSHARED -c -o $@ $< + +$(SWIGSO): $(SWIGLOBJ) + $(CC) $(LDFLAGS) -shared -o $@ $< -L. -lselinux -l$(PYLIBVER) -L$(LIBDIR) -Wl,-soname,$@,-z,defs + $(LIBSO): $(LOBJS) $(CC) $(LDFLAGS) -shared -o $@ $^ -ldl -lsepol -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs ln -sf $@ $(TARGET)
@@ -32,16 +48,26 @@ %.lo: %.c policy.h $(CC) $(CFLAGS) -fpic -DSHARED -c -o $@ $< -install: all +$(SWIGCOUT): $(SWIGIF) + $(SWIG) $^ + +swigify: $(SWIGIF) + $(SWIG) $^ + +install: all install-pywrap test -d $(LIBDIR) || install -m 755 -d $(LIBDIR) install -m 644 $(LIBA) $(LIBDIR) test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR) install -m 755 $(LIBSO) $(SHLIBDIR) cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET) +install-pywrap: + test -d $(PYTHONLIBDIR)/site-packages || install -m 755 -d $(PYTHONLIBDIR)/site-packages + install -m 755 $(SWIGFILES) $(PYTHONLIBDIR)/site-packages + relabel: /sbin/restorecon $(SHLIBDIR)/$(LIBSO) clean: - -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET) + -rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET)
src/selinuxswig.i +105 -0
105 lines not on this page · raw message
<snip>
src/selinuxswig.i line 105
Quoted 3 lines
src/selinuxswig.i +3
-0+ +extern int getseuserbyname(const char *linuxuser, char **seuser, char **level); +
Why not include the header so that API changes get reflected when changes are made?
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines · Joshua Brindle
<snip>
Quoted 4 lines
(quoted diff) +2
-0+ +extern int getseuserbyname(const char *linuxuser, char **seuser,char **level);
+Why not include the header so that API changes get reflected when changes are made?
First it will not build some of the _raw functions, I believe there is a problem with the hidden_profile handling. But I also do not want to support some of the more exotic uses of the library. So I just went in and grabbed the ones I could see most people using. Raw functions can be mimiced using some of the translation calls. I could be convinced either way. The main goal to start was to get is_selinux_enabled and is_selinux_mls_enabled.
Signature · 4 lines
-- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Ok, merged as of libselinux 1.27.23. Also added the generated files as in the libsemanage case to avoid requiring swig for building, IIUC.
I am a little concerned about the consistency issue, as noted by Joshua.
Signature · 8 lines
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 [email protected] with the words "unsubscribe selinux" without quotes as the message.