Blame SOURCES/libsemanage-rhat.patch

e74907
diff --git a/libsemanage/man/man3/semanage_bool_set_active.3 b/libsemanage/man/man3/semanage_bool_set_active.3
e74907
index 026e29d..d868fe8 100644
e74907
--- a/libsemanage/man/man3/semanage_bool_set_active.3
e74907
+++ b/libsemanage/man/man3/semanage_bool_set_active.3
e74907
@@ -40,7 +40,7 @@ This function requires an semanage connection to be established (see
e74907
 ).
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned, and the semanage error callback is invoked, describing the error.
e74907
+In case of failure, \-1 is returned, and the semanage error callback is invoked, describing the error.
e74907
 Otherwise 0 is returned.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/man/man3/semanage_count.3 b/libsemanage/man/man3/semanage_count.3
e74907
index b131cbe..b865a21 100644
e74907
--- a/libsemanage/man/man3/semanage_count.3
e74907
+++ b/libsemanage/man/man3/semanage_count.3
e74907
@@ -33,7 +33,7 @@ This function requires an semanage connection to be established (see
e74907
 )
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned, and the semanage error callback is invoked, describing the error.
e74907
+In case of failure, \-1 is returned, and the semanage error callback is invoked, describing the error.
e74907
 Otherwise a non-negative integer is returned (a commit number). The same number will be returned by all other semanage object read calls until the next commit.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/man/man3/semanage_del.3 b/libsemanage/man/man3/semanage_del.3
e74907
index 5b11ce3..4dd0a77 100644
e74907
--- a/libsemanage/man/man3/semanage_del.3
e74907
+++ b/libsemanage/man/man3/semanage_del.3
e74907
@@ -40,7 +40,7 @@ This function requires an semanage connection to be established (see
e74907
 ).
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned, and the semanage error callback is invoked, describing the error.
e74907
+In case of failure, \-1 is returned, and the semanage error callback is invoked, describing the error.
e74907
 Otherwise 0 is returned.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/man/man3/semanage_exists.3 b/libsemanage/man/man3/semanage_exists.3
e74907
index da401c2..6d68c76 100644
e74907
--- a/libsemanage/man/man3/semanage_exists.3
e74907
+++ b/libsemanage/man/man3/semanage_exists.3
e74907
@@ -38,7 +38,7 @@ This function requires an semanage connection to be established (see
e74907
 )
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned, and the semanage error callback is invoked, describing the error.
e74907
+In case of failure, \-1 is returned, and the semanage error callback is invoked, describing the error.
e74907
 Otherwise a non-negative integer is returned (a commit number). The same number will be returned by all other read calls to the semanage database until the next commit.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/man/man3/semanage_iterate.3 b/libsemanage/man/man3/semanage_iterate.3
e74907
index 8773800..1528164 100644
e74907
--- a/libsemanage/man/man3/semanage_iterate.3
e74907
+++ b/libsemanage/man/man3/semanage_iterate.3
e74907
@@ -31,7 +31,7 @@ if that is necessary.
e74907
 
e74907
 The handler code may not invoke any semanage write requests for the same object type (i.e. modifying the underlying store is not allowed). The iterate function is reentrant only while inside a transaction (see
e74907
 .B semanage_begin_transaction
e74907
-). It is not safe to execute other semanage read or write requests within iterate if not inside a transaction. The handler may return -1 to signal error exit, 0 to signal continue, and 1 to signal successful exit early (the iterate function will stop accordingly). 
e74907
+). It is not safe to execute other semanage read or write requests within iterate if not inside a transaction. The handler may return \-1 to signal error exit, 0 to signal continue, and 1 to signal successful exit early (the iterate function will stop accordingly).
e74907
 
e74907
 .TP
e74907
 .B Parameters:
e74907
@@ -50,7 +50,7 @@ This function requires an semanage connection to be established (see
e74907
 )
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned, and the semanage error callback is invoked, describing the error.
e74907
+In case of failure, \-1 is returned, and the semanage error callback is invoked, describing the error.
e74907
 Otherwise a non-negative integer is returned (a commit number). The same number will be returned by all other semanage object read calls until the next commit.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/man/man3/semanage_list.3 b/libsemanage/man/man3/semanage_list.3
