s3-auth rename auth_ntlmssp_steal_session_info()
[nivanova/samba-autobuild/.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 /* The following definitions come from auth/auth_builtin.c  */
48
49 NTSTATUS auth_builtin_init(void);
50
51 /* The following definitions come from auth/auth_compat.c  */
52
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,
59                  const char *smb_name,
60                  const struct tsocket_address *remote_address,
61                  DATA_BLOB password_blob);
62
63 /* The following definitions come from auth/auth_domain.c  */
64
65 void attempt_machine_password_change(void);
66 NTSTATUS auth_domain_init(void);
67
68 NTSTATUS auth_netlogond_init(void);
69
70 /* The following definitions come from auth/auth_ntlmssp.c  */
71
72 NTSTATUS auth_ntlmssp_session_info(TALLOC_CTX *mem_ctx,
73                                    struct auth_ntlmssp_state *auth_ntlmssp_state,
74                                    struct auth_session_info **session_info);
75 NTSTATUS auth_ntlmssp_prepare(const struct tsocket_address *remote_address,
76                               struct auth_ntlmssp_state **auth_ntlmssp_state);
77 NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state *auth_ntlmssp_state);
78 NTSTATUS auth_generic_start(struct auth_ntlmssp_state *auth_ntlmssp_state, const char *oid);
79
80
81 /* The following definitions come from auth/auth_sam.c  */
82
83 NTSTATUS check_sam_security(const DATA_BLOB *challenge,
84                             TALLOC_CTX *mem_ctx,
85                             const struct auth_usersupplied_info *user_info,
86                             struct auth_serversupplied_info **server_info);
87 NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
88                                   TALLOC_CTX *mem_ctx,
89                                   const struct auth_usersupplied_info *user_info,
90                                   struct netr_SamInfo3 **pinfo3);
91 NTSTATUS auth_sam_init(void);
92
93 /* The following definitions come from auth/auth_server.c  */
94
95 NTSTATUS auth_server_init(void);
96
97 /* The following definitions come from auth/auth_unix.c  */
98
99 NTSTATUS auth_unix_init(void);
100
101 /* The following definitions come from auth/auth_util.c  */
102 struct tsocket_address;
103
104 NTSTATUS make_user_info_map(struct auth_usersupplied_info **user_info,
105                             const char *smb_name,
106                             const char *client_domain,
107                             const char *workstation_name,
108                             const struct tsocket_address *remote_address,
109                             DATA_BLOB *lm_pwd,
110                             DATA_BLOB *nt_pwd,
111                             const struct samr_Password *lm_interactive_pwd,
112                             const struct samr_Password *nt_interactive_pwd,
113                             const char *plaintext,
114                             enum auth_password_state password_state);
115 bool make_user_info_netlogon_network(struct auth_usersupplied_info **user_info,
116                                      const char *smb_name,
117                                      const char *client_domain,
118                                      const char *workstation_name,
119                                      const struct tsocket_address *remote_address,
120                                      uint32 logon_parameters,
121                                      const uchar *lm_network_pwd,
122                                      int lm_pwd_len,
123                                      const uchar *nt_network_pwd,
124                                      int nt_pwd_len);
125 bool make_user_info_netlogon_interactive(struct auth_usersupplied_info **user_info,
126                                          const char *smb_name,
127                                          const char *client_domain,
128                                          const char *workstation_name,
129                                          const struct tsocket_address *remote_address,
130                                          uint32 logon_parameters,
131                                          const uchar chal[8],
132                                          const uchar lm_interactive_pwd[16],
133                                          const uchar nt_interactive_pwd[16],
134                                          const uchar *dc_sess_key);
135 bool make_user_info_for_reply(struct auth_usersupplied_info **user_info,
136                               const char *smb_name,
137                               const char *client_domain,
138                               const struct tsocket_address *remote_address,
139                               const uint8 chal[8],
140                               DATA_BLOB plaintext_password);
141 NTSTATUS make_user_info_for_reply_enc(struct auth_usersupplied_info **user_info,
142                                       const char *smb_name,
143                                       const char *client_domain,
144                                       const struct tsocket_address *remote_address,
145                                       DATA_BLOB lm_resp, DATA_BLOB nt_resp);
146 bool make_user_info_guest(const struct tsocket_address *remote_address,
147                           struct auth_usersupplied_info **user_info);
148
149 struct samu;
150 NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
151                               struct samu *sampass);
152 NTSTATUS create_local_token(TALLOC_CTX *mem_ctx,
153                             const struct auth_serversupplied_info *server_info,
154                             DATA_BLOB *session_key,
155                             const char *smb_name,
156                             struct auth_session_info **session_info_out);
157 NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
158                                     bool is_guest,
159                                     uid_t *uid, gid_t *gid,
160                                     char **found_username,
161                                     struct security_token **token);
162 bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
163 bool user_in_group(const char *username, const char *groupname);
164 struct passwd;
165 NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
166                              char *unix_username,
167                              struct passwd *pwd);
168 NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
169                                          const char *username,
170                                          bool is_guest,
171                                          struct auth_session_info **session_info);
172 struct auth_session_info *copy_session_info(TALLOC_CTX *mem_ctx,
173                                              const struct auth_session_info *src);
174 bool init_guest_info(void);
175 NTSTATUS init_system_info(void);
176 bool session_info_set_session_key(struct auth_session_info *info,
177                                  DATA_BLOB session_key);
178 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
179                                 struct auth_serversupplied_info **server_info);
180 NTSTATUS make_session_info_guest(TALLOC_CTX *mem_ctx,
181                                 struct auth_session_info **server_info);
182 NTSTATUS make_session_info_system(TALLOC_CTX *mem_ctx,
183                                  struct auth_session_info **session_info);
184 const struct auth_session_info *get_session_info_system(void);
185 bool copy_current_user(struct current_user *dst, struct current_user *src);
186 struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser,
187                              char **p_save_username, bool create );
188 NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
189                                 const char *sent_nt_username,
190                                 const char *domain,
191                                 struct auth_serversupplied_info **server_info,
192                                 struct netr_SamInfo3 *info3);
193 struct wbcAuthUserInfo;
194 NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
195                                           const char *sent_nt_username,
196                                           const char *domain,
197                                           const struct wbcAuthUserInfo *info,
198                                           struct auth_serversupplied_info **server_info);
199 void free_user_info(struct auth_usersupplied_info **user_info);
200 bool make_auth_methods(struct auth_context *auth_context, auth_methods **auth_method) ;
201 bool is_trusted_domain(const char* dom_name);
202
203 /* The following definitions come from auth/user_info.c  */
204
205 NTSTATUS make_user_info(struct auth_usersupplied_info **ret_user_info,
206                         const char *smb_name,
207                         const char *internal_username,
208                         const char *client_domain,
209                         const char *domain,
210                         const char *workstation_name,
211                         const struct tsocket_address *remote_address,
212                         const DATA_BLOB *lm_pwd,
213                         const DATA_BLOB *nt_pwd,
214                         const struct samr_Password *lm_interactive_pwd,
215                         const struct samr_Password *nt_interactive_pwd,
216                         const char *plaintext_password,
217                         enum auth_password_state password_state);
218 void free_user_info(struct auth_usersupplied_info **user_info);
219
220 NTSTATUS do_map_to_guest_server_info(NTSTATUS status,
221                                      struct auth_serversupplied_info **server_info,
222                                      const char *user, const char *domain);
223
224 /* The following definitions come from auth/auth_winbind.c  */
225
226 NTSTATUS auth_winbind_init(void);
227
228 /* The following definitions come from auth/server_info.c  */
229
230 struct netr_SamInfo2;
231 struct netr_SamInfo3;
232 struct netr_SamInfo6;
233
234 struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx);
235 NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
236                                 uint8_t *pipe_session_key,
237                                 size_t pipe_session_key_len,
238                                 struct netr_SamInfo2 *sam2);
239 NTSTATUS serverinfo_to_SamInfo3(const struct auth_serversupplied_info *server_info,
240                                 uint8_t *pipe_session_key,
241                                 size_t pipe_session_key_len,
242                                 struct netr_SamInfo3 *sam3);
243 NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
244                                 uint8_t *pipe_session_key,
245                                 size_t pipe_session_key_len,
246                                 struct netr_SamInfo6 *sam6);
247 NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
248                           struct samu *samu,
249                           const char *login_server,
250                           struct netr_SamInfo3 **_info3,
251                           struct extra_auth_info *extra);
252 struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
253                                          struct netr_SamInfo3 *orig);
254 struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx,
255                                         const struct wbcAuthUserInfo *info);
256
257 /* The following definitions come from auth/auth_wbc.c  */
258
259 NTSTATUS auth_wbc_init(void);
260
261 /* The following definitions come from auth/pampass.c  */
262
263 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
264 bool smb_pam_close_session(char *user, char *tty, char *rhost);
265 NTSTATUS smb_pam_accountcheck(const char *user, const char *rhost);
266 NTSTATUS smb_pam_passcheck(const char * user, const char * rhost,
267                            const char * password);
268 bool smb_pam_passchange(const char *user, const char *rhost,
269                         const char *oldpassword, const char *newpassword);
270 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
271 bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
272
273 /* The following definitions come from auth/pass_check.c  */
274
275 void dfs_unlogin(void);
276 NTSTATUS pass_check(const struct passwd *pass,
277                     const char *user,
278                     const char *rhost,
279                     const char *password,
280                     bool run_cracker);
281
282 /* The following definitions come from auth/token_util.c  */
283
284 bool nt_token_check_sid ( const struct dom_sid *sid, const struct security_token *token );
285 bool nt_token_check_domain_rid( struct security_token *token, uint32 rid );
286 struct security_token *get_root_nt_token( void );
287 NTSTATUS add_aliases(const struct dom_sid *domain_sid,
288                      struct security_token *token);
289 struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
290                                             const struct dom_sid *user_sid,
291                                             bool is_guest,
292                                             int num_groupsids,
293                                             const struct dom_sid *groupsids);
294 NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
295                                           bool is_guest,
296                                           const struct netr_SamInfo3 *info3,
297                                           const struct extra_auth_info *extra,
298                                           struct security_token **ntok);
299 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
300                            int n_groups, gid_t *groups);
301
302 /* The following definitions come from auth/user_util.c  */
303
304 bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out);
305 bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname);
306 bool user_in_list(TALLOC_CTX *ctx, const char *user,const char **list);
307
308 /* The following definitions come from auth/user_krb5.c  */
309 struct PAC_LOGON_INFO;
310 NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
311                                      const char *cli_name,
312                                      const char *princ_name,
313                                      struct PAC_LOGON_INFO *logon_info,
314                                      bool *is_mapped,
315                                      bool *mapped_to_guest,
316                                      char **ntuser,
317                                      char **ntdomain,
318                                      char **username,
319                                      struct passwd **_pw);
320 NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
321                                 char *ntuser,
322                                 char *ntdomain,
323                                 char *username,
324                                 struct passwd *pw,
325                                 struct PAC_LOGON_INFO *logon_info,
326                                 bool mapped_to_guest, bool username_was_mapped,
327                                 DATA_BLOB *session_key,
328                                 struct auth_session_info **session_info);
329
330 #endif /* _AUTH_PROTO_H_ */