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_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,
47 /* The following definitions come from auth/auth_builtin.c */
49 NTSTATUS auth_builtin_init(void);
51 /* The following definitions come from auth/auth_compat.c */
53 NTSTATUS check_plaintext_password(const char *smb_name,
54 const struct tsocket_address *remote_address,
55 DATA_BLOB plaintext_password,
56 struct auth_serversupplied_info **server_info);
57 bool password_ok(struct auth_context *actx, bool global_encrypted,
58 const char *session_workgroup,
60 const struct tsocket_address *remote_address,
61 DATA_BLOB password_blob);
63 /* The following definitions come from auth/auth_domain.c */
65 void attempt_machine_password_change(void);
66 NTSTATUS auth_domain_init(void);
68 NTSTATUS auth_netlogond_init(void);
70 /* The following definitions come from auth/auth_generic.c */
72 NTSTATUS auth_generic_prepare(TALLOC_CTX *mem_ctx, const struct tsocket_address *remote_address,
73 struct gensec_security **gensec_security_out);
75 /* The following definitions come from auth/auth_ntlmssp.c */
77 NTSTATUS auth3_generate_session_info(struct auth4_context *auth_context,
79 void *server_returned_info,
80 const char *original_user_name,
81 uint32_t session_info_flags,
82 struct auth_session_info **session_info);
84 NTSTATUS auth3_get_challenge(struct auth4_context *auth4_context,
87 bool auth3_may_set_challenge(struct auth4_context *auth4_context);
88 NTSTATUS auth3_set_challenge(struct auth4_context *auth4_context, const uint8_t *chal,
89 const char *challenge_set_by);
91 NTSTATUS auth3_check_password(struct auth4_context *auth4_context,
93 const struct auth_usersupplied_info *user_info,
94 void **server_returned_info,
95 DATA_BLOB *session_key, DATA_BLOB *lm_session_key);
97 /* The following definitions come from auth/auth_sam.c */
99 NTSTATUS check_sam_security(const DATA_BLOB *challenge,
101 const struct auth_usersupplied_info *user_info,
102 struct auth_serversupplied_info **server_info);
103 NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
105 const struct auth_usersupplied_info *user_info,
106 struct netr_SamInfo3 **pinfo3);
107 NTSTATUS auth_sam_init(void);
109 /* The following definitions come from auth/auth_server.c */
111 NTSTATUS auth_server_init(void);
113 /* The following definitions come from auth/auth_unix.c */
115 NTSTATUS auth_unix_init(void);
117 /* The following definitions come from auth/auth_util.c */
118 struct tsocket_address;
120 NTSTATUS make_user_info_map(struct auth_usersupplied_info **user_info,
121 const char *smb_name,
122 const char *client_domain,
123 const char *workstation_name,
124 const struct tsocket_address *remote_address,
125 const DATA_BLOB *lm_pwd,
126 const DATA_BLOB *nt_pwd,
127 const struct samr_Password *lm_interactive_pwd,
128 const struct samr_Password *nt_interactive_pwd,
129 const char *plaintext,
130 enum auth_password_state password_state);
131 bool make_user_info_netlogon_network(struct auth_usersupplied_info **user_info,
132 const char *smb_name,
133 const char *client_domain,
134 const char *workstation_name,
135 const struct tsocket_address *remote_address,
136 uint32 logon_parameters,
137 const uchar *lm_network_pwd,
139 const uchar *nt_network_pwd,
141 bool make_user_info_netlogon_interactive(struct auth_usersupplied_info **user_info,
142 const char *smb_name,
143 const char *client_domain,
144 const char *workstation_name,
145 const struct tsocket_address *remote_address,
146 uint32 logon_parameters,
148 const uchar lm_interactive_pwd[16],
149 const uchar nt_interactive_pwd[16],
150 const uchar *dc_sess_key);
151 bool make_user_info_for_reply(struct auth_usersupplied_info **user_info,
152 const char *smb_name,
153 const char *client_domain,
154 const struct tsocket_address *remote_address,
156 DATA_BLOB plaintext_password);
157 NTSTATUS make_user_info_for_reply_enc(struct auth_usersupplied_info **user_info,
158 const char *smb_name,
159 const char *client_domain,
160 const struct tsocket_address *remote_address,
161 DATA_BLOB lm_resp, DATA_BLOB nt_resp);
162 bool make_user_info_guest(const struct tsocket_address *remote_address,
163 struct auth_usersupplied_info **user_info);
166 NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
167 struct samu *sampass);
168 NTSTATUS create_local_token(TALLOC_CTX *mem_ctx,
169 const struct auth_serversupplied_info *server_info,
170 DATA_BLOB *session_key,
171 const char *smb_name,
172 struct auth_session_info **session_info_out);
173 NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
175 uid_t *uid, gid_t *gid,
176 char **found_username,
177 struct security_token **token);
178 bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
179 bool user_in_group(const char *username, const char *groupname);
181 NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
184 NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
185 const char *username,
187 struct auth_session_info **session_info);
188 struct auth_session_info *copy_session_info(TALLOC_CTX *mem_ctx,
189 const struct auth_session_info *src);
190 bool init_guest_info(void);
191 NTSTATUS init_system_info(void);
192 bool session_info_set_session_key(struct auth_session_info *info,
193 DATA_BLOB session_key);
194 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
195 struct auth_serversupplied_info **server_info);
196 NTSTATUS make_session_info_guest(TALLOC_CTX *mem_ctx,
197 struct auth_session_info **server_info);
198 NTSTATUS make_session_info_system(TALLOC_CTX *mem_ctx,
199 struct auth_session_info **session_info);
200 const struct auth_session_info *get_session_info_system(void);
201 bool copy_current_user(struct current_user *dst, struct current_user *src);
202 struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser,
203 char **p_save_username, bool create );
204 NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
205 const char *sent_nt_username,
207 struct auth_serversupplied_info **server_info,
208 struct netr_SamInfo3 *info3);
209 struct wbcAuthUserInfo;
210 NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
211 const char *sent_nt_username,
213 const struct wbcAuthUserInfo *info,
214 struct auth_serversupplied_info **server_info);
215 void free_user_info(struct auth_usersupplied_info **user_info);
216 bool is_trusted_domain(const char* dom_name);
218 /* The following definitions come from auth/user_info.c */
220 NTSTATUS make_user_info(struct auth_usersupplied_info **ret_user_info,
221 const char *smb_name,
222 const char *internal_username,
223 const char *client_domain,
225 const char *workstation_name,
226 const struct tsocket_address *remote_address,
227 const DATA_BLOB *lm_pwd,
228 const DATA_BLOB *nt_pwd,
229 const struct samr_Password *lm_interactive_pwd,
230 const struct samr_Password *nt_interactive_pwd,
231 const char *plaintext_password,
232 enum auth_password_state password_state);
233 void free_user_info(struct auth_usersupplied_info **user_info);
235 NTSTATUS do_map_to_guest_server_info(NTSTATUS status,
236 struct auth_serversupplied_info **server_info,
237 const char *user, const char *domain);
239 /* The following definitions come from auth/auth_winbind.c */
241 NTSTATUS auth_winbind_init(void);
243 /* The following definitions come from auth/server_info.c */
245 struct netr_SamInfo2;
246 struct netr_SamInfo3;
247 struct netr_SamInfo6;
249 struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx);
250 NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
251 uint8_t *pipe_session_key,
252 size_t pipe_session_key_len,
253 struct netr_SamInfo2 *sam2);
254 NTSTATUS serverinfo_to_SamInfo3(const struct auth_serversupplied_info *server_info,
255 uint8_t *pipe_session_key,
256 size_t pipe_session_key_len,
257 struct netr_SamInfo3 *sam3);
258 NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
259 uint8_t *pipe_session_key,
260 size_t pipe_session_key_len,
261 struct netr_SamInfo6 *sam6);
262 NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
264 const char *login_server,
265 struct netr_SamInfo3 **_info3,
266 struct extra_auth_info *extra);
267 struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
268 struct netr_SamInfo3 *orig);
269 struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx,
270 const struct wbcAuthUserInfo *info);
272 /* The following definitions come from auth/auth_wbc.c */
274 NTSTATUS auth_wbc_init(void);
276 /* The following definitions come from auth/pampass.c */
278 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
279 bool smb_pam_close_session(char *user, char *tty, char *rhost);
280 NTSTATUS smb_pam_accountcheck(const char *user, const char *rhost);
281 NTSTATUS smb_pam_passcheck(const char * user, const char * rhost,
282 const char * password);
283 bool smb_pam_passchange(const char *user, const char *rhost,
284 const char *oldpassword, const char *newpassword);
285 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
286 bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
288 /* The following definitions come from auth/pass_check.c */
290 void dfs_unlogin(void);
291 NTSTATUS pass_check(const struct passwd *pass,
294 const char *password,
297 /* The following definitions come from auth/token_util.c */
299 bool nt_token_check_sid ( const struct dom_sid *sid, const struct security_token *token );
300 bool nt_token_check_domain_rid( struct security_token *token, uint32 rid );
301 struct security_token *get_root_nt_token( void );
302 NTSTATUS add_aliases(const struct dom_sid *domain_sid,
303 struct security_token *token);
304 struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
305 const struct dom_sid *user_sid,
308 const struct dom_sid *groupsids);
309 NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
311 const struct netr_SamInfo3 *info3,
312 const struct extra_auth_info *extra,
313 struct security_token **ntok);
314 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
315 int n_groups, gid_t *groups);
317 /* The following definitions come from auth/user_util.c */
319 bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out);
320 bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname);
321 bool user_in_list(TALLOC_CTX *ctx, const char *user,const char **list);
323 /* The following definitions come from auth/user_krb5.c */
324 struct PAC_LOGON_INFO;
325 NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
326 const char *cli_name,
327 const char *princ_name,
328 struct PAC_LOGON_INFO *logon_info,
330 bool *mapped_to_guest,
334 struct passwd **_pw);
335 NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
340 struct PAC_LOGON_INFO *logon_info,
341 bool mapped_to_guest, bool username_was_mapped,
342 DATA_BLOB *session_key,
343 struct auth_session_info **session_info);
346 #endif /* _AUTH_PROTO_H_ */