e74907
index 9376702..acc161f 100644
e74907
--- a/libsemanage/man/man3/semanage_list.3
e74907
+++ b/libsemanage/man/man3/semanage_list.3
e74907
@@ -39,7 +39,7 @@ This function requires an semanage connection to be established (see
e74907
 )
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned, and the semanage error callback is invoked, describing the error.
e74907
+In case of failure, \-1 is returned, and the semanage error callback is invoked, describing the error.
e74907
 Otherwise a non-negative integer is returned (a commit number). The same number will be returned by all other semanage object read calls until the next commit.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/man/man3/semanage_modify.3 b/libsemanage/man/man3/semanage_modify.3
e74907
index 04bd801..ee23900 100644
e74907
--- a/libsemanage/man/man3/semanage_modify.3
e74907
+++ b/libsemanage/man/man3/semanage_modify.3
e74907
@@ -42,7 +42,7 @@ This function requires an semanage connection to be established (see
e74907
 ).
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned, and the semanage error callback is invoked, describing the error.
e74907
+In case of failure, \-1 is returned, and the semanage error callback is invoked, describing the error.
e74907
 Otherwise 0 is returned.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/man/man3/semanage_query.3 b/libsemanage/man/man3/semanage_query.3
e74907
index 1a6cdb2..e61c8b8 100644
e74907
--- a/libsemanage/man/man3/semanage_query.3
e74907
+++ b/libsemanage/man/man3/semanage_query.3
e74907
@@ -39,7 +39,7 @@ This function requires an semanage connection to be established (see
e74907
 )
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned, and the semanage error callback is invoked, describing the error.
e74907
+In case of failure, \-1 is returned, and the semanage error callback is invoked, describing the error.
e74907
 Otherwise a non-negative integer is returned (a commit number). The same number will be returned by all other semanage object read calls until the next commit.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/man/man3/semanage_set_root.3 b/libsemanage/man/man3/semanage_set_root.3
e74907
index 2ae0f17..664822e 100644
e74907
--- a/libsemanage/man/man3/semanage_set_root.3
e74907
+++ b/libsemanage/man/man3/semanage_set_root.3
e74907
@@ -15,7 +15,7 @@ Set the alternate root directory for SELinux configuration directory.
e74907
 This function sets an alternate root directory to for SELinux configuration paths to be used by the semanage library.
e74907
 
e74907
 .SH "RETURN VALUE"
e74907
-In case of failure, -1 is returned.
e74907
+In case of failure, \-1 is returned.
e74907
 Otherwise 0 is returned.
e74907
 
e74907
 .SH "SEE ALSO"
e74907
diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
e74907
index c63bb22..edb84cc 100644
e74907
--- a/libsemanage/src/Makefile
e74907
+++ b/libsemanage/src/Makefile
e74907
@@ -92,7 +92,7 @@ $(LIBA): $(OBJS)
e74907
 	$(RANLIB) $@
e74907
 
e74907
 $(LIBSO): $(LOBJS)
e74907
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -lselinux -lbz2 -lustr -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
e74907
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -laudit -lselinux -lbz2 -lustr -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
e74907
 	ln -sf $@ $(TARGET)
e74907
 
e74907
 $(LIBPC): $(LIBPC).in ../VERSION
e74907
diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
e74907
index 3c81d7a..f3b9b5c 100644
e74907
--- a/libsemanage/src/genhomedircon.c
e74907
+++ b/libsemanage/src/genhomedircon.c
e74907
@@ -283,7 +283,7 @@ static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s)
e74907
 	char *rbuf = NULL;
e74907
 	char *path = NULL;
e74907
 	long rbuflen;
e74907
-	uid_t temp, minuid = 500;
e74907
+	uid_t temp, minuid = 500, maxuid = 60000;
e74907
 	int minuid_set = 0;
