auth4: Fix map_user_info_cracknames for domain==NULL
authorVolker Lendecke <vl@samba.org>
Sun, 26 Feb 2017 08:16:02 +0000 (09:16 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 28 Feb 2017 09:01:13 +0000 (10:01 +0100)
DsCrackNameOneName directly fails for DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT
if the name passed in does not contain a \. The only caller of
map_user_info_cracknames (auth_check_password_send) passes in
lpcfg_workgroup(), which does not contain a \. Add in the \ also for
the default_domain case.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/auth/ntlm/auth_util.c

index 3e5a0da59c2ebeab3f65d0792d9b4d8399b9074d..f7b01eb6ece165cffb6cd51fc69b44b32ee245f2 100644 (file)
@@ -128,12 +128,11 @@ static NTSTATUS map_user_info_cracknames(struct ldb_context *sam_ctx,
                        return NT_STATUS_NO_MEMORY;
                }
        } else {
-               char *domain_name;
+               const char *domain_name = default_domain;
                if (user_info->client.domain_name && *user_info->client.domain_name) {
-                       domain_name = talloc_asprintf(tmp_ctx, "%s\\", user_info->client.domain_name);
-               } else {
-                       domain_name = talloc_strdup(tmp_ctx, default_domain);
+                       domain_name = user_info->client.domain_name;
                }
+               domain_name = talloc_asprintf(tmp_ctx, "%s\\", domain_name);
                if (domain_name == NULL) {
                        talloc_free(tmp_ctx);
                        return NT_STATUS_NO_MEMORY;