From 2690310743920dfe20ac235c1e3617e0f421eddc Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 26 Apr 2022 07:24:10 +0200 Subject: [PATCH] s3:passdb: Refactor lookup_name_smbconf() This will be changed to support UPNs too in the next patch. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15054 Signed-off-by: Andreas Schneider Reviewed-by: Jeremy Allison --- source3/passdb/lookup_sid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c index dbea5578f92..de9dd123239 100644 --- a/source3/passdb/lookup_sid.c +++ b/source3/passdb/lookup_sid.c @@ -465,13 +465,14 @@ bool lookup_name_smbconf(TALLOC_CTX *mem_ctx, struct dom_sid *ret_sid, enum lsa_SidType *ret_type) { char *qualified_name = NULL; - const char *p; + const char *p = strchr_m(full_name, *lp_winbind_separator()); + bool is_qualified = p != NULL; - if ((p = strchr_m(full_name, *lp_winbind_separator())) != NULL) { + if (is_qualified) { /* The name is already qualified with a domain. */ - if (*lp_winbind_separator() != '\\') { + if (p != NULL && *lp_winbind_separator() != '\\') { /* lookup_name() needs '\\' as a separator */ qualified_name = talloc_strdup(mem_ctx, full_name);