e74907
 	struct passwd pwstorage, *pwbuf;
e74907
 	struct stat buf;
e74907
@@ -333,6 +333,14 @@ static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s)
e74907
 	free(path);
e74907
 	path = NULL;
e74907
 
e74907
+	path = semanage_findval(PATH_ETC_LOGIN_DEFS, "UID_MAX", NULL);
e74907
+	if (path && *path) {
e74907
+		temp = atoi(path);
e74907
+		maxuid = temp;
e74907
+	}
e74907
+	free(path);
e74907
+	path = NULL;
e74907
+
e74907
 	path = semanage_findval(PATH_ETC_LIBUSER, "LU_UIDNUMBER", "=");
e74907
 	if (path && *path) {
e74907
 		temp = atoi(path);
e74907
@@ -352,7 +360,7 @@ static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s)
e74907
 		goto fail;
e74907
 	setpwent();
e74907
 	while ((retval = getpwent_r(&pwstorage, rbuf, rbuflen, &pwbuf)) == 0) {
e74907
-		if (pwbuf->pw_uid < minuid)
e74907
+		if (pwbuf->pw_uid < minuid || pwbuf->pw_uid > maxuid)
e74907
 			continue;
e74907
 		if (!semanage_list_find(shells, pwbuf->pw_shell))
e74907
 			continue;
e74907
@@ -385,7 +393,7 @@ static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s)
e74907
 
e74907
 			/* NOTE: old genhomedircon printed a warning on match */
e74907
 			if (hand.matched) {
e74907
-				WARN(s->h_semanage, "%s homedir %s or its parent directory conflicts with a file context already specified in the policy.  This usually indicates an incorrectly defined system account.  If it is a system account please make sure its uid is less than %u or its login shell is /sbin/nologin.", pwbuf->pw_name, pwbuf->pw_dir, minuid);
e74907
+				WARN(s->h_semanage, "%s homedir %s or its parent directory conflicts with a file context already specified in the policy.  This usually indicates an incorrectly defined system account.  If it is a system account please make sure its uid is less than %u or greater than %u or its login shell is /sbin/nologin.", pwbuf->pw_name, pwbuf->pw_dir, minuid, maxuid);
e74907
 			} else {
e74907
 				if (semanage_list_push(&homedir_list, path))
e74907
 					goto fail;
e74907
diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
e74907
index 57ef49f..4b040c3 100644
e74907
--- a/libsemanage/src/semanage_store.c
e74907
+++ b/libsemanage/src/semanage_store.c
e74907
@@ -1234,6 +1234,10 @@ static int semanage_install_active(semanage_handle_t * sh)
e74907
 
e74907
 	retval = 0;
e74907
       cleanup:
e74907
+	(void) unlink(active_kernel);
e74907
+	if (symlink(store_pol, active_kernel) < 0) {
e74907
+		ERR(sh, "Unable to create sybolic link from %s to %s error code %d.", active_kernel, store_pol, r);
e74907
+	}
e74907
 	free(storepath);
e74907
 	return retval;
e74907
 }
e74907
diff --git a/libsemanage/src/seusers_local.c b/libsemanage/src/seusers_local.c
e74907
index e7cf12c..f379211 100644
e74907
--- a/libsemanage/src/seusers_local.c
e74907
+++ b/libsemanage/src/seusers_local.c
e74907
@@ -8,27 +8,177 @@ typedef struct semanage_seuser record_t;
e74907
 
e74907
 #include <sepol/policydb.h>
e74907
 #include <sepol/context.h>
e74907
+#include <libaudit.h>
e74907
+#include <errno.h>
e74907
 #include "user_internal.h"
e74907
 #include "seuser_internal.h"
e74907
 #include "handle.h"
e74907
 #include "database.h"
e74907
 #include "debug.h"
