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 krb5-related debug #915

Closed
wants to merge 4 commits into from

Conversation

alexey-tikhonov
Copy link
Member

This PR is continuation of cleanup work done in #883.

KEYTAB_CLEAN_NAME macro was replaced with sss_printable_keytab_name() function and a number of issues related with usage of krb5_get_error_message() were fixed.

@sumit-bose
Copy link
Contributor

Hi @alexey-tikhonov,

thanks for the patches. I had a comment about the 3rd one, please see inline.

bye,
Sumit

Ensure `sss_krb5_get_error_message()` never returns NULL
as result is used in a lot of places where checks are not performed.
Few sss_krb5_get_error_message() related memory leaks were fixed.
(Existing KRB5_DEBUG() macro did not fit to be used in those places)
@alexey-tikhonov
Copy link
Member Author

Hi @sumit-bose,

I had a comment about the 3rd one, please see inline.

Thank you for the review. I think I have addressed your comment.

if (krberr) {
DEBUG(SSSDBG_OP_FAILURE, "Failed to get default realm name: %s\n",
sss_krb5_get_error_message(context, krberr));
if (krberr != EOK) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

thank you for adding back the messages. I now only have a minor nitpick. I prefer to use EOK only for our own functions where we know they have return EOK;. For library calls like e.g. here krb5_get_default_realm() I'd prefer with the documented return values, so 0 in this case. I'm sure there are place where we do not handle this consistently but since I noticed it here, I wanted to add this comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I will fix this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Error handling was done wrong in a few aspects
in ldap_child_get_tgt_sync() function.

As per documentation:
"The behavior of krb5_get_error_message() is only defined
(1) the first time it is called after a failed call to a krb5 function
 using the same context, and
(2) only when the error code passed in is the same as that returned
by the krb5 function."

Both (1) and (2) were violated heavily.

Additionally in some cases ldap_child_get_tgt_sync() declared as
returning `krb5_error_code` was actually returning non krb5 error code.
KEYTAB_CLEAN_NAME macro was replaced with `sss_printable_keytab_name()`
function that provides real path in case of default keytab.
@sumit-bose
Copy link
Contributor

Thanks, ACK.

bye,
Sumit

@pbrezina
Copy link
Member

  • master
    • f9f6a3d - KEYTAB_CLEAN_NAME macro was replaced
    • 33c94b6 - ldap_child: sanitization of error handling
    • 4239a85 - Amended sss_krb5_get_error_message() usage.
    • a163f65 - util/sss_krb5: amended sss_krb5_get_error_message()

@alexey-tikhonov alexey-tikhonov deleted the fix_krb5_debug branch January 11, 2020 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants