s4:auth Move struct auth_usersupplied_info to a common location
authorAndrew Bartlett <abartlet@samba.org>
Tue, 4 May 2010 06:44:08 +0000 (16:44 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 12 Jul 2010 04:36:28 +0000 (14:36 +1000)
This also changes the calling convention slightly - we should always
allocate this with talloc_zero() to allow some elements to be
optional.  Some elements may only make sense in Samba3, which I hope
will use this common structure.

Andrew Bartlett

auth/common_auth.h [new file with mode: 0644]
source4/auth/auth.h
source4/auth/ntlm/auth_simple.c
source4/auth/ntlm/auth_util.c
source4/auth/ntlmssp/ntlmssp_server.c
source4/rpc_server/netlogon/dcerpc_netlogon.c
source4/smb_server/smb/sesssetup.c

diff --git a/auth/common_auth.h b/auth/common_auth.h
new file mode 100644 (file)
index 0000000..14a0b2b
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+   Unix SMB/CIFS implementation.
+   Standardised Authentication types
+   Copyright (C) Andrew Bartlett 2001-2010
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define USER_INFO_CASE_INSENSITIVE_USERNAME 0x01 /* username may be in any case */
+#define USER_INFO_CASE_INSENSITIVE_PASSWORD 0x02 /* password may be in any case */
+#define USER_INFO_DONT_CHECK_UNIX_ACCOUNT   0x04 /* don't check unix account status */
+#define USER_INFO_INTERACTIVE_LOGON         0x08 /* don't check unix account status */
+
+enum auth_password_state {
+       AUTH_PASSWORD_RESPONSE,
+       AUTH_PASSWORD_HASH,
+       AUTH_PASSWORD_PLAIN
+};
+
+struct auth_usersupplied_info
+{
+       const char *workstation_name;
+       const struct tsocket_address *remote_host;
+
+       uint32_t logon_parameters;
+
+       bool mapped_state;
+       bool was_mapped;
+       /* the values the client gives us */
+       struct {
+               const char *account_name;
+               const char *domain_name;
+       } client, mapped;
+
+       enum auth_password_state password_state;
+
+       struct {
+               struct {
+                       DATA_BLOB lanman;
+                       DATA_BLOB nt;
+               } response;
+               struct {
+                       struct samr_Password *lanman;
+                       struct samr_Password *nt;
+               } hash;
+
+               char *plaintext;
+       } password;
+       uint32_t flags;
+};
index 9ce338c8aefda56d3f9dca93c95a90e7070235cc..ce583c871cdbd30f32aa595054928381a1ead329 100644 (file)
@@ -22,6 +22,7 @@
 #define _SAMBA_AUTH_H
 
 #include "librpc/gen_ndr/ndr_krb5pac.h"
+#include "../auth/common_auth.h"
 
 extern const char *krbtgt_attrs[];
 extern const char *server_attrs[];
@@ -43,52 +44,10 @@ struct loadparm_context;
 /* version 0 - till samba4 is stable - metze */
 #define AUTH_INTERFACE_VERSION 0
 
-#define USER_INFO_CASE_INSENSITIVE_USERNAME 0x01 /* username may be in any case */
-#define USER_INFO_CASE_INSENSITIVE_PASSWORD 0x02 /* password may be in any case */
-#define USER_INFO_DONT_CHECK_UNIX_ACCOUNT   0x04 /* don't check unix account status */
-#define USER_INFO_INTERACTIVE_LOGON         0x08 /* don't check unix account status */
-
 #define AUTH_SESSION_INFO_DEFAULT_GROUPS 0x01 /* Add the user to the default world and network groups */
 #define AUTH_SESSION_INFO_AUTHENTICATED  0x02 /* Add the user to the 'authenticated users' group */
 #define AUTH_SESSION_INFO_ENTERPRISE_DC  0x04 /* Add the user to the 'enterprise DC' group */
 
-enum auth_password_state {
-       AUTH_PASSWORD_RESPONSE,
-       AUTH_PASSWORD_HASH,
-       AUTH_PASSWORD_PLAIN
-};
-
-struct auth_usersupplied_info
-{
-       const char *workstation_name;
-       const struct tsocket_address *remote_host;
-
-       uint32_t logon_parameters;
-
-       bool mapped_state;
-       /* the values the client gives us */
-       struct {
-               const char *account_name;
-               const char *domain_name;
-       } client, mapped;
-
-       enum auth_password_state password_state;
-
-       union {
-               struct {
-                       DATA_BLOB lanman;
-                       DATA_BLOB nt;
-               } response;
-               struct {
-                       struct samr_Password *lanman;
-                       struct samr_Password *nt;
-               } hash;
-
-               char *plaintext;
-       } password;
-       uint32_t flags;
-};
-
 struct auth_serversupplied_info
 {
        struct dom_sid *account_sid;
index 9c8f7f64acf3e6fa97519d7476889f193d172b86..65a08cd92b7ff3348af7dc2b81102949fc81f771 100644 (file)
@@ -56,7 +56,7 @@ _PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
                return nt_status;
        }
 
-       user_info = talloc(tmp_ctx, struct auth_usersupplied_info);
+       user_info = talloc_zero(tmp_ctx, struct auth_usersupplied_info);
        if (!user_info) {
                talloc_free(tmp_ctx);
                return NT_STATUS_NO_MEMORY;
index 92df0bfe802b84baf6ac7a941d21f5c8b5d68f01..9e6050b904fd9cfd5fb76f1fc8a1312b10b494a9 100644 (file)
@@ -74,7 +74,7 @@ NTSTATUS map_user_info(TALLOC_CTX *mem_ctx,
                domain = default_domain;
        }
 
-       *user_info_mapped = talloc(mem_ctx, struct auth_usersupplied_info);
+       *user_info_mapped = talloc_zero(mem_ctx, struct auth_usersupplied_info);
        if (!*user_info_mapped) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -124,7 +124,7 @@ NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_contex
                {
                        uint8_t chal[8];
                        DATA_BLOB chall_blob;
-                       user_info_temp = talloc(mem_ctx, struct auth_usersupplied_info);
+                       user_info_temp = talloc_zero(mem_ctx, struct auth_usersupplied_info);
                        if (!user_info_temp) {
                                return NT_STATUS_NO_MEMORY;
                        }
@@ -190,7 +190,7 @@ NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_contex
                        struct samr_Password lanman;
                        struct samr_Password nt;
                        
-                       user_info_temp = talloc(mem_ctx, struct auth_usersupplied_info);
+                       user_info_temp = talloc_zero(mem_ctx, struct auth_usersupplied_info);
                        if (!user_info_temp) {
                                return NT_STATUS_NO_MEMORY;
                        }
index 5562180f3a1b008af39e44c4fd4f5f2622786480..69fc49c707400e28bd2a75a6b5c800cc403692d0 100644 (file)
@@ -632,7 +632,7 @@ static NTSTATUS auth_ntlmssp_check_password(struct ntlmssp_state *ntlmssp_state,
        NTSTATUS nt_status;
        struct auth_usersupplied_info *user_info;
 
-       user_info = talloc(ntlmssp_state, struct auth_usersupplied_info);
+       user_info = talloc_zero(ntlmssp_state, struct auth_usersupplied_info);
        if (!user_info) {
                return NT_STATUS_NO_MEMORY;
        }
index 28e517f0c945778efc767cde20007ce22823cdca..6eec94e34fe5f9780abb56f1abb9ed761ea33423 100644 (file)
@@ -491,13 +491,9 @@ static NTSTATUS dcesrv_netr_LogonSamLogon_base(struct dcesrv_call_state *dce_cal
        struct netr_SamInfo3 *sam3;
        struct netr_SamInfo6 *sam6;
 
-       user_info = talloc(mem_ctx, struct auth_usersupplied_info);
+       user_info = talloc_zero(mem_ctx, struct auth_usersupplied_info);
        NT_STATUS_HAVE_NO_MEMORY(user_info);
 
-       user_info->flags = 0;
-       user_info->mapped_state = false;
-       user_info->remote_host = NULL;
-
        switch (r->in.logon_level) {
        case NetlogonInteractiveInformation:
        case NetlogonServiceInformation:
index b61fce0887d235414688b0a69384a657c614eb25..936a7ce27db93e3a542d8c80c854b1573946b2f8 100644 (file)
@@ -144,7 +144,7 @@ static void sesssetup_old(struct smbsrv_request *req, union smb_sesssetup *sess)
                if (!remote_machine) goto nomem;
        }
 
-       user_info = talloc(req, struct auth_usersupplied_info);
+       user_info = talloc_zero(req, struct auth_usersupplied_info);
        if (!user_info) goto nomem;
        
        user_info->mapped_state = false;
@@ -319,7 +319,7 @@ static void sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *sess)
                if (!remote_machine) goto nomem;
        }
 
-       user_info = talloc(req, struct auth_usersupplied_info);
+       user_info = talloc_zero(req, struct auth_usersupplied_info);
        if (!user_info) goto nomem;
 
        user_info->mapped_state = false;