s3-auth: Remove auth_netlogond
[obnox/samba/samba-obnox.git] / source3 / auth / proto.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  Password and authentication handling
4  *
5  *  Copyright (C) Andrew Tridgell               1992-2001
6  *  Copyright (C) Luke Kenneth Casson Leighton  1996-2000
7  *  Copyright (C) Jeremy Allison                1997-2001
8  *  Copyright (C) John H Terpsta                1999-2001
9  *  Copyright (C) Tim Potter                    2000
10  *  Copyright (C) Andrew Bartlett               2001-2003
11  *  Copyright (C) Jelmer Vernooij               2002
12  *  Copyright (C) Rafal Szczesniak              2002
13  *  Copyright (C) Gerald Carter                 2003
14  *  Copyright (C) Volker Lendecke               2006,2010
15  *  Copyright (C) Michael Adam                  2007
16  *  Copyright (C) Dan Sledz                     2009
17  *  Copyright (C) Simo Sorce                    2010
18  *
19  *  This program is free software; you can redistribute it and/or modify
20  *  it under the terms of the GNU General Public License as published by
21  *  the Free Software Foundation; either version 3 of the License, or
22  *  (at your option) any later version.
23  *
24  *  This program is distributed in the hope that it will be useful,
25  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
26  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  *  GNU General Public License for more details.
28  *
29  *  You should have received a copy of the GNU General Public License
30  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
31  */
32
33 #ifndef _AUTH_PROTO_H_
34 #define _AUTH_PROTO_H_
35
36 /* The following definitions come from auth/auth.c  */
37
38 NTSTATUS smb_register_auth(int version, const char *name, auth_init_function init);
39 bool load_auth_module(struct auth_context *auth_context,
40                       const char *module, auth_methods **ret) ;
41 NTSTATUS make_auth_context_subsystem(TALLOC_CTX *mem_ctx,
42                                      struct auth_context **auth_context);
43 NTSTATUS make_auth_context_fixed(TALLOC_CTX *mem_ctx,
44                                  struct auth_context **auth_context,
45                                  uchar chal[8]) ;
46
47 /****************************************************************************
48  Try to get a challenge out of the various authentication modules.
49  Returns a const char of length 8 bytes.
50 ****************************************************************************/
51
52 NTSTATUS auth_get_ntlm_challenge(struct auth_context *auth_context,
53                                  uint8_t chal[8]);
54
55 /**
56  * Check a user's Plaintext, LM or NTLM password.
57  *
58  * Check a user's password, as given in the user_info struct and return various
59  * interesting details in the server_info struct.
60  *
61  * This function does NOT need to be in a become_root()/unbecome_root() pair
62  * as it makes the calls itself when needed.
63  *
64  * The return value takes precedence over the contents of the server_info 
65  * struct.  When the return is other than NT_STATUS_OK the contents 
66  * of that structure is undefined.
67  *
68  * @param user_info Contains the user supplied components, including the passwords.
69  *                  Must be created with make_user_info() or one of its wrappers.
70  *
71  * @param auth_context Supplies the challenges and some other data. 
72  *                  Must be created with make_auth_context(), and the challenges should be 
73  *                  filled in, either at creation or by calling the challenge geneation 
74  *                  function auth_get_challenge().  
75  *
76  * @param server_info If successful, contains information about the authentication, 
77  *                    including a struct samu struct describing the user.
78  *
79  * @return An NTSTATUS with NT_STATUS_OK or an appropriate error.
80  *
81  **/
82
83 NTSTATUS auth_check_ntlm_password(const struct auth_context *auth_context,
84                                   const struct auth_usersupplied_info *user_info, 
85                                   struct auth_serversupplied_info **server_info);
86
87 /* The following definitions come from auth/auth_builtin.c  */
88
89 NTSTATUS auth_builtin_init(void);
90
91 /* The following definitions come from auth/auth_domain.c  */
92
93 void attempt_machine_password_change(void);
94 NTSTATUS auth_domain_init(void);
95
96 /* The following definitions come from auth/auth_generic.c  */
97
98 NTSTATUS make_auth4_context(TALLOC_CTX *mem_ctx, struct auth4_context **auth4_context_out);
99 NTSTATUS auth_generic_prepare(TALLOC_CTX *mem_ctx, const struct tsocket_address *remote_address,
100                               struct gensec_security **gensec_security_out);
101
102 NTSTATUS auth_check_password_session_info(struct auth4_context *auth_context,
103                                           TALLOC_CTX *mem_ctx,
104                                           struct auth_usersupplied_info *user_info,
105                                           struct auth_session_info **session_info);
106
107 /* The following definitions come from auth/auth_ntlmssp.c  */
108
109 NTSTATUS auth3_generate_session_info(struct auth4_context *auth_context,
110                                      TALLOC_CTX *mem_ctx,
111                                      void *server_returned_info,
112                                      const char *original_user_name,
113                                      uint32_t session_info_flags,
114                                      struct auth_session_info **session_info);
115
116 NTSTATUS auth3_get_challenge(struct auth4_context *auth4_context,
117                              uint8_t chal[8]);
118
119 bool auth3_may_set_challenge(struct auth4_context *auth4_context);
120 NTSTATUS auth3_set_challenge(struct auth4_context *auth4_context, const uint8_t *chal,
121                              const char *challenge_set_by);
122
123 NTSTATUS auth3_check_password(struct auth4_context *auth4_context,
124                               TALLOC_CTX *mem_ctx,
125                               const struct auth_usersupplied_info *user_info,
126                               void **server_returned_info,
127                               DATA_BLOB *session_key, DATA_BLOB *lm_session_key);
128
129 /* The following definitions come from auth/auth_sam.c  */
130
131 NTSTATUS check_sam_security(const DATA_BLOB *challenge,
132                             TALLOC_CTX *mem_ctx,
133                             const struct auth_usersupplied_info *user_info,
134                             struct auth_serversupplied_info **server_info);
135 NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
136                                   TALLOC_CTX *mem_ctx,
137                                   const struct auth_usersupplied_info *user_info,
138                                   struct netr_SamInfo3 **pinfo3);
139 NTSTATUS auth_sam_init(void);
140
141 /* The following definitions come from auth/auth_unix.c  */
142
143 NTSTATUS auth_unix_init(void);
144
145 /* The following definitions come from auth/auth_util.c  */
146 struct tsocket_address;
147
148 NTSTATUS make_user_info_map(struct auth_usersupplied_info **user_info,
149                             const char *smb_name,
150                             const char *client_domain,
151                             const char *workstation_name,
152                             const struct tsocket_address *remote_address,
153                             const DATA_BLOB *lm_pwd,
154                             const DATA_BLOB *nt_pwd,
155                             const struct samr_Password *lm_interactive_pwd,
156                             const struct samr_Password *nt_interactive_pwd,
157                             const char *plaintext,
158                             enum auth_password_state password_state);
159 bool make_user_info_netlogon_network(struct auth_usersupplied_info **user_info,
160                                      const char *smb_name,
161                                      const char *client_domain,
162                                      const char *workstation_name,
163                                      const struct tsocket_address *remote_address,
164                                      uint32 logon_parameters,
165                                      const uchar *lm_network_pwd,
166                                      int lm_pwd_len,
167                                      const uchar *nt_network_pwd,
168                                      int nt_pwd_len);
169 bool make_user_info_netlogon_interactive(struct auth_usersupplied_info **user_info,
170                                          const char *smb_name,
171                                          const char *client_domain,
172                                          const char *workstation_name,
173                                          const struct tsocket_address *remote_address,
174                                          uint32 logon_parameters,
175                                          const uchar chal[8],
176                                          const uchar lm_interactive_pwd[16],
177                                          const uchar nt_interactive_pwd[16],
178                                          const uchar *dc_sess_key);
179 bool make_user_info_for_reply(struct auth_usersupplied_info **user_info,
180                               const char *smb_name,
181                               const char *client_domain,
182                               const struct tsocket_address *remote_address,
183                               const uint8 chal[8],
184                               DATA_BLOB plaintext_password);
185 NTSTATUS make_user_info_for_reply_enc(struct auth_usersupplied_info **user_info,
186                                       const char *smb_name,
187                                       const char *client_domain,
188                                       const struct tsocket_address *remote_address,
189                                       DATA_BLOB lm_resp, DATA_BLOB nt_resp);
190 bool make_user_info_guest(const struct tsocket_address *remote_address,
191                           struct auth_usersupplied_info **user_info);
192
193 struct samu;
194 NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
195                               struct samu *sampass);
196 NTSTATUS create_local_token(TALLOC_CTX *mem_ctx,
197                             const struct auth_serversupplied_info *server_info,
198                             DATA_BLOB *session_key,
199                             const char *smb_name,
200                             struct auth_session_info **session_info_out);
201 NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
202                                     bool is_guest,
203                                     uid_t *uid, gid_t *gid,
204                                     char **found_username,
205                                     struct security_token **token);
206 bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
207 bool user_in_group(const char *username, const char *groupname);
208 struct passwd;
209 NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
210                              char *unix_username,
211                              struct passwd *pwd);
212 NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
213                                          const char *username,
214                                          bool is_guest,
215                                          struct auth_session_info **session_info);
216 struct auth_session_info *copy_session_info(TALLOC_CTX *mem_ctx,
217                                              const struct auth_session_info *src);
218 bool init_guest_info(void);
219 NTSTATUS init_system_session_info(void);
220 bool session_info_set_session_key(struct auth_session_info *info,
221                                  DATA_BLOB session_key);
222 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
223                                 struct auth_serversupplied_info **server_info);
224 NTSTATUS make_session_info_guest(TALLOC_CTX *mem_ctx,
225                                 struct auth_session_info **server_info);
226 NTSTATUS make_session_info_system(TALLOC_CTX *mem_ctx,
227                                  struct auth_session_info **session_info);
228 const struct auth_session_info *get_session_info_system(void);
229 struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser,
230                              char **p_save_username, bool create );
231 NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
232                                 const char *sent_nt_username,
233                                 const char *domain,
234                                 struct auth_serversupplied_info **server_info,
235                                 struct netr_SamInfo3 *info3);
236 struct wbcAuthUserInfo;
237 NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
238                                           const char *sent_nt_username,
239                                           const char *domain,
240                                           const struct wbcAuthUserInfo *info,
241                                           struct auth_serversupplied_info **server_info);
242 void free_user_info(struct auth_usersupplied_info **user_info);
243 bool is_trusted_domain(const char* dom_name);
244 NTSTATUS session_extract_session_key(const struct auth_session_info *session_info, DATA_BLOB *session_key, enum session_key_use_intent intent);
245
246 /* The following definitions come from auth/user_info.c  */
247
248 NTSTATUS make_user_info(struct auth_usersupplied_info **ret_user_info,
249                         const char *smb_name,
250                         const char *internal_username,
251                         const char *client_domain,
252                         const char *domain,
253                         const char *workstation_name,
254                         const struct tsocket_address *remote_address,
255                         const DATA_BLOB *lm_pwd,
256                         const DATA_BLOB *nt_pwd,
257                         const struct samr_Password *lm_interactive_pwd,
258                         const struct samr_Password *nt_interactive_pwd,
259                         const char *plaintext_password,
260                         enum auth_password_state password_state);
261 void free_user_info(struct auth_usersupplied_info **user_info);
262
263 NTSTATUS do_map_to_guest_server_info(NTSTATUS status,
264                                      struct auth_serversupplied_info **server_info,
265                                      const char *user, const char *domain);
266
267 /* The following definitions come from auth/auth_winbind.c  */
268
269 NTSTATUS auth_winbind_init(void);
270
271 /* The following definitions come from auth/server_info.c  */
272
273 struct netr_SamInfo2;
274 struct netr_SamInfo3;
275 struct netr_SamInfo6;
276
277 struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx);
278 NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
279                                 uint8_t *pipe_session_key,
280                                 size_t pipe_session_key_len,
281                                 struct netr_SamInfo2 *sam2);
282 NTSTATUS serverinfo_to_SamInfo3(const struct auth_serversupplied_info *server_info,
283                                 uint8_t *pipe_session_key,
284                                 size_t pipe_session_key_len,
285                                 struct netr_SamInfo3 *sam3);
286 NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
287                                 uint8_t *pipe_session_key,
288                                 size_t pipe_session_key_len,
289                                 struct netr_SamInfo6 *sam6);
290 NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
291                           struct samu *samu,
292                           const char *login_server,
293                           struct netr_SamInfo3 **_info3,
294                           struct extra_auth_info *extra);
295 struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
296                                          struct netr_SamInfo3 *orig);
297 struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx,
298                                         const struct wbcAuthUserInfo *info);
299
300 /* The following definitions come from auth/auth_wbc.c  */
301
302 NTSTATUS auth_wbc_init(void);
303
304 /* The following definitions come from auth/pampass.c  */
305
306 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
307 bool smb_pam_close_session(char *user, char *tty, char *rhost);
308 NTSTATUS smb_pam_accountcheck(const char *user, const char *rhost);
309 NTSTATUS smb_pam_passcheck(const char * user, const char * rhost,
310                            const char * password);
311 bool smb_pam_passchange(const char *user, const char *rhost,
312                         const char *oldpassword, const char *newpassword);
313 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
314 bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
315
316 /* The following definitions come from auth/pass_check.c  */
317
318 void dfs_unlogin(void);
319 NTSTATUS pass_check(const struct passwd *pass,
320                     const char *user,
321                     const char *rhost,
322                     const char *password,
323                     bool run_cracker);
324
325 /* The following definitions come from auth/token_util.c  */
326
327 bool nt_token_check_sid ( const struct dom_sid *sid, const struct security_token *token );
328 bool nt_token_check_domain_rid( struct security_token *token, uint32 rid );
329 struct security_token *get_root_nt_token( void );
330 NTSTATUS add_aliases(const struct dom_sid *domain_sid,
331                      struct security_token *token);
332 struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
333                                             const struct dom_sid *user_sid,
334                                             bool is_guest,
335                                             int num_groupsids,
336                                             const struct dom_sid *groupsids);
337 NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
338                                           bool is_guest,
339                                           const struct netr_SamInfo3 *info3,
340                                           const struct extra_auth_info *extra,
341                                           struct security_token **ntok);
342 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
343                            int n_groups, gid_t *groups);
344
345 /* The following definitions come from auth/user_util.c  */
346
347 bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out);
348 bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname);
349 bool user_in_list(TALLOC_CTX *ctx, const char *user,const char **list);
350
351 /* The following definitions come from auth/user_krb5.c  */
352 struct PAC_LOGON_INFO;
353 NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
354                                      const char *cli_name,
355                                      const char *princ_name,
356                                      struct PAC_LOGON_INFO *logon_info,
357                                      bool *is_mapped,
358                                      bool *mapped_to_guest,
359                                      char **ntuser,
360                                      char **ntdomain,
361                                      char **username,
362                                      struct passwd **_pw);
363 NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
364                                 char *ntuser,
365                                 char *ntdomain,
366                                 char *username,
367                                 struct passwd *pw,
368                                 struct PAC_LOGON_INFO *logon_info,
369                                 bool mapped_to_guest, bool username_was_mapped,
370                                 DATA_BLOB *session_key,
371                                 struct auth_session_info **session_info);
372
373
374 #endif /* _AUTH_PROTO_H_ */