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_ntlmssp.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_sam.c */
77 NTSTATUS check_sam_security(const DATA_BLOB *challenge,
79 const struct auth_usersupplied_info *user_info,
80 struct auth_serversupplied_info **server_info);
81 NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
83 const struct auth_usersupplied_info *user_info,
84 struct netr_SamInfo3 **pinfo3);
85 NTSTATUS auth_sam_init(void);
87 /* The following definitions come from auth/auth_server.c */
89 NTSTATUS auth_server_init(void);
91 /* The following definitions come from auth/auth_unix.c */
93 NTSTATUS auth_unix_init(void);
95 /* The following definitions come from auth/auth_util.c */
96 struct tsocket_address;
98 NTSTATUS make_user_info_map(struct auth_usersupplied_info **user_info,
100 const char *client_domain,
101 const char *workstation_name,
102 const struct tsocket_address *remote_address,
103 const DATA_BLOB *lm_pwd,
104 const DATA_BLOB *nt_pwd,
105 const struct samr_Password *lm_interactive_pwd,
106 const struct samr_Password *nt_interactive_pwd,
107 const char *plaintext,
108 enum auth_password_state password_state);
109 bool make_user_info_netlogon_network(struct auth_usersupplied_info **user_info,
110 const char *smb_name,
111 const char *client_domain,
112 const char *workstation_name,
113 const struct tsocket_address *remote_address,
114 uint32 logon_parameters,
115 const uchar *lm_network_pwd,
117 const uchar *nt_network_pwd,
119 bool make_user_info_netlogon_interactive(struct auth_usersupplied_info **user_info,
120 const char *smb_name,
121 const char *client_domain,
122 const char *workstation_name,
123 const struct tsocket_address *remote_address,
124 uint32 logon_parameters,
126 const uchar lm_interactive_pwd[16],
127 const uchar nt_interactive_pwd[16],
128 const uchar *dc_sess_key);
129 bool make_user_info_for_reply(struct auth_usersupplied_info **user_info,
130 const char *smb_name,
131 const char *client_domain,
132 const struct tsocket_address *remote_address,
134 DATA_BLOB plaintext_password);
135 NTSTATUS make_user_info_for_reply_enc(struct auth_usersupplied_info **user_info,
136 const char *smb_name,
137 const char *client_domain,
138 const struct tsocket_address *remote_address,
139 DATA_BLOB lm_resp, DATA_BLOB nt_resp);
140 bool make_user_info_guest(const struct tsocket_address *remote_address,
141 struct auth_usersupplied_info **user_info);
144 NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
145 struct samu *sampass);
146 NTSTATUS create_local_token(TALLOC_CTX *mem_ctx,
147 const struct auth_serversupplied_info *server_info,
148 DATA_BLOB *session_key,
149 const char *smb_name,
150 struct auth_session_info **session_info_out);
151 NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
153 uid_t *uid, gid_t *gid,
154 char **found_username,
155 struct security_token **token);
156 bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
157 bool user_in_group(const char *username, const char *groupname);
159 NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
162 NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
163 const char *username,
165 struct auth_session_info **session_info);
166 struct auth_session_info *copy_session_info(TALLOC_CTX *mem_ctx,
167 const struct auth_session_info *src);
168 bool init_guest_info(void);
169 NTSTATUS init_system_info(void);
170 bool session_info_set_session_key(struct auth_session_info *info,
171 DATA_BLOB session_key);
172 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
173 struct auth_serversupplied_info **server_info);
174 NTSTATUS make_session_info_guest(TALLOC_CTX *mem_ctx,
175 struct auth_session_info **server_info);
176 NTSTATUS make_session_info_system(TALLOC_CTX *mem_ctx,
177 struct auth_session_info **session_info);
178 const struct auth_session_info *get_session_info_system(void);
179 bool copy_current_user(struct current_user *dst, struct current_user *src);
180 struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser,
181 char **p_save_username, bool create );
182 NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
183 const char *sent_nt_username,
185 struct auth_serversupplied_info **server_info,
186 struct netr_SamInfo3 *info3);
187 struct wbcAuthUserInfo;
188 NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
189 const char *sent_nt_username,
191 const struct wbcAuthUserInfo *info,
192 struct auth_serversupplied_info **server_info);
193 void free_user_info(struct auth_usersupplied_info **user_info);
194 bool is_trusted_domain(const char* dom_name);
196 /* The following definitions come from auth/user_info.c */
198 NTSTATUS make_user_info(struct auth_usersupplied_info **ret_user_info,
199 const char *smb_name,
200 const char *internal_username,
201 const char *client_domain,
203 const char *workstation_name,
204 const struct tsocket_address *remote_address,
205 const DATA_BLOB *lm_pwd,
206 const DATA_BLOB *nt_pwd,
207 const struct samr_Password *lm_interactive_pwd,
208 const struct samr_Password *nt_interactive_pwd,
209 const char *plaintext_password,
210 enum auth_password_state password_state);
211 void free_user_info(struct auth_usersupplied_info **user_info);
213 NTSTATUS do_map_to_guest_server_info(NTSTATUS status,
214 struct auth_serversupplied_info **server_info,
215 const char *user, const char *domain);
217 /* The following definitions come from auth/auth_winbind.c */
219 NTSTATUS auth_winbind_init(void);
221 /* The following definitions come from auth/server_info.c */
223 struct netr_SamInfo2;
224 struct netr_SamInfo3;
225 struct netr_SamInfo6;
227 struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx);
228 NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
229 uint8_t *pipe_session_key,
230 size_t pipe_session_key_len,
231 struct netr_SamInfo2 *sam2);
232 NTSTATUS serverinfo_to_SamInfo3(const struct auth_serversupplied_info *server_info,
233 uint8_t *pipe_session_key,
234 size_t pipe_session_key_len,
235 struct netr_SamInfo3 *sam3);
236 NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
237 uint8_t *pipe_session_key,
238 size_t pipe_session_key_len,
239 struct netr_SamInfo6 *sam6);
240 NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
242 const char *login_server,
243 struct netr_SamInfo3 **_info3,
244 struct extra_auth_info *extra);
245 struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
246 struct netr_SamInfo3 *orig);
247 struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx,
248 const struct wbcAuthUserInfo *info);
250 /* The following definitions come from auth/auth_wbc.c */
252 NTSTATUS auth_wbc_init(void);
254 /* The following definitions come from auth/pampass.c */
256 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
257 bool smb_pam_close_session(char *user, char *tty, char *rhost);
258 NTSTATUS smb_pam_accountcheck(const char *user, const char *rhost);
259 NTSTATUS smb_pam_passcheck(const char * user, const char * rhost,
260 const char * password);
261 bool smb_pam_passchange(const char *user, const char *rhost,
262 const char *oldpassword, const char *newpassword);
263 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
264 bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
266 /* The following definitions come from auth/pass_check.c */
268 void dfs_unlogin(void);
269 NTSTATUS pass_check(const struct passwd *pass,
272 const char *password,
275 /* The following definitions come from auth/token_util.c */
277 bool nt_token_check_sid ( const struct dom_sid *sid, const struct security_token *token );
278 bool nt_token_check_domain_rid( struct security_token *token, uint32 rid );
279 struct security_token *get_root_nt_token( void );
280 NTSTATUS add_aliases(const struct dom_sid *domain_sid,
281 struct security_token *token);
282 struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
283 const struct dom_sid *user_sid,
286 const struct dom_sid *groupsids);
287 NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
289 const struct netr_SamInfo3 *info3,
290 const struct extra_auth_info *extra,
291 struct security_token **ntok);
292 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
293 int n_groups, gid_t *groups);
295 /* The following definitions come from auth/user_util.c */
297 bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out);
298 bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname);
299 bool user_in_list(TALLOC_CTX *ctx, const char *user,const char **list);
301 /* The following definitions come from auth/user_krb5.c */
302 struct PAC_LOGON_INFO;
303 NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
304 const char *cli_name,
305 const char *princ_name,
306 struct PAC_LOGON_INFO *logon_info,
308 bool *mapped_to_guest,
312 struct passwd **_pw);
313 NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
318 struct PAC_LOGON_INFO *logon_info,
319 bool mapped_to_guest, bool username_was_mapped,
320 DATA_BLOB *session_key,
321 struct auth_session_info **session_info);
323 #endif /* _AUTH_PROTO_H_ */