psss / rpms / libselinux

Forked from rpms/libselinux 5 years ago
Clone
ae85aab
diff --exclude-from=exclude -N -u -r nsalibselinux/src/Makefile libselinux-1.27.22/src/Makefile
ae85aab
--- nsalibselinux/src/Makefile	2005-11-16 21:39:52.000000000 -0500
4bb08c5
+++ libselinux-1.27.22/src/Makefile	2005-11-28 16:48:08.000000000 -0500
ae85aab
@@ -3,25 +3,41 @@
ae85aab
 LIBDIR ?= $(PREFIX)/lib
ae85aab
 SHLIBDIR ?= $(DESTDIR)/lib
ae85aab
 INCLUDEDIR ?= $(PREFIX)/include
ae85aab
+PYLIBVER ?= python2.4
4bb08c5
+PYINC ?= /usr/include/$(PYLIBVER)
4bb08c5
+PYLIB ?= /usr/lib/$(PYLIBVER)
4bb08c5
+PYTHONLIBDIR ?= $(LIBDIR)/$(PYLIBVER)
ae85aab
 
ae85aab
 LIBVERSION = 1
ae85aab
 
ae85aab
-
ae85aab
 LIBA=libselinux.a 
ae85aab
 TARGET=libselinux.so
ae85aab
+SWIGIF= selinuxswig.i
ae85aab
+SWIGCOUT= selinuxswig_wrap.c
ae85aab
+SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT)) 
ae85aab
+SWIGSO=_selinux.so
ae85aab
+SWIGFILES=$(SWIGSO) selinux.py 
ae85aab
 LIBSO=$(TARGET).$(LIBVERSION)
ae85aab
-OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
ae85aab
-LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
ae85aab
+OBJS= $(patsubst %.c,%.o,$(filter-out $(SWIGCOUT),$(wildcard *.c))) 
ae85aab
+LOBJS= $(patsubst %.c,%.lo,$(filter-out $(SWIGCOUT),$(wildcard *.c)))
ae85aab
 CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
ae85aab
 override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
ae85aab
 RANLIB=ranlib
ae85aab
 
ae85aab
-all: $(LIBA) $(LIBSO)
ae85aab
+SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./
ae85aab
+
ae85aab
+all: $(LIBA) $(LIBSO) $(SWIGSO)
ae85aab
 
ae85aab
 $(LIBA):  $(OBJS)
ae85aab
 	$(AR) rcs $@ $^
ae85aab
 	$(RANLIB) $@
ae85aab
 
ae85aab
+$(SWIGLOBJ): $(SWIGCOUT)
ae85aab
+	$(CC) $(CFLAGS) -I$(PYINC) -fpic -DSHARED -c -o $@ $<
ae85aab
+
ae85aab
+$(SWIGSO): $(SWIGLOBJ)
4bb08c5
+	$(CC) $(LDFLAGS) -shared -o $@ $< -L. -lselinux -L$(LIBDIR) -Wl,-soname,$@
ae85aab
+
ae85aab
 $(LIBSO): $(LOBJS)
ae85aab
 	$(CC) $(LDFLAGS) -shared -o $@ $^ -ldl -lsepol -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs
ae85aab
 	ln -sf $@ $(TARGET) 
ae85aab
@@ -32,16 +48,26 @@
ae85aab
 %.lo:  %.c policy.h
ae85aab
 	$(CC) $(CFLAGS) -fpic -DSHARED -c -o $@ $<
ae85aab
 
ae85aab
-install: all
ae85aab
+$(SWIGCOUT): $(SWIGIF)
ae85aab
+	$(SWIG) $^
ae85aab
+
ae85aab
+swigify: $(SWIGIF)
ae85aab
+	$(SWIG) $^
ae85aab
+
ae85aab
+install: all install-pywrap
ae85aab
 	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
ae85aab
 	install -m 644 $(LIBA) $(LIBDIR)
ae85aab
 	test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
ae85aab
 	install -m 755 $(LIBSO) $(SHLIBDIR)
ae85aab
 	cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET)
ae85aab
 
ae85aab
+install-pywrap: 
ae85aab
+	test -d $(PYTHONLIBDIR)/site-packages || install -m 755 -d $(PYTHONLIBDIR)/site-packages
ae85aab
+	install -m 755 $(SWIGFILES) $(PYTHONLIBDIR)/site-packages
ae85aab
+
ae85aab
 relabel:
ae85aab
 	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
ae85aab
 
ae85aab
 clean: 
ae85aab
-	-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET) 
ae85aab
+	-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) 
ae85aab
 
