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