s3-auth Use *unix_token rather than utok in struct auth3_session_info
[samba.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 3 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, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "../auth/common_auth.h"
23
24 struct extra_auth_info {
25         struct dom_sid user_sid;
26         struct dom_sid pgid_sid;
27 };
28
29 struct auth_serversupplied_info {
30         bool guest;
31         bool system;
32
33         struct security_unix_token utok;
34
35         /* NT group information taken from the info3 structure */
36
37         struct security_token *security_token;
38
39         /* This is the final session key, as used by SMB signing, and
40          * (truncated to 16 bytes) encryption on the SAMR and LSA pipes
41          * when over ncacn_np.
42          * It is calculated by NTLMSSP from the session key in the info3,
43          * and is  set from the Kerberos session key using
44          * krb5_auth_con_getremotesubkey().
45          *
46          * Bottom line, it is not the same as the session keys in info3.
47          */
48
49         DATA_BLOB session_key;
50         DATA_BLOB lm_session_key;
51
52         struct netr_SamInfo3 *info3;
53
54         /* this structure is filled *only* in pathological cases where the user
55          * sid or the primary group sid are not sids of the domain. Normally
56          * this happens only for unix accounts that have unix domain sids.
57          * This is checked only when info3.rid and/or info3.primary_gid are set
58          * to the special invalid value of 0xFFFFFFFF */
59         struct extra_auth_info extra;
60
61         /*
62          * This is a token from /etc/passwd and /etc/group
63          */
64         bool nss_token;
65
66         char *unix_name;
67
68         /*
69          * For performance reasons we keep an alpha_strcpy-sanitized version
70          * of the username around as long as the global variable current_user
71          * still exists. If we did not do keep this, we'd have to call
72          * alpha_strcpy whenever we do a become_user(), potentially on every
73          * smb request. See set_current_user_info.
74          */
75         char *sanitized_username;
76 };
77
78 struct auth3_session_info {
79         bool guest;
80         bool system;
81
82         struct security_unix_token *unix_token;
83
84         /* NT group information taken from the info3 structure */
85
86         struct security_token *security_token;
87
88         /* This is the final session key, as used by SMB signing, and
89          * (truncated to 16 bytes) encryption on the SAMR and LSA pipes
90          * when over ncacn_np.
91          * It is calculated by NTLMSSP from the session key in the info3,
92          * and is  set from the Kerberos session key using
93          * krb5_auth_con_getremotesubkey().
94          *
95          * Bottom line, it is not the same as the session keys in info3.
96          */
97
98         DATA_BLOB session_key;
99         DATA_BLOB lm_session_key;
100
101         struct netr_SamInfo3 *info3;
102
103         /* this structure is filled *only* in pathological cases where the user
104          * sid or the primary group sid are not sids of the domain. Normally
105          * this happens only for unix accounts that have unix domain sids.
106          * This is checked only when info3.rid and/or info3.primary_gid are set
107          * to the special invalid value of 0xFFFFFFFF */
108         struct extra_auth_info extra;
109
110         /*
111          * This is a token from /etc/passwd and /etc/group
112          */
113         bool nss_token;
114
115         char *unix_name;
116
117         /*
118          * For performance reasons we keep an alpha_strcpy-sanitized version
119          * of the username around as long as the global variable current_user
120          * still exists. If we did not do keep this, we'd have to call
121          * alpha_strcpy whenever we do a become_user(), potentially on every
122          * smb request. See set_current_user_info.
123          */
124         char *sanitized_username;
125 };
126
127 struct auth_context {
128         DATA_BLOB challenge; 
129
130         /* Who set this up in the first place? */ 
131         const char *challenge_set_by; 
132
133         bool challenge_may_be_modified;
134
135         struct auth_methods *challenge_set_method; 
136         /* What order are the various methods in?   Try to stop it changing under us */ 
137         struct auth_methods *auth_method_list;  
138
139         NTSTATUS (*get_ntlm_challenge)(struct auth_context *auth_context,
140                                        uint8_t chal[8]);
141         NTSTATUS (*check_ntlm_password)(const struct auth_context *auth_context,
142                                         const struct auth_usersupplied_info *user_info, 
143                                         struct auth_serversupplied_info **server_info);
144         NTSTATUS (*nt_status_squash)(NTSTATUS nt_status);
145 };
146
147 typedef struct auth_methods
148 {
149         struct auth_methods *prev, *next;
150         const char *name; /* What name got this module */
151
152         NTSTATUS (*auth)(const struct auth_context *auth_context,
153                          void *my_private_data, 
154                          TALLOC_CTX *mem_ctx,
155                          const struct auth_usersupplied_info *user_info, 
156                          struct auth_serversupplied_info **server_info);
157
158         /* If you are using this interface, then you are probably
159          * getting something wrong.  This interface is only for
160          * security=server, and makes a number of compromises to allow
161          * that.  It is not compatible with being a PDC.  */
162         DATA_BLOB (*get_chal)(const struct auth_context *auth_context,
163                               void **my_private_data, 
164                               TALLOC_CTX *mem_ctx);
165
166         /* Used to keep tabs on things like the cli for SMB server authentication */
167         void *private_data;
168
169 } auth_methods;
170
171 typedef NTSTATUS (*auth_init_function)(struct auth_context *, const char *, struct auth_methods **);
172
173 struct auth_init_function_entry {
174         const char *name;
175         /* Function to create a member of the authmethods list */
176
177         auth_init_function init;
178
179         struct auth_init_function_entry *prev, *next;
180 };
181
182 struct auth_ntlmssp_state;
183
184 /* Changed from 1 -> 2 to add the logon_parameters field. */
185 /* Changed from 2 -> 3 when we reworked many auth structures to use IDL or be in common with Samba4 */
186 #define AUTH_INTERFACE_VERSION 3
187
188 #include "auth/proto.h"
189
190 #endif /* _SMBAUTH_H_ */