ae85aab
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinuxswig.i libselinux-1.27.22/src/selinuxswig.i
ae85aab
--- nsalibselinux/src/selinuxswig.i	1969-12-31 19:00:00.000000000 -0500
ae85aab
+++ libselinux-1.27.22/src/selinuxswig.i	2005-11-17 12:02:28.000000000 -0500
ae85aab
@@ -0,0 +1,105 @@
ae85aab
+/* Author: Dan Walsh
ae85aab
+ *
ae85aab
+ * Copyright (C) 2004-2005 Red Hat
ae85aab
+ * 
ae85aab
+ *  This library is free software; you can redistribute it and/or
ae85aab
+ *  modify it under the terms of the GNU Lesser General Public
ae85aab
+ *  License as published by the Free Software Foundation; either
ae85aab
+ *  version 2.1 of the License, or (at your option) any later version.
ae85aab
+ *
ae85aab
+ *  This library is distributed in the hope that it will be useful,
ae85aab
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae85aab
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ae85aab
+ *  Lesser General Public License for more details.
ae85aab
+ *
ae85aab
+ *  You should have received a copy of the GNU Lesser General Public
ae85aab
+ *  License along with this library; if not, write to the Free Software
ae85aab
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
ae85aab
+ */
ae85aab
+
ae85aab
+
ae85aab
+%module selinux
ae85aab
+%{
ae85aab
+	#include "selinux/selinux.h"
ae85aab
+%}
ae85aab
+
ae85aab
+extern int is_selinux_enabled(void);
ae85aab
+extern int is_selinux_mls_enabled(void);
ae85aab
+extern int getcon(security_context_t *con);
ae85aab
+extern int setcon(security_context_t con);
ae85aab
+extern int getpidcon(pid_t pid, security_context_t *con);
ae85aab
+extern int getprevcon(security_context_t *con);
ae85aab
+extern int getexeccon(security_context_t *con);
ae85aab
+extern int setexeccon(security_context_t con);
ae85aab
+extern int getfscreatecon(security_context_t *con);
ae85aab
+extern int setfscreatecon(security_context_t context);
ae85aab
+extern int getfilecon(const char *path, security_context_t *con);
ae85aab
+extern int lgetfilecon(const char *path, security_context_t *con);
ae85aab
+extern int fgetfilecon(int fd, security_context_t *con);
ae85aab
+extern int setfilecon(const char *path, security_context_t con);
ae85aab
+extern int lsetfilecon(const char *path, security_context_t con);
ae85aab
+extern int fsetfilecon(int fd, security_context_t con);
ae85aab
+extern int getpeercon(int fd, security_context_t *con);
ae85aab
+extern int selinux_mkload_policy(int preservebools);
ae85aab
+extern int selinux_init_load_policy(int *enforce);
ae85aab
+extern int security_set_boolean_list(size_t boolcnt, 
ae85aab
+				     SELboolean *boollist, 
ae85aab
+				     int permanent);
ae85aab
+extern int security_load_booleans(char *path);
ae85aab
+extern int security_check_context(security_context_t con);
ae85aab
+extern int security_canonicalize_context(security_context_t con,
ae85aab
+					 security_context_t *canoncon);
ae85aab
+extern int security_getenforce(void);
ae85aab
+extern int security_setenforce(int value);
ae85aab
+extern int security_disable(void);
ae85aab
+extern int security_policyvers(void);
ae85aab
+extern int security_get_boolean_names(char ***names, int *len);
ae85aab
+extern int security_get_boolean_pending(const char *name);
ae85aab
+extern int security_get_boolean_active(const char *name);
ae85aab
+extern int security_set_boolean(const char *name, int value);
ae85aab
+extern int security_commit_booleans(void);
ae85aab
+
ae85aab
+/* Set flags controlling operation of matchpathcon_init or matchpathcon. */
ae85aab
+#define MATCHPATHCON_BASEONLY 1 /* Only process the base file_contexts file. */
70810f1
+#define MATCHPATHCON_NOTRANS  2 /* Do not perform any context translation. */
ae85aab
+extern void set_matchpathcon_flags(unsigned int flags);
ae85aab
+extern int matchpathcon_init(const char *path);
ae85aab
+extern int matchpathcon(const char *path,
ae85aab
+			mode_t mode,
ae85aab
+			security_context_t *con);
ae85aab
+
ae85aab
+extern int matchmediacon(const char *media,
ae85aab
+		 security_context_t *con);
ae85aab
+
ae85aab
+extern int selinux_getenforcemode(int *enforce);
ae85aab
+extern const char *selinux_policy_root(void);
ae85aab
+extern const char *selinux_binary_policy_path(void);
ae85aab
+extern const char *selinux_failsafe_context_path(void);
ae85aab
+extern const char *selinux_removable_context_path(void);
ae85aab
+extern const char *selinux_default_context_path(void);
ae85aab
+extern const char *selinux_user_contexts_path(void);
ae85aab
+extern const char *selinux_file_context_path(void);
ae85aab
+extern const char *selinux_homedir_context_path(void);
ae85aab
+extern const char *selinux_media_context_path(void);
ae85aab
+extern const char *selinux_contexts_path(void);
ae85aab
+extern const char *selinux_booleans_path(void);
ae85aab
+extern const char *selinux_customizable_types_path(void);
ae85aab
+extern const char *selinux_users_path(void);
ae85aab
+extern const char *selinux_usersconf_path(void);
ae85aab
+extern const char *selinux_translations_path(void);
ae85aab
+extern const char *selinux_path(void);
ae85aab
+extern int selinux_check_passwd_access(access_vector_t requested);
ae85aab
+extern int checkPasswdAccess(access_vector_t requested);
ae85aab
+extern int rpm_execcon(unsigned int verified, 
ae85aab
+		       const char *filename, 
ae85aab
+		       char *const argv[], char *const envp[]);
ae85aab
+
ae85aab
+extern int is_context_customizable (security_context_t scontext);
ae85aab
+
ae85aab
+extern int selinux_trans_to_raw_context(security_context_t trans, 
ae85aab
+					security_context_t *rawp);
ae85aab
+extern int selinux_raw_to_trans_context(security_context_t raw, 
ae85aab
+					security_context_t *transp);
ae85aab
+
ae85aab
+extern int getseuserbyname(const char *linuxuser, char **seuser, char **level);
ae85aab
+
4bb08c5
+}