4e7eb469bacf97c6b4ef45e119711de9a3c8b41e
[nivanova/samba-autobuild/.git] / source3 / include / auth.h
1 #ifndef _SMBAUTH_H_
2 #define _SMBAUTH_H_
3 /* 
4    Unix SMB/CIFS implementation.
5    Standardised Authentication types
6    Copyright (C) Andrew Bartlett 2001
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 typedef struct auth_usersupplied_info {
24         DATA_BLOB lm_resp;
25         DATA_BLOB nt_resp;
26         DATA_BLOB lm_interactive_pwd;
27         DATA_BLOB nt_interactive_pwd;
28         DATA_BLOB plaintext_password;
29         
30         BOOL encrypted;
31         
32         BOOL was_mapped;              /* Did the username map actually match? */
33         char *client_domain;          /* domain name string */
34         char *domain;                 /* domain name after mapping */
35         char *internal_username;      /* username after mapping */
36         char *smb_name;               /* username before mapping */
37         char *wksta_name;             /* workstation name (netbios calling
38                                        * name) unicode string */
39         
40         uint32 logon_parameters;
41
42 } auth_usersupplied_info;
43
44 typedef struct auth_serversupplied_info {
45         BOOL guest;
46
47         DOM_SID *sids;  /* These SIDs are preliminary between
48                            check_ntlm_password and the token creation. */
49         size_t num_sids;
50
51         uid_t uid;
52         gid_t gid;
53         
54         /* This groups info is needed for when we become_user() for this uid */
55         size_t n_groups;
56         gid_t *groups;
57         
58         /* NT group information taken from the info3 structure */
59         
60         NT_USER_TOKEN *ptok;
61         
62         DATA_BLOB user_session_key;
63         DATA_BLOB lm_session_key;
64
65         char *login_server; /* which server authorized the login? */
66         
67         struct samu *sam_account;
68         
69         void *pam_handle;
70
71         BOOL was_mapped;        /* Did the username map match? */
72         char *unix_name;
73         
74 } auth_serversupplied_info;
75
76 struct auth_context {
77         DATA_BLOB challenge; 
78
79         /* Who set this up in the first place? */ 
80         const char *challenge_set_by; 
81
82         BOOL challenge_may_be_modified;
83
84         struct auth_methods *challenge_set_method; 
85         /* What order are the various methods in?   Try to stop it changing under us */ 
86         struct auth_methods *auth_method_list;  
87
88         TALLOC_CTX *mem_ctx;
89         const uint8 *(*get_ntlm_challenge)(struct auth_context *auth_context);
90         NTSTATUS (*check_ntlm_password)(const struct auth_context *auth_context,
91                                         const struct auth_usersupplied_info *user_info, 
92                                         struct auth_serversupplied_info **server_info);
93         NTSTATUS (*nt_status_squash)(NTSTATUS nt_status);
94         void (*free)(struct auth_context **auth_context);
95 };
96
97 typedef struct auth_methods
98 {
99         struct auth_methods *prev, *next;
100         const char *name; /* What name got this module */
101
102         NTSTATUS (*auth)(const struct auth_context *auth_context,
103                          void *my_private_data, 
104                          TALLOC_CTX *mem_ctx,
105                          const struct auth_usersupplied_info *user_info, 
106                          auth_serversupplied_info **server_info);
107
108         /* If you are using this interface, then you are probably
109          * getting something wrong.  This interface is only for
110          * security=server, and makes a number of compromises to allow
111          * that.  It is not compatible with being a PDC.  */
112         DATA_BLOB (*get_chal)(const struct auth_context *auth_context,
113                               void **my_private_data, 
114                               TALLOC_CTX *mem_ctx);
115         
116         /* Used to keep tabs on things like the cli for SMB server authentication */
117         void *private_data;
118
119 } auth_methods;
120
121 typedef NTSTATUS (*auth_init_function)(struct auth_context *, const char *, struct auth_methods **);
122
123 struct auth_init_function_entry {
124         const char *name;
125         /* Function to create a member of the authmethods list */
126
127         auth_init_function init;
128
129         struct auth_init_function_entry *prev, *next;
130 };
131
132 typedef struct auth_ntlmssp_state {
133         TALLOC_CTX *mem_ctx;
134         struct auth_context *auth_context;
135         struct auth_serversupplied_info *server_info;
136         struct ntlmssp_state *ntlmssp_state;
137 } AUTH_NTLMSSP_STATE;
138
139 /* Changed from 1 -> 2 to add the logon_parameters field. */
140 #define AUTH_INTERFACE_VERSION 2
141
142 #endif /* _SMBAUTH_H_ */