#include "includes.h"
#include "auth/auth.h"
#include "auth/auth_sam_reply.h"
-#include "s3_smbd_proto.h"
+#include "s3compat.h"
#include "smbd/service.h"
#include "libcli/security/dom_sid.h"
#include "dsdb/samdb/samdb.h"
#include "dynconfig/dynconfig.h"
#include "smbd/process_model.h"
#include "tevent/tevent.h"
+#include "s3compat.h"
#include "s3compat_wrapper.h"
-#include "s3compat_proto.h"
#include "s3compat_globals.h"
static struct stream_connection *samba3_conn;
#include "smbd/service_task.h"
#include "smbd/process_model.h"
-#include "s3compat_wrapper.h"
+#include "s3compat.h"
#include "s3replace.h"
#include "s3compat_globals.h"
-#include "s3compat_proto.h"
+#include "s3compat_wrapper.h"
_PUBLIC_ void s3compat_winbind_task_init(struct task_server *task)
{
s3compat_initialise_winbindd(lp_configfile(task->lp_ctx));
}
-_PUBLIC_ void s3compat_winbind_accept(struct stream_connection *conn)
+_PUBLIC_ NTSTATUS s3compat_winbind_accept(struct wbsrv_connection *wbsrv_conn)
+{
+ wbsrv_conn->protocol_private_data
+ = s3compat_winbindd_accepted_new_connection(wbsrv_conn,
+ wbsrv_conn->listen_socket->privileged);
+ if (wbsrv_conn->protocol_private_data) {
+ return NT_STATUS_OK;
+ } else {
+ return NT_STATUS_NO_MEMORY;
+ }
+}
+
+_PUBLIC_ NTSTATUS s3compat_winbind_process_request(struct wbsrv_samba3_call *call)
+{
+ struct winbindd_cli_state *state = talloc_get_type_abort(call->wbconn->protocol_private_data,
+ struct winbindd_cli_state);
+ call->private_data = state;
+ s3compat_winbind_process_s3_request(state, call, call->request);
+
+ /* always pretend this was an async reply - source3/winbindd
+ * will call winbind_request_finished every time */
+ call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC;
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ void s3compat_winbind_request_finished(struct winbindd_response *response, struct wbsrv_samba3_call *call)
+{
+ call = talloc_get_type_abort(call, struct wbsrv_samba3_call);
+ call->response = talloc_steal(call, response);
+ wbsrv_samba3_send_reply(call);
+}
+
+_PUBLIC_ void s3compat_winbind_terminate_connection(struct wbsrv_connection *wbconn, const char *reason)
{
- struct wbsrv_listen_socket *wbsrv_socket = talloc_get_type(conn->private_data,
- struct wbsrv_listen_socket);
- s3compat_winbindd_accepted_new_connection(socket_get_fd(conn->socket),
- wbsrv_socket->privileged);
- return;
+ wbconn = talloc_get_type_abort(wbconn, struct wbsrv_connection);
+ return wbsrv_terminate_connection(wbconn, reason);
}
#include "includes.h"
#include "auth/auth.h"
#include "auth/auth_sam_reply.h"
-#include "s3_smbd_proto.h"
+#include "s3compat.h"
#include "s3compat_globals.h"
#include "s3compat_authenticate.h"
#include "auth/credentials/credentials.h"
#include "includes.h"
#include "source3/smbd/globals.h"
#include "s3compat_wrapper.h"
+#include "s3compat/s3compat.h"
#include "source3/winbindd/winbindd.h"
/* Unlike the smbd init functions, this is only run in the winbindd
/* Call into the source3/winbindd per-client code here, as we have
* already bound to the sockets and accepted the connection at this
* point */
-_PUBLIC_ void s3compat_winbindd_accepted_new_connection(int accepted_sock, bool privileged)
+_PUBLIC_ struct winbindd_cli_state *s3compat_winbindd_accepted_new_connection(struct wbsrv_connection *wbsrv_conn,
+ bool privileged)
{
- winbindd_accepted_new_connection(accepted_sock, privileged);
+ struct winbindd_cli_state *state = talloc_zero(wbsrv_conn, struct winbindd_cli_state);
+ if (!state) {
+ return NULL;
+ }
+ state->privileged = privileged;
+ state->last_access = time(NULL);
+ state->wbsrv_conn = wbsrv_conn;
+ winbindd_add_client(state);
+ return state;
+}
+
+_PUBLIC_ void s3compat_winbind_process_s3_request(struct winbindd_cli_state *state,
+ struct wbsrv_samba3_call *call,
+ struct winbindd_request *request)
+{
+ state->last_access = time(NULL);
+ state->request = request;
+ state->response = NULL;
+ state->call = call;
+
+ wb_process_request(state);
+}
+
+bool winbindd_use_idmap_cache(void)
+{
+ return true;
+}
+
+bool winbindd_use_cache(void)
+{
+ return true;
}
+void request_finished(struct winbindd_cli_state *state)
+{
+ s3compat_winbind_request_finished(state->response, state->call);
+ TALLOC_FREE(state->mem_ctx);
+ state->response = NULL;
+ state->cmd_name = "no request";
+ state->recv_fn = NULL;
+}
+
+void winbindd_remove_client(struct winbindd_cli_state *state)
+{
+ /* It's a dead client - hold a funeral */
+
+ if (state == NULL) {
+ return;
+ }
+
+ winbindd_remove_client_from_list(state);
+
+ s3compat_winbind_terminate_connection(state->wbsrv_conn, "remove_client: "
+ "client removed from server");
+}
-
struct auth_usersupplied_info;
struct auth_serversupplied_info;
-
+struct wbsrv_connection;
+struct winbindd_cli_state;
+struct winbindd_request;
+struct wbsrv_samba3_call;
#include "s3compat_wrapper_proto.h"
-_PUBLIC_ void s3compat_initialise_winbindd(const char *config_file);
-_PUBLIC_ void s3compat_winbindd_accepted_new_connection(int accepted_sock, bool privileged);
-_PUBLIC_ void s3compat_initialise(const char *config_file, bool interactive);
-_PUBLIC_ void s3compat_smbd_process(void);
+void s3compat_initialise_winbindd(const char *config_file);
+struct winbindd_cli_state *s3compat_winbindd_accepted_new_connection(struct wbsrv_connection *wbsrv_conn, bool privileged);
+void s3compat_winbind_process_s3_request(struct winbindd_cli_state *state,
+ struct wbsrv_samba3_call *call,
+ struct winbindd_request *request);
+void s3compat_initialise(const char *config_file, bool interactive);
+void s3compat_smbd_process(void);
#include "smbd/service_stream.h"
#include "lib/stream/packet.h"
#include "lib/tsocket/tsocket.h"
+#include "param/param.h"
+#include "s3compat/s3compat.h"
/*
work out if a packet is complete for protocols that use a 32 bit host byte
return status;
}
- status = wbsrv_samba3_handle_call(call);
-
+#if ENABLE_S3COMPAT
+ /* this is a hack for now to enable the s3 winbindd
+ in s4 */
+ if (lp_parm_bool(call->wbconn->lp_ctx, NULL, "s3compat", "winbindd", false)) {
+ status = s3compat_winbind_process_request(call);
+ } else
+#endif
+ {
+ status = wbsrv_samba3_handle_call(call);
+ }
if (!NT_STATUS_IS_OK(status)) {
talloc_free(call);
return status;
#include "libcli/util/tstream.h"
#include "param/param.h"
#include "param/secrets.h"
+#include "s3compat/s3compat.h"
void wbsrv_terminate_connection(struct wbsrv_connection *wbconn, const char *reason)
{
struct tevent_req *subreq;
int rc;
-#if ENABLE_S3COMPAT
- /* this is a hack for now to enable the s3 winbindd
- in s4 */
- if (lp_parm_bool(conn->lp_ctx, NULL, "s3compat", "winbindd", false)) {
- void s3compat_winbind_accept(struct stream_connection *conn);
- s3compat_winbind_accept(conn);
- return;
- }
-#endif
wbsrv_conn = talloc_zero(conn, struct wbsrv_connection);
if (wbsrv_conn == NULL) {
stream_terminate_connection(conn, "wbsrv_accept: out of memory");
wbsrv_conn->lp_ctx = wbsrv_socket->service->task->lp_ctx;
conn->private_data = wbsrv_conn;
+#if ENABLE_S3COMPAT
+ /* this is a hack for now to enable the s3 winbindd
+ in s4 */
+ if (lp_parm_bool(conn->lp_ctx, NULL, "s3compat", "winbindd", false)) {
+ s3compat_winbind_accept(wbsrv_conn);
+ }
+#endif
/*
* The winbind pdu's has the length as 4 byte (initial_read_size),
* wbsrv_samba3_packet_full_request provides the pdu length then.