s3: Pass up domain name from msrpc name_to_sid
authorVolker Lendecke <vl@samba.org>
Thu, 8 Sep 2011 12:00:35 +0000 (14:00 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 11 Oct 2011 13:21:10 +0000 (15:21 +0200)
This fixes a bug where winbind caching did the wrong thing. rpcclient
lookupnames for \\domain admins (without domain) followed by a wbinfo -s <sid>
made the wbinfo call return \\domain admins as name, not the one with the
correct domain prefix.

source3/winbindd/winbindd_msrpc.c

index 05daf2400bde5c690efd477e021da9e699a2bd48..4ea925d1f6b6d27e113406c5db82e98ecc0558b8 100644 (file)
@@ -229,6 +229,7 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
        char *full_name = NULL;
        NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
        char *mapped_name = NULL;
+       const char **returned_domain = NULL;
 
        if (*name == NULL || **name=='\0') {
                full_name = talloc_asprintf(mem_ctx, "%s", *domain_name);
@@ -260,13 +261,21 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
                 full_name?full_name:"", *domain_name ));
 
        result = winbindd_lookup_names(mem_ctx, domain, 1,
-                                      (const char **)&full_name, NULL,
+                                      (const char **)&full_name,
+                                      &returned_domain,
                                       &sids, &types);
        if (!NT_STATUS_IS_OK(result))
                return result;
 
        /* Return rid and type if lookup successful */
 
+       if ((returned_domain != NULL) && (domain_name != NULL)) {
+               *domain_name = talloc_strdup(mem_ctx, *returned_domain);
+               if (*domain_name == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+       }
+
        sid_copy(sid, &sids[0]);
        *type = types[0];