s4:s3compat Change s3compat winbind interface and add prototypes
authorAndrew Bartlett <abartlet@samba.org>
Fri, 14 May 2010 11:08:30 +0000 (21:08 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 3 Jun 2010 01:14:07 +0000 (11:14 +1000)
It's just asking for trouble to use manually created unsyncronised
prototypes.

The winbind change is to have the source3/winbind code engange after
the parsing of the packet, rather than before.  This is because
otherwise there was a conflict with the stream_connection code.

Andrew Bartlett

source4/s3compat/machine_sid.c
source4/s3compat/s3_smbd.c
source4/s3compat/s3_winbind.c
source4/s3compat/s3compat_authenticate.c
source4/s3compat/s3compat_winbindd.c
source4/s3compat/s3compat_wrapper.h
source4/winbind/wb_samba3_protocol.c
source4/winbind/wb_server.c

index 0835725b51991d7d722be6c150e8932f1e9abbf9..97acdf1eee7f0a01b94e127f9705cef167bad031 100644 (file)
@@ -23,7 +23,7 @@
 #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"
index 3d9583a41898a8bcfe3842d1777e68e937725826..2f97661865ae38c0c7cb3b40ebe4e7b45a57f4bc 100644 (file)
@@ -31,8 +31,8 @@
 #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;
 
index be2ce250263fc8f179d7ebc5446ffb67957c57b4..ad90272e70a0fba2617a1988da3340ba9f220540 100644 (file)
 #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) 
 {
@@ -45,11 +45,40 @@ _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);
 }
index b7378ef24a98460d21ccfe7031acfcf1a21fbbc8..5215bffc0a66104977e91cedaebfb507ed9dd442 100644 (file)
@@ -23,7 +23,7 @@
 #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"
index 85dd81951ede59fa40c52f793bb077551170158d..5b4b71fa0f2e85e74d9d6986d85f3655d2b1089e 100644 (file)
@@ -22,6 +22,7 @@
 #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
@@ -63,8 +64,61 @@ _PUBLIC_ void s3compat_initialise_winbindd(const char *config_file)
 /* 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");
+}
index 35619e5a85e843bae1b2ef6d69e171899956cfce..cb14b305d3337340a5234b94bc783a51b78871c2 100644 (file)
@@ -1,10 +1,15 @@
-
 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);
 
index 8d0127ba04fa94f6d4f51ecb88d9fb9a89907dfe..db96f7291cbcef556a4de01fd9954e96846d6556 100644 (file)
@@ -24,6 +24,8 @@
 #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
@@ -318,8 +320,16 @@ NTSTATUS wbsrv_samba3_process(struct wbsrv_samba3_call *call)
                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;
index 5407323c8191e95cbb622ba05a5f364d78c8612a..ae42563af4c0774d5f7cc86b24915c2a57079dd4 100644 (file)
@@ -28,6 +28,7 @@
 #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)
 {
@@ -112,15 +113,6 @@ static void wbsrv_accept(struct stream_connection *conn)
        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");
@@ -150,6 +142,13 @@ static void wbsrv_accept(struct stream_connection *conn)
        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.