s3:winbind: Add a generic cache for NDR based parent-child requests
[sfrench/samba-autobuild/.git] / source3 / winbindd / winbindd_proto.h
1 /*
2  * Unix SMB/CIFS implementation.
3  * collected prototypes header
4  *
5  * frozen from "make proto" in May 2008
6  *
7  * Copyright (C) Michael Adam 2008
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef _WINBINDD_PROTO_H_
24 #define _WINBINDD_PROTO_H_
25
26
27 /* The following definitions come from auth/token_util.c  */
28
29 bool nt_token_check_sid ( const DOM_SID *sid, const NT_USER_TOKEN *token );
30 bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid );
31 NT_USER_TOKEN *get_root_nt_token( void );
32 NTSTATUS add_aliases(const DOM_SID *domain_sid,
33                      struct nt_user_token *token);
34 struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
35                                             const DOM_SID *user_sid,
36                                             bool is_guest,
37                                             int num_groupsids,
38                                             const DOM_SID *groupsids);
39 void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token);
40 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
41                            int n_groups, gid_t *groups);
42
43 /* The following definitions come from smbd/connection.c  */
44
45 bool yield_connection(connection_struct *conn, const char *name);
46 int count_current_connections( const char *sharename, bool clear  );
47 int count_all_current_connections(void);
48 bool claim_connection(connection_struct *conn, const char *name,
49                       uint32 msg_flags);
50 bool register_message_flags(bool doreg, uint32 msg_flags);
51
52 /* The following definitions come from winbindd/winbindd.c  */
53
54 struct event_context *winbind_event_context(void);
55 struct messaging_context *winbind_messaging_context(void);
56 void request_error(struct winbindd_cli_state *state);
57 void request_ok(struct winbindd_cli_state *state);
58 bool winbindd_setup_sig_term_handler(bool parent);
59 bool winbindd_setup_sig_hup_handler(const char *lfile);
60 bool winbindd_use_idmap_cache(void);
61 bool winbindd_use_cache(void);
62 int main(int argc, char **argv, char **envp);
63
64 /* The following definitions come from winbindd/winbindd_ads.c  */
65
66
67 /* The following definitions come from winbindd/winbindd_async.c  */
68
69 void do_async(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
70               const struct winbindd_request *request,
71               void (*cont)(TALLOC_CTX *mem_ctx, bool success,
72                            struct winbindd_response *response,
73                            void *c, void *private_data),
74               void *c, void *private_data);
75 void winbindd_lookupsid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
76                               void (*cont)(void *private_data, bool success,
77                                            const char *dom_name,
78                                            const char *name,
79                                            enum lsa_SidType type),
80                               void *private_data);
81 enum winbindd_result winbindd_dual_lookupsid(struct winbindd_domain *domain,
82                                              struct winbindd_cli_state *state);
83 void winbindd_lookupname_async(TALLOC_CTX *mem_ctx,
84                                const char *dom_name, const char *name,
85                                void (*cont)(void *private_data, bool success,
86                                             const DOM_SID *sid,
87                                             enum lsa_SidType type),
88                                enum winbindd_cmd orig_cmd,
89                                void *private_data);
90 enum winbindd_result winbindd_dual_lookupname(struct winbindd_domain *domain,
91                                               struct winbindd_cli_state *state);
92 void winbindd_listent_async(TALLOC_CTX *mem_ctx,
93                                struct winbindd_domain *domain,
94                                void (*cont)(void *private_data, bool success,
95                                      fstring dom_name, char* extra_data),
96                                void *private_data, enum ent_type type);
97 enum winbindd_result winbindd_dual_list_users(struct winbindd_domain *domain,
98                                               struct winbindd_cli_state *state);
99 enum winbindd_result winbindd_dual_list_groups(struct winbindd_domain *domain,
100                                                struct winbindd_cli_state *state);
101 bool print_sidlist(TALLOC_CTX *mem_ctx, const DOM_SID *sids,
102                    size_t num_sids, char **result, ssize_t *len);
103 bool parse_sidlist(TALLOC_CTX *mem_ctx, const char *sidstr,
104                    DOM_SID **sids, size_t *num_sids);
105 enum winbindd_result winbindd_dual_lookuprids(struct winbindd_domain *domain,
106                                               struct winbindd_cli_state *state);
107 void winbindd_getsidaliases_async(struct winbindd_domain *domain,
108                                   TALLOC_CTX *mem_ctx,
109                                   const DOM_SID *sids, size_t num_sids,
110                                   void (*cont)(void *private_data,
111                                                bool success,
112                                                const DOM_SID *aliases,
113                                                size_t num_aliases),
114                                   void *private_data);
115 enum winbindd_result winbindd_dual_getsidaliases(struct winbindd_domain *domain,
116                                                  struct winbindd_cli_state *state);
117 void winbindd_gettoken_async(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid,
118                              void (*cont)(void *private_data, bool success,
119                                           DOM_SID *sids, size_t num_sids),
120                              void *private_data);
121 void query_user_async(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
122                       const DOM_SID *sid,
123                       void (*cont)(void *private_data, bool success,
124                                    const char *acct_name,
125                                    const char *full_name,
126                                    const char *homedir,
127                                    const char *shell,
128                                    gid_t gid,
129                                    uint32 group_rid),
130                       void *private_data);
131
132 /* The following definitions come from winbindd/winbindd_cache.c  */
133
134 void winbindd_check_cache_size(time_t t);
135 struct cache_entry *centry_start(struct winbindd_domain *domain, NTSTATUS status);
136 NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const DOM_SID *sid);
137 NTSTATUS wcache_get_creds(struct winbindd_domain *domain, 
138                           TALLOC_CTX *mem_ctx, 
139                           const DOM_SID *sid,
140                           const uint8 **cached_nt_pass,
141                           const uint8 **cached_salt);
142 NTSTATUS wcache_save_creds(struct winbindd_domain *domain, 
143                            TALLOC_CTX *mem_ctx, 
144                            const DOM_SID *sid, 
145                            const uint8 nt_pass[NT_HASH_LEN]);
146 void wcache_invalidate_samlogon(struct winbindd_domain *domain, 
147                                 struct netr_SamInfo3 *info3);
148 bool wcache_invalidate_cache(void);
149 bool init_wcache(void);
150 bool initialize_winbindd_cache(void);
151 void close_winbindd_cache(void);
152 NTSTATUS wcache_sid_to_name(struct winbindd_domain *domain,
153                             const struct dom_sid *sid,
154                             TALLOC_CTX *mem_ctx,
155                             char **domain_name,
156                             char **name,
157                             enum lsa_SidType *type);
158 NTSTATUS wcache_lookup_groupmem(struct winbindd_domain *domain,
159                                 TALLOC_CTX *mem_ctx,
160                                 const struct dom_sid *group_sid,
161                                 uint32_t *num_names,
162                                 struct dom_sid **sid_mem, char ***names,
163                                 uint32_t **name_types);
164 bool lookup_cached_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
165                        char **domain_name, char **name,
166                        enum lsa_SidType *type);
167 bool lookup_cached_name(TALLOC_CTX *mem_ctx,
168                         const char *domain_name,
169                         const char *name,
170                         DOM_SID *sid,
171                         enum lsa_SidType *type);
172 void cache_name2sid(struct winbindd_domain *domain, 
173                     const char *domain_name, const char *name,
174                     enum lsa_SidType type, const DOM_SID *sid);
175 NTSTATUS wcache_name_to_sid(struct winbindd_domain *domain,
176                             const char *domain_name,
177                             const char *name,
178                             struct dom_sid *sid,
179                             enum lsa_SidType *type);
180 NTSTATUS wcache_query_user(struct winbindd_domain *domain,
181                            TALLOC_CTX *mem_ctx,
182                            const struct dom_sid *user_sid,
183                            struct wbint_userinfo *info);
184 NTSTATUS wcache_lookup_useraliases(struct winbindd_domain *domain,
185                                    TALLOC_CTX *mem_ctx,
186                                    uint32 num_sids, const DOM_SID *sids,
187                                    uint32 *pnum_aliases, uint32 **paliases);
188 NTSTATUS wcache_lookup_usergroups(struct winbindd_domain *domain,
189                                   TALLOC_CTX *mem_ctx,
190                                   const struct dom_sid *user_sid,
191                                   uint32_t *pnum_sids,
192                                   struct dom_sid **psids);
193
194 void wcache_flush_cache(void);
195 NTSTATUS wcache_count_cached_creds(struct winbindd_domain *domain, int *count);
196 NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const DOM_SID *sid) ;
197 bool set_global_winbindd_state_offline(void);
198 void set_global_winbindd_state_online(void);
199 bool get_global_winbindd_state_offline(void);
200 int winbindd_validate_cache(void);
201 int winbindd_validate_cache_nobackup(void);
202 bool winbindd_cache_validate_and_initialize(void);
203 bool wcache_tdc_fetch_list( struct winbindd_tdc_domain **domains, size_t *num_domains );
204 bool wcache_tdc_add_domain( struct winbindd_domain *domain );
205 struct winbindd_tdc_domain * wcache_tdc_fetch_domain( TALLOC_CTX *ctx, const char *name );
206 void wcache_tdc_clear( void );
207 NTSTATUS nss_get_info_cached( struct winbindd_domain *domain, 
208                               const DOM_SID *user_sid,
209                               TALLOC_CTX *ctx,
210                               ADS_STRUCT *ads, LDAPMessage *msg,
211                               const char **homedir, const char **shell,
212                               const char **gecos, gid_t *p_gid);
213 bool wcache_fetch_ndr(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
214                       uint32_t opnum, const DATA_BLOB *req, DATA_BLOB *resp);
215 void wcache_store_ndr(struct winbindd_domain *domain, uint32_t opnum,
216                       const DATA_BLOB *req, const DATA_BLOB *resp);
217
218 /* The following definitions come from winbindd/winbindd_ccache_access.c  */
219
220 void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state);
221 enum winbindd_result winbindd_dual_ccache_ntlm_auth(struct winbindd_domain *domain,
222                                                 struct winbindd_cli_state *state);
223
224 /* The following definitions come from winbindd/winbindd_cm.c  */
225
226 void set_domain_offline(struct winbindd_domain *domain);
227 void set_domain_online_request(struct winbindd_domain *domain);
228 void winbind_add_failed_connection_entry(const struct winbindd_domain *domain,
229                                         const char *server,
230                                         NTSTATUS result);
231 void invalidate_cm_connection(struct winbindd_cm_conn *conn);
232 void close_conns_after_fork(void);
233 NTSTATUS init_dc_connection(struct winbindd_domain *domain);
234 NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
235                         struct rpc_pipe_client **cli, struct policy_handle *sam_handle);
236 NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
237                         struct rpc_pipe_client **cli, struct policy_handle *lsa_policy);
238 NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
239                              struct rpc_pipe_client **cli);
240
241 /* The following definitions come from winbindd/winbindd_cred_cache.c  */
242
243 bool ccache_entry_exists(const char *username);
244 bool ccache_entry_identical(const char *username,
245                             uid_t uid,
246                             const char *ccname);
247 void ccache_remove_all_after_fork(void);
248 void ccache_regain_all_now(void);
249 NTSTATUS add_ccache_to_list(const char *princ_name,
250                             const char *ccname,
251                             const char *service,
252                             const char *username,
253                             const char *realm,
254                             uid_t uid,
255                             time_t create_time,
256                             time_t ticket_end,
257                             time_t renew_until,
258                             bool postponed_request);
259 NTSTATUS remove_ccache(const char *username);
260 struct WINBINDD_MEMORY_CREDS *find_memory_creds_by_name(const char *username);
261 NTSTATUS winbindd_add_memory_creds(const char *username,
262                                    uid_t uid,
263                                    const char *pass);
264 NTSTATUS winbindd_delete_memory_creds(const char *username);
265 NTSTATUS winbindd_replace_memory_creds(const char *username,
266                                        const char *pass);
267
268 /* The following definitions come from winbindd/winbindd_creds.c  */
269
270 NTSTATUS winbindd_get_creds(struct winbindd_domain *domain,
271                             TALLOC_CTX *mem_ctx,
272                             const DOM_SID *sid,
273                             struct netr_SamInfo3 **info3,
274                             const uint8 *cached_nt_pass[NT_HASH_LEN],
275                             const uint8 *cred_salt[NT_HASH_LEN]);
276 NTSTATUS winbindd_store_creds(struct winbindd_domain *domain,
277                               TALLOC_CTX *mem_ctx, 
278                               const char *user, 
279                               const char *pass, 
280                               struct netr_SamInfo3 *info3,
281                               const DOM_SID *user_sid);
282 NTSTATUS winbindd_update_creds_by_info3(struct winbindd_domain *domain,
283                                         TALLOC_CTX *mem_ctx,
284                                         const char *user,
285                                         const char *pass,
286                                         struct netr_SamInfo3 *info3);
287 NTSTATUS winbindd_update_creds_by_sid(struct winbindd_domain *domain,
288                                       TALLOC_CTX *mem_ctx,
289                                       const DOM_SID *sid,
290                                       const char *pass);
291 NTSTATUS winbindd_update_creds_by_name(struct winbindd_domain *domain,
292                                        TALLOC_CTX *mem_ctx,
293                                        const char *user,
294                                        const char *pass);
295
296 /* The following definitions come from winbindd/winbindd_domain.c  */
297
298 void setup_domain_child(struct winbindd_domain *domain,
299                         struct winbindd_child *child);
300
301 /* The following definitions come from winbindd/winbindd_dual.c  */
302
303 struct tevent_req *wb_child_request_send(TALLOC_CTX *mem_ctx,
304                                          struct tevent_context *ev,
305                                          struct winbindd_child *child,
306                                          struct winbindd_request *request);
307 int wb_child_request_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
308                           struct winbindd_response **presponse, int *err);
309 struct tevent_req *wb_domain_request_send(TALLOC_CTX *mem_ctx,
310                                           struct tevent_context *ev,
311                                           struct winbindd_domain *domain,
312                                           struct winbindd_request *request);
313 int wb_domain_request_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
314                            struct winbindd_response **presponse, int *err);
315
316 void async_request(TALLOC_CTX *mem_ctx, struct winbindd_child *child,
317                    struct winbindd_request *request,
318                    struct winbindd_response *response,
319                    void (*continuation)(void *private_data, bool success),
320                    void *private_data);
321 void async_domain_request(TALLOC_CTX *mem_ctx,
322                           struct winbindd_domain *domain,
323                           struct winbindd_request *request,
324                           struct winbindd_response *response,
325                           void (*continuation)(void *private_data_data, bool success),
326                           void *private_data_data);
327 void sendto_child(struct winbindd_cli_state *state,
328                   struct winbindd_child *child);
329 void sendto_domain(struct winbindd_cli_state *state,
330                    struct winbindd_domain *domain);
331 void setup_child(struct winbindd_domain *domain, struct winbindd_child *child,
332                  const struct winbindd_child_dispatch_table *table,
333                  const char *logprefix,
334                  const char *logname);
335 void winbind_child_died(pid_t pid);
336 void winbindd_flush_negative_conn_cache(struct winbindd_domain *domain);
337 void winbind_msg_debug(struct messaging_context *msg_ctx,
338                          void *private_data,
339                          uint32_t msg_type,
340                          struct server_id server_id,
341                          DATA_BLOB *data);
342 void winbind_msg_offline(struct messaging_context *msg_ctx,
343                          void *private_data,
344                          uint32_t msg_type,
345                          struct server_id server_id,
346                          DATA_BLOB *data);
347 void winbind_msg_online(struct messaging_context *msg_ctx,
348                         void *private_data,
349                         uint32_t msg_type,
350                         struct server_id server_id,
351                         DATA_BLOB *data);
352 void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
353                               void *private_data,
354                               uint32_t msg_type,
355                               struct server_id server_id,
356                               DATA_BLOB *data);
357 void winbind_msg_dump_event_list(struct messaging_context *msg_ctx,
358                                  void *private_data,
359                                  uint32_t msg_type,
360                                  struct server_id server_id,
361                                  DATA_BLOB *data);
362 void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
363                                   void *private_data,
364                                   uint32_t msg_type,
365                                   struct server_id server_id,
366                                   DATA_BLOB *data);
367 bool winbindd_reinit_after_fork(const char *logfilename);
368 struct winbindd_domain *wb_child_domain(void);
369
370 /* The following definitions come from winbindd/winbindd_group.c  */
371
372 void winbindd_getgrnam(struct winbindd_cli_state *state);
373 void winbindd_getgrgid(struct winbindd_cli_state *state);
374 void winbindd_setgrent(struct winbindd_cli_state *state);
375 void winbindd_endgrent(struct winbindd_cli_state *state);
376 void winbindd_getgrent(struct winbindd_cli_state *state);
377 void winbindd_list_groups(struct winbindd_cli_state *state);
378 void winbindd_getgroups(struct winbindd_cli_state *state);
379 void winbindd_getusersids(struct winbindd_cli_state *state);
380 void winbindd_getuserdomgroups(struct winbindd_cli_state *state);
381 void winbindd_getsidaliases(struct winbindd_cli_state *state);
382 enum winbindd_result winbindd_dual_getuserdomgroups(struct winbindd_domain *domain,
383                                                     struct winbindd_cli_state *state);
384 bool get_sam_group_entries(struct getent_state *ent);
385 bool fill_grent(TALLOC_CTX *mem_ctx, struct winbindd_gr *gr,
386                 const char *dom_name, const char *gr_name, gid_t unix_gid);
387 NTSTATUS winbindd_print_groupmembers(struct talloc_dict *members,
388                                      TALLOC_CTX *mem_ctx,
389                                      int *num_members, char **result);
390
391
392 /* The following definitions come from winbindd/winbindd_idmap.c  */
393
394 void init_idmap_child(void);
395 struct winbindd_child *idmap_child(void);
396 void winbindd_set_mapping_async(TALLOC_CTX *mem_ctx, const struct id_map *map,
397                              void (*cont)(void *private_data, bool success),
398                              void *private_data);
399 enum winbindd_result winbindd_dual_set_mapping(struct winbindd_domain *domain,
400                                             struct winbindd_cli_state *state);
401 void winbindd_remove_mapping_async(TALLOC_CTX *mem_ctx, const struct id_map *map,
402                              void (*cont)(void *private_data, bool success),
403                              void *private_data);
404 enum winbindd_result winbindd_dual_remove_mapping(struct winbindd_domain *domain,
405                                             struct winbindd_cli_state *state);
406 void winbindd_set_hwm_async(TALLOC_CTX *mem_ctx, const struct unixid *xid,
407                              void (*cont)(void *private_data, bool success),
408                              void *private_data);
409 enum winbindd_result winbindd_dual_set_hwm(struct winbindd_domain *domain,
410                                             struct winbindd_cli_state *state);
411 void winbindd_sids2xids_async(TALLOC_CTX *mem_ctx, void *sids, int size,
412                          void (*cont)(void *private_data, bool success, void *data, int len),
413                          void *private_data);
414 enum winbindd_result winbindd_dual_sids2xids(struct winbindd_domain *domain,
415                                            struct winbindd_cli_state *state);
416 void winbindd_sid2uid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
417                          void (*cont)(void *private_data, bool success, uid_t uid),
418                          void *private_data);
419 enum winbindd_result winbindd_dual_sid2uid(struct winbindd_domain *domain,
420                                            struct winbindd_cli_state *state);
421 void winbindd_sid2gid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
422                          void (*cont)(void *private_data, bool success, gid_t gid),
423                          void *private_data);
424 enum winbindd_result winbindd_dual_sid2gid(struct winbindd_domain *domain,
425                                            struct winbindd_cli_state *state);
426 void winbindd_uid2sid_async(TALLOC_CTX *mem_ctx, uid_t uid,
427                             void (*cont)(void *private_data, bool success, const char *sid),
428                             void *private_data);
429 enum winbindd_result winbindd_dual_uid2sid(struct winbindd_domain *domain,
430                                            struct winbindd_cli_state *state);
431 void winbindd_gid2sid_async(TALLOC_CTX *mem_ctx, gid_t gid,
432                             void (*cont)(void *private_data, bool success, const char *sid),
433                             void *private_data);
434 enum winbindd_result winbindd_dual_gid2sid(struct winbindd_domain *domain,
435                                            struct winbindd_cli_state *state);
436
437 /* The following definitions come from winbindd/winbindd_locator.c  */
438
439 void init_locator_child(void);
440 struct winbindd_child *locator_child(void);
441 void winbindd_dsgetdcname(struct winbindd_cli_state *state);
442
443 /* The following definitions come from winbindd/winbindd_misc.c  */
444
445 void winbindd_check_machine_acct(struct winbindd_cli_state *state);
446 enum winbindd_result winbindd_dual_check_machine_acct(struct winbindd_domain *domain,
447                                                       struct winbindd_cli_state *state);
448 void winbindd_list_ent(struct winbindd_cli_state *state, enum ent_type type);
449 void winbindd_list_trusted_domains(struct winbindd_cli_state *state);
450 enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
451                                                         struct winbindd_cli_state *state);
452 void winbindd_getdcname(struct winbindd_cli_state *state);
453 enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,
454                                              struct winbindd_cli_state *state);
455 void winbindd_show_sequence(struct winbindd_cli_state *state);
456 enum winbindd_result winbindd_dual_show_sequence(struct winbindd_domain *domain,
457                                                  struct winbindd_cli_state *state);
458 void winbindd_domain_info(struct winbindd_cli_state *state);
459 void winbindd_ping(struct winbindd_cli_state *state);
460 void winbindd_info(struct winbindd_cli_state *state);
461 void winbindd_interface_version(struct winbindd_cli_state *state);
462 void winbindd_domain_name(struct winbindd_cli_state *state);
463 void winbindd_netbios_name(struct winbindd_cli_state *state);
464 void winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
465
466 /* The following definitions come from winbindd/winbindd_ndr.c  */
467
468 void ndr_print_winbindd_child(struct ndr_print *ndr,
469                               const char *name,
470                               const struct winbindd_child *r);
471 void ndr_print_winbindd_cm_conn(struct ndr_print *ndr,
472                                 const char *name,
473                                 const struct winbindd_cm_conn *r);
474 void ndr_print_winbindd_methods(struct ndr_print *ndr,
475                                 const char *name,
476                                 const struct winbindd_methods *r);
477 void ndr_print_winbindd_domain(struct ndr_print *ndr,
478                                const char *name,
479                                const struct winbindd_domain *r);
480
481 /* The following definitions come from winbindd/winbindd_pam.c  */
482
483 struct winbindd_domain *find_auth_domain(struct winbindd_cli_state *state, 
484                                         const char *domain_name);
485 void winbindd_pam_auth(struct winbindd_cli_state *state);
486 NTSTATUS winbindd_dual_pam_auth_cached(struct winbindd_domain *domain,
487                                        struct winbindd_cli_state *state,
488                                        struct netr_SamInfo3 **info3);
489 NTSTATUS winbindd_dual_pam_auth_kerberos(struct winbindd_domain *domain,
490                                          struct winbindd_cli_state *state, 
491                                          struct netr_SamInfo3 **info3);
492 NTSTATUS winbindd_dual_pam_auth_samlogon(struct winbindd_domain *domain,
493                                          struct winbindd_cli_state *state,
494                                          struct netr_SamInfo3 **info3);
495 enum winbindd_result winbindd_dual_pam_auth(struct winbindd_domain *domain,
496                                             struct winbindd_cli_state *state) ;
497 void winbindd_pam_auth_crap(struct winbindd_cli_state *state);
498 enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain,
499                                                  struct winbindd_cli_state *state) ;
500 void winbindd_pam_chauthtok(struct winbindd_cli_state *state);
501 enum winbindd_result winbindd_dual_pam_chauthtok(struct winbindd_domain *contact_domain,
502                                                  struct winbindd_cli_state *state);
503 void winbindd_pam_logoff(struct winbindd_cli_state *state);
504 enum winbindd_result winbindd_dual_pam_logoff(struct winbindd_domain *domain,
505                                               struct winbindd_cli_state *state) ;
506 void winbindd_pam_chng_pswd_auth_crap(struct winbindd_cli_state *state);
507 enum winbindd_result winbindd_dual_pam_chng_pswd_auth_crap(struct winbindd_domain *domainSt, struct winbindd_cli_state *state);
508
509 /* The following definitions come from winbindd/winbindd_passdb.c  */
510
511
512 /* The following definitions come from winbindd/winbindd_reconnect.c  */
513
514
515 /* The following definitions come from winbindd/winbindd_sid.c  */
516
517 void winbindd_lookupsid(struct winbindd_cli_state *state);
518 void winbindd_lookupname(struct winbindd_cli_state *state);
519 void winbindd_lookuprids(struct winbindd_cli_state *state);
520 void winbindd_sid_to_uid(struct winbindd_cli_state *state);
521 void winbindd_sid_to_gid(struct winbindd_cli_state *state);
522 void winbindd_set_mapping(struct winbindd_cli_state *state);
523 void winbindd_remove_mapping(struct winbindd_cli_state *state);
524 void winbindd_set_hwm(struct winbindd_cli_state *state);
525 void winbindd_uid_to_sid(struct winbindd_cli_state *state);
526 void winbindd_gid_to_sid(struct winbindd_cli_state *state);
527 void winbindd_allocate_uid(struct winbindd_cli_state *state);
528 enum winbindd_result winbindd_dual_allocate_uid(struct winbindd_domain *domain,
529                                                 struct winbindd_cli_state *state);
530 void winbindd_allocate_gid(struct winbindd_cli_state *state);
531 enum winbindd_result winbindd_dual_allocate_gid(struct winbindd_domain *domain,
532                                                 struct winbindd_cli_state *state);
533
534 /* The following definitions come from winbindd/winbindd_user.c  */
535
536 bool fillup_pw_field(const char *lp_template,
537                             const char *username,
538                             const char *domname,
539                             uid_t uid,
540                             gid_t gid,
541                             const char *in,
542                      fstring out);
543
544 enum winbindd_result winbindd_dual_userinfo(struct winbindd_domain *domain,
545                                             struct winbindd_cli_state *state);
546 void winbindd_getpwnam(struct winbindd_cli_state *state);
547 void winbindd_getpwuid(struct winbindd_cli_state *state);
548 void winbindd_getpwsid(struct winbindd_cli_state *state);
549 void winbindd_setpwent(struct winbindd_cli_state *state);
550 void winbindd_endpwent(struct winbindd_cli_state *state);
551 void winbindd_getpwent(struct winbindd_cli_state *state);
552 void winbindd_list_users(struct winbindd_cli_state *state);
553
554 /* The following definitions come from winbindd/winbindd_util.c  */
555
556 struct winbindd_domain *domain_list(void);
557 void free_domain_list(void);
558 void rescan_trusted_domains(struct tevent_context *ev, struct tevent_timer *te,
559                             struct timeval now, void *private_data);
560 enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domain,
561                                                    struct winbindd_cli_state *state);
562 bool init_domain_list(void);
563 void check_domain_trusted( const char *name, const DOM_SID *user_sid );
564 struct winbindd_domain *find_domain_from_name_noinit(const char *domain_name);
565 struct winbindd_domain *find_domain_from_name(const char *domain_name);
566 struct winbindd_domain *find_domain_from_sid_noinit(const DOM_SID *sid);
567 struct winbindd_domain *find_domain_from_sid(const DOM_SID *sid);
568 struct winbindd_domain *find_our_domain(void);
569 struct winbindd_domain *find_root_domain(void);
570 struct winbindd_domain *find_builtin_domain(void);
571 struct winbindd_domain *find_lookup_domain_from_sid(const DOM_SID *sid);
572 struct winbindd_domain *find_lookup_domain_from_name(const char *domain_name);
573 bool winbindd_lookup_sid_by_name(TALLOC_CTX *mem_ctx,
574                                  enum winbindd_cmd orig_cmd,
575                                  struct winbindd_domain *domain, 
576                                  const char *domain_name,
577                                  const char *name, DOM_SID *sid, 
578                                  enum lsa_SidType *type);
579 bool winbindd_lookup_name_by_sid(TALLOC_CTX *mem_ctx,
580                                  struct winbindd_domain *domain,
581                                  DOM_SID *sid,
582                                  char **dom_name,
583                                  char **name,
584                                  enum lsa_SidType *type);
585 void free_getent_state(struct getent_state *state);
586 bool parse_domain_user(const char *domuser, fstring domain, fstring user);
587 bool parse_domain_user_talloc(TALLOC_CTX *mem_ctx, const char *domuser,
588                               char **domain, char **user);
589 void parse_add_domuser(void *buf, char *domuser, int *len);
590 bool canonicalize_username(fstring username_inout, fstring domain, fstring user);
591 void fill_domain_username(fstring name, const char *domain, const char *user, bool can_assume);
592 char *fill_domain_username_talloc(TALLOC_CTX *ctx,
593                                   const char *domain,
594                                   const char *user,
595                                   bool can_assume);
596 const char *get_winbind_pipe_dir(void) ;
597 char *get_winbind_priv_pipe_dir(void) ;
598 int open_winbindd_socket(void);
599 int open_winbindd_priv_socket(void);
600 struct winbindd_cli_state *winbindd_client_list(void);
601 void winbindd_add_client(struct winbindd_cli_state *cli);
602 void winbindd_remove_client(struct winbindd_cli_state *cli);
603 void winbindd_kill_all_clients(void);
604 int winbindd_num_clients(void);
605 NTSTATUS lookup_usergroups_cached(struct winbindd_domain *domain,
606                                   TALLOC_CTX *mem_ctx,
607                                   const DOM_SID *user_sid,
608                                   uint32 *p_num_groups, DOM_SID **user_sids);
609
610 NTSTATUS normalize_name_map(TALLOC_CTX *mem_ctx,
611                              struct winbindd_domain *domain,
612                              const char *name,
613                              char **normalized);
614 NTSTATUS normalize_name_unmap(TALLOC_CTX *mem_ctx,
615                               char *name,
616                               char **normalized);
617
618 NTSTATUS resolve_username_to_alias(TALLOC_CTX *mem_ctx,
619                                    struct winbindd_domain *domain,
620                                    const char *name, char **alias);
621 NTSTATUS resolve_alias_to_username(TALLOC_CTX *mem_ctx,
622                                    struct winbindd_domain *domain,
623                                    const char *alias, char **name);
624
625 bool winbindd_can_contact_domain(struct winbindd_domain *domain);
626 bool winbindd_internal_child(struct winbindd_child *child);
627 void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain);
628 void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain);
629 void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain);
630 void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain);
631 void set_auth_errors(struct winbindd_response *resp, NTSTATUS result);
632
633 /* The following definitions come from winbindd/winbindd_wins.c  */
634
635 void winbindd_wins_byip(struct winbindd_cli_state *state);
636 void winbindd_wins_byname(struct winbindd_cli_state *state);
637
638 struct tevent_req *wb_ping_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
639                                 struct winbindd_cli_state *cli,
640                                 struct winbindd_request *request);
641 NTSTATUS wb_ping_recv(struct tevent_req *req,
642                       struct winbindd_response *resp);
643
644 enum winbindd_result winbindd_dual_ping(struct winbindd_domain *domain,
645                                         struct winbindd_cli_state *state);
646
647 struct rpc_pipe_client *wbint_rpccli_create(TALLOC_CTX *mem_ctx,
648                                             struct winbindd_domain *domain,
649                                             struct winbindd_child *child);
650 enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
651                                           struct winbindd_cli_state *state);
652
653 struct tevent_req *wb_lookupsid_send(TALLOC_CTX *mem_ctx,
654                                      struct tevent_context *ev,
655                                      const struct dom_sid *sid);
656 NTSTATUS wb_lookupsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
657                            enum lsa_SidType *type, const char **domain,
658                            const char **name);
659
660 struct tevent_req *winbindd_lookupsid_send(TALLOC_CTX *mem_ctx,
661                                            struct tevent_context *ev,
662                                            struct winbindd_cli_state *cli,
663                                            struct winbindd_request *request);
664 NTSTATUS winbindd_lookupsid_recv(struct tevent_req *req,
665                                  struct winbindd_response *response);
666
667 struct tevent_req *wb_lookupname_send(TALLOC_CTX *mem_ctx,
668                                       struct tevent_context *ev,
669                                       const char *dom_name, const char *name,
670                                       uint32_t flags);
671 NTSTATUS wb_lookupname_recv(struct tevent_req *req, struct dom_sid *sid,
672                             enum lsa_SidType *type);
673
674 struct tevent_req *winbindd_lookupname_send(TALLOC_CTX *mem_ctx,
675                                             struct tevent_context *ev,
676                                             struct winbindd_cli_state *cli,
677                                             struct winbindd_request *request);
678 NTSTATUS winbindd_lookupname_recv(struct tevent_req *req,
679                                   struct winbindd_response *response);
680
681 struct tevent_req *wb_sid2uid_send(TALLOC_CTX *mem_ctx,
682                                    struct tevent_context *ev,
683                                    const struct dom_sid *sid);
684 NTSTATUS wb_sid2uid_recv(struct tevent_req *req, uid_t *uid);
685
686 struct tevent_req *winbindd_sid_to_uid_send(TALLOC_CTX *mem_ctx,
687                                             struct tevent_context *ev,
688                                             struct winbindd_cli_state *cli,
689                                             struct winbindd_request *request);
690 NTSTATUS winbindd_sid_to_uid_recv(struct tevent_req *req,
691                                   struct winbindd_response *response);
692
693 struct tevent_req *wb_sid2gid_send(TALLOC_CTX *mem_ctx,
694                                    struct tevent_context *ev,
695                                    const struct dom_sid *sid);
696 NTSTATUS wb_sid2gid_recv(struct tevent_req *req, gid_t *gid);
697
698 struct tevent_req *winbindd_sid_to_gid_send(TALLOC_CTX *mem_ctx,
699                                             struct tevent_context *ev,
700                                             struct winbindd_cli_state *cli,
701                                             struct winbindd_request *request);
702 NTSTATUS winbindd_sid_to_gid_recv(struct tevent_req *req,
703                                   struct winbindd_response *response);
704
705 struct tevent_req *wb_uid2sid_send(TALLOC_CTX *mem_ctx,
706                                    struct tevent_context *ev,
707                                    uid_t uid);
708 NTSTATUS wb_uid2sid_recv(struct tevent_req *req, struct dom_sid *sid);
709
710 struct tevent_req *winbindd_uid_to_sid_send(TALLOC_CTX *mem_ctx,
711                                             struct tevent_context *ev,
712                                             struct winbindd_cli_state *cli,
713                                             struct winbindd_request *request);
714 NTSTATUS winbindd_uid_to_sid_recv(struct tevent_req *req,
715                                   struct winbindd_response *response);
716
717 struct tevent_req *wb_gid2sid_send(TALLOC_CTX *mem_ctx,
718                                    struct tevent_context *ev,
719                                    gid_t gid);
720 NTSTATUS wb_gid2sid_recv(struct tevent_req *req, struct dom_sid *sid);
721
722 struct tevent_req *winbindd_gid_to_sid_send(TALLOC_CTX *mem_ctx,
723                                             struct tevent_context *ev,
724                                             struct winbindd_cli_state *cli,
725                                             struct winbindd_request *request);
726 NTSTATUS winbindd_gid_to_sid_recv(struct tevent_req *req,
727                                   struct winbindd_response *response);
728
729 struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx,
730                                      struct tevent_context *ev,
731                                      const struct dom_sid *user_sid);
732 NTSTATUS wb_queryuser_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
733                            struct wbint_userinfo **pinfo);
734
735 struct tevent_req *wb_getpwsid_send(TALLOC_CTX *mem_ctx,
736                                     struct tevent_context *ev,
737                                     const struct dom_sid *user_sid,
738                                     struct winbindd_pw *pw);
739 NTSTATUS wb_getpwsid_recv(struct tevent_req *req);
740
741 struct tevent_req *winbindd_getpwsid_send(TALLOC_CTX *mem_ctx,
742                                           struct tevent_context *ev,
743                                           struct winbindd_cli_state *cli,
744                                           struct winbindd_request *request);
745 NTSTATUS winbindd_getpwsid_recv(struct tevent_req *req,
746                                 struct winbindd_response *response);
747
748 struct tevent_req *winbindd_getpwnam_send(TALLOC_CTX *mem_ctx,
749                                           struct tevent_context *ev,
750                                           struct winbindd_cli_state *cli,
751                                           struct winbindd_request *request);
752 NTSTATUS winbindd_getpwnam_recv(struct tevent_req *req,
753                                 struct winbindd_response *response);
754
755 struct tevent_req *winbindd_getpwuid_send(TALLOC_CTX *mem_ctx,
756                                           struct tevent_context *ev,
757                                           struct winbindd_cli_state *cli,
758                                           struct winbindd_request *request);
759 NTSTATUS winbindd_getpwuid_recv(struct tevent_req *req,
760                                 struct winbindd_response *response);
761 struct tevent_req *wb_lookupuseraliases_send(TALLOC_CTX *mem_ctx,
762                                              struct tevent_context *ev,
763                                              struct winbindd_domain *domain,
764                                              int num_sids,
765                                              const struct dom_sid *sids);
766 NTSTATUS wb_lookupuseraliases_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
767                                    uint32_t *num_aliases, uint32_t **aliases);
768 struct tevent_req *winbindd_getsidaliases_send(TALLOC_CTX *mem_ctx,
769                                                struct tevent_context *ev,
770                                                struct winbindd_cli_state *cli,
771                                                struct winbindd_request *request);
772 NTSTATUS winbindd_getsidaliases_recv(struct tevent_req *req,
773                                      struct winbindd_response *response);
774 struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx,
775                                             struct tevent_context *ev,
776                                             struct winbindd_domain *domain,
777                                             const struct dom_sid *sid);
778 NTSTATUS wb_lookupusergroups_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
779                                   int *num_sids, struct dom_sid **sids);
780
781 struct tevent_req *winbindd_getuserdomgroups_send(TALLOC_CTX *mem_ctx,
782                                                   struct tevent_context *ev,
783                                                   struct winbindd_cli_state *cli,
784                                                   struct winbindd_request *request);
785 NTSTATUS winbindd_getuserdomgroups_recv(struct tevent_req *req,
786                                         struct winbindd_response *response);
787 struct tevent_req *wb_gettoken_send(TALLOC_CTX *mem_ctx,
788                                     struct tevent_context *ev,
789                                     const struct dom_sid *sid);
790 NTSTATUS wb_gettoken_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
791                           int *num_sids, struct dom_sid **sids);
792 struct tevent_req *winbindd_getgroups_send(TALLOC_CTX *mem_ctx,
793                                            struct tevent_context *ev,
794                                            struct winbindd_cli_state *cli,
795                                            struct winbindd_request *request);
796 NTSTATUS winbindd_getgroups_recv(struct tevent_req *req,
797                                  struct winbindd_response *response);
798
799 struct tevent_req *wb_seqnum_send(TALLOC_CTX *mem_ctx,
800                                   struct tevent_context *ev,
801                                   struct winbindd_domain *domain);
802 NTSTATUS wb_seqnum_recv(struct tevent_req *req, uint32_t *seqnum);
803
804 struct tevent_req *wb_seqnums_send(TALLOC_CTX *mem_ctx,
805                                    struct tevent_context *ev);
806 NTSTATUS wb_seqnums_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
807                          int *num_domains, struct winbindd_domain ***domains,
808                          NTSTATUS **stati, uint32_t **seqnums);
809
810 struct tevent_req *winbindd_show_sequence_send(TALLOC_CTX *mem_ctx,
811                                                struct tevent_context *ev,
812                                                struct winbindd_cli_state *cli,
813                                                struct winbindd_request *request);
814 NTSTATUS winbindd_show_sequence_recv(struct tevent_req *req,
815                                      struct winbindd_response *response);
816
817 struct tevent_req *wb_group_members_send(TALLOC_CTX *mem_ctx,
818                                          struct tevent_context *ev,
819                                          const struct dom_sid *sid,
820                                          enum lsa_SidType type,
821                                          int max_depth);
822 NTSTATUS wb_group_members_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
823                                struct talloc_dict **members);
824
825 struct tevent_req *wb_getgrsid_send(TALLOC_CTX *mem_ctx,
826                                     struct tevent_context *ev,
827                                     const struct dom_sid *group_sid,
828                                     int max_nesting);
829 NTSTATUS wb_getgrsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
830                           const char **domname, const char **name, gid_t *gid,
831                           struct talloc_dict **members);
832
833 struct tevent_req *winbindd_getgrgid_send(TALLOC_CTX *mem_ctx,
834                                           struct tevent_context *ev,
835                                           struct winbindd_cli_state *cli,
836                                           struct winbindd_request *request);
837 NTSTATUS winbindd_getgrgid_recv(struct tevent_req *req,
838                                 struct winbindd_response *response);
839
840 struct tevent_req *winbindd_getgrnam_send(TALLOC_CTX *mem_ctx,
841                                           struct tevent_context *ev,
842                                           struct winbindd_cli_state *cli,
843                                           struct winbindd_request *request);
844 NTSTATUS winbindd_getgrnam_recv(struct tevent_req *req,
845                                 struct winbindd_response *response);
846
847 #endif /*  _WINBINDD_PROTO_H_  */