Skip to contentSkip to conversation

Cleaned up patch

PATCH Daniel J Walsh 1 participant 1 message Aug 11, 2008 SELinux security module

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

seusers still does not seem to work correctly.

semanage login -a -s staff_u username
semanage login -m -s user_u username

seem to work.

semanage login -d username

leaves it in a wierd state.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkigXu4ACgkQrlYvE4MpobOc/wCeO26g+v1iaVTd6Ue60Yn2VmJy eZUAniVcFJHM0iahxmXp3m0FnXC4OZU5
=0Jes
-----END PGP SIGNATURE-----

src/direct_api.c +22 -7
diff --exclude-from=exclude -N -u -r nsalibsemanage/src/direct_api.c libsemanage-2.0.27/src/direct_api.c
@@ -491,9 +491,9 @@
 
 	/* FIXME: get rid of these, once we support loading the existing policy,
 	 * instead of rebuilding it */
-	modified |= seusers_modified;
-	modified |= fcontexts_modified;
-	modified |= users_extra_modified;
+	//      modified |= seusers_modified;
+	//	modified |= fcontexts_modified;
+	//	modified |= users_extra_modified;
 
 	/* If there were policy changes, or explicitly requested, rebuild the policy */
 	if (sh->do_rebuild || modified) {
@@ -582,6 +582,7 @@
 				retval = -1;
 				goto cleanup;
 			}
+
 			retval = write_file(sh, ofilename,
 					    sepol_module_package_get_seusers(base),
 					    sepol_module_package_get_seusers_len(base));
@@ -667,11 +668,25 @@
 		retval = semanage_verify_kernel(sh);
 		if (retval < 0)
 			goto cleanup;
-	}
-
-	/* FIXME: else if !modified, but seusers_modified, 
-	 * load the existing policy instead of rebuilding */
+	} else {
+		sepol_policydb_create(&out);
+		modified |= seusers_modified;
+		modified |= fcontexts_modified;
+		modified |= users_extra_modified;
+		
+		retval = semanage_read_policydb(sh, out);
+		if (retval < 0)
+			goto cleanup;
 
+		dbase_policydb_attach((dbase_policydb_t *) pusers_base->dbase,out);
+		dbase_policydb_attach((dbase_policydb_t *) pports->dbase, out);
+		dbase_policydb_attach((dbase_policydb_t *) pifaces->dbase, out);
+		dbase_policydb_attach((dbase_policydb_t *) pbools->dbase, out);
+		dbase_policydb_attach((dbase_policydb_t *) pnodes->dbase, out);
+		retval = semanage_base_merge_components(sh);
+		if (retval < 0)
+		  goto cleanup;
+	}
 	/* ======= Post-process: Validate non-policydb components ===== */
 
 	/* Validate local modifications to file contexts.
src/semanage_store.c +41 -0

47 lines not on this page · raw message

src/semanage_store.h +3 -0
diff --exclude-from=exclude -N -u -r nsalibsemanage/src/semanage_store.h libsemanage-2.0.27/src/semanage_store.h
@@ -97,6 +97,9 @@
 			    sepol_module_package_t * base,
 			    sepol_policydb_t ** policydb);
 
+int semanage_read_policydb(semanage_handle_t * sh,
+			    sepol_policydb_t * policydb);
+
 int semanage_write_policydb(semanage_handle_t * sh,
 			    sepol_policydb_t * policydb);