The branch, v4-15-test has been updated
       via  eed7de8a7e6 s3:passdb: Also allow to handle UPNs in 
lookup_name_smbconf()
       via  ca282bfff2b s3:passdb: Refactor lookup_name_smbconf()
       via  7defa615c57 s3:passdb: Use already defined pointer in 
lookup_name_smbconf()
       via  f11fef04471 s3:passdb: Add support to handle UPNs in lookup_name()
       via  84438001458 s3:passdb: Remove trailing spaces in lookup_sid.c
      from  e04bceba9aa VERSION: Bump version up to Samba 4.15.8...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-15-test


- Log -----------------------------------------------------------------
commit eed7de8a7e6aadc14ef3bd94ea1e1052da24ed8d
Author: Andreas Schneider <a...@cryptomilk.org>
Date:   Tue Apr 26 07:39:12 2022 +0200

    s3:passdb: Also allow to handle UPNs in lookup_name_smbconf()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15054
    
    Signed-off-by: Andreas Schneider <a...@cryptomilk.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 28fc44f2852046d03cada161ed1001d04d9e1554)
    
    Autobuild-User(v4-15-test): Jule Anger <jan...@samba.org>
    Autobuild-Date(v4-15-test): Thu Apr 28 08:45:28 UTC 2022 on sn-devel-184

commit ca282bfff2b76e8c5e3cf6ab6b050521c5bb660d
Author: Andreas Schneider <a...@cryptomilk.org>
Date:   Tue Apr 26 07:24:10 2022 +0200

    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 <a...@cryptomilk.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 2690310743920dfe20ac235c1e3617e0f421eddc)

commit 7defa615c57d9de2fde8eab3eaf86e7bcba9f863
Author: Andreas Schneider <a...@cryptomilk.org>
Date:   Tue Apr 26 12:26:25 2022 +0200

    s3:passdb: Use already defined pointer in lookup_name_smbconf()
    
    Signed-off-by: Andreas Schneider <a...@cryptomilk.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit ed8e466854d6d8d6120388716a7b604df7a4db27)

commit f11fef0447183da7334320dece5122cc010417e4
Author: Andreas Schneider <a...@cryptomilk.org>
Date:   Tue Apr 26 07:12:02 2022 +0200

    s3:passdb: Add support to handle UPNs in lookup_name()
    
    This address an issue if sssd is running and handling nsswitch. If we look 
up
    a user with getpwnam("DOMAIN\user") it will return user@REALM in the passwd
    structure. We need to be able to deal with that.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15054
    
    Signed-off-by: Andreas Schneider <a...@cryptomilk.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 2a03fb91c1120718ada9d4b8421044cb7eae7b83)

commit 844380014582b2e034d05740aa85ad0f96b24248
Author: Andreas Schneider <a...@cryptomilk.org>
Date:   Tue Apr 26 07:10:56 2022 +0200

    s3:passdb: Remove trailing spaces in lookup_sid.c
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15054
    
    Signed-off-by: Andreas Schneider <a...@cryptomilk.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 756cd0eed30322ae6dbd5402ec11441387475884)

-----------------------------------------------------------------------

Summary of changes:
 source3/passdb/lookup_sid.c | 52 +++++++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 21 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index a551bcfd24a..426ea3f81bd 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1,4 +1,4 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    uid/user handling
    Copyright (C) Andrew Tridgell         1992-1998
@@ -72,7 +72,7 @@ static bool lookup_unix_group_name(const char *name, struct 
dom_sid *sid)
  If an explicit domain name was given in the form domain\user, it
  has to try that. If no explicit domain name was given, we have
  to do guesswork.
-*****************************************************************/  
+*****************************************************************/
 
 bool lookup_name(TALLOC_CTX *mem_ctx,
                 const char *full_name, int flags,
@@ -100,8 +100,18 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
                                        PTR_DIFF(p, full_name));
                name = talloc_strdup(tmp_ctx, p+1);
        } else {
-               domain = talloc_strdup(tmp_ctx, "");
-               name = talloc_strdup(tmp_ctx, full_name);
+               char *q = strchr_m(full_name, '@');
+
+               /* Set the domain for UPNs */
+               if (q != NULL) {
+                       name = talloc_strndup(tmp_ctx,
+                                             full_name,
+                                             PTR_DIFF(q, full_name));
+                       domain = talloc_strdup(tmp_ctx, q + 1);
+               } else {
+                       domain = talloc_strdup(tmp_ctx, "");
+                       name = talloc_strdup(tmp_ctx, full_name);
+               }
        }
 
        if ((domain == NULL) || (name == NULL)) {
@@ -300,7 +310,7 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
                goto ok;
        }
 
-       /* 6. Builtin aliases */        
+       /* 6. Builtin aliases */
 
        if ((flags & LOOKUP_NAME_BUILTIN) &&
            lookup_builtin_name(name, &rid))
@@ -454,24 +464,24 @@ bool lookup_name_smbconf(TALLOC_CTX *mem_ctx,
                 const char **ret_domain, const char **ret_name,
                 struct dom_sid *ret_sid, enum lsa_SidType *ret_type)
 {
-       char *qualified_name;
-       const char *p;
+       char *qualified_name = NULL;
+       const char *p = strchr_m(full_name, *lp_winbind_separator());
+       bool is_qualified = p != NULL || strchr_m(full_name, '@') != NULL;
 
-       if ((p = strchr_m(full_name, *lp_winbind_separator())) != NULL) {
+       /* For DOMAIN\user or user@REALM directly call lookup_name(). */
+       if (is_qualified) {
 
                /* The name is already qualified with a domain. */
 
-               if (*lp_winbind_separator() != '\\') {
-                       char *tmp;
-
+               if (p != NULL && *lp_winbind_separator() != '\\') {
                        /* lookup_name() needs '\\' as a separator */
 
-                       tmp = talloc_strdup(mem_ctx, full_name);
-                       if (!tmp) {
+                       qualified_name = talloc_strdup(mem_ctx, full_name);
+                       if (qualified_name == NULL) {
                                return false;
                        }
-                       tmp[p - full_name] = '\\';
-                       full_name = tmp;
+                       qualified_name[p - full_name] = '\\';
+                       full_name = qualified_name;
                }
 
                return lookup_name(mem_ctx, full_name, flags,
@@ -882,7 +892,7 @@ NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
        }
 
        /* First build up the data structures:
-        * 
+        *
         * dom_infos is a list of domains referenced in the list of
         * SIDs. Later we will walk the list of domains and look up the RIDs
         * in bulk.
@@ -1070,7 +1080,7 @@ NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
 
 /*****************************************************************
  *THE CANONICAL* convert SID to name function.
-*****************************************************************/  
+*****************************************************************/
 
 bool lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
                const char **ret_domain, const char **ret_name,
@@ -1104,7 +1114,7 @@ bool lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid 
*sid,
                goto done;
        }
 
-       if ((ret_name != NULL) && 
+       if ((ret_name != NULL) &&
            !(*ret_name = talloc_strdup(mem_ctx, name->name))) {
                goto done;
        }
@@ -1130,7 +1140,7 @@ bool lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid 
*sid,
 
 /*****************************************************************
  *THE LEGACY* convert SID to id function.
-*****************************************************************/  
+*****************************************************************/
 
 static bool legacy_sid_to_unixid(const struct dom_sid *psid, struct unixid *id)
 {
@@ -1465,7 +1475,7 @@ fail:
 
 /*****************************************************************
  *THE CANONICAL* convert SID to uid function.
-*****************************************************************/  
+*****************************************************************/
 
 bool sid_to_uid(const struct dom_sid *psid, uid_t *puid)
 {
@@ -1527,7 +1537,7 @@ bool sid_to_uid(const struct dom_sid *psid, uid_t *puid)
 /*****************************************************************
  *THE CANONICAL* convert SID to gid function.
  Group mapping is used for gids that maps to Wellknown SIDs
-*****************************************************************/  
+*****************************************************************/
 
 bool sid_to_gid(const struct dom_sid *psid, gid_t *pgid)
 {


-- 
Samba Shared Repository

Reply via email to