Skip to contentSkip to conversation

move module read/write code into libsepol

PATCH In review Jason Tang 2 participants 3 messages Aug 2, 2005 SELinux security module

lore
Share & tools
lore

Jason Tang

author
#0 lore raw

PATCH 1/1 move module read/write code into libsepol

With the newly agreed upon use of libsepol as "internal representation of data" it has become apparant that module read/write code really belongs in libsepol and not in libsemanage. The following patch moves that logic into a new file libsepol/module.c. It also corrects an outstanding error, by adding checkpolicy/test and policycoreutils/semodule_package into their parents' Makefile.

Signature · 1 line
Jason Tang / [email protected]
checkpolicy/Makefile renamed from selinux-usr/checkpolicy/Makefile +3 -1
diff -purN nsa/selinux-usr/checkpolicy/Makefile nsa-selinux-usr/checkpolicy/Makefile
@@ -19,6 +19,7 @@ CHECKMODOBJS = $(CHECKOBJS) checkmodule.
 LDLIBS=$(LIBDIR)/libsepol.a -lfl
 
 all:  $(TARGETS)
+	$(MAKE) -C test
 
 checkpolicy: $(CHECKPOLOBJS)
 
@@ -50,5 +51,6 @@ relabel: install
 	/sbin/restorecon $(BINDIR)/checkmodule
 
 clean:
-	-rm -f $(TARGETS) $(CHECKPOLOBJS) $(CHECKMODOBJS) y.tab.c y.tab.h lex.yy.c 
+	-rm -f $(TARGETS) $(CHECKPOLOBJS) $(CHECKMODOBJS) y.tab.c y.tab.h lex.yy.c
+	$(MAKE) -C test clean
 
checkpolicy/test/dismod.c renamed from selinux-usr/checkpolicy/test/dismod.c +4 -4
diff -purN nsa/selinux-usr/checkpolicy/test/dismod.c nsa-selinux-usr/checkpolicy/test/dismod.c
@@ -32,7 +32,7 @@
 #include <sepol/conditional.h>
 #include <sepol/flask.h>
 #include <sepol/link.h>
-#include <semod/module.h>
+#include <sepol/module.h>
 
 #include <byteswap.h>
 #include <endian.h>
@@ -691,11 +691,11 @@ static int read_policy(char *filename, p
                 exit(1);
         }
         rewind(in_fp);
