r13316: Let the carnage begin....
[kai/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 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         char *client_domain;          /* domain name string */
33         char *domain;                 /* domain name after mapping */
34         char *internal_username;      /* username after mapping */
35         char *smb_name;               /* username before mapping */
36         char *wksta_name;             /* workstation name (netbios calling
37                                        * name) unicode string */
38         
39         uint32 logon_parameters;
40
41 } auth_usersupplied_info;
42
43 typedef struct auth_serversupplied_info {
44         BOOL guest;
45
46         DOM_SID *sids;  /* These SIDs are preliminary between
47                            check_ntlm_password and the token creation. */
48         size_t num_sids;
49
50         uid_t uid;
51         gid_t gid;
52         
53         /* This groups info is needed for when we become_user() for this uid */
54         size_t n_groups;
55         gid_t *groups;
56         
57         /* NT group information taken from the info3 structure */
58         
59         NT_USER_TOKEN *ptok;
60         
61         DATA_BLOB user_session_key;
62         DATA_BLOB lm_session_key;
63
64         char *login_server; /* which server authorized the login? */
65         
66         SAM_ACCOUNT *sam_account;
67         
68         void *pam_handle;
69
70         char *unix_name;
71         
72 } auth_serversupplied_info;
73
74 struct auth_context {
75         DATA_BLOB challenge; 
76
77         /* Who set this up in the first place? */ 
78         const char *challenge_set_by; 
79
80         BOOL challenge_may_be_modified;
81
82         struct auth_methods *challenge_set_method; 
83         /* What order are the various methods in?   Try to stop it changing under us */ 
84         struct auth_methods *auth_method_list;  
85
86         TALLOC_CTX *mem_ctx;
87         const uint8 *(*get_ntlm_challenge)(struct auth_context *auth_context);
88         NTSTATUS (*check_ntlm_password)(const struct auth_context *auth_context,
89                                         const struct auth_usersupplied_info *user_info, 
90                                         struct auth_serversupplied_info **server_info);
91         NTSTATUS (*nt_status_squash)(NTSTATUS nt_status);
92         void (*free)(struct auth_context **auth_context);
93 };
94
95 typedef struct auth_methods
96 {
97         struct auth_methods *prev, *next;
98         const char *name; /* What name got this module */
99
100         NTSTATUS (*auth)(const struct auth_context *auth_context,
101                          void *my_private_data, 
102                          TALLOC_CTX *mem_ctx,
103                          const struct auth_usersupplied_info *user_info, 
104                          auth_serversupplied_info **server_info);
105
106         /* If you are using this interface, then you are probably
107          * getting something wrong.  This interface is only for
108          * security=server, and makes a number of compromises to allow
109          * that.  It is not compatible with being a PDC.  */
110         DATA_BLOB (*get_chal)(const struct auth_context *auth_context,
111                               void **my_private_data, 
112                               TALLOC_CTX *mem_ctx);
113         
114         /* Used to keep tabs on things like the cli for SMB server authentication */
115         void *private_data;
116         
117         /* Function to clean up the above arbitary structure */
118         void (*free_private_data)(void **private_data);
119
120         /* Function to send a keepalive message on the above structure */
121         void (*send_keepalive)(void **private_data);
122
123 } auth_methods;
124
125 typedef NTSTATUS (*auth_init_function)(struct auth_context *, const char *, struct auth_methods **);
126
127 struct auth_init_function_entry {
128         const char *name;
129         /* Function to create a member of the authmethods list */
130
131         auth_init_function init;
132
133         struct auth_init_function_entry *prev, *next;
134 };
135
136 typedef struct auth_ntlmssp_state {
137         TALLOC_CTX *mem_ctx;
138         struct auth_context *auth_context;
139         struct auth_serversupplied_info *server_info;
140         struct ntlmssp_state *ntlmssp_state;
141 } AUTH_NTLMSSP_STATE;
142
143 /* Changed from 1 -> 2 to add the logon_parameters field. */
144 #define AUTH_INTERFACE_VERSION 2
145
146 #endif /* _SMBAUTH_H_ */