s3:auth Change winbindd -> auth interface to more standard structures
authorAndrew Bartlett <abartlet@samba.org>
Mon, 17 May 2010 09:04:31 +0000 (19:04 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 12 Jul 2010 04:36:29 +0000 (14:36 +1000)
This removes conversions to and from the source3 varient of the
server_info structure when replaced in s3compat, and presents a tidier
interface to winbindd in any case.

Andrew Bartlett

auth/common_auth.h
source3/auth/check_samsec.c
source3/winbindd/winbindd_pam.c

index 1663755594df0c2952d0bc5bb1f6a4226fadb270..b73f5f66a1b6514105c64b5fae9b4ec6b556d450 100644 (file)
@@ -91,7 +91,7 @@ NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx,
                             const char *impersonate_princ_s,
                             struct PAC_LOGON_INFO **logon_info);
 NTSTATUS auth_samba4_init(void);
-NTSTATUS check_sam_security(const DATA_BLOB *challenge,
-                           TALLOC_CTX *mem_ctx,
-                           const struct auth_usersupplied_info *user_info,
-                           struct auth_serversupplied_info **server_info);
+NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
+                                 TALLOC_CTX *mem_ctx,
+                                 const struct auth_usersupplied_info *user_info,
+                                 struct netr_SamInfo3 **pinfo3);
index df5dc31b9c97cc6317bad7b6e72b9da362db2f68..46e05aa0c2df39e3e6787caf50c8a4970d11b744 100644 (file)
@@ -509,3 +509,40 @@ done:
        data_blob_free(&lm_sess_key);
        return nt_status;
 }
+
+/* This helper function for winbindd returns a very similar value to
+ * what a NETLOGON call would give, without the indirection */
+NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
+                                 TALLOC_CTX *mem_ctx,
+                                 const struct auth_usersupplied_info *user_info,
+                                 struct netr_SamInfo3 **pinfo3)
+{
+       struct auth_serversupplied_info *server_info = NULL;
+       struct netr_SamInfo3 *info3;
+       NTSTATUS status;
+       TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+       if (!tmp_ctx) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       status = check_sam_security(challenge, tmp_ctx, user_info, &server_info);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(10, ("check_sam_security failed: %s\n",
+                          nt_errstr(status)));
+               return status;
+       }
+
+       info3 = TALLOC_ZERO_P(mem_ctx, struct netr_SamInfo3);
+       if (info3 == NULL) {
+               talloc_free(tmp_ctx);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       status = serverinfo_to_SamInfo3(server_info, NULL, 0, info3);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(10, ("serverinfo_to_SamInfo3 failed: %s\n",
+                          nt_errstr(status)));
+               return status;
+       }
+       *pinfo3 = info3;
+       return NT_STATUS_OK;
+}
index 1d91d5b8a62b78b2c50bc352b7e5020f819b8280..95bf9c639c561210aeb45a2986a4b86f6a2c566c 100644 (file)
@@ -1131,8 +1131,6 @@ static NTSTATUS winbindd_dual_auth_passdb(TALLOC_CTX *mem_ctx,
                                          struct netr_SamInfo3 **pinfo3)
 {
        struct auth_usersupplied_info *user_info = NULL;
-       struct auth_serversupplied_info *server_info = NULL;
-       struct netr_SamInfo3 *info3;
        NTSTATUS status;
 
        status = make_user_info(&user_info, user, user, domain, domain,
@@ -1143,30 +1141,13 @@ static NTSTATUS winbindd_dual_auth_passdb(TALLOC_CTX *mem_ctx,
                return status;
        }
 
-       status = check_sam_security(challenge, talloc_tos(), user_info,
-                                   &server_info);
-       free_user_info(&user_info);
-
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(10, ("check_ntlm_password failed: %s\n",
-                          nt_errstr(status)));
-               return status;
-       }
-
-       info3 = TALLOC_ZERO_P(mem_ctx, struct netr_SamInfo3);
-       if (info3 == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       status = serverinfo_to_SamInfo3(server_info, NULL, 0, info3);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(10, ("serverinfo_to_SamInfo3 failed: %s\n",
-                          nt_errstr(status)));
-               return status;
-       }
+       /* We don't want any more mapping of the username */
+       user_info->mapped_state = True;
 
+       status = check_sam_security_info3(challenge, talloc_tos(), user_info,
+                                         pinfo3);
+       free_user_info(&user_info);
        DEBUG(10, ("Authenticated user %s\\%s successfully\n", domain, user));
-       *pinfo3 = info3;
        return NT_STATUS_OK;
 }