From b6d55f88d6e4b16e6fbeba6a682efc7196fdc202 Mon Sep 17 00:00:00 2001 From: John Wass Date: Tue, 6 Dec 2022 10:44:12 -0500 Subject: [PATCH] [no merge] debug --- crates/pyo3/src/system.rs | 3 ++- examples/trust_deployments.py | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 examples/trust_deployments.py diff --git a/crates/pyo3/src/system.rs b/crates/pyo3/src/system.rs index 6a7256072..2e04887b1 100644 --- a/crates/pyo3/src/system.rs +++ b/crates/pyo3/src/system.rs @@ -99,7 +99,8 @@ impl PySystem { /// Update the host system with this state of this System and signal fapolicyd to reload trust pub fn deploy(&self) -> PyResult<()> { - daemon::deploy(self).map_err(|e| exceptions::PyRuntimeError::new_err(format!("{:?}", e))) + self.deploy_only() + //daemon::deploy(self).map_err(|e| exceptions::PyRuntimeError::new_err(format!("{:?}", e))) } /// Update the host system with this state of this System diff --git a/examples/trust_deployments.py b/examples/trust_deployments.py new file mode 100644 index 000000000..c20762086 --- /dev/null +++ b/examples/trust_deployments.py @@ -0,0 +1,40 @@ +import pathlib +import itertools as it +from fapolicy_analyzer import * + +with open("/etc/fapolicyd/trust.d/00.trust", "w") as f: + f.write("/foo/bar 1 00000000000000000000000\n") + f.write("/foo/baz 2 00000000000000000000000\n") + +with open("/etc/fapolicyd/trust.d/01.trust", "w") as f: + f.write("/foo/bing 3 00000000000000000000000\n") + f.write("/foo/boom 4 00000000000000000000000\n") + +with open("/etc/fapolicyd/fapolicyd.trust", "w") as f: + f.write("/foo/blah 5 00000000000000000000000\n") + f.write("/foo/barf 6 00000000000000000000000\n") + +s1 = System() +print(f"system1 has {len(s1.ancillary_trust())} trust entries") + +xs1 = Changeset() +for p in it.islice(pathlib.Path("/bin").iterdir(), 5): + xs1.add_trust(str(p)) +print(f"adding {xs1.len()} trust entries") + +s2 = s1.apply_changeset(xs1) +print(f"system2 has {len(s2.ancillary_trust())} trust entries") +s2.deploy() + +s3 = System() +print(f"s3 system has {len(s3.ancillary_trust())} trust entries") + +xs2 = Changeset() +xs2.del_trust("/bin/yappi") +s4 = s3.apply_changeset(xs2) +print(f"system4 has {len(s4.ancillary_trust())} trust entries") + +s4.deploy() + +s5 = System() +print(f"reloaded system has {len(s5.ancillary_trust())} trust entries")