-        if (le32_to_cpu(buf[0]) == SEMOD_MODULE_PACKAGE_MAGIC) {
-                semod_module_package_t package;
+        if (le32_to_cpu(buf[0]) == SEPOL_MODULE_PACKAGE_MAGIC) {
+                sepol_module_package_t package;
                 package.policy = policy;
                 package.file_contexts = NULL;
-                retval = semod_module_package_read(&package, &f, 1);
+                retval = sepol_module_package_read(&package, &f, 1);
                 free(package.file_contexts);
         }
         else {
checkpolicy/test/Makefile renamed from selinux-usr/checkpolicy/test/Makefile +1 -1
diff -purN nsa/selinux-usr/checkpolicy/test/Makefile nsa-selinux-usr/checkpolicy/test/Makefile
@@ -9,7 +9,7 @@ INCLUDEDIR ?= $(PREFIX)/include
 CFLAGS ?= -g -Wall -O2 -pipe
 override CFLAGS += -I$(INCLUDEDIR)
 
-LDLIBS=-lfl -lsemod -lselinux $(LIBDIR)/libsepol.a -L$(LIBDIR)
+LDLIBS=-lfl -lselinux $(LIBDIR)/libsepol.a -L$(LIBDIR)
 
 all: dispol dismod
 
libsemanage/include/semanage/commit_api.h renamed from selinux-usr/libsemanage/include/semanage/commit_api.h +7 -8
diff -purN nsa/selinux-usr/libsemanage/include/semanage/commit_api.h nsa-selinux-usr/libsemanage/include/semanage/commit_api.h
@@ -20,15 +20,14 @@
 #ifndef SEMOD_COMMIT_API_H
 #define SEMOD_COMMIT_API_H
 
-#include "semanage/module.h"
-
+#include <sepol/module.h>
 #include <stdlib.h>
 
 int semod_link_sandbox(char *sandbox,
-                       semod_module_package_t **base,
-                       semod_module_package_t ***mods, int *num_modules,
+                       sepol_module_package_t **base,
+                       sepol_module_package_t ***mods, int *num_modules,
                        char *error_buf, size_t error_buf_size);
-int semod_expand_sandbox(char *sandbox, semod_module_package_t *base,
+int semod_expand_sandbox(char *sandbox, sepol_module_package_t *base,
                          uint32_t policyvers,
                          char *error_buf, size_t error_buf_size);
 int semod_install_sandbox (char *sandbox,
@@ -39,8 +38,8 @@ int semod_verify_modules(char *sandbox, 
 int semod_verify_linked(char *sandbox);
 int semod_verify_kernel(char *sandbox);
 
-int semod_load_module (char *filename, semod_module_package_t **package);
-int semod_write_module (char *filename, semod_module_package_t *package,
-                        uint32_t policy_type, int policyvers);
+int semod_load_module(char *filename, sepol_module_package_t **package);
+int semod_write_module(char *filename, sepol_module_package_t *package,
+                       uint32_t policy_type, int policyvers);
 
 #endif
libsemanage/include/semanage/module.h renamed from selinux-usr/libsemanage/include/semanage/module.h +0 -50

50 lines not on this page · raw message

libsemanage/src/commit_api.c renamed from selinux-usr/libsemanage/src/commit_api.c +14 -14
diff -purN nsa/selinux-usr/libsemanage/src/commit_api.c nsa-selinux-usr/libsemanage/src/commit_api.c
@@ -22,7 +22,6 @@
 #endif
 
 #include "semanage/commit_api.h"
-#include "semanage/module.h"
 #include "semanage/module_store.h"
 #include "semanage/semod_conf.h"
 
@@ -40,6 +39,7 @@
 #include <sepol/sepol.h>
 #include <sepol/link.h>
 #include <sepol/expand.h>
+#include <sepol/module.h>
 #include <selinux/selinux.h>
 
 static int exec_prog (external_prog_t *v, char *new_name, char *old_name);
@@ -78,8 +78,8 @@ static void write_error(char *error_buf,
  * could not be linked (and error_buf will contain details).
  */
 int semod_link_sandbox(char *sandbox,
-                       semod_module_package_t **base,
-                       semod_module_package_t ***mods, int *num_modules,
+                       sepol_module_package_t **base,
+                       sepol_module_package_t ***mods, int *num_modules,
                        char *error_buf, size_t error_buf_size) {
         char *base_filename = NULL, **module_filenames = NULL;
         int retval, i;
@@ -150,8 +150,8 @@ int semod_link_sandbox(char *sandbox,
                 }
         }
         
-        if (semod_link_packages (*base, *mods, *num_modules, 0, error_buf,
-                                 error_buf_size) != 0) {
+        if (sepol_link_packages(*base, *mods, *num_modules, 0, error_buf,
+                                error_buf_size) != 0) {
                 retval = -4;
                 goto cleanup;
         }
@@ -174,7 +174,7 @@ int semod_link_sandbox(char *sandbox,
  * memory, -2 if could not expand (and error_buf will contain
  * details), or -3 if could not write expanded policy.
  */
-int semod_expand_sandbox(char *sandbox, semod_module_package_t *base,
+int semod_expand_sandbox(char *sandbox, sepol_module_package_t *base,
                          uint32_t policyvers,
                          char *error_buf, size_t error_buf_size) {
         policydb_t out;
@@ -432,14 +432,14 @@ int semod_verify_kernel (char *sandbox) 
  * module_package_destroy().  Returns 0 on success, -1 if out of
  * memory, or -2 if the module could not be loaded.
  */
-int semod_load_module (char *filename, semod_module_package_t **package) {
+int semod_load_module(char *filename, sepol_module_package_t **package) {
 	int retval = 0;
 	struct policy_file pf;
 
-	if ((*package = (semod_module_package_t*) malloc (sizeof (**package))) == NULL) {
+	if ((*package = (sepol_module_package_t*) malloc(sizeof(**package))) == NULL) {
                 return -1;
 	}
-	if (semod_module_package_init (*package) == -1) {
+	if (sepol_module_package_init(*package) == -1) {
                 return -1;
         }
 
@@ -447,7 +447,7 @@ int semod_load_module (char *filename, s
                 return -2;
 	}
 	pf.type = PF_USE_STDIO;
-	if (semod_module_package_read (*package, &pf, 0) == -1) {
+	if (sepol_module_package_read(*package, &pf, 0) == -1) {
                 retval = -2;
         }
 	(void) fclose (pf.fp);
@@ -464,8 +464,8 @@ int semod_load_module (char *filename, s
 /* Writes a module (or a base) to the file given by a fully-qualified
  * 'filename'.  Returns 0 on success, -1 if file could not be written.
  */
-int semod_write_module (char *filename, semod_module_package_t *package,
-                        uint32_t policy_type, int policyvers) {
+int semod_write_module(char *filename, sepol_module_package_t *package,
+                       uint32_t policy_type, int policyvers) {
         struct policy_file pf;
         FILE *outfile;
         int retval;
@@ -475,8 +475,8 @@ int semod_write_module (char *filename, 
         }
         pf.type = PF_USE_STDIO;
         pf.fp = outfile;
-        retval = semod_module_package_write (package, &pf);
-        (void) fclose (outfile);
+        retval = sepol_module_package_write(package, &pf);
+        fclose(outfile);
         if (retval == -1) {
                 return -1;
         }
libsemanage/src/module.c renamed from selinux-usr/libsemanage/src/module.c +0 -355

355 lines not on this page · raw message

libsemanage/src/module_direct_api.c renamed from selinux-usr/libsemanage/src/module_direct_api.c +8 -7
diff -purN nsa/selinux-usr/libsemanage/src/module_direct_api.c nsa-selinux-usr/libsemanage/src/module_direct_api.c
@@ -22,10 +22,11 @@
 #endif
 
 #include "semanage/commit_api.h"
-#include "semanage/module.h"
 #include "semanage/module_store.h"
 #include "semanage/semod_conf.h"
 
+#include <sepol/module.h>
+
 #include <fcntl.h>
 #include <stdarg.h>
 #include <string.h>
@@ -294,7 +295,7 @@ int semod_direct_list_sandbox(char *sand
 int semod_direct_commit(char *sandbox, unsigned int policyvers,
                         char *error_buf, size_t error_buf_size) {
         char **mod_filenames = NULL, *linked_filename = NULL, *fc_filename = NULL;
-        semod_module_package_t *base = NULL, **mods = NULL;
+        sepol_module_package_t *base = NULL, **mods = NULL;
         int retval, num_modfiles = 0, num_modules = 0, i;
 
         if (semod_get_sandbox_modules_names (sandbox, &mod_filenames, &num_modfiles) != 0 ||
@@ -348,9 +349,9 @@ int semod_direct_commit(char *sandbox, u
         free (mod_filenames);
         free (linked_filename);
         free (fc_filename);
-        semod_module_package_destroy (base);
+        sepol_module_package_destroy(base);
         for (i = 0; mods != NULL && i < num_modules; i++) {
-                semod_module_package_destroy (mods[i]);
+                sepol_module_package_destroy(mods[i]);
         }
         free (mods);
         return retval;
@@ -419,8 +420,8 @@ static int parse_module_headers (char *s
         pf.fp = NULL;
         if (module_data == NULL ||
             data_len <= 0 ||
-            semod_module_package_info (&pf, &file_type, module_name,
-                                       version) == -1) {
+            sepol_module_package_info(&pf, &file_type, module_name,
+                                      version) == -1) {
                 write_error (error_buf, error_buf_size, "Could not read module file.");
                 return -2;
         }
@@ -457,7 +458,7 @@ static int parse_base_headers (char *san
         pf.fp = NULL;
         if (module_data == NULL ||
             data_len <= 0 ||
-            semod_module_package_info (&pf, &file_type, &module_name, &version) == -1) {
+            sepol_module_package_info(&pf, &file_type, &module_name, &version) == -1) {
                 write_error (error_buf, error_buf_size, "Could not read base policy file.");
                 return -2;
         }
libsemanage/src/module_store.c renamed from selinux-usr/libsemanage/src/module_store.c +4 -3
diff -purN nsa/selinux-usr/libsemanage/src/module_store.c nsa-selinux-usr/libsemanage/src/module_store.c
@@ -28,10 +28,11 @@
 #define _GNU_SOURCE
 #endif
 
-#include "semanage/module.h"
 #include "semanage/module_store.h"
 #include "semanage/semod_conf.h"
 
+#include <sepol/module.h>
+
 #include <assert.h>
 #include <dirent.h>
 #include <errno.h>
@@ -359,7 +360,7 @@ char *semod_get_active_module_filename (
                         continue;  /* could not open this module for reading */
 		}
 		pf.type = PF_USE_STDIO;
-		retval = semod_module_package_info (&pf, &type, &name, &version);
+		retval = sepol_module_package_info(&pf, &type, &name, &version);
                 (void) fclose (pf.fp);
                 free (version);
 		if (retval == 0 && type == POLICY_MOD && strcmp (name, module_name) == 0) {
@@ -729,7 +730,7 @@ static int semod_build_modules_list (con
 		}
                 free (filename);
 		pf.type = PF_USE_STDIO;
-		if (semod_module_package_info (&pf, &type, &name, &version)) {
+		if (sepol_module_package_info(&pf, &type, &name, &version)) {
 			(void) fclose (pf.fp);
                         continue;
 		}
libsepol/include/sepol/module.h renamed from selinux-usr/libsepol/include/sepol/module.h +49 -0

49 lines not on this page · raw message

libsepol/include/sepol/policydb.h renamed from selinux-usr/libsepol/include/sepol/policydb.h +0 -3
diff -purN nsa/selinux-usr/libsepol/include/sepol/policydb.h nsa-selinux-usr/libsepol/include/sepol/policydb.h
@@ -570,9 +570,6 @@ extern int sepol_mls_enabled(void);
 #define POLICYDB_MOD_MAGIC SELINUX_MOD_MAGIC
 #define POLICYDB_MOD_STRING "SE Linux Module"
 
-/* Just here for debugging module packages */
-#define SEMOD_MODULE_PACKAGE_MAGIC 0xf97cff8e
-
 #endif	/* _POLICYDB_H_ */
 
 /* FLASK */
libsepol/src/module.c renamed from selinux-usr/libsepol/src/module.c +355 -0

355 lines not on this page · raw message

libsepol/src/private.h renamed from selinux-usr/libsepol/src/private.h +26 -0
diff -purN nsa/selinux-usr/libsepol/src/private.h nsa-selinux-usr/libsepol/src/private.h
@@ -57,4 +57,30 @@ static inline void *next_entry(struct po
 	return buffer;
 }
 
+static inline size_t put_entry(const void *ptr, size_t size, size_t n, struct policy_file *fp)
+{
+	size_t bytes = size * n;
+
+	switch (fp->type) {
+	case PF_USE_STDIO:
+		return fwrite(ptr, size, n, fp->fp);
+	case PF_USE_MEMORY:
+		if (bytes > fp->len) {
+			errno = ENOSPC;
+			return 0;
+		}
+
+		memcpy(fp->data, ptr, bytes);
+		fp->data += bytes;
+		fp->len -= bytes;
+		return n;
+	case PF_LEN:
+		fp->len += bytes;
+		return n;
+	default:
+		return 0;
+	}
+	return 0;
+}
+
 extern int mls_enabled;
libsepol/src/write.c renamed from selinux-usr/libsepol/src/write.c +1 -27
diff -purN nsa/selinux-usr/libsepol/src/write.c nsa-selinux-usr/libsepol/src/write.c
@@ -15,7 +15,7 @@
  *	Module writing support
  *
  * Copyright (C) 2004-2005 Trusted Computer Solutions, Inc.
- * Copyright (C) 2003 - 2004 Tresys Technology, LLC
+ * Copyright (C) 2003-2005 Tresys Technology, LLC
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -69,32 +69,6 @@ int sepol_set_policyvers(unsigned int ty
 	return 0;
 }
 
-static inline size_t put_entry(const void *ptr, size_t size, size_t n, struct policy_file *fp)
-{
-	size_t bytes = size * n;
-
-	switch (fp->type) {
-	case PF_USE_STDIO:
-		return fwrite(ptr, size, n, fp->fp);
-	case PF_USE_MEMORY:
-		if (bytes > fp->len) {
-			errno = ENOSPC;
-			return 0;
-		}
-
-		memcpy(fp->data, ptr, bytes);
-		fp->data += bytes;
-		fp->len -= bytes;
-		return n;
-	case PF_LEN:
-		fp->len += bytes;
-		return n;
-	default:
-		return 0;
-	}
-	return 0;
-}
-
 static int ebitmap_write(ebitmap_t * e, struct policy_file * fp)
 {
 	ebitmap_node_t *n;
policycoreutils/Makefile renamed from selinux-usr/policycoreutils/Makefile +1 -1
diff -purN nsa/selinux-usr/policycoreutils/Makefile nsa-selinux-usr/policycoreutils/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS=setfiles load_policy newrole run_init restorecon audit2allow audit2why scripts po sestatus semodule_link semodule_expand semodule
+SUBDIRS=setfiles load_policy newrole run_init restorecon audit2allow audit2why scripts po sestatus semodule_link semodule_expand semodule_package semodule
 
 all install relabel clean: 
 	@for subdir in $(SUBDIRS); do \
policycoreutils/semodule_expand/semodule_expand.c renamed from selinux-usr/policycoreutils/semodule_expand/semodule_expand.c +4 -4
diff -purN nsa/selinux-usr/policycoreutils/semodule_expand/semodule_expand.c nsa-selinux-usr/policycoreutils/semodule_expand/semodule_expand.c
@@ -7,7 +7,7 @@
  *	the Free Software Foundation, version 2.
  */
 
-#include <semanage/module.h>
+#include <sepol/module.h>
 #include <sepol/expand.h>
 #include <sepol/services.h>
 
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
 	char ch, *basename, *outname, error_buf [256];
 	int fd, ret, show_version = 0, verbose = 0;
 	struct policy_file pf;
-	semod_module_package_t base;
+	sepol_module_package_t base;
 	policydb_t out;
 	FILE *outfile;
 	struct stat sb;
@@ -95,7 +95,7 @@ int main(int argc, char **argv)
 	outname = argv[optind];
 	
 	/* read the base module */
-	if (semod_module_package_init(&base))
+	if (sepol_module_package_init(&base))
 		exit(1);
 	fd = open(basename, O_RDONLY);
 	if (fd < 0) {
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
 	pf.type = PF_USE_MEMORY;
 	pf.data = map;
 	pf.len = sb.st_size;
-	ret = semod_module_package_read(&base, &pf, 0);
+	ret = sepol_module_package_read(&base, &pf, 0);
 	if (ret) {
 		fprintf(stderr, "%s:  error(s) encountered while parsing configuration\n", argv[0]);
 		exit(1);
policycoreutils/semodule_link/semodule_link.c renamed from selinux-usr/policycoreutils/semodule_link/semodule_link.c +11 -11
diff -purN nsa/selinux-usr/policycoreutils/semodule_link/semodule_link.c nsa-selinux-usr/policycoreutils/semodule_link/semodule_link.c
@@ -6,7 +6,7 @@
  *	the Free Software Foundation, version 2.
  */
  
-#include <semanage/module.h>
+#include <sepol/module.h>
 
 #include <getopt.h>
 #include <fcntl.h>
@@ -29,18 +29,18 @@ static void usage(char *program_name)
         exit(1);
 }
 
-static semod_module_package_t *load_module(char *filename)
+static sepol_module_package_t *load_module(char *filename)
 {
 	int ret;
 	struct policy_file pf;
-	semod_module_package_t *p;
+	sepol_module_package_t *p;
 
-	p = (semod_module_package_t*)malloc(sizeof(semod_module_package_t));
+	p = (sepol_module_package_t*)malloc(sizeof(sepol_module_package_t));
 	if (!p) {
 		fprintf(stderr, "Memory error\n");
 		return NULL;
 	}
-	if (semod_module_package_init(p))
+	if (sepol_module_package_init(p))
 		return NULL;
 		
 	pf.fp = fopen(filename, "r");
@@ -54,7 +54,7 @@ static semod_module_package_t *load_modu
 	
 	printf("loading policy from file %s\n", filename);
 	
-	ret = semod_module_package_read(p, &pf, 0);
+	ret = sepol_module_package_read(p, &pf, 0);
 	if (ret) {
 		fprintf(stderr, "error(s) encountered while parsing configuration\n");
 		exit(1);
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
 {
 	int i, show_version = 0, verbose = 0, num_mods;
 	char ch, *basename, *outname = NULL, error_buf[256];
-	semod_module_package_t *base, **mods;
+	sepol_module_package_t *base, **mods;
 	FILE *outfile;
 	struct policy_file pf;
 	
@@ -121,12 +121,12 @@ int main(int argc, char **argv)
         }
        
         num_mods = argc - optind;
-        mods = (semod_module_package_t**)malloc(sizeof(semod_module_package_t*) * num_mods);
+        mods = (sepol_module_package_t**)malloc(sizeof(sepol_module_package_t*) * num_mods);
         if (!mods) {
         	fprintf(stderr, "Memory error\n");
         	exit(1);	
         }
-        memset(mods, 0, sizeof(semod_module_package_t*) * num_mods);
+        memset(mods, 0, sizeof(sepol_module_package_t*) * num_mods);
         
         for (i = 0; optind < argc; optind++, i++) {
         	mods[i] = load_module(argv[optind]);
@@ -135,7 +135,7 @@ int main(int argc, char **argv)
         }
 
         error_buf[0] = '\0';
-        if (semod_link_packages(base, mods, num_mods, verbose, error_buf, sizeof (error_buf))) {
+        if (sepol_link_packages(base, mods, num_mods, verbose, error_buf, sizeof (error_buf))) {
         	fprintf(stderr, "error linking modules: %s\n", error_buf);
         	exit(1);	
         }
@@ -154,7 +154,7 @@ int main(int argc, char **argv)
 	
 		pf.type = PF_USE_STDIO;
 		pf.fp = outfile;
-        	if (semod_module_package_write(base, &pf)) {
+        	if (sepol_module_package_write(base, &pf)) {
         		fprintf(stderr, "Error writing module\n");
         		exit(1);	
         	}	
policycoreutils/semodule_package/semodule_package.c renamed from selinux-usr/policycoreutils/semodule_package/semodule_package.c +2 -2
diff -purN nsa/selinux-usr/policycoreutils/semodule_package/semodule_package.c nsa-selinux-usr/policycoreutils/semodule_package/semodule_package.c
@@ -6,7 +6,7 @@
  *	the Free Software Foundation, version 2.
  */
  
-#include <semanage/module.h>
+#include <sepol/module.h>
 
 #include <fcntl.h>
 #include <stdio.h>
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
 	if (file_to_policy_file(argv[1], &out, "w"))
 		exit(1);
 		
-        if (semod_module_package_create(&mod, (argc == 3 ? NULL : &fc), &out)) {
+        if (sepol_module_package_create(&mod, (argc == 3 ? NULL : &fc), &out)) {
                 fprintf(stderr, "Could not write module package\n");
                 exit(1);
         }
#1 lore raw
Quoted 6 lines · Jason Tang

With the newly agreed upon use of libsepol as "internal representation of data" it has become apparant that module read/write code really belongs in libsepol and not in libsemanage. The following patch moves that logic into a new file libsepol/module.c. It also corrects an outstanding error, by adding checkpolicy/test and policycoreutils/semodule_package into their parents' Makefile.

dismod doesn't compile in our tree (missing definitions related to policycon).

I'm adding further compiler warning flags to libsepol, and have fixed current occurrences of such warnings, and I'd suggest that libsemanage do likewise (adding the same warning flags to it yields several warnings). Patch for libsepol is below.

Index: libsepol/include/sepol/conditional.h
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/include/sepol/conditional.h,v retrieving revision 1.9

include/sepol/conditional.h +1 -1
diff -u -p -r1.9 conditional.h
@@ -81,7 +81,7 @@ typedef struct cond_node {
 	avrule_t *avtrue_list;
 	avrule_t *avfalse_list;
 	/* these fields are not written to binary policy */
-	int nbools;
+	unsigned int nbools;
 	uint32_t bool_ids[COND_MAX_BOOLS];
 	uint32_t expr_pre_comp;
 	/*                                               */

Index: libsepol/src/Makefile
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/Makefile,v retrieving revision 1.9

src/Makefile +1 -1
diff -u -p -r1.9 Makefile
@@ -10,7 +10,7 @@ TARGET=libsepol.so
 LIBSO=$(TARGET).$(LIBVERSION)
 OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
 LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
-CFLAGS ?= -Wall
+CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
 override CFLAGS += -I. -I../include -D_GNU_SOURCE
 
 all: $(LIBA) $(LIBSO)

Index: libsepol/src/avrule_block.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/avrule_block.c,v retrieving revision 1.1

src/avrule_block.c +1 -1
diff -u -p -r1.1 avrule_block.c
@@ -61,7 +61,7 @@ avrule_decl_t *avrule_decl_create(uint32
 }
 
 static void scope_index_destroy(scope_index_t *scope) {
-        int i;
+        unsigned int i;
         if (scope == NULL) {
                 return;
         }

Index: libsepol/src/conditional.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/conditional.c,v retrieving revision 1.8

src/conditional.c +9 -8
diff -u -p -r1.8 conditional.c
@@ -58,8 +58,8 @@ void cond_optimize_lists(cond_list_t* cl
 }
 
 
-static int bool_present(int target, unsigned int bools[], int num_bools) {
-	int i = 0;
+static int bool_present(unsigned int target, unsigned int bools[], unsigned int num_bools) {
+	unsigned int i = 0;
 	int ret = 1;
 
 	if (num_bools > COND_MAX_BOOLS) {
@@ -71,7 +71,7 @@ static int bool_present(int target, unsi
 }
 
 static int same_bools(cond_node_t *a, cond_node_t *b) {
-	int i, x;
+	unsigned int i, x;
 	
 	x = a->nbools;
 
@@ -133,7 +133,7 @@ cond_node_t *cond_node_find(policydb_t *
                             cond_node_t *needle, cond_node_t *haystack,
                             int *was_created) {
 	cond_node_t *new_node;
-	int i;
+	unsigned int i;
 
 	while(haystack) {
 		if (cond_expr_equal(needle,haystack)) {
@@ -309,7 +309,8 @@ int cond_normalize_expr(policydb_t *p, c
 {
 	cond_expr_t *ne,*e;
 	cond_av_list_t *tmp;
-	int i, j, k, orig_value[COND_MAX_BOOLS];
+	unsigned int i, j, orig_value[COND_MAX_BOOLS];
+	int k;
 	uint32_t test = 0x0;
 	avrule_t *tmp2;
 
@@ -372,7 +373,7 @@ int cond_normalize_expr(policydb_t *p, c
 		}
 		
 		/* loop through all possible combinations of values for bools in expression */
-		for(test = 0x0; test < (0x1 << cn->nbools) ; test++) {
+		for(test = 0x0; test < (0x1U << cn->nbools) ; test++) {
 			/* temporarily set the value for all the bools in the
 			 * expression using the corr.  bit in test */
 			for(j = 0; j < cn->nbools; j++) {
@@ -479,7 +480,7 @@ int cond_init_bool_indexes(policydb_t *p
 	return 0;
 }
 
-int cond_destroy_bool(hashtab_key_t key, hashtab_datum_t datum, void *p)
+int cond_destroy_bool(hashtab_key_t key, hashtab_datum_t datum, void *p __attribute__ ((unused)))
 {
 	if (key)
 		free(key);
@@ -511,7 +512,7 @@ static int bool_isvalid(cond_bool_datum_
 	return 1;
 }
 
-int cond_read_bool(policydb_t *p, hashtab_t h, struct policy_file *fp)
+int cond_read_bool(policydb_t *p __attribute__ ((unused)), hashtab_t h, struct policy_file *fp)
 {
 	char *key = 0;
 	cond_bool_datum_t *booldatum;

Index: libsepol/src/constraint.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/constraint.c,v retrieving revision 1.2

src/constraint.c +3 -3
diff -u -p -r1.2 constraint.c
@@ -35,7 +35,7 @@ void constraint_expr_destroy(constraint_
         }
 }
 
-static int expand_constraint_bit(constraint_expr_t *expr, constraint_expr_t *dest_expr,
+static int expand_constraint_bit(constraint_expr_t *expr __attribute__ ((unused)), constraint_expr_t *dest_expr,
                                  int bit, uint32_t *typemap) {
         if (typemap != NULL) {
                 if (ebitmap_set_bit(&dest_expr->names, typemap[bit] - 1, 1)) {
@@ -50,10 +50,10 @@ static int expand_constraint_bit(constra
         return 0;
 }
 
-int expand_constraint(constraint_expr_t *expr, constraint_expr_t *dest_expr,
+int expand_constraint(constraint_expr_t *expr __attribute__ ((unused)), constraint_expr_t *dest_expr,
                       uint32_t *typemap, policydb_t *pol) {
          ebitmap_t e;
-         int i, j;
+         unsigned int i, j;
          if (type_set_expand(expr->type_names, &e, pol)) {
                  ebitmap_destroy(&e);
                  return -1;

Index: libsepol/src/expand.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/expand.c,v retrieving revision 1.1

src/expand.c +11 -7
diff -u -p -r1.1 expand.c
@@ -44,6 +44,9 @@ typedef struct expand_state {
 
 /* Write an error message to the current error buffer, up to the
  * buffer's specified size. */
+#ifdef __GNUC__
+__attribute__ ((format (printf, 2, 3)))
+#endif
 static void write_error (expand_state_t *state, char *fmt, ...) {
         va_list ap;
         if (state->error_buf == NULL) {
@@ -671,7 +674,7 @@ static int cats_copy_callback(hashtab_ke
 
 static int copy_role_allows(expand_state_t *state, role_allow_rule_t *rules)
 {
-	int i, j;
+	unsigned int i, j;
 	role_allow_t *cur_allow, *n, *l;
 	role_allow_rule_t *cur;
 	ebitmap_t roles, new_roles;
@@ -734,7 +737,7 @@ static int copy_role_allows(expand_state
 
 static int copy_role_trans(expand_state_t *state, role_trans_rule_t *rules)
 {
-	int i, j;
+	unsigned int i, j;
 	role_trans_t *n, *l, *cur_trans;
 	role_trans_rule_t *cur;
 	ebitmap_t roles, types;
@@ -1054,7 +1057,8 @@ static int expand_rule_helper(policydb_t
                               int enabled, char **error_msg,
                               ebitmap_t *stypes, ebitmap_t *ttypes)
 {
-        int i, j, retval;
+	unsigned int i, j;
+	int retval;
         for (i = ebitmap_startbit(stypes); i < ebitmap_length(stypes); i++) {
                 if (!ebitmap_get_bit(stypes, i))
                         continue;
@@ -1214,7 +1218,7 @@ static int context_copy(context_struct_t
 
 static int ocontext_copy(expand_state_t *state)
 {
-	int i, j;
+	unsigned int i, j;
 	ocontext_t *c, *n, *l;
 	
 	for (i = 0; i < OCON_NUM; i++) {	
@@ -1384,7 +1388,7 @@ static int type_attr_remove(hashtab_key_
 
 int expand_convert_type_set(policydb_t *p, uint32_t *typemap, type_set_t *set, ebitmap_t *types)
 {
-        int i;
+        unsigned int i;
         ebitmap_t tmp;
         
         ebitmap_init(types);
@@ -1439,7 +1443,7 @@ int expand_rule(policydb_t *source_pol,
 
 int role_set_expand(role_set_t *x, ebitmap_t *r, policydb_t *p)
 {
-        int i;
+        unsigned int i;
 
         ebitmap_init(r);
 
@@ -1477,7 +1481,7 @@ int role_set_expand(role_set_t *x, ebitm
  */
 int type_set_expand(type_set_t *set, ebitmap_t *t, policydb_t *p)
 {
-        int i;
+        unsigned int i;
         ebitmap_t types, neg_types;
 
         ebitmap_init(&types);

Index: libsepol/src/genusers.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/genusers.c,v retrieving revision 1.16

src/genusers.c +6 -3
diff -u -p -r1.16 genusers.c
@@ -21,6 +21,9 @@ void sepol_debug(int on) { 
 	sepol_debug_compat(on);
 };
 
+#ifdef __GNUC__
+__attribute__ ((format (printf, 1, 2)))
+#endif
 void __sepol_debug_printf(const char *fmt, ...) {
 	if (gdebug) {
 		va_list ap;
@@ -281,7 +284,7 @@ static int load_users(struct policydb *p
 
 /* Select users for removal based on whether they were defined in the
    new users configuration. */
-static int select_user(hashtab_key_t key, hashtab_datum_t datum, void *datap)
+static int select_user(hashtab_key_t key __attribute__ ((unused)), hashtab_datum_t datum, void *datap __attribute__ ((unused)))
 {
 	user_datum_t *usrdatum = datum;
 	
@@ -319,13 +322,13 @@ static void kill_user(hashtab_key_t key,
    As the SID table is remapped by the kernel upon a policy reload,
    this is safe for existing SIDs.  But it could be a problem for
    constraints if they refer to the particular user.  */
-static int remap_users(hashtab_key_t key, hashtab_datum_t datum, void *p)
+static int remap_users(hashtab_key_t key __attribute__ ((unused)), hashtab_datum_t datum, void *p)
 {
 	user_datum_t *usrdatum = datum;
 	struct kill_user_data *kud = p;
 	struct policydb *pol = kud->policydb;
 	ebitmap_t *free_users = kud->free_users;
-	int i;
+	unsigned int i;
 
 	if (usrdatum->value > pol->p_users.nprim) {
 		for (i = ebitmap_startbit(free_users); i < ebitmap_length(free_users); i++) {

Index: libsepol/src/hierarchy.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/hierarchy.c,v retrieving revision 1.5

src/hierarchy.c +2 -2
diff -u -p -r1.5 hierarchy.c
@@ -73,7 +73,7 @@ static int find_parent(char *type, char 
 /* This function verifies that the type passed in either has a parent or is in the 
  * root of the namespace, 0 on success, 1 on orphan and -1 on error
  */
-static int check_type_hierarchy_callback(hashtab_key_t k, hashtab_datum_t d, void *args)
+static int check_type_hierarchy_callback(hashtab_key_t k __attribute__ ((unused)), hashtab_datum_t d, void *args)
 {
 	char *parent;
 	hierarchy_args_t *a;
@@ -280,7 +280,7 @@ static int check_cond_avtab_hierarchy(co
  * This function should be called with hashtab_map, it will return 0 on success, 1 on 
  * constraint violation and -1 on error
  */
-static int check_role_hierarchy_callback(hashtab_key_t k, hashtab_datum_t d, void *args)
+static int check_role_hierarchy_callback(hashtab_key_t k __attribute__ ((unused)), hashtab_datum_t d, void *args)
 {
 	char *parent;
 	hierarchy_args_t *a;

Index: libsepol/src/link.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/link.c,v retrieving revision 1.1

src/link.c +15 -11
diff -u -p -r1.1 link.c
@@ -107,6 +107,9 @@ static int add_i_to_a(uint32_t i, uint32
 
 /* Write an error message to the current error buffer, up to the
  * buffer's specified size. */
+#ifdef __GNUC__
+__attribute__ ((format (printf, 2, 3)))
+#endif
 static void write_error(link_state_t *state, char *fmt, ...) {
         va_list ap;
         if (state->error_buf == NULL) {
@@ -121,7 +124,7 @@ static void write_error(link_state_t *st
  * structure within, as well as the pointer itself. */
 static void policy_module_destroy(policy_module_t *mod)
 {
-        int i;
+        unsigned int i;
         if (mod == NULL) {
                 return;
         }
@@ -557,9 +560,9 @@ static int alias_copy_callback(hashtab_k
 /*********** callbacks that fix bitmaps ***********/
 
 static int type_set_convert(type_set_t *types, type_set_t *dst,
-                            policy_module_t *mod, link_state_t *state)
+                            policy_module_t *mod, link_state_t *state __attribute__ ((unused)))
 {
-	int i;
+	unsigned int i;
         for (i = ebitmap_startbit(&types->types); i < ebitmap_length(&types->types); i++) {
                 if (ebitmap_get_bit(&types->types, i)) {
                         assert(mod->map[SYM_TYPES][i]);
@@ -611,7 +614,7 @@ static int type_set_or_convert(type_set_
 static int role_set_or_convert(role_set_t *roles, role_set_t *dst,
                                policy_module_t *mod, link_state_t *state)
 {
-	int i;
+	unsigned int i;
 	ebitmap_t tmp;
 
 	ebitmap_init(&tmp);
@@ -637,7 +640,7 @@ static int role_set_or_convert(role_set_
 
 static int role_fix_callback(hashtab_key_t key, hashtab_datum_t datum, void *data)
 {
-        int i;
+        unsigned int i;
         char *id = key;
         role_datum_t *role, *dest_role = NULL;
 	link_state_t *state = (link_state_t *)data;
@@ -680,7 +683,7 @@ static int role_fix_callback(hashtab_key
 
 static int type_fix_callback(hashtab_key_t key, hashtab_datum_t datum, void *data)
 {
-        int i;
+        unsigned int i;
         char *id = key;
         type_datum_t *type, *new_type = NULL;
 	link_state_t *state = (link_state_t *)data;
@@ -1105,7 +1108,7 @@ static int copy_module_identifiers(link_
 
 static int copy_scope_index(scope_index_t *src, scope_index_t *dest,
                             policy_module_t *module, link_state_t *state) {
-        int i, j;
+        unsigned int i, j;
         uint32_t largest_mapped_class_value = 0;
         /* copy the scoping information for this avrule decl block */
         for (i = 0; i < SYM_NUM; i++) {
@@ -1223,7 +1226,8 @@ static int copy_avrule_block(link_state_
 
 static int scope_copy_callback(hashtab_key_t key, hashtab_datum_t datum, void *data)
 {
-        int i, ret;
+	unsigned int i;
+	int ret;
         char *id = key, *new_id = NULL;
         scope_datum_t *scope, *base_scope;
 	link_state_t *state = (link_state_t *)data;
@@ -1377,7 +1381,7 @@ static int is_decl_requires_met(link_sta
          * redundant checks.  A very obvious improvement is to cache
          * which symbols have been verified, so that they do not need
          * to be re-checked.) */
-        int i, j;
+        unsigned int i, j;
         ebitmap_t *bitmap;
         char *id, *perm_id;
         policydb_t *pol = state->base;
@@ -1560,7 +1564,7 @@ int merge_avrules(link_state_t *state, a
         block = block->next; /* start with the first non-base block */
         while (block != NULL) {
                 avrule_decl_t *decl = block->enabled;
-                int i, j;
+                unsigned int i, j;
 
                 block = block->next;
                 if (decl == NULL) {
@@ -1678,7 +1682,7 @@ static int check_symbol_used(hashtab_key
         /* if the scope is declared and at least one of its decls is
          * enabled then don't remove this symbol */
         if (scope->scope == SCOPE_DECL) {
-                int i;
+                unsigned int i;
                 for (i = 0; i < scope->decl_ids_len; i++) {
                         avrule_decl_t *decl = state->decl_id_to_decl[scope->decl_ids[i]];
                         if (decl->enabled) {

Index: libsepol/src/mls.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/mls.c,v retrieving revision 1.7

src/mls.c +7 -6
diff -u -p -r1.7 mls.c
@@ -43,7 +43,7 @@
  */
 int mls_compute_context_len(policydb_t *policydb, context_struct_t * context)
 {
-	int i, l, len, range;
+	unsigned int i, l, len, range;
 
 	if (!mls_enabled)
 		return 0;
@@ -95,7 +95,7 @@ void mls_sid_to_context(policydb_t *poli
                         char **scontext)
 {
 	char *scontextp;
-	int i, l, range, wrote_sep;
+	unsigned int i, l, range, wrote_sep;
 
 	if (!mls_enabled)
 		return;
@@ -174,7 +174,7 @@ int mls_context_isvalid(policydb_t *p, c
 {
 	level_datum_t *levdatum;
 	user_datum_t *usrdatum;
-	int i, l;
+	unsigned int i, l;
 
 	if (!mls_enabled)
 		return 1;
@@ -245,7 +245,8 @@ int mls_context_to_sid(policydb_t *polic
 	char *scontextp, *p, *rngptr;
 	level_datum_t *levdatum;
 	cat_datum_t *catdatum, *rngdatum;
-	int l, rc = -EINVAL;
+	unsigned int l;
+	int rc = -EINVAL;
 
 	if (!mls_enabled)
 		return 0;
@@ -305,7 +306,7 @@ int mls_context_to_sid(policydb_t *polic
 
 				/* If range, set all categories in range */
 				if (rngptr) {
-					int i;
+					unsigned int i;
 
 					rngdatum = (cat_datum_t *)hashtab_search(policydb->p_cats.table, (hashtab_key_t)rngptr);
 					if (!rngdatum) {
@@ -464,7 +465,7 @@ int mls_convert_context(policydb_t * old
 	level_datum_t *levdatum;
 	cat_datum_t *catdatum;
 	ebitmap_t bitmap;
-	int l, i;
+	unsigned int l, i;
 
 	if (!mls_enabled)
 		return 0;

Index: libsepol/src/policydb.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/policydb.c,v retrieving revision 1.18

src/policydb.c +29 -26

192 lines not on this page · raw message

Index: libsepol/src/private.h
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/private.h,v retrieving revision 1.8

src/private.h +8 -5
diff -u -p -r1.8 private.h
@@ -20,13 +20,16 @@
 
 /* Policy compatibility information. */
 struct policydb_compat_info {
-	int type;
-        int version;
-	int sym_num;
-	int ocon_num;
+	unsigned int type;
+        unsigned int version;
+	unsigned int sym_num;
+	unsigned int ocon_num;
 };
 
-extern struct policydb_compat_info *policydb_lookup_compat(int version, int type);
+extern struct policydb_compat_info *policydb_lookup_compat(unsigned int version, unsigned int type);
+#ifdef __GNUC__
+__attribute__ ((format (printf, 1, 2)))
+#endif
 extern void __sepol_debug_printf(const char *fmt, ...);
 
 /* Reading from a policy "file". */

Index: libsepol/src/services.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/services.c,v retrieving revision 1.18

src/services.c +5 -1
diff -u -p -r1.18 services.c
@@ -943,7 +943,11 @@ int sepol_load_policy(void * data, size_
 	convert_context_args_t args;
 	uint32_t seqno;
 	int rc = 0;
-	struct policy_file file = { 0, data, len }, *fp = &file;
+	struct policy_file file = { 
+	  .type = PF_USE_MEMORY, 
+	  .data = data, 
+	  .len = len,
+	  .fp = NULL }, *fp = &file;
 
 	if (policydb_read(&newpolicydb, fp, 1)) {
 		return -EINVAL;

Index: libsepol/src/user_record.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/user_record.c,v retrieving revision 1.2

src/user_record.c +7 -7
diff -u -p -r1.2 user_record.c
@@ -19,7 +19,7 @@ struct sepol_user {
 	char** roles;
 
 	/* The number of roles */
-	int num_roles;
+	unsigned int num_roles;
 
 	/* The default role */
 	char* def_role;
@@ -151,7 +151,7 @@ int sepol_user_add_role(sepol_user_t use
 }
 
 int sepol_user_has_role(sepol_user_t user, const char* role) {
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < user->num_roles; i++)
 		if (!strcmp(user->roles[i], role)) 
@@ -164,7 +164,7 @@ int sepol_user_set_roles(
 	const char** roles_arr,
 	size_t num_roles) {
 
-	int i;
+	unsigned int i;
 	char** tmp_roles =
 		(char**) calloc(1, sizeof(char*) * num_roles);
 	if (!tmp_roles) 
@@ -198,7 +198,7 @@ int sepol_user_get_roles(
 	const char*** roles_arr, 
 	size_t* num_roles) {
 
-	int i;	
+	unsigned int i;	
 	const char** tmp_roles = 
 		(const char**) malloc(sizeof (char*) * user->num_roles);
 	if (!tmp_roles)
@@ -219,7 +219,7 @@ int sepol_user_get_roles(
 }
 
 int sepol_user_del_role(sepol_user_t user, const char* role) {
-	int i;
+	unsigned int i;
 	for (i = 0; i < user->num_roles; i++) {
 		if (!strcmp(user->roles[i], role)) {
 
@@ -301,7 +301,7 @@ int sepol_user_create(sepol_user_t* user
 /* Deep copy clone */
 int sepol_user_clone(sepol_user_t user, sepol_user_t* user_ptr) {
 	sepol_user_t new_user = NULL;
-	int i;
+	unsigned int i;
 
 	if (sepol_user_create(&new_user) < 0)
 		goto err;
@@ -336,7 +336,7 @@ int sepol_user_clone(sepol_user_t user, 
 
 /* Destroy */
 void sepol_user_free(sepol_user_t user) {
-	int i;
+	unsigned int i;
 
 	if (!user)
 		return;

Index: libsepol/src/users.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/users.c,v retrieving revision 1.3

src/users.c +4 -2
diff -u -p -r1.3 users.c
@@ -20,7 +20,9 @@ void sepol_set_delusers(int on) {
 /* Select users for removal based on whether they were defined in the
    new users configuration. */
 static int select_user(
-	hashtab_key_t key, hashtab_datum_t datum, void *datap) {
+	hashtab_key_t key __attribute__ ((unused)), 
+	hashtab_datum_t datum, 
+	void *datap __attribute__ ((unused))) {
 	user_datum_t *usrdatum = datum;
 
 	if (!usrdatum->defined)
@@ -167,7 +169,7 @@ int sepol_user_load(policydb_t* policydb
 	/* Low-level representation */
 	user_datum_t* usrdatum = NULL;
 	role_datum_t* roldatum;
-	int i;
+	unsigned int i;
 
 	context_struct_t context;
 	unsigned bit;

Index: libsepol/src/util.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/util.c,v retrieving revision 1.2

src/util.c +2 -1
diff -u -p -r1.2 util.c
@@ -148,7 +148,8 @@ int symtab_insert(policydb_t *pol, uint3
                   uint32_t scope, uint32_t avrule_decl_id,
                   uint32_t *value)
 {
-        int rc, i, retval = 0;
+	int rc, retval = 0;
+	unsigned int i;
         scope_datum_t *scope_datum;
         
         /* check if the symbol is already there.  multiple

Index: libsepol/src/write.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/write.c,v retrieving revision 1.12

src/write.c +5 -5
diff -u -p -r1.12 write.c
@@ -387,7 +387,7 @@ static int cond_write_bool(hashtab_key_t
 {
 	cond_bool_datum_t *booldatum;
 	uint32_t buf[3], len;
-	int items, items2;
+	unsigned int items, items2;
 	struct policy_file *fp = p;
 
 	booldatum = (cond_bool_datum_t*)datum;
@@ -829,7 +829,7 @@ static int (*write_f[SYM_NUM]) (hashtab_
 
 static int ocontext_write (struct policydb_compat_info *info, policydb_t * p,
                            struct policy_file * fp) {
-        int i, j;
+        unsigned int i, j;
         size_t nel, items, len;
 	uint32_t buf[32];
         ocontext_t *c;
@@ -1110,10 +1110,10 @@ static int role_allow_rule_write(role_al
 	return 0;
 }
 
-static int scope_index_write(scope_index_t *scope_index, int num_scope_syms,
+static int scope_index_write(scope_index_t *scope_index, unsigned int num_scope_syms,
                              struct policy_file *fp)
 {
-        int i;
+        unsigned int i;
         uint32_t buf[1];
         for (i = 0; i < num_scope_syms; i++) {
                 if (ebitmap_write(scope_index->scope + i, fp) == -1) {
@@ -1204,7 +1204,7 @@ static int scope_write(hashtab_key_t key
         struct policy_file *fp = (struct policy_file *) p;
         uint32_t static_buf[32], *dyn_buf = NULL, *buf;
         size_t key_len = strlen(key);
-        int items = 2 + scope->decl_ids_len, i;
+        unsigned int items = 2 + scope->decl_ids_len, i;
 
         if (items >= sizeof(buf)) {
                 /* too many things required, so dynamically create a
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.
#2 lore raw
In reply to Jason Tang
Quoted 6 lines · Jason Tang

With the newly agreed upon use of libsepol as "internal representation of data" it has become apparant that module read/write code really belongs in libsepol and not in libsemanage. The following patch moves that logic into a new file libsepol/module.c. It also corrects an outstanding error, by adding checkpolicy/test and policycoreutils/semodule_package into their parents' Makefile.

Other than the dismod issue, the patch looks good. Thanks, merged (with dismod presently not included in the build).

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.