Skip to content

Commit

Permalink
[no merge] debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jw3 committed Dec 6, 2022
1 parent a1ca0c1 commit b6d55f8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/pyo3/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions examples/trust_deployments.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit b6d55f8

Please sign in to comment.