mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipa-pki-retrieve-key: ensure we do not crash
If ipa-pki-retrieve-key fails for some reason (which may be a "legitimate" reason, e.g. the server it is attempting to contact being offline), the program terminates with an uncaught exception, resulting in crash report. Catch all exceptions; if an exception gets raised, report the traceback and exit with nonzero status. Fixes: https://pagure.io/freeipa/issue/7115 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
committed by
Stanislav Laznicka
parent
c4505f0804
commit
09f746f568
@@ -4,12 +4,15 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
from ipalib import constants
|
from ipalib import constants
|
||||||
from ipalib.config import Env
|
from ipalib.config import Env
|
||||||
from ipaplatform.paths import paths
|
from ipaplatform.paths import paths
|
||||||
from ipaserver.secrets.client import CustodiaClient
|
from ipaserver.secrets.client import CustodiaClient
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
env = Env()
|
env = Env()
|
||||||
env._finalize()
|
env._finalize()
|
||||||
|
|
||||||
@@ -30,3 +33,10 @@ client = CustodiaClient(
|
|||||||
# Print the response JSON to stdout; it is already in the format
|
# Print the response JSON to stdout; it is already in the format
|
||||||
# that Dogtag's ExternalProcessKeyRetriever expects
|
# that Dogtag's ExternalProcessKeyRetriever expects
|
||||||
print(client.fetch_key(keyname, store=False))
|
print(client.fetch_key(keyname, store=False))
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except BaseException:
|
||||||
|
traceback.print_exc()
|
||||||
|
sys.exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user