r12866: This removes the abstraction layer in winbindd intended to deal with
[kai/samba.git] / source4 / winbind / wb_server.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Main winbindd server routines
4
5    Copyright (C) Stefan Metzmacher      2005
6    Copyright (C) Andrew Tridgell        2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "nsswitch/winbindd_nss.h"
24
25 #define WINBINDD_DIR "/tmp/.winbindd/"
26 #define WINBINDD_SOCKET WINBINDD_DIR"socket"
27 /* the privileged socket is in smbd_tmp_dir() */
28 #define WINBINDD_PRIVILEGED_SOCKET "winbind_socket"
29
30 #define WINBINDD_SAMBA3_SOCKET WINBINDD_DIR"pipe"
31 /* the privileged socket is in smbd_tmp_dir() */
32 #define WINBINDD_SAMBA3_PRIVILEGED_SOCKET "winbind_pipe"
33
34 /* this struct stores global data for the winbind task */
35 struct wbsrv_service {
36         struct task_server *task;
37
38         const struct dom_sid *primary_sid;
39         struct wbsrv_domain *domains;
40 };
41
42 struct wbsrv_samconn {
43         struct wbsrv_domain *domain;
44         void *private_data;
45
46         struct composite_context (*seqnum_send)(struct wbsrv_samconn *);
47         NTSTATUS (*seqnum_recv)(struct composite_context *, uint64_t *);
48 };
49
50 struct wb_dom_info {
51         const char *name;
52         const char *dns_name;
53         const struct dom_sid *sid;
54
55         const char *dc_name;
56         const char *dc_dns_name;
57         const char *dc_address;
58 };
59
60 struct wbsrv_domain {
61         struct wbsrv_domain *next, *prev;
62
63         struct wb_dom_info *info;
64
65         struct dcerpc_pipe *lsa_pipe;
66         struct policy_handle *lsa_policy;
67         uint8_t lsa_auth_type;
68
69         struct dcerpc_pipe *samr_pipe;
70         struct policy_handle *samr_handle;
71         struct policy_handle *domain_handle;
72
73         struct ldap_connection *ldap_conn;
74
75         struct dcerpc_pipe *netlogon_pipe;
76         struct cli_credentials *schannel_creds;
77 };
78
79 /*
80   state of a listen socket and it's protocol information
81 */
82 struct wbsrv_listen_socket {
83         const char *socket_path;
84         struct wbsrv_service *service;
85         BOOL privileged;
86 };
87
88 /*
89   state of an open winbind connection
90 */
91 struct wbsrv_connection {
92         /* stream connection we belong to */
93         struct stream_connection *conn;
94
95         /* the listening socket we belong to, it holds protocol hooks */
96         struct wbsrv_listen_socket *listen_socket;
97
98         /* storage for protocol specific data */
99         void *protocol_private_data;
100
101         /* how many calls are pending */
102         uint32_t pending_calls;
103
104         struct packet_context *packet;
105 };
106
107 #define WBSRV_SAMBA3_SET_STRING(dest, src) do { \
108         strncpy(dest, src, sizeof(dest)-1);\
109 } while(0)
110
111 /*
112   state of one request
113
114   NOTE about async replies:
115    if the backend wants to reply later:
116
117    - it should set the WBSRV_CALL_FLAGS_REPLY_ASYNC flag, and may set a 
118      talloc_destructor on the this structure or on the private_data (if it's a
119      talloc child of this structure), so that wbsrv_terminate_connection
120      called by another call clean up the whole connection correct.
121    - When the backend is ready to reply it should call wbsrv_send_reply(call),
122      wbsrv_send_reply implies talloc_free(call), so the backend should use 
123      talloc_reference(call), if it needs it later. 
124    - If wbsrv_send_reply doesn't return NT_STATUS_OK, the backend function 
125      should call, wbsrv_terminate_connection(call->wbconn, nt_errstr(status));
126      return;
127
128 */
129 struct wbsrv_samba3_call {
130 #define WBSRV_CALL_FLAGS_REPLY_ASYNC 0x00000001
131         uint32_t flags;
132
133         /* the connection the call belongs to */
134         struct wbsrv_connection *wbconn;
135
136         /* the backend should use this event context */
137         struct event_context *event_ctx;
138
139         /* here the backend can store stuff like composite_context's ... */
140         void *private_data;
141
142         /* the request structure of the samba3 protocol */
143         struct winbindd_request request;
144         
145         /* the response structure of the samba3 protocol*/
146         struct winbindd_response response;
147 };
148
149 struct netr_LMSessionKey;
150 struct netr_UserSessionKey;
151
152 #include "winbind/wb_proto.h"