Skip to content

Commit

Permalink
CVE-2020-25717: s3-auth: fix MIT Realm regression
Browse files Browse the repository at this point in the history
This looks like a regression introduced by the recent security fixes. This
commit should hopefully fixes it.

As a quick solution it might be possible to use the username map script based on
the example in https://bugzilla.samba.org/show_bug.cgi?id=14901#c0. We're not
sure this behaves identical, but it might work in the standalone server case.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14922

Reported-at: https://lists.samba.org/archive/samba/2021-November/238720.html

Pair-Programmed-With: Stefan Metzmacher <[email protected]>

Signed-off-by: Ralph Boehme <[email protected]>
Signed-off-by: Stefan Metzmacher <[email protected]>
  • Loading branch information
slowfranklin authored and metze-samba committed Dec 3, 2021
1 parent f621317 commit 1e61de8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source3/auth/user_krb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
char *fuser = NULL;
char *unixuser = NULL;
struct passwd *pw = NULL;
bool may_retry = false;

DEBUG(3, ("Kerberos ticket principal name is [%s]\n", princ_name));

Expand All @@ -71,6 +72,7 @@ NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
domain = realm;
} else {
domain = lp_workgroup();
may_retry = true;
}

fuser = talloc_asprintf(mem_ctx,
Expand All @@ -89,6 +91,13 @@ NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
*mapped_to_guest = false;

pw = smb_getpwnam(mem_ctx, fuser, &unixuser, true);
if (may_retry && pw == NULL && !*is_mapped) {
fuser = talloc_strdup(mem_ctx, user);
if (!fuser) {
return NT_STATUS_NO_MEMORY;
}
pw = smb_getpwnam(mem_ctx, fuser, &unixuser, true);
}
if (pw) {
if (!unixuser) {
return NT_STATUS_NO_MEMORY;
Expand Down

0 comments on commit 1e61de8

Please sign in to comment.