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