Skip to content
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

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

rjeffman
Copy link
Collaborator

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

keyfile = self._certmonger_metadata.get("key-file")
if keyfile:
try:
_fstat = os.stat(keyfile)
Copy link
Collaborator

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')
                        )
                    )

Copy link
Collaborator Author

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?

Copy link
Collaborator

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

Copy link
Collaborator Author

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>'.
@rjeffman rjeffman changed the title Workaround getcert issue when cert key-file is missing fix: Workaround getcert issue when cert key-file is missing Nov 26, 2024
@richm
Copy link
Collaborator

richm commented Nov 26, 2024

[citest]

@richm
Copy link
Collaborator

richm commented Nov 26, 2024

looks like the Fedora failures are unrelated (problem with ipa?)

@richm richm merged commit 9f4c6ea into linux-system-roles:main Nov 26, 2024
21 of 24 checks passed
@rjeffman rjeffman deleted the fix_rhel13333 branch November 26, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants