-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Workaround getcert issue when cert key-file is missing #243
Conversation
keyfile = self._certmonger_metadata.get("key-file") | ||
if keyfile: | ||
try: | ||
_fstat = os.stat(keyfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of os.stat
with exception handling, you can do something like
if keyfile and not os.path.exists(keyfile):
self.module.fail_json(
"Resubmiting a request without the private key "
"file may hang certmonger. Please, stop monitoring "
"certificate '{0}' before reissuing.".format(
self._certmonger_metadata.get('nickname')
)
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I shouldn't process the stat result.
What if the file has been removed and a directory created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I shouldn't process the stat result.
What if the file has been removed and a directory created?
ok, but in with the current code, _fstat
is not used, and CodeQL flags it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I change to use os.path.isfile
. More than that and we would be looking into the file content, which I believe is way out of scope here.
When trying to resubmit a certificate request that had the key file removed, "getcert" hangs indefinitely, causing the role to not respond. This workaround checks if the private key file has been removed and fails ressubmiting the certificate request until the situation is fixed, by the user, using 'getcert stop-tracking --id <cert ID>'.
a6ee37c
to
76221c7
Compare
[citest] |
looks like the Fedora failures are unrelated (problem with ipa?) |
When trying to resubmit a certificate request that had the key file removed, "getcert" hangs indefinitely, causing the role to not respond.
This workaround checks if the private key file has been removed and fails ressubmiting the certificate request until the situation is fixed, by the user, using 'getcert stop-tracking --id '.
Issue Tracker Tickets (Jira or BZ if any): RHEL-13333