[PATCH 3/7] checkpolicy/dismod: avoid duplicate initialization and fix module linking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Avoid duplicate policydb initialization when reading a kernel policy.
One caller, main(), already performs the initialization.  The other one,
link_module(), needs to do it also for the module policy case.

Also set the target platform to enable module linking.

Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
---
 checkpolicy/test/dismod.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/checkpolicy/test/dismod.c b/checkpolicy/test/dismod.c
index 9f4a669b..ac2d61d2 100644
--- a/checkpolicy/test/dismod.c
+++ b/checkpolicy/test/dismod.c
@@ -824,10 +824,6 @@ static int read_policy(char *filename, policydb_t * policy, int verbose)
 		package->policy = NULL;
 		sepol_module_package_free(package);
 	} else {
-		if (policydb_init(policy)) {
-			fprintf(stderr, "%s:  Out of memory!\n", __FUNCTION__);
-			exit(1);
-		}
 		retval = policydb_read(policy, &f, verbose);
 	}
 	fclose(in_fp);
@@ -856,9 +852,15 @@ static void link_module(policydb_t * base, FILE * out_fp, int verbose)
 		return;
 	}
 
+	if (policydb_init(mods)) {
+		fprintf(stderr, "Out of memory!\n");
+		exit(1);
+	}
+
 	/* read the binary policy */
 	if (verbose)
 		fprintf(out_fp, "Reading module...\n");
+	policydb_set_target_platform(mods, base->target_platform);
 	if (read_policy(module_name, mods, verbose)) {
 		fprintf(stderr,
 			"%s:  error(s) encountered while loading policy\n",
-- 
2.43.0





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux