2 Unix SMB/CIFS implementation.
3 Main winbindd server routines
5 Copyright (C) Stefan Metzmacher 2005
6 Copyright (C) Andrew Tridgell 2005
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.
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.
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.
23 #define WINBINDD_DIR "/tmp/.winbindd/"
24 #define WINBINDD_SOCKET WINBINDD_DIR"socket"
25 /* the privileged socket is in smbd_tmp_dir() */
26 #define WINBINDD_PRIVILEGED_SOCKET "winbind_socket"
28 #define WINBINDD_SAMBA3_SOCKET WINBINDD_DIR"pipe"
29 /* the privileged socket is in smbd_tmp_dir() */
30 #define WINBINDD_SAMBA3_PRIVILEGED_SOCKET "winbind_pipe"
32 /* this struct stores global data for the winbind task */
33 struct wbsrv_service {
34 struct task_server *task;
36 struct dcerpc_pipe *netlogon_auth2_pipe;
37 struct cli_credentials *schannel_creds;
39 struct dcerpc_pipe *lsa_pipe;
40 struct dcerpc_pipe *netlogon_pipe;
44 this is an abstraction for the actual protocol being used,
45 so that we can listen on different sockets with different protocols
46 e.g. the old samba3 protocol on one socket and a new protocol on another socket
48 struct wbsrv_protocol_ops {
50 BOOL allow_pending_calls;
51 uint32_t (*packet_length)(DATA_BLOB blob);
52 NTSTATUS (*pull_request)(DATA_BLOB blob, TALLOC_CTX *mem_ctx, struct wbsrv_call **call);
53 NTSTATUS (*handle_call)(struct wbsrv_call *call);
54 NTSTATUS (*push_reply)(struct wbsrv_call *call, TALLOC_CTX *mem_ctx, DATA_BLOB *blob);
58 state of a listen socket and it's protocol information
60 struct wbsrv_listen_socket {
61 const char *socket_path;
62 struct wbsrv_service *service;
64 const struct wbsrv_protocol_ops *ops;
68 state of an open winbind connection
70 struct wbsrv_connection {
71 /* stream connection we belong to */
72 struct stream_connection *conn;
74 /* the listening socket we belong to, it holds protocol hooks */
75 struct wbsrv_listen_socket *listen_socket;
77 /* storage for protocol specific data */
78 void *protocol_private_data;
80 /* the partial data we've receiced yet */
83 /* the amount that we used yet from the partial buffer */
84 uint32_t partial_read;
86 /* prevent loops when we use half async code, while processing a requuest */
89 /* how many calls are pending */
90 uint32_t pending_calls;
92 struct data_blob_list_item *send_queue;
98 NOTE about async replies:
99 if the backend wants to reply later:
101 - it should set the WBSRV_CALL_FLAGS_REPLY_ASYNC flag, and may set a
102 talloc_destructor on the this structure or on the private_data (if it's a
103 talloc child of this structure), so that wbsrv_terminate_connection
104 called by another call clean up the whole connection correct.
105 - When the backend is ready to reply it should call wbsrv_send_reply(call),
106 wbsrv_send_reply implies talloc_free(call), so the backend should use
107 talloc_reference(call), if it needs it later.
108 - If wbsrv_send_reply doesn't return NT_STATUS_OK, the backend function
109 should call, wbsrv_terminate_connection(call->wbconn, nt_errstr(status));
114 #define WBSRV_CALL_FLAGS_REPLY_ASYNC 0x00000001
117 /* the backend should use this event context */
118 struct event_context *event_ctx;
120 /* the connection the call belongs to */
121 struct wbsrv_connection *wbconn;
123 /* storage for protocol specific data */