eb71cf8
diff --exclude-from=exclude -N -u -r nsacheckpolicy/Makefile checkpolicy-1.25.3/Makefile
eb71cf8
--- nsacheckpolicy/Makefile	2005-07-28 15:18:33.000000000 -0400
eb71cf8
+++ checkpolicy-1.25.3/Makefile	2005-07-29 09:18:09.000000000 -0400
eb71cf8
@@ -6,7 +6,7 @@
eb71cf8
 MANDIR ?= $(PREFIX)/share/man
eb71cf8
 LIBDIR ?= $(PREFIX)/lib
eb71cf8
 INCLUDEDIR ?= $(PREFIX)/include
eb71cf8
-TARGETS = checkpolicy checkmodule
eb71cf8
+TARGETS = checkpolicy checkmodule semodule_package
e6e4a01
 
eb71cf8
 CFLAGS ?= -g -Wall -O2 -pipe -fno-strict-aliasing
e6e4a01
 
eb71cf8
@@ -15,8 +15,9 @@
eb71cf8
 CHECKOBJS = y.tab.o lex.yy.o queue.o module_compiler.o
eb71cf8
 CHECKPOLOBJS = $(CHECKOBJS) checkpolicy.o
eb71cf8
 CHECKMODOBJS = $(CHECKOBJS) checkmodule.o
eb71cf8
+SEMODULE_PACKAGEOBJS = semodule_package.o
e6e4a01
 
eb71cf8
-LDLIBS=$(LIBDIR)/libsepol.a -lfl
eb71cf8
+LDLIBS=$(LIBDIR)/libsepol.a -lfl 
e6e4a01
 
eb71cf8
 all:  $(TARGETS)
e6e4a01
 
eb71cf8
@@ -24,6 +25,9 @@
e6e4a01
 
eb71cf8
 checkmodule: $(CHECKMODOBJS)
e6e4a01
 
eb71cf8
+semodule_package: $(SEMODULE_PACKAGEOBJS)
eb71cf8
+	$(CC) -o $@ $^ ${LIBDIR}/libsemanage.a $(LIBDIR)/libsepol.a 
eb71cf8
+
eb71cf8
 %.o: %.c 
eb71cf8
 	$(CC) $(CFLAGS) -o $@ -c $<
e6e4a01
 
eb71cf8
diff --exclude-from=exclude -N -u -r nsacheckpolicy/semodule_package.c checkpolicy-1.25.3/semodule_package.c
eb71cf8
--- nsacheckpolicy/semodule_package.c	1969-12-31 19:00:00.000000000 -0500
eb71cf8
+++ checkpolicy-1.25.3/semodule_package.c	2005-07-28 15:30:24.000000000 -0400
eb71cf8
@@ -0,0 +1,74 @@
eb71cf8
+/* Authors: Karl MacMillan <kmacmillan@tresys.com>
eb71cf8
+ *
eb71cf8
+ * Copyright (C) 2004 Tresys Technology, LLC
eb71cf8
+ *	This program is free software; you can redistribute it and/or modify
eb71cf8
+ *  	it under the terms of the GNU General Public License as published by
eb71cf8
+ *	the Free Software Foundation, version 2.
eb71cf8
+ */
eb71cf8
+ 
eb71cf8
+#include <semanage/module.h>
eb71cf8
+
eb71cf8
+#include <fcntl.h>
eb71cf8
+#include <stdio.h>
eb71cf8
+#include <stdlib.h>
eb71cf8
+#include <unistd.h>
eb71cf8
+
eb71cf8
+extern char *optarg;
eb71cf8
+
eb71cf8
+static void usage(char *progname)
eb71cf8
+{
eb71cf8
+	printf("usage: %s PACKAGE MODULE [FILE_CONTEXTS]\n", progname);
eb71cf8
+        printf("Build a package from a module and optional file contexts.\n");
eb71cf8
+        printf("Options:\n");
eb71cf8
+        printf("  PACKAGE        name of file to write generated package\n");
eb71cf8
+        printf("  MODULE         base or policy module to wrap\n");
eb71cf8
+        printf("  FILE_CONTEXTS  file containing file contexts for this package\n");
eb71cf8
+	exit(1);
eb71cf8
+}
eb71cf8
+
eb71cf8
+static int file_to_policy_file(char *filename, struct policy_file *pf, char *mode)
eb71cf8
+{
eb71cf8
+	FILE *f;
eb71cf8
+	
eb71cf8
+	memset(pf, 0, sizeof(struct policy_file));
eb71cf8
+	
eb71cf8
+	f = fopen(filename, mode);
eb71cf8
+	if (!f) {
eb71cf8
+		fprintf(stderr, "Could not open file %s\n", filename);
eb71cf8
+		return -1;	
eb71cf8
+	}
eb71cf8
+	pf->type = PF_USE_STDIO;
eb71cf8
+	pf->fp = f;
eb71cf8
+	
eb71cf8
+	return 0;
eb71cf8
+}
eb71cf8
+
eb71cf8
+int main(int argc, char **argv)
eb71cf8
+{
eb71cf8
+	struct policy_file out, mod, fc;
eb71cf8
+	
eb71cf8
+	if (argc < 3 || argc > 4)
eb71cf8
+		usage(argv[0]);
eb71cf8
+	
eb71cf8
+	if (file_to_policy_file(argv[1], &out, "w"))
eb71cf8
+		exit(1);
eb71cf8
+		
eb71cf8
+	if (file_to_policy_file(argv[2], &mod, "r"))
eb71cf8
+		exit(1);
eb71cf8
+	
eb71cf8
+	if (argc == 3) {
eb71cf8
+		if (semod_module_package_create(&mod, NULL, &out)) {
eb71cf8
+			fprintf(stderr, "Could not write module package\n");
eb71cf8
+			exit(1);
eb71cf8
+		}
eb71cf8
+	} else if (argc == 4) {
eb71cf8
+		if (file_to_policy_file(argv[3], &fc, "r"))
eb71cf8
+			exit(1);
eb71cf8
+		if (semod_module_package_create(&mod, &fc, &out)) {
eb71cf8
+			fprintf(stderr, "Could not write module package\n");
eb71cf8
+			exit(1);
eb71cf8
+		}
eb71cf8
+	}
eb71cf8
+	
eb71cf8
+	return 0;
eb71cf8
+}