e74907
+#include "string.h"
e74907
+#include <stdlib.h>
e74907
+
e74907
+static char *semanage_user_roles(semanage_handle_t * handle, const char *sename) {
e74907
+	char *roles = NULL;
e74907
+	unsigned int num_roles;
e74907
+	size_t i;
e74907
+	size_t size = 0;
e74907
+	const char **roles_arr;
e74907
+	semanage_user_key_t *key = NULL;
e74907
+	semanage_user_t * user;
e74907
+	if (semanage_user_key_create(handle, sename, &key) >= 0) {
e74907
+		if (semanage_user_query(handle, key, &user) >= 0) {
e74907
+			if (semanage_user_get_roles(handle, 
e74907
+						    user, 
e74907
+						    &roles_arr, 
e74907
+						    &num_roles) >= 0) {
e74907
+				for (i = 0; i
e74907
+					size += (strlen(roles_arr[i]) + 1);
e74907
+				}
e74907
+				roles = malloc(size);
e74907
+				if (roles) {
e74907
+					strcpy(roles,roles_arr[0]);
e74907
+					for (i = 1; i
e74907
+						strcat(roles,",");
e74907
+						strcat(roles,roles_arr[i]);
e74907
+					}
e74907
+				}
e74907
+			}
e74907
+			semanage_user_free(user);
e74907
+		}
e74907
+		semanage_user_key_free(key);
e74907
+	}
e74907
+	return roles;
e74907
+}
e74907
+
e74907
+static int semanage_seuser_audit(semanage_handle_t * handle,
e74907
+			  const semanage_seuser_t * seuser, 
e74907
+			  const semanage_seuser_t * previous,
e74907
+			  int audit_type, 
e74907
+			  int success) {
e74907
+	const char *name = NULL;
e74907
+	const char *sename = NULL;
e74907
+	char *roles = NULL;
e74907
+	const char *mls = NULL;
e74907
+	const char *psename = NULL;
e74907
+	const char *pmls = NULL;
e74907
+	char *proles = NULL;
e74907
+	char msg[1024];
e74907
+	const char *sep = "-";
e74907
+	int rc = -1;
e74907
+	strcpy(msg, "login");
e74907
+	if (seuser) {
e74907
+		name = semanage_seuser_get_name(seuser);
e74907
+		sename = semanage_seuser_get_sename(seuser);
e74907
+		mls = semanage_seuser_get_mlsrange(seuser);
e74907
+		roles = semanage_user_roles(handle, sename);
e74907
+	}
e74907
+	if (previous) {
e74907
+		psename = semanage_seuser_get_sename(previous);
e74907
+		pmls = semanage_seuser_get_mlsrange(previous);
e74907
+		proles = semanage_user_roles(handle, psename);
e74907
+	}
e74907
+	if (audit_type != AUDIT_ROLE_REMOVE) {
e74907
+		if (sename && (!psename || strcmp(psename, sename) != 0)) {
e74907
+			strcat(msg,sep);
e74907
+			strcat(msg,"sename");
e74907
+			sep = ",";
e74907
+		}
e74907
+		if (roles && (!proles || strcmp(proles, roles) != 0)) {
e74907
+			strcat(msg,sep);
e74907
+			strcat(msg,"role");
e74907
+			sep = ",";
e74907
+		}
e74907
+		if (mls && (!pmls || strcmp(pmls, mls) != 0)) {
e74907
+			strcat(msg,sep);
e74907
+			strcat(msg,"range");
e74907
+		}
e74907
+	}
e74907
+
e74907
+	int fd = audit_open();
e74907
+	if (fd < 0)
e74907
+	{
e74907
+		/* If kernel doesn't support audit, bail out */
e74907
+		if (errno == EINVAL || errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT) {
e74907
+			rc = 0;
e74907
+			goto err;
e74907
+		}
e74907
+		rc = fd;
e74907
+		goto err;
e74907
+	}
e74907
+	audit_log_semanage_message(fd, audit_type, NULL, msg, name, 0, sename, roles, mls, psename, proles, pmls, NULL, NULL,NULL, success);
e74907
+	rc = 0;
e74907
+err:
e74907
+	audit_close(fd);
e74907
+	free(roles);
e74907
+	free(proles);
e74907
+	return rc;
e74907
+}
e74907
 
e74907
 int semanage_seuser_modify_local(semanage_handle_t * handle,
e74907
 				 const semanage_seuser_key_t * key,
e74907
 				 const semanage_seuser_t * data)
e74907
 {
e74907
-
e74907
+	int rc;
e74907
+	void *callback = (void *) handle->msg_callback;
e74907
 	dbase_config_t *dconfig = semanage_seuser_dbase_local(handle);
e74907
-	return dbase_modify(handle, dconfig, key, data);
e74907
+	const char *sename = semanage_seuser_get_sename(data);
e74907
+	const char *mls_range = semanage_seuser_get_mlsrange(data);
e74907
+	semanage_seuser_t *previous = NULL;
e74907
+	semanage_seuser_t *new = NULL;
e74907
+
e74907
+	if (!sename) {
e74907
+		errno=EINVAL;
e74907
+		return -1;
e74907
+	}
e74907
+	if (semanage_seuser_clone(handle, data, &new) < 0) {
e74907
+		goto err;
e74907
+	}
e74907
+		
e74907
+	if (!mls_range && semanage_mls_enabled(handle)) {
e74907
+		semanage_user_key_t *ukey = NULL;
e74907
+		semanage_user_t *u = NULL;
e74907
+		rc = semanage_user_key_create(handle, sename, &ukey);
e74907
+		if (rc < 0)
e74907
+			goto err;
e74907
+
e74907
+		rc = semanage_user_query(handle, ukey, &u);
e74907
+		semanage_user_key_free(ukey);
e74907
+		if (rc >= 0 ) {
e74907
+			mls_range = semanage_user_get_mlsrange(u);
e74907
+			rc = semanage_seuser_set_mlsrange(handle, new, mls_range);
e74907
+			semanage_user_free(u);
e74907
+		}
e74907
+		if (rc < 0)
e74907
+			goto err;
e74907
+	}
e74907
+
e74907
+	handle->msg_callback = NULL;
e74907
+	(void) semanage_seuser_query(handle, key, &previous);
e74907
+	handle->msg_callback = callback;
e74907
+	rc = dbase_modify(handle, dconfig, key, new);
e74907
+	if (semanage_seuser_audit(handle, new, previous, AUDIT_ROLE_ASSIGN, rc == 0) < 0) 
e74907
+		rc = -1;
e74907
+err:
e74907
+	if (previous)
e74907
+		semanage_seuser_free(previous);
e74907
+	semanage_seuser_free(new);
e74907
+	return rc;
e74907
 }
e74907
 
e74907
 int semanage_seuser_del_local(semanage_handle_t * handle,
e74907
 			      const semanage_seuser_key_t * key)
e74907
 {
e74907
-
e74907
+	int rc;
e74907
+	semanage_seuser_t *seuser = NULL;
e74907
 	dbase_config_t *dconfig = semanage_seuser_dbase_local(handle);
e74907
-	return dbase_del(handle, dconfig, key);
e74907
+	rc = dbase_del(handle, dconfig, key);
e74907
+	semanage_seuser_query(handle, key, &seuser);
e74907
+	if (semanage_seuser_audit(handle, NULL, seuser, AUDIT_ROLE_REMOVE, rc == 0) < 0) 
e74907
+		rc = -1;
e74907
+	if (seuser)
e74907
+		semanage_seuser_free(seuser);
e74907
+	return rc;
e74907
 }
e74907
 
e74907
 int semanage_seuser_query_local(semanage_handle_t * handle,
e74907
diff --git a/libsemanage/src/users_local.c b/libsemanage/src/users_local.c
e74907
index 8742ca1..b78ad0e 100644
e74907
--- a/libsemanage/src/users_local.c
e74907
+++ b/libsemanage/src/users_local.c
e74907
@@ -6,9 +6,14 @@ typedef struct semanage_user_key record_key_t;
e74907
 typedef struct semanage_user record_t;
e74907
 #define DBASE_RECORD_DEFINED
e74907
 
e74907
+#include <string.h>
e74907
+#include <stdlib.h>
e74907
 #include "user_internal.h"
e74907
+#include "seuser_internal.h"
e74907
 #include "handle.h"
e74907
 #include "database.h"
e74907
+#include "errno.h"
e74907
+#include "debug.h"
e74907
 
e74907
 int semanage_user_modify_local(semanage_handle_t * handle,
e74907
 			       const semanage_user_key_t * key,
e74907
@@ -19,9 +24,43 @@ int semanage_user_modify_local(semanage_handle_t * handle,
e74907
 	return dbase_modify(handle, dconfig, key, data);
e74907
 }
e74907
 
e74907
+static int lookup_seuser(semanage_handle_t * handle, const semanage_user_key_t *k) {
e74907
+	semanage_user_t *user;
e74907
+	semanage_seuser_t **records;
e74907
+	const char *name;
e74907
+	const char *sename;
e74907
+	unsigned int count;
e74907
+	size_t i;
e74907
+	int rc = 0;
e74907
+	if (semanage_user_query(handle, k, &user) < 0)
e74907
+		return 0;
e74907
+	name = semanage_user_get_name(user);
e74907
+	semanage_seuser_list_local(handle,
e74907
+				   &records,
e74907
+				   &count);
e74907
+	for(i=0; i
e74907
+		sename = semanage_seuser_get_sename(records[i]);
e74907
+		if (strcmp(name, sename) == 0) {
e74907
+			errno = EINVAL;
e74907
+			ERR(handle, "%s is being used by %s login record", 
e74907
+			    sename, semanage_seuser_get_name(records[i]));
e74907
+			rc = -1;
e74907
+		}
e74907
+	}
e74907
+	for(i=0; i
e74907
+		semanage_seuser_free(records[i]);
e74907
+	free(records);
e74907
+	semanage_user_free(user);
e74907
+	if (rc)
e74907
+		errno = EINVAL;
e74907
+	return rc;
e74907
+}
e74907
+
e74907
 int semanage_user_del_local(semanage_handle_t * handle,
e74907
 			    const semanage_user_key_t * key)
e74907
 {
e74907
+	if (lookup_seuser(handle, key))
e74907
+		return -1;
e74907
 
e74907
 	dbase_config_t *dconfig = semanage_user_dbase_local(handle);
e74907
 	return dbase_del(handle, dconfig, key);
e74907
diff --git a/libsemanage/src/utilities.c b/libsemanage/src/utilities.c
e74907
index 349a4be..a340fc8 100644
e74907
--- a/libsemanage/src/utilities.c
e74907
+++ b/libsemanage/src/utilities.c
e74907
@@ -140,6 +140,10 @@ int semanage_list_push(semanage_list_t ** list, char *data)
e74907
 
e74907
 	if (!data)
e74907
 		return EINVAL;
e74907
+
e74907
+	if (semanage_list_find(*list, data) != NULL)
e74907
+		return 0;
e74907
+
e74907
 	if (!(temp = malloc(sizeof(semanage_list_t))))
e74907
 		return ENOMEM;
e74907
 
e74907
diff --git a/libsemanage/tests/Makefile b/libsemanage/tests/Makefile
e74907
index f92455c..ad1869b 100644
e74907
--- a/libsemanage/tests/Makefile
e74907
+++ b/libsemanage/tests/Makefile
e74907
@@ -13,7 +13,7 @@ EXECUTABLE = libsemanage-tests
e74907
 CC = gcc
e74907
 CFLAGS = -c -g -o0 -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute -Wno-unused-parameter
e74907
 INCLUDE = -I$(TESTSRC) -I$(TESTSRC)/../include
e74907
-LDFLAGS = -lcunit -lustr -lbz2
e74907
+LDFLAGS = -lcunit -lustr -lbz2 -lpthread
e74907
 OBJECTS = $(SOURCES:.c=.o) 
e74907
 
e74907
 all: $(EXECUTABLE)