diff --git a/samples/base-with-selinux.json b/samples/base-with-selinux.json new file mode 100644 index 00000000..81dd0936 --- /dev/null +++ b/samples/base-with-selinux.json @@ -0,0 +1,23 @@ +{ + "name": "base-with-selinux", + "stages": [ + { + "name": "io.weldr.untree", + "options": { + "tree": "base" + } + }, + { + "name": "io.weldr.selinux", + "options": { + "file_contexts": "etc/selinux/targeted/contexts/files/file_contexts" + } + } + ], + "assembler": { + "name": "io.weldr.tree", + "options": { + "tree": "base-with-selinux" + } + } +} diff --git a/samples/base.json b/samples/base.json index 6108bc17..92902ccc 100644 --- a/samples/base.json +++ b/samples/base.json @@ -14,7 +14,8 @@ } }, "packages": [ - "@Core" + "@Core", + "selinux-policy-targeted" ] } } diff --git a/stages/io.weldr.selinux b/stages/io.weldr.selinux new file mode 100755 index 00000000..1285d9b6 --- /dev/null +++ b/stages/io.weldr.selinux @@ -0,0 +1,16 @@ +#!/usr/bin/python3 + +import json +import os +import subprocess +import sys + +def main(tree, options): + file_contexts = os.path.join(f"{tree}", options["file_contexts"]) + + subprocess.run(["setfiles", "-F", "-r", f"{tree}", f"{file_contexts}", f"{tree}"], check=True) + +if __name__ == '__main__': + args = json.load(sys.stdin) + r = main(args["tree"], args["options"]) + sys.exit(r)