ctdb: Print locks latency in machinereadable stats
[Samba.git] / source3 / auth / proto.h
blob75cf1e6724fbb6ff3130b8af187b0443a03600c8
1 /*
2 * Unix SMB/CIFS implementation.
3 * Password and authentication handling
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
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.
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.
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/>.
33 #ifndef _AUTH_PROTO_H_
34 #define _AUTH_PROTO_H_
36 /* The following definitions come from auth/auth.c */
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_auth3_context_for_ntlm(TALLOC_CTX *mem_ctx,
42 struct auth_context **auth_context);
43 NTSTATUS make_auth3_context_for_netlogon(TALLOC_CTX *mem_ctx,
44 struct auth_context **auth_context);
45 NTSTATUS make_auth3_context_for_winbind(TALLOC_CTX *mem_ctx,
46 struct auth_context **auth_context);
47 bool auth3_context_set_challenge(struct auth_context *ctx, uint8_t chal[8],
48 const char *challenge_set_by);
50 /****************************************************************************
51 Try to get a challenge out of the various authentication modules.
52 Returns a const char of length 8 bytes.
53 ****************************************************************************/
55 NTSTATUS auth_get_ntlm_challenge(struct auth_context *auth_context,
56 uint8_t chal[8]);
58 /**
59 * Check a user's Plaintext, LM or NTLM password.
61 * Check a user's password, as given in the user_info struct and return various
62 * interesting details in the server_info struct.
64 * This function does NOT need to be in a become_root()/unbecome_root() pair
65 * as it makes the calls itself when needed.
67 * The return value takes precedence over the contents of the server_info
68 * struct. When the return is other than NT_STATUS_OK the contents
69 * of that structure is undefined.
71 * @param mem_ctx The memory context to use to allocate server_info
73 * @param user_info Contains the user supplied components, including the passwords.
74 * Must be created with make_user_info() or one of its wrappers.
76 * @param auth_context Supplies the challenges and some other data.
77 * Must be created with make_auth_context(), and the challenges should be
78 * filled in, either at creation or by calling the challenge geneation
79 * function auth_get_challenge().
81 * @param pserver_info If successful, contains information about the authentication,
82 * including a struct samu struct describing the user.
84 * @param pauthoritative Indicates if the result should be treated as final
85 * result.
87 * @return An NTSTATUS with NT_STATUS_OK or an appropriate error.
89 **/
90 NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx,
91 const struct auth_context *auth_context,
92 const struct auth_usersupplied_info *user_info,
93 struct auth_serversupplied_info **pserver_info,
94 uint8_t *pauthoritative);
96 /* The following definitions come from auth/auth_builtin.c */
98 NTSTATUS auth_builtin_init(TALLOC_CTX *mem_ctx);
100 /* The following definitions come from auth/auth_generic.c */
102 NTSTATUS make_auth4_context(TALLOC_CTX *mem_ctx, struct auth4_context **auth4_context_out);
103 NTSTATUS auth_generic_prepare(TALLOC_CTX *mem_ctx,
104 const struct tsocket_address *remote_address,
105 const struct tsocket_address *local_address,
106 const char *service_description,
107 struct gensec_security **gensec_security_out);
109 NTSTATUS auth_check_password_session_info(struct auth4_context *auth_context,
110 TALLOC_CTX *mem_ctx,
111 struct auth_usersupplied_info *user_info,
112 struct auth_session_info **session_info);
114 /* The following definitions come from auth/auth_ntlmssp.c */
116 NTSTATUS auth3_generate_session_info(struct auth4_context *auth_context,
117 TALLOC_CTX *mem_ctx,
118 void *server_returned_info,
119 const char *original_user_name,
120 uint32_t session_info_flags,
121 struct auth_session_info **session_info);
123 NTSTATUS auth3_get_challenge(struct auth4_context *auth4_context,
124 uint8_t chal[8]);
126 NTSTATUS auth3_set_challenge(struct auth4_context *auth4_context, const uint8_t *chal,
127 const char *challenge_set_by);
129 NTSTATUS auth3_check_password(struct auth4_context *auth4_context,
130 TALLOC_CTX *mem_ctx,
131 const struct auth_usersupplied_info *user_info,
132 uint8_t *pauthoritative,
133 void **server_returned_info,
134 DATA_BLOB *session_key, DATA_BLOB *lm_session_key);
136 /* The following definitions come from auth/auth_sam.c */
138 NTSTATUS check_sam_security(const DATA_BLOB *challenge,
139 TALLOC_CTX *mem_ctx,
140 const struct auth_usersupplied_info *user_info,
141 struct auth_serversupplied_info **server_info);
142 NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
143 TALLOC_CTX *mem_ctx,
144 const struct auth_usersupplied_info *user_info,
145 struct netr_SamInfo3 **pinfo3);
146 NTSTATUS auth_sam_init(TALLOC_CTX *mem_ctx);
148 /* The following definitions come from auth/auth_unix.c */
150 NTSTATUS auth_unix_init(TALLOC_CTX *mem_ctx);
152 /* The following definitions come from auth/auth_util.c */
153 struct tsocket_address;
155 NTSTATUS make_user_info_map(TALLOC_CTX *mem_ctx,
156 struct auth_usersupplied_info **user_info,
157 const char *smb_name,
158 const char *client_domain,
159 const char *workstation_name,
160 const struct tsocket_address *remote_address,
161 const struct tsocket_address *local_address,
162 const char *service_description,
163 const DATA_BLOB *lm_pwd,
164 const DATA_BLOB *nt_pwd,
165 const struct samr_Password *lm_interactive_pwd,
166 const struct samr_Password *nt_interactive_pwd,
167 const char *plaintext,
168 enum auth_password_state password_state);
169 bool make_user_info_netlogon_network(TALLOC_CTX *mem_ctx,
170 struct auth_usersupplied_info **user_info,
171 const char *smb_name,
172 const char *client_domain,
173 const char *workstation_name,
174 const struct tsocket_address *remote_address,
175 const struct tsocket_address *local_address,
176 uint32_t logon_parameters,
177 const uchar *lm_network_pwd,
178 int lm_pwd_len,
179 const uchar *nt_network_pwd,
180 int nt_pwd_len);
181 bool make_user_info_netlogon_interactive(TALLOC_CTX *mem_ctx,
182 struct auth_usersupplied_info **user_info,
183 const char *smb_name,
184 const char *client_domain,
185 const char *workstation_name,
186 const struct tsocket_address *remote_address,
187 const struct tsocket_address *local_address,
188 uint32_t logon_parameters,
189 const uchar chal[8],
190 const uchar lm_interactive_pwd[16],
191 const uchar nt_interactive_pwd[16]);
192 bool make_user_info_for_reply(TALLOC_CTX *mem_ctx,
193 struct auth_usersupplied_info **user_info,
194 const char *smb_name,
195 const char *client_domain,
196 const struct tsocket_address *remote_address,
197 const struct tsocket_address *local_address,
198 const char *service_description,
199 const uint8_t chal[8],
200 DATA_BLOB plaintext_password);
201 NTSTATUS make_user_info_for_reply_enc(TALLOC_CTX *mem_ctx,
202 struct auth_usersupplied_info **user_info,
203 const char *smb_name,
204 const char *client_domain,
205 const struct tsocket_address *remote_address,
206 const struct tsocket_address *local_address,
207 const char *service_description,
208 DATA_BLOB lm_resp, DATA_BLOB nt_resp);
209 bool make_user_info_guest(TALLOC_CTX *mem_ctx,
210 const struct tsocket_address *remote_address,
211 const struct tsocket_address *local_address,
212 const char *service_description,
213 struct auth_usersupplied_info **user_info);
215 struct samu;
216 NTSTATUS make_server_info_sam(TALLOC_CTX *mem_ctx,
217 struct samu *sampass,
218 struct auth_serversupplied_info **pserver_info);
219 NTSTATUS create_local_token(TALLOC_CTX *mem_ctx,
220 const struct auth_serversupplied_info *server_info,
221 DATA_BLOB *session_key,
222 const char *smb_name,
223 struct auth_session_info **session_info_out);
226 * The unix name should be constructed as DOMAIN+ACCOUNT,
227 * while '+' will be the "winbind separator" character.
229 #define AUTH3_UNIX_HINT_QUALIFIED_NAME 0x00000001
231 * The unix name will be just ACCOUNT
233 #define AUTH3_UNIX_HINT_ISLOLATED_NAME 0x00000002
235 * Don't translate the nt token SIDS into uid/gids
237 #define AUTH3_UNIX_HINT_DONT_TRANSLATE_FROM_SIDS 0x00000004
239 * Don't translate the unix token uid/gids to S-1-22-X-Y SIDS
241 #define AUTH3_UNIX_HINT_DONT_TRANSLATE_TO_SIDS 0x00000008
243 * The unix token won't get expanded gid values
244 * from getgroups_unix_user()
246 #define AUTH3_UNIX_HINT_DONT_EXPAND_UNIX_GROUPS 0x00000010
247 NTSTATUS auth3_user_info_dc_add_hints(struct auth_user_info_dc *user_info_dc,
248 uid_t uid,
249 gid_t gid,
250 uint32_t flags);
251 NTSTATUS auth3_session_info_create(TALLOC_CTX *mem_ctx,
252 const struct auth_user_info_dc *user_info_dc,
253 const char *original_user_name,
254 uint32_t session_info_flags,
255 struct auth_session_info **session_info_out);
256 NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
257 bool is_guest,
258 uid_t *uid, gid_t *gid,
259 char **found_username,
260 struct security_token **token);
261 bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
262 bool user_sid_in_group_sid(const struct dom_sid *sid, const struct dom_sid *group_sid);
263 bool user_in_group(const char *username, const char *groupname);
264 struct passwd;
265 NTSTATUS make_server_info_pw(TALLOC_CTX *mem_ctx,
266 const char *unix_username,
267 const struct passwd *pwd,
268 struct auth_serversupplied_info **server_info);
269 NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
270 const char *username,
271 bool is_guest,
272 struct auth_session_info **session_info);
273 bool init_guest_session_info(TALLOC_CTX *mem_ctx);
274 NTSTATUS init_system_session_info(TALLOC_CTX *mem_ctx);
275 bool session_info_set_session_key(struct auth_session_info *info,
276 DATA_BLOB session_key);
277 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
278 struct auth_serversupplied_info **server_info);
279 NTSTATUS make_session_info_guest(TALLOC_CTX *mem_ctx,
280 struct auth_session_info **server_info);
281 NTSTATUS make_server_info_anonymous(TALLOC_CTX *mem_ctx,
282 struct auth_serversupplied_info **server_info);
283 NTSTATUS make_session_info_anonymous(TALLOC_CTX *mem_ctx,
284 struct auth_session_info **psession_info);
285 NTSTATUS make_session_info_system(TALLOC_CTX *mem_ctx,
286 struct auth_session_info **session_info);
287 const struct auth_session_info *get_session_info_system(void);
288 struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser,
289 char **p_save_username, bool create );
290 NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
291 const char *sent_nt_username,
292 const char *domain,
293 struct auth_serversupplied_info **server_info,
294 const struct netr_SamInfo3 *info3);
295 struct wbcAuthUserInfo;
296 NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
297 const char *sent_nt_username,
298 const char *domain,
299 const struct wbcAuthUserInfo *info,
300 struct auth_serversupplied_info **server_info);
301 bool is_trusted_domain(const char* dom_name);
302 NTSTATUS session_extract_session_key(const struct auth_session_info *session_info, DATA_BLOB *session_key, enum session_key_use_intent intent);
304 /* The following definitions come from auth/user_info.c */
306 NTSTATUS make_user_info(TALLOC_CTX *mem_ctx,
307 struct auth_usersupplied_info **ret_user_info,
308 const char *smb_name,
309 const char *internal_username,
310 const char *client_domain,
311 const char *domain,
312 const char *workstation_name,
313 const struct tsocket_address *remote_address,
314 const struct tsocket_address *local_address,
315 const char *service_description,
316 const DATA_BLOB *lm_pwd,
317 const DATA_BLOB *nt_pwd,
318 const struct samr_Password *lm_interactive_pwd,
319 const struct samr_Password *nt_interactive_pwd,
320 const char *plaintext_password,
321 enum auth_password_state password_state);
323 NTSTATUS do_map_to_guest_server_info(TALLOC_CTX *mem_ctx,
324 NTSTATUS status,
325 const char *user,
326 const char *domain,
327 struct auth_serversupplied_info **server_info);
329 /* The following definitions come from auth/auth_winbind.c */
331 NTSTATUS auth_winbind_init(TALLOC_CTX *mem_ctx);
333 /* The following definitions come from auth/server_info.c */
335 struct netr_SamInfo2;
336 struct netr_SamInfo3;
337 struct netr_SamInfo6;
339 struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx);
340 NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
341 struct netr_SamInfo2 *sam2);
342 NTSTATUS serverinfo_to_SamInfo3(const struct auth_serversupplied_info *server_info,
343 struct netr_SamInfo3 *sam3);
344 NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
345 struct netr_SamInfo6 *sam6);
346 NTSTATUS create_info3_from_pac_logon_info(TALLOC_CTX *mem_ctx,
347 const struct PAC_LOGON_INFO *logon_info,
348 struct netr_SamInfo3 **pp_info3);
349 NTSTATUS create_info6_from_pac(TALLOC_CTX *mem_ctx,
350 const struct PAC_LOGON_INFO *logon_info,
351 const struct PAC_UPN_DNS_INFO *upn_dns_info,
352 struct netr_SamInfo6 **pp_info6);
353 NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
354 struct samu *samu,
355 const char *login_server,
356 struct netr_SamInfo3 **_info3,
357 struct extra_auth_info *extra);
358 NTSTATUS passwd_to_SamInfo3(TALLOC_CTX *mem_ctx,
359 const char *unix_username,
360 const struct passwd *pwd,
361 struct netr_SamInfo3 **pinfo3,
362 struct extra_auth_info *extra);
364 /* The following definitions come from auth/pampass.c */
366 bool smb_pam_claim_session(const char *user, const char *tty, const char *rhost);
367 bool smb_pam_close_session(const char *user, const char *tty, const char *rhost);
368 NTSTATUS smb_pam_accountcheck(const char *user, const char *rhost);
369 NTSTATUS smb_pam_passcheck(const char * user, const char * rhost,
370 const char * password);
371 bool smb_pam_passchange(const char *user, const char *rhost,
372 const char *oldpassword, const char *newpassword);
374 /* The following definitions come from auth/pass_check.c */
376 NTSTATUS pass_check(const struct passwd *pass,
377 const char *user,
378 const char *rhost,
379 const char *password,
380 bool run_cracker);
382 /* The following definitions come from auth/token_util.c */
384 bool nt_token_check_sid ( const struct dom_sid *sid, const struct security_token *token );
385 bool nt_token_check_domain_rid( struct security_token *token, uint32_t rid );
386 struct security_token *get_root_nt_token( void );
387 NTSTATUS add_aliases(const struct dom_sid *domain_sid,
388 struct security_token *token);
389 struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
390 const struct dom_sid *user_sid,
391 bool is_guest,
392 int num_groupsids,
393 const struct dom_sid *groupsids);
394 NTSTATUS finalize_local_nt_token(struct security_token *result,
395 uint32_t session_info_flags);
396 NTSTATUS get_user_sid_info3_and_extra(const struct netr_SamInfo3 *info3,
397 const struct extra_auth_info *extra,
398 struct dom_sid *sid);
399 NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
400 bool is_guest,
401 const struct netr_SamInfo3 *info3,
402 const struct extra_auth_info *extra,
403 struct security_token **ntok);
404 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
405 int n_groups, gid_t *groups);
407 /* The following definitions come from auth/user_util.c */
409 bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out);
410 bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname);
411 bool user_in_list(TALLOC_CTX *ctx, const char *user, const char * const *list);
413 /* The following definitions come from auth/user_krb5.c */
414 struct PAC_LOGON_INFO;
415 NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
416 const char *cli_name,
417 const char *princ_name,
418 struct PAC_LOGON_INFO *logon_info,
419 bool *is_mapped,
420 bool *mapped_to_guest,
421 char **ntuser,
422 char **ntdomain,
423 char **username,
424 struct passwd **_pw);
425 NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
426 char *ntuser,
427 char *ntdomain,
428 char *username,
429 struct passwd *pw,
430 const struct netr_SamInfo3 *info3,
431 bool mapped_to_guest, bool username_was_mapped,
432 DATA_BLOB *session_key,
433 struct auth_session_info **session_info);
435 /* The following definitions come from auth/auth_samba4.c */
437 NTSTATUS auth_samba4_init(TALLOC_CTX *mem_ctx);
439 #endif /* _AUTH_PROTO_H_ */