checkpolicy/checkpolicy-rhat.patch

112 lines
3.0 KiB
Diff

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