forked from osbuild/osbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stages: add
org.osbuild.update-crypto-policies
stage
This stage calls `update-crypto-policies` to set the policy applicable for the various cryptographic back-ends, such as SSL/TLS libraries. Signed-off-by: Miguel Martín <mmartinv@redhat.com>
- Loading branch information
Showing
6 changed files
with
2,308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/python3 | ||
""" | ||
Sets the policy applicable for the various cryptographic back-ends, | ||
such as SSL/TLS libraries. | ||
This stage calls `update-crypto-policies` to set the system's | ||
cryptographic policy. | ||
Notes: | ||
- Requires 'chroot' in the buildroot. | ||
- Runs the 'update-crypto-policies' script from the image in the chroot. | ||
""" | ||
|
||
|
||
import subprocess | ||
import sys | ||
|
||
from osbuild import api | ||
|
||
SCHEMA_2 = r""" | ||
"options": { | ||
"additionalProperties": false, | ||
"description": "Sets the current policy and overwrites the config file", | ||
"required": [ "policy" ], | ||
"properties": { | ||
"policy": { | ||
"type": "string", | ||
"minLength": 1, | ||
"description": "The policy to be applied." | ||
} | ||
} | ||
} | ||
""" | ||
|
||
|
||
def main(tree, options): | ||
policy = options.get("policy", "") | ||
if policy == "": | ||
return 1 | ||
|
||
cmd = ["/usr/sbin/chroot", tree, | ||
"/usr/bin/update-crypto-policies", "--set", policy] | ||
|
||
subprocess.run(cmd, check=True) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
args = api.arguments() | ||
r = main(args["tree"], args["options"]) | ||
sys.exit(r) |
Oops, something went wrong.