r26230: Use task-provided loadparm context in a couple more places, avoid loadparm...
[jelmer/samba4-debian.git] / source / wrepl_server / wrepl_in_connection.c
index 1178eb766ea667debf0f8f41f9193c4fb5299c46..65c8b6118f38389e6f1b3a24b704047b14f918ae 100644 (file)
@@ -55,6 +55,7 @@ static NTSTATUS wreplsrv_recv_request(void *private, DATA_BLOB blob)
        DATA_BLOB packet_out_blob;
        struct wrepl_wrap packet_out_wrap;
        NTSTATUS status;
+       enum ndr_err_code ndr_err;
 
        call = talloc_zero(wreplconn, struct wreplsrv_in_call);
        NT_STATUS_HAVE_NO_MEMORY(call);
@@ -64,9 +65,11 @@ static NTSTATUS wreplsrv_recv_request(void *private, DATA_BLOB blob)
        packet_in_blob.data = blob.data + 4;
        packet_in_blob.length = blob.length - 4;
 
-       status = ndr_pull_struct_blob(&packet_in_blob, call, &call->req_packet,
-                                     (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet);
-       NT_STATUS_NOT_OK_RETURN(status);
+       ndr_err = ndr_pull_struct_blob(&packet_in_blob, call, &call->req_packet,
+                                      (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               return ndr_map_error2ntstatus(ndr_err);
+       }
 
        if (DEBUGLVL(10)) {
                DEBUG(10,("Received WINS-Replication packet of length %u\n", 
@@ -85,9 +88,11 @@ static NTSTATUS wreplsrv_recv_request(void *private, DATA_BLOB blob)
 
        /* and now encode the reply */
        packet_out_wrap.packet = call->rep_packet;
-       status = ndr_push_struct_blob(&packet_out_blob, call, &packet_out_wrap,
+       ndr_err = ndr_push_struct_blob(&packet_out_blob, call, &packet_out_wrap,
                                      (ndr_push_flags_fn_t)ndr_push_wrepl_wrap);
-       NT_STATUS_NOT_OK_RETURN(status);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               return ndr_map_error2ntstatus(ndr_err);
+       }
 
        if (DEBUGLVL(10)) {
                DEBUG(10,("Sending WINS-Replication packet of length %d\n", (int)packet_out_blob.length));
@@ -253,7 +258,7 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
 /*
   startup the wrepl port 42 server sockets
 */
-NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service)
+NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadparm_context *lp_ctx)
 {
        NTSTATUS status;
        struct task_server *task = service->task;
@@ -270,7 +275,7 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service)
                return NT_STATUS_INTERNAL_ERROR;
        }
 
-       if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) {
+       if (lp_interfaces(lp_ctx) && lp_bind_interfaces_only(lp_ctx)) {
                int num_interfaces = iface_count();
                int i;
 
@@ -289,7 +294,7 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service)
                        }
                }
        } else {
-               address = lp_socket_address(global_loadparm);
+               address = lp_socket_address(lp_ctx);
                status = stream_setup_socket(task->event_ctx, model_ops, &wreplsrv_stream_ops,
                                             "ipv4", address, &port, service);
                if (!NT_STATUS_IS_OK(status)) {