Skip to content

[autobackport: sssd-2-9] krb5: improve reporting failure on reading keytab#8554

Closed
sssd-bot wants to merge 1 commit into
SSSD:sssd-2-9from
sssd-bot:SSSD-sssd-backport-pr8530-to-sssd-2-9
Closed

[autobackport: sssd-2-9] krb5: improve reporting failure on reading keytab#8554
sssd-bot wants to merge 1 commit into
SSSD:sssd-2-9from
sssd-bot:SSSD-sssd-backport-pr8530-to-sssd-2-9

Conversation

@sssd-bot

Copy link
Copy Markdown
Contributor

This is an automatic backport of PR#8530 krb5: improve reporting failure on reading keytab to branch sssd-2-9, created by @257.

Please make sure this backport is correct.

Note

The commits were cherry-picked without conflicts.

You can push changes to this pull request

git remote add sssd-bot [email protected]:sssd-bot/sssd.git
git fetch sssd-bot refs/heads/SSSD-sssd-backport-pr8530-to-sssd-2-9
git checkout SSSD-sssd-backport-pr8530-to-sssd-2-9
git push sssd-bot SSSD-sssd-backport-pr8530-to-sssd-2-9 --force

Original commits
3d27526 - krb5: improve reporting failure on reading keytab

Backported commits

  • 0d7dfbf - krb5: improve reporting failure on reading keytab

Original Pull Request Body

also, s/has not entries/has no entries/ when keytab_file has actually
no entries.

Signed-off-by: Paymon MARANDI [email protected]

also, s/has not entries/has no entries/ when keytab_file has actually
no entries.

Signed-off-by: Paymon MARANDI <[email protected]>
Reviewed-by: Alexey Tikhonov <[email protected]>
Reviewed-by: Pavel Březina <[email protected]>
(cherry picked from commit 3d27526)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a readability check using faccessat and relocates the sss_krb5_kt_have_content check within the copy_keytab_into_memory function in src/providers/krb5/krb5_keytab.c. Feedback indicates that the faccessat check should be restricted to FILE: keytabs to prevent potential regressions with non-file-based keytab types such as KCM: or API:.

Comment on lines +162 to +170
if (faccessat(AT_FDCWD, sep+1, R_OK, AT_EACCESS) != 0) {
saved_errno = errno;
DEBUG(SSSDBG_CRIT_FAILURE,
"keytab [%s] is not readable: [%d][%s].\n",
keytab_file, saved_errno, sss_strerror(saved_errno));

kerr = KRB5KRB_ERR_GENERIC;
goto done;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The readability check with faccessat is applied to all keytab types that are not MEMORY:. This could cause issues with other valid keytab types like KCM: or API:, which are not file-based and for which faccessat would likely fail, causing a regression.

To avoid this, the check should be performed only for FILE: keytabs.

Suggested change
if (faccessat(AT_FDCWD, sep+1, R_OK, AT_EACCESS) != 0) {
saved_errno = errno;
DEBUG(SSSDBG_CRIT_FAILURE,
"keytab [%s] is not readable: [%d][%s].\n",
keytab_file, saved_errno, sss_strerror(saved_errno));
kerr = KRB5KRB_ERR_GENERIC;
goto done;
}
if (strncmp(keytab_name, "FILE:", sizeof("FILE:") - 1) == 0) {
if (faccessat(AT_FDCWD, sep+1, R_OK, AT_EACCESS) != 0) {
saved_errno = errno;
DEBUG(SSSDBG_CRIT_FAILURE,
"keytab [%s] is not readable: [%d][%s].\n",
keytab_file, saved_errno, sss_strerror(saved_errno));
kerr = KRB5KRB_ERR_GENERIC;
goto done;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

how many cases are there? i was hoping for an enum but krb5_keytab is just an opaque type.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's follow up in #8555

@alexey-tikhonov alexey-tikhonov added the no-backport This should go to target branch only. label Mar 27, 2026
@alexey-tikhonov

Copy link
Copy Markdown
Member

I realized that since sssd-2-9 doesn't have support to run under non-root it's not very useful to backport this patch here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-backport This should go to target branch only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants