2f49e06
diff --git libselinux-2.7/Makefile libselinux-2.7/Makefile
f2f46ec
index 1ecab17..16531fe 100644
2f49e06
--- libselinux-2.7/Makefile
2f49e06
+++ libselinux-2.7/Makefile
f2f46ec
@@ -21,13 +21,14 @@ export DISABLE_SETRANS DISABLE_RPM DISABLE_FLAGS ANDROID_HOST
e58e944
 
f2f46ec
 USE_PCRE2 ?= n
f2f46ec
 ifeq ($(USE_PCRE2),y)
f2f46ec
-	PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 $(shell $(PKG_CONFIG) --cflags libpcre2-8)
f2f46ec
-	PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs libpcre2-8)
f2f46ec
+	PCRE_MODULE := libpcre2-8
f2f46ec
+	PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8
f2f46ec
 else
f2f46ec
-	PCRE_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcre)
f2f46ec
-	PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs libpcre)
f2f46ec
+	PCRE_MODULE := libpcre
f2f46ec
 endif
f2f46ec
-export PCRE_CFLAGS PCRE_LDLIBS
f2f46ec
+PCRE_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PCRE_MODULE))
f2f46ec
+PCRE_LDLIBS := $(shell $(PKG_CONFIG) --libs $(PCRE_MODULE))
f2f46ec
+export PCRE_MODULE PCRE_CFLAGS PCRE_LDLIBS
f2f46ec
 
f2f46ec
 OS := $(shell uname)
f2f46ec
 export OS
e46a333
diff --git libselinux-2.7/include/Makefile libselinux-2.7/include/Makefile
e46a333
index 757a6c9..8ab9ce9 100644
e46a333
--- libselinux-2.7/include/Makefile
e46a333
+++ libselinux-2.7/include/Makefile
e46a333
@@ -1,12 +1,12 @@
e46a333
 # Installation directories.
e46a333
-PREFIX ?= $(DESTDIR)/usr
e46a333
-INCDIR ?= $(PREFIX)/include/selinux
e46a333
+PREFIX ?= /usr
e46a333
+INCDIR = $(PREFIX)/include/selinux
e46a333
 
e46a333
 all:
e46a333
 
e46a333
 install: all
e46a333
-	test -d $(INCDIR) || install -m 755 -d $(INCDIR)
e46a333
-	install -m 644 $(wildcard selinux/*.h) $(INCDIR)
e46a333
+	test -d $(DESTDIR)$(INCDIR) || install -m 755 -d $(DESTDIR)$(INCDIR)
e46a333
+	install -m 644 $(wildcard selinux/*.h) $(DESTDIR)$(INCDIR)
e46a333
 
e46a333
 relabel:
e46a333
 
e46a333
diff --git libselinux-2.7/man/Makefile libselinux-2.7/man/Makefile
e46a333
index 0643e6a..f634d1f 100644
e46a333
--- libselinux-2.7/man/Makefile
e46a333
+++ libselinux-2.7/man/Makefile
e46a333
@@ -1,17 +1,18 @@
e46a333
 # Installation directories.
e46a333
-MAN8DIR ?= $(DESTDIR)/usr/share/man/man8
e46a333
-MAN5DIR ?= $(DESTDIR)/usr/share/man/man5
e46a333
-MAN3DIR ?= $(DESTDIR)/usr/share/man/man3
e46a333
+PREFIX	?= /usr
e46a333
+MAN8DIR ?= $(PREFIX)/share/man/man8
e46a333
+MAN5DIR ?= $(PREFIX)/share/man/man5
e46a333
+MAN3DIR ?= $(PREFIX)/share/man/man3
e46a333
 
e46a333
 all:
e46a333
 
e46a333
 install: all
e46a333
-	mkdir -p $(MAN3DIR)
e46a333
-	mkdir -p $(MAN5DIR)
e46a333
-	mkdir -p $(MAN8DIR)
e46a333
-	install -m 644 man3/*.3 $(MAN3DIR)
e46a333
-	install -m 644 man5/*.5 $(MAN5DIR)
e46a333
-	install -m 644 man8/*.8 $(MAN8DIR)
e46a333
+	mkdir -p $(DESTDIR)$(MAN3DIR)
e46a333
+	mkdir -p $(DESTDIR)$(MAN5DIR)
e46a333
+	mkdir -p $(DESTDIR)$(MAN8DIR)
e46a333
+	install -m 644 man3/*.3 $(DESTDIR)$(MAN3DIR)
e46a333
+	install -m 644 man5/*.5 $(DESTDIR)$(MAN5DIR)
e46a333
+	install -m 644 man8/*.8 $(DESTDIR)$(MAN8DIR)
e46a333
 
e46a333
 relabel:
e46a333
 
e46a333
diff --git libselinux-2.7/man/man5/removable_context.5 libselinux-2.7/man/man5/removable_context.5
e46a333
index 60aaa93..f16e8bd 100644
e46a333
--- libselinux-2.7/man/man5/removable_context.5
e46a333
+++ libselinux-2.7/man/man5/removable_context.5
e46a333
@@ -3,8 +3,7 @@
e46a333
 removable_context \- The SELinux removable devices context configuration file
e46a333
 .
e46a333
 .SH "DESCRIPTION"
e46a333
-This file contains the default label that should be used for removable devices that are not defined in the \fImedia\fR file (that is described in
e46a333
-.BR selabel_media "(5)). "
e46a333
+This file contains the default label that should be used for removable devices.
e46a333
 .sp
e46a333
 .BR selinux_removable_context_path "(3) "
e46a333
 will return the active policy path to this file. The default removable context file is:
e46a333
@@ -34,4 +33,4 @@ A user, role, type and optional range (for MCS/MLS) separated by colons (:) that
e46a333
 system_u:object_r:removable_t:s0
e46a333
 .
e46a333
 .SH "SEE ALSO"
e46a333
-.BR selinux "(8), " selinux_removable_context_path "(3), " selabel_media "(5), " selinux_config "(5) "
e46a333
+.BR selinux "(8), " selinux_removable_context_path "(3), " selinux_config "(5) "
e46a333
diff --git libselinux-2.7/man/man5/selabel_media.5 libselinux-2.7/man/man5/selabel_media.5
e46a333
index 395ed0e..b7c28e3 100644
e46a333
--- libselinux-2.7/man/man5/selabel_media.5
e46a333
+++ libselinux-2.7/man/man5/selabel_media.5
e46a333
@@ -52,8 +52,6 @@ The default media contexts file is:
e46a333
 .RE
e46a333
 .sp
e46a333
 Where \fI{SELINUXTYPE}\fR is the entry from the selinux configuration file \fIconfig\fR (see \fBselinux_config\fR(5)).
e46a333
-.sp
e46a333
-Should there not be a valid entry in the \fImedia\fR file, then the default \fIremovable_context\fR file will be read (see \fBremovable_context\fR(5)).
e46a333
 .
e46a333
 .SH "FILE FORMAT"
e46a333
 Each line within the \fImedia\fR file is as follows:
e46a333
@@ -90,4 +88,4 @@ this is not set, then it is possible for an invalid context to be returned.
e46a333
 .SH "SEE ALSO"
e46a333
 .ad l
e46a333
 .nh
e46a333
-.BR selinux "(8), " selabel_open "(3), " selabel_lookup "(3), " selabel_stats "(3), " selabel_close "(3), " selinux_set_callback "(3), " selinux_media_context_path "(3), " freecon "(3), " selinux_config "(5), " removable_context "(5) "
e46a333
+.BR selinux "(8), " selabel_open "(3), " selabel_lookup "(3), " selabel_stats "(3), " selabel_close "(3), " selinux_set_callback "(3), " selinux_media_context_path "(3), " freecon "(3), " selinux_config "(5) "
2f49e06
diff --git libselinux-2.7/man/man8/selinux.8 libselinux-2.7/man/man8/selinux.8
2f49e06
index e37aee6..bf23b65 100644
2f49e06
--- libselinux-2.7/man/man8/selinux.8
2f49e06
+++ libselinux-2.7/man/man8/selinux.8
e58e944
@@ -91,11 +91,13 @@ This manual page was written by Dan Walsh <dwalsh@redhat.com>.
e58e944
 .BR sepolicy (8),
e58e944
 .BR system-config-selinux (8),
e58e944
 .BR togglesebool (8),
e58e944
-.BR restorecon (8),
e58e944
 .BR fixfiles (8),
e58e944
+.BR restorecon (8),
e58e944
 .BR setfiles (8),
e58e944
 .BR semanage (8),
2f49e06
 .BR sepolicy (8)
2f49e06
+.BR seinfo (8),
2f49e06
+.BR sesearch (8)
e58e944
 
e58e944
 Every confined service on the system has a man page in the following format:
e58e944
 .br
f2f46ec
diff --git libselinux-2.7/src/Makefile libselinux-2.7/src/Makefile
680bec3
index 2408fae..8af04aa 100644
f2f46ec
--- libselinux-2.7/src/Makefile
f2f46ec
+++ libselinux-2.7/src/Makefile
e46a333
@@ -8,19 +8,17 @@ RUBYPREFIX ?= $(notdir $(RUBY))
e46a333
 PKG_CONFIG ?= pkg-config
e46a333
 
e46a333
 # Installation directories.
e46a333
-PREFIX ?= $(DESTDIR)/usr
e46a333
+PREFIX ?= /usr
e46a333
 LIBDIR ?= $(PREFIX)/lib
e46a333
-SHLIBDIR ?= $(DESTDIR)/lib
e46a333
+SHLIBDIR ?= /lib
e46a333
 INCLUDEDIR ?= $(PREFIX)/include
e46a333
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
e46a333
 PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
e46a333
-PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
680bec3
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(plat_specific=1, prefix='$(PREFIX)'))")
e46a333
 PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in imp.get_suffixes() if t == imp.C_EXTENSION][0])')
e46a333
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
e46a333
 RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
e46a333
-RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
e46a333
-LIBBASE ?= $(shell basename $(LIBDIR))
e46a333
-LIBSEPOLA ?= $(LIBDIR)/libsepol.a
e46a333
+RUBYINSTALL ?= $(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
e46a333
 
e46a333
 VERSION = $(shell cat ../VERSION)
e46a333
 LIBVERSION = 1
e46a333
@@ -50,6 +48,13 @@ LIBSO=$(TARGET).$(LIBVERSION)
e46a333
 AUDIT2WHYLOBJ=$(PYPREFIX)audit2why.lo
e46a333
 AUDIT2WHYSO=$(PYPREFIX)audit2why.so
e46a333
 
e46a333
+# If no specific libsepol.a is specified, fall back on LDFLAGS search path
e46a333
+# Otherwise, as $(LIBSEPOLA) already appears in the dependencies, there
e46a333
+# is no need to define a value for LDLIBS_LIBSEPOLA
e46a333
+ifeq ($(LIBSEPOLA),)
e46a333
+        LDLIBS_LIBSEPOLA := -l:libsepol.a
e46a333
+endif
e46a333
+
e46a333
 GENERATED=$(SWIGCOUT) $(SWIGRUBYCOUT) selinuxswig_python_exception.i
e46a333
 SRCS= $(filter-out $(GENERATED) audit2why.c, $(sort $(wildcard *.c)))
e46a333
 
e46a333
@@ -148,7 +153,7 @@ $(LIBSO): $(LOBJS)
f2f46ec
 	ln -sf $@ $(TARGET)
f2f46ec
 
f2f46ec
 $(LIBPC): $(LIBPC).in ../VERSION
f2f46ec
-	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
e46a333
+	sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBDIR):; s:@includedir@:$(INCLUDEDIR):; s:@PCRE_MODULE@:$(PCRE_MODULE):' < $< > $@
f2f46ec
 
f2f46ec
 selinuxswig_python_exception.i: ../include/selinux/selinux.h
f2f46ec
 	bash -e exception.sh > $@ || (rm -f $@ ; false)
e46a333
@@ -157,7 +162,7 @@ $(AUDIT2WHYLOBJ): audit2why.c
e46a333
 	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
e46a333
 
e46a333
 $(AUDIT2WHYSO): $(AUDIT2WHYLOBJ) $(LIBSEPOLA)
e46a333
-	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(PYLIBS)
e46a333
+	$(CC) $(CFLAGS) $(LDFLAGS) -L. -shared -o $@ $^ -lselinux $(LDLIBS_LIBSEPOLA) $(PYLIBS)
e46a333
 
e46a333
 %.o:  %.c policy.h
e46a333
 	$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
e46a333
@@ -177,26 +182,26 @@ swigify: $(SWIGIF)
e46a333
 	$(SWIG) $<
e46a333
 
e46a333
 install: all 
e46a333
-	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
e46a333
-	install -m 644 $(LIBA) $(LIBDIR)
e46a333
-	test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
e46a333
-	install -m 755 $(LIBSO) $(SHLIBDIR)
e46a333
-	test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
e46a333
-	install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
e46a333
-	ln -sf --relative $(SHLIBDIR)/$(LIBSO) $(LIBDIR)/$(TARGET)
e46a333
+	test -d $(DESTDIR)$(LIBDIR) || install -m 755 -d $(DESTDIR)$(LIBDIR)
e46a333
+	install -m 644 $(LIBA) $(DESTDIR)$(LIBDIR)
e46a333
+	test -d $(DESTDIR)$(SHLIBDIR) || install -m 755 -d $(DESTDIR)$(SHLIBDIR)
e46a333
+	install -m 755 $(LIBSO) $(DESTDIR)$(SHLIBDIR)
e46a333
+	test -d $(DESTDIR)$(LIBDIR)/pkgconfig || install -m 755 -d $(DESTDIR)$(LIBDIR)/pkgconfig
e46a333
+	install -m 644 $(LIBPC) $(DESTDIR)$(LIBDIR)/pkgconfig
e46a333
+	ln -sf --relative $(DESTDIR)$(SHLIBDIR)/$(LIBSO) $(DESTDIR)$(LIBDIR)/$(TARGET)
e46a333
 
e46a333
 install-pywrap: pywrap
e46a333
-	test -d $(PYSITEDIR)/selinux || install -m 755 -d $(PYSITEDIR)/selinux
e46a333
-	install -m 755 $(SWIGSO) $(PYSITEDIR)/_selinux$(PYCEXT)
e46a333
-	install -m 755 $(AUDIT2WHYSO) $(PYSITEDIR)/selinux/audit2why$(PYCEXT)
e46a333
-	install -m 644 $(SWIGPYOUT) $(PYSITEDIR)/selinux/__init__.py
680bec3
+	test -d $(DESTDIR)$(PYTHONLIBDIR)/selinux || install -m 755 -d $(DESTDIR)$(PYTHONLIBDIR)/selinux
680bec3
+	install -m 755 $(SWIGSO) $(DESTDIR)$(PYTHONLIBDIR)/_selinux$(PYCEXT)
680bec3
+	install -m 755 $(AUDIT2WHYSO) $(DESTDIR)$(PYTHONLIBDIR)/selinux/audit2why$(PYCEXT)
680bec3
+	install -m 644 $(SWIGPYOUT) $(DESTDIR)$(PYTHONLIBDIR)/selinux/__init__.py
e46a333
 
e46a333
 install-rubywrap: rubywrap
e46a333
-	test -d $(RUBYINSTALL) || install -m 755 -d $(RUBYINSTALL) 
e46a333
-	install -m 755 $(SWIGRUBYSO) $(RUBYINSTALL)/selinux.so
e46a333
+	test -d $(DESTDIR)$(RUBYINSTALL) || install -m 755 -d $(DESTDIR)$(RUBYINSTALL) 
e46a333
+	install -m 755 $(SWIGRUBYSO) $(DESTDIR)$(RUBYINSTALL)/selinux.so
e46a333
 
e46a333
 relabel:
e46a333
-	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
e46a333
+	/sbin/restorecon $(DESTDIR)$(SHLIBDIR)/$(LIBSO)
e46a333
 
e46a333
 clean-pywrap:
e46a333
 	-rm -f $(SWIGLOBJ) $(SWIGSO) $(AUDIT2WHYLOBJ) $(AUDIT2WHYSO)
f2f46ec
diff --git libselinux-2.7/src/avc.c libselinux-2.7/src/avc.c
f2f46ec
index 96b2678..5230efd 100644
f2f46ec
--- libselinux-2.7/src/avc.c
f2f46ec
+++ libselinux-2.7/src/avc.c
f2f46ec
@@ -4,7 +4,7 @@
f2f46ec
  * Author : Eamon Walsh <ewalsh@epoch.ncsc.mil>
f2f46ec
  *
f2f46ec
  * Derived from the kernel AVC implementation by
f2f46ec
- * Stephen Smalley <sds@epoch.ncsc.mil> and 
f2f46ec
+ * Stephen Smalley <sds@tycho.nsa.gov> and
f2f46ec
  * James Morris <jmorris@redhat.com>.
f2f46ec
  */
f2f46ec
 #include <selinux/avc.h>
2f49e06
diff --git libselinux-2.7/src/avc_sidtab.c libselinux-2.7/src/avc_sidtab.c
e58e944
index 9669264..c775430 100644
2f49e06
--- libselinux-2.7/src/avc_sidtab.c
2f49e06
+++ libselinux-2.7/src/avc_sidtab.c
e58e944
@@ -81,6 +81,11 @@ sidtab_context_to_sid(struct sidtab *s,
e58e944
 	int hvalue, rc = 0;
e58e944
 	struct sidtab_node *cur;
e58e944
 
e58e944
+	if (! ctx) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
 	*sid = NULL;
e58e944
 	hvalue = sidtab_hash(ctx);
e58e944
 
2f49e06
diff --git libselinux-2.7/src/booleans.c libselinux-2.7/src/booleans.c
2f49e06
index 1da55bf..604c588 100644
2f49e06
--- libselinux-2.7/src/booleans.c
2f49e06
+++ libselinux-2.7/src/booleans.c
7f0ad32
@@ -55,6 +55,7 @@ int security_get_boolean_names(char ***names, int *len)
7f0ad32
 	snprintf(path, sizeof path, "%s%s", selinux_mnt, SELINUX_BOOL_DIR);
7f0ad32
 	*len = scandir(path, &namelist, &filename_select, alphasort);
7f0ad32
 	if (*len <= 0) {
7f0ad32
+		errno = ENOENT;
7f0ad32
 		return -1;
7f0ad32
 	}
7f0ad32
 
2f49e06
diff --git libselinux-2.7/src/canonicalize_context.c libselinux-2.7/src/canonicalize_context.c
2f49e06
index ba4c9a2..c815872 100644
2f49e06
--- libselinux-2.7/src/canonicalize_context.c
2f49e06
+++ libselinux-2.7/src/canonicalize_context.c
e58e944
@@ -17,6 +17,11 @@ int security_canonicalize_context_raw(const char * con,
e58e944
 	size_t size;
e58e944
 	int fd, ret;
e58e944
 
e58e944
+	if (! con) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
 	if (!selinux_mnt) {
e58e944
 		errno = ENOENT;
e58e944
 		return -1;
2f49e06
diff --git libselinux-2.7/src/check_context.c libselinux-2.7/src/check_context.c
2f49e06
index 8a7997f..5be8434 100644
2f49e06
--- libselinux-2.7/src/check_context.c
2f49e06
+++ libselinux-2.7/src/check_context.c
e58e944
@@ -14,6 +14,11 @@ int security_check_context_raw(const char * con)
e58e944
 	char path[PATH_MAX];
e58e944
 	int fd, ret;
e58e944
 
e58e944
+	if (! con) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
 	if (!selinux_mnt) {
e58e944
 		errno = ENOENT;
e58e944
 		return -1;
2f49e06
diff --git libselinux-2.7/src/compute_av.c libselinux-2.7/src/compute_av.c
2f49e06
index 1d05e7b..d9095cc 100644
2f49e06
--- libselinux-2.7/src/compute_av.c
2f49e06
+++ libselinux-2.7/src/compute_av.c
e58e944
@@ -26,6 +26,11 @@ int security_compute_av_flags_raw(const char * scon,
e58e944
 		return -1;
e58e944
 	}
e58e944
 
e58e944
+	if ((! scon) || (! tcon)) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
 	snprintf(path, sizeof path, "%s/access", selinux_mnt);
2f49e06
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e944
 	if (fd < 0)
2f49e06
diff --git libselinux-2.7/src/compute_create.c libselinux-2.7/src/compute_create.c
2f49e06
index 0975aea..3e6a48c 100644
2f49e06
--- libselinux-2.7/src/compute_create.c
2f49e06
+++ libselinux-2.7/src/compute_create.c
e58e944
@@ -64,6 +64,11 @@ int security_compute_create_name_raw(const char * scon,
e58e944
 		return -1;
e58e944
 	}
e58e944
 
e58e944
+	if ((! scon) || (! tcon)) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
 	snprintf(path, sizeof path, "%s/create", selinux_mnt);
2f49e06
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e944
 	if (fd < 0)
2f49e06
diff --git libselinux-2.7/src/compute_member.c libselinux-2.7/src/compute_member.c
2f49e06
index 4e2d221..d1dd977 100644
2f49e06
--- libselinux-2.7/src/compute_member.c
2f49e06
+++ libselinux-2.7/src/compute_member.c
e58e944
@@ -25,6 +25,11 @@ int security_compute_member_raw(const char * scon,
e58e944
 		return -1;
e58e944
 	}
e58e944
 
e58e944
+	if ((! scon) || (! tcon)) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
 	snprintf(path, sizeof path, "%s/member", selinux_mnt);
2f49e06
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e944
 	if (fd < 0)
2f49e06
diff --git libselinux-2.7/src/compute_relabel.c libselinux-2.7/src/compute_relabel.c
2f49e06
index 49f77ef..c3db7c0 100644
2f49e06
--- libselinux-2.7/src/compute_relabel.c
2f49e06
+++ libselinux-2.7/src/compute_relabel.c
e58e944
@@ -25,6 +25,11 @@ int security_compute_relabel_raw(const char * scon,
e58e944
 		return -1;
e58e944
 	}
e58e944
 
e58e944
+	if ((! scon) || (! tcon)) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
 	snprintf(path, sizeof path, "%s/relabel", selinux_mnt);
2f49e06
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e944
 	if (fd < 0)
2f49e06
diff --git libselinux-2.7/src/compute_user.c libselinux-2.7/src/compute_user.c
2f49e06
index 7b88121..401fd10 100644
2f49e06
--- libselinux-2.7/src/compute_user.c
2f49e06
+++ libselinux-2.7/src/compute_user.c
e58e944
@@ -24,6 +24,11 @@ int security_compute_user_raw(const char * scon,
e58e944
 		return -1;
e58e944
 	}
e58e944
 
e58e944
+	if (! scon) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
 	snprintf(path, sizeof path, "%s/user", selinux_mnt);
2f49e06
 	fd = open(path, O_RDWR | O_CLOEXEC);
e58e944
 	if (fd < 0)
2f49e06
diff --git libselinux-2.7/src/fsetfilecon.c libselinux-2.7/src/fsetfilecon.c
e58e944
index 52707d0..0cbe12d 100644
2f49e06
--- libselinux-2.7/src/fsetfilecon.c
2f49e06
+++ libselinux-2.7/src/fsetfilecon.c
e58e944
@@ -9,8 +9,12 @@
e58e944
 
e58e944
 int fsetfilecon_raw(int fd, const char * context)
e58e944
 {
e58e944
-	int rc = fsetxattr(fd, XATTR_NAME_SELINUX, context, strlen(context) + 1,
e58e944
-			 0);
e58e944
+	int rc;
e58e944
+	if (! context) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+	rc = fsetxattr(fd, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0);
e58e944
 	if (rc < 0 && errno == ENOTSUP) {
e58e944
 		char * ccontext = NULL;
e58e944
 		int err = errno;
f2f46ec
diff --git libselinux-2.7/src/libselinux.pc.in libselinux-2.7/src/libselinux.pc.in
e46a333
index 2cd04d3..7c66b1f 100644
f2f46ec
--- libselinux-2.7/src/libselinux.pc.in
f2f46ec
+++ libselinux-2.7/src/libselinux.pc.in
e46a333
@@ -1,12 +1,12 @@
e46a333
 prefix=@prefix@
e46a333
 exec_prefix=${prefix}
e46a333
-libdir=${exec_prefix}/@libdir@
e46a333
+libdir=@libdir@
e46a333
 includedir=@includedir@
e46a333
 
e46a333
 Name: libselinux
f2f46ec
 Description: SELinux utility library
f2f46ec
 Version: @VERSION@
f2f46ec
 URL: http://userspace.selinuxproject.org/
f2f46ec
-Requires.private: libsepol libpcre
f2f46ec
+Requires.private: libsepol @PCRE_MODULE@
f2f46ec
 Libs: -L${libdir} -lselinux
f2f46ec
 Cflags: -I${includedir}
2f49e06
diff --git libselinux-2.7/src/lsetfilecon.c libselinux-2.7/src/lsetfilecon.c
e58e944
index 1d3b28a..ea6d70b 100644
2f49e06
--- libselinux-2.7/src/lsetfilecon.c
2f49e06
+++ libselinux-2.7/src/lsetfilecon.c
e58e944
@@ -9,8 +9,13 @@
e58e944
 
e58e944
 int lsetfilecon_raw(const char *path, const char * context)
e58e944
 {
e58e944
-	int rc = lsetxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1,
e58e944
-			 0);
e58e944
+	int rc;
e58e944
+	if (! context) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+
e58e944
+	rc = lsetxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0);
e58e944
 	if (rc < 0 && errno == ENOTSUP) {
e58e944
 		char * ccontext = NULL;
e58e944
 		int err = errno;
2f49e06
diff --git libselinux-2.7/src/setfilecon.c libselinux-2.7/src/setfilecon.c
e58e944
index d05969c..3f0200e 100644
2f49e06
--- libselinux-2.7/src/setfilecon.c
2f49e06
+++ libselinux-2.7/src/setfilecon.c
e58e944
@@ -9,8 +9,12 @@
e58e944
 
e58e944
 int setfilecon_raw(const char *path, const char * context)
e58e944
 {
e58e944
-	int rc = setxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1,
e58e944
-			0);
e58e944
+	int rc;
e58e944
+	if (! context) {
e58e944
+		errno=EINVAL;
e58e944
+		return -1;
e58e944
+	}
e58e944
+	rc = setxattr(path, XATTR_NAME_SELINUX, context, strlen(context) + 1, 0);
e58e944
 	if (rc < 0 && errno == ENOTSUP) {
e58e944
 		char * ccontext = NULL;
e58e944
 		int err = errno;
e46a333
diff --git libselinux-2.7/utils/Makefile libselinux-2.7/utils/Makefile
e46a333
index eb4851a..d06ffd6 100644
e46a333
--- libselinux-2.7/utils/Makefile
e46a333
+++ libselinux-2.7/utils/Makefile
e46a333
@@ -1,8 +1,6 @@
e46a333
 # Installation directories.
e46a333
-PREFIX ?= $(DESTDIR)/usr
e46a333
-LIBDIR ?= $(PREFIX)/lib
e46a333
+PREFIX ?= /usr
e46a333
 SBINDIR ?= $(PREFIX)/sbin
e46a333
-INCLUDEDIR ?= $(PREFIX)/include
e46a333
 
e46a333
 OS ?= $(shell uname)
e46a333
 
e46a333
@@ -63,8 +61,8 @@ sefcontext_compile: sefcontext_compile.o ../src/regex.o
e46a333
 all: $(TARGETS)
e46a333
 
e46a333
 install: all
e46a333
-	-mkdir -p $(SBINDIR)
e46a333
-	install -m 755 $(TARGETS) $(SBINDIR)
e46a333
+	-mkdir -p $(DESTDIR)$(SBINDIR)
e46a333
+	install -m 755 $(TARGETS) $(DESTDIR)$(SBINDIR)
e46a333
 
e46a333
 clean:
e46a333
 	rm -f $(TARGETS) *.o *~
2f49e06
diff --git libselinux-2.7/utils/matchpathcon.c libselinux-2.7/utils/matchpathcon.c
2f49e06
index 67e4a43..9756d7d 100644
2f49e06
--- libselinux-2.7/utils/matchpathcon.c
2f49e06
+++ libselinux-2.7/utils/matchpathcon.c
2f49e06
@@ -14,7 +14,7 @@
2f49e06
 static __attribute__ ((__noreturn__)) void usage(const char *progname)
7f0ad32
 {
7f0ad32
 	fprintf(stderr,
7f0ad32
-		"usage:  %s [-N] [-n] [-f file_contexts] [ -P policy_root_path ] [-p prefix] [-Vq] path...\n",
7f0ad32
+		"usage:  %s [-V] [-N] [-n] [-m type] [-f file_contexts_file] [-p prefix] [-P policy_root_path] filepath...\n",
7f0ad32
 		progname);
7f0ad32
 	exit(1);
7f0ad32
 }