~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source4/wrepl_server/wrepl_in_connection.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "smbd/process_model.h"
32
32
#include "system/network.h"
33
33
#include "lib/socket/netif.h"
 
34
#include "lib/tsocket/tsocket.h"
 
35
#include "libcli/util/tstream.h"
34
36
#include "param/param.h"
35
37
 
36
38
void wreplsrv_terminate_in_connection(struct wreplsrv_in_connection *wreplconn, const char *reason)
38
40
        stream_terminate_connection(wreplconn->conn, reason);
39
41
}
40
42
 
41
 
static int terminate_after_send_destructor(struct wreplsrv_in_connection **tas)
42
 
{
43
 
        wreplsrv_terminate_in_connection(*tas, "wreplsrv_in_connection: terminate_after_send");
44
 
        return 0;
45
 
}
46
 
 
47
43
/*
48
44
  receive some data on a WREPL connection
49
45
*/
50
 
static NTSTATUS wreplsrv_recv_request(void *private_data, DATA_BLOB blob)
 
46
static NTSTATUS wreplsrv_process(struct wreplsrv_in_connection *wrepl_conn,
 
47
                                 struct wreplsrv_in_call **_call)
51
48
{
52
 
        struct wreplsrv_in_connection *wreplconn = talloc_get_type(private_data, struct wreplsrv_in_connection);
53
 
        struct wreplsrv_in_call *call;
54
 
        DATA_BLOB packet_in_blob;
55
 
        DATA_BLOB packet_out_blob;
56
49
        struct wrepl_wrap packet_out_wrap;
57
50
        NTSTATUS status;
58
51
        enum ndr_err_code ndr_err;
59
 
 
60
 
        call = talloc_zero(wreplconn, struct wreplsrv_in_call);
61
 
        NT_STATUS_HAVE_NO_MEMORY(call);
62
 
        call->wreplconn = wreplconn;
63
 
        talloc_steal(call, blob.data);
64
 
 
65
 
        packet_in_blob.data = blob.data + 4;
66
 
        packet_in_blob.length = blob.length - 4;
67
 
 
68
 
        ndr_err = ndr_pull_struct_blob(&packet_in_blob, call, 
69
 
                                       lp_iconv_convenience(wreplconn->service->task->lp_ctx),
 
52
        struct wreplsrv_in_call *call = *_call;
 
53
 
 
54
        ndr_err = ndr_pull_struct_blob(&call->in, call,
70
55
                                       &call->req_packet,
71
56
                                       (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet);
72
57
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
74
59
        }
75
60
 
76
61
        if (DEBUGLVL(10)) {
77
 
                DEBUG(10,("Received WINS-Replication packet of length %u\n", 
78
 
                          (unsigned)packet_in_blob.length + 4));
 
62
                DEBUG(10,("Received WINS-Replication packet of length %u\n",
 
63
                          (unsigned int) call->in.length + 4));
79
64
                NDR_PRINT_DEBUG(wrepl_packet, &call->req_packet);
80
65
        }
81
66
 
84
69
        if (!NT_STATUS_IS_OK(status)) {
85
70
                /* w2k just ignores invalid packets, so we do */
86
71
                DEBUG(10,("Received WINS-Replication packet was invalid, we just ignore it\n"));
87
 
                talloc_free(call);
 
72
                TALLOC_FREE(call);
 
73
                *_call = NULL;
88
74
                return NT_STATUS_OK;
89
75
        }
90
76
 
91
77
        /* and now encode the reply */
92
78
        packet_out_wrap.packet = call->rep_packet;
93
 
        ndr_err = ndr_push_struct_blob(&packet_out_blob, call, 
94
 
                                       lp_iconv_convenience(wreplconn->service->task->lp_ctx),
 
79
        ndr_err = ndr_push_struct_blob(&call->out, call,
95
80
                                       &packet_out_wrap,
96
 
                                      (ndr_push_flags_fn_t)ndr_push_wrepl_wrap);
 
81
                                       (ndr_push_flags_fn_t) ndr_push_wrepl_wrap);
97
82
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
98
83
                return ndr_map_error2ntstatus(ndr_err);
99
84
        }
100
85
 
101
86
        if (DEBUGLVL(10)) {
102
 
                DEBUG(10,("Sending WINS-Replication packet of length %d\n", (int)packet_out_blob.length));
 
87
                DEBUG(10,("Sending WINS-Replication packet of length %u\n",
 
88
                         (unsigned int) call->out.length));
103
89
                NDR_PRINT_DEBUG(wrepl_packet, &call->rep_packet);
104
90
        }
105
91
 
 
92
        return NT_STATUS_OK;
 
93
}
 
94
 
 
95
static void wreplsrv_call_loop(struct tevent_req *subreq);
 
96
 
 
97
/*
 
98
  called when we get a new connection
 
99
*/
 
100
static void wreplsrv_accept(struct stream_connection *conn)
 
101
{
 
102
        struct wreplsrv_service *service = talloc_get_type(conn->private_data, struct wreplsrv_service);
 
103
        struct wreplsrv_in_connection *wrepl_conn;
 
104
        struct tsocket_address *peer_addr;
 
105
        char *peer_ip;
 
106
        struct tevent_req *subreq;
 
107
        int rc;
 
108
 
 
109
        wrepl_conn = talloc_zero(conn, struct wreplsrv_in_connection);
 
110
        if (wrepl_conn == NULL) {
 
111
                stream_terminate_connection(conn,
 
112
                                            "wreplsrv_accept: out of memory");
 
113
                return;
 
114
        }
 
115
 
 
116
        wrepl_conn->send_queue = tevent_queue_create(conn, "wrepl_accept");
 
117
        if (wrepl_conn->send_queue == NULL) {
 
118
                stream_terminate_connection(conn,
 
119
                                            "wrepl_accept: out of memory");
 
120
                return;
 
121
        }
 
122
 
 
123
        TALLOC_FREE(conn->event.fde);
 
124
 
 
125
        rc = tstream_bsd_existing_socket(wrepl_conn,
 
126
                                         socket_get_fd(conn->socket),
 
127
                                         &wrepl_conn->tstream);
 
128
        if (rc < 0) {
 
129
                stream_terminate_connection(conn,
 
130
                                            "wrepl_accept: out of memory");
 
131
                return;
 
132
        }
 
133
        socket_set_flags(conn->socket, SOCKET_FLAG_NOCLOSE);
 
134
 
 
135
        wrepl_conn->conn = conn;
 
136
        wrepl_conn->service = service;
 
137
 
 
138
        peer_addr = conn->remote_address;
 
139
 
 
140
        if (!tsocket_address_is_inet(peer_addr, "ipv4")) {
 
141
                DEBUG(0,("wreplsrv_accept: non ipv4 peer addr '%s'\n",
 
142
                        tsocket_address_string(peer_addr, wrepl_conn)));
 
143
                wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_accept: "
 
144
                                "invalid peer IP");
 
145
                return;
 
146
        }
 
147
 
 
148
        peer_ip = tsocket_address_inet_addr_string(peer_addr, wrepl_conn);
 
149
        if (peer_ip == NULL) {
 
150
                wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_accept: "
 
151
                                "could not convert peer IP into a string");
 
152
                return;
 
153
        }
 
154
 
 
155
        wrepl_conn->partner = wreplsrv_find_partner(service, peer_ip);
 
156
        irpc_add_name(conn->msg_ctx, "wreplsrv_connection");
 
157
 
 
158
        /*
 
159
         * The wrepl pdu's has the length as 4 byte (initial_read_size),
 
160
         * packet_full_request_u32 provides the pdu length then.
 
161
         */
 
162
        subreq = tstream_read_pdu_blob_send(wrepl_conn,
 
163
                                            wrepl_conn->conn->event.ctx,
 
164
                                            wrepl_conn->tstream,
 
165
                                            4, /* initial_read_size */
 
166
                                            packet_full_request_u32,
 
167
                                            wrepl_conn);
 
168
        if (subreq == NULL) {
 
169
                wreplsrv_terminate_in_connection(wrepl_conn, "wrepl_accept: "
 
170
                                "no memory for tstream_read_pdu_blob_send");
 
171
                return;
 
172
        }
 
173
        tevent_req_set_callback(subreq, wreplsrv_call_loop, wrepl_conn);
 
174
}
 
175
 
 
176
static void wreplsrv_call_writev_done(struct tevent_req *subreq);
 
177
 
 
178
static void wreplsrv_call_loop(struct tevent_req *subreq)
 
179
{
 
180
        struct wreplsrv_in_connection *wrepl_conn = tevent_req_callback_data(subreq,
 
181
                                      struct wreplsrv_in_connection);
 
182
        struct wreplsrv_in_call *call;
 
183
        NTSTATUS status;
 
184
 
 
185
        call = talloc_zero(wrepl_conn, struct wreplsrv_in_call);
 
186
        if (call == NULL) {
 
187
                wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_call_loop: "
 
188
                                "no memory for wrepl_samba3_call");
 
189
                return;
 
190
        }
 
191
        call->wreplconn = wrepl_conn;
 
192
 
 
193
        status = tstream_read_pdu_blob_recv(subreq,
 
194
                                            call,
 
195
                                            &call->in);
 
196
        TALLOC_FREE(subreq);
 
197
        if (!NT_STATUS_IS_OK(status)) {
 
198
                const char *reason;
 
199
 
 
200
                reason = talloc_asprintf(call, "wreplsrv_call_loop: "
 
201
                                         "tstream_read_pdu_blob_recv() - %s",
 
202
                                         nt_errstr(status));
 
203
                if (!reason) {
 
204
                        reason = nt_errstr(status);
 
205
                }
 
206
 
 
207
                wreplsrv_terminate_in_connection(wrepl_conn, reason);
 
208
                return;
 
209
        }
 
210
 
 
211
        DEBUG(10,("Received wrepl packet of length %lu from %s\n",
 
212
                 (long) call->in.length,
 
213
                 tsocket_address_string(wrepl_conn->conn->remote_address, call)));
 
214
 
 
215
        /* skip length header */
 
216
        call->in.data += 4;
 
217
        call->in.length -= 4;
 
218
 
 
219
        status = wreplsrv_process(wrepl_conn, &call);
 
220
        if (!NT_STATUS_IS_OK(status)) {
 
221
                const char *reason;
 
222
 
 
223
                reason = talloc_asprintf(call, "wreplsrv_call_loop: "
 
224
                                         "tstream_read_pdu_blob_recv() - %s",
 
225
                                         nt_errstr(status));
 
226
                if (reason == NULL) {
 
227
                        reason = nt_errstr(status);
 
228
                }
 
229
 
 
230
                wreplsrv_terminate_in_connection(wrepl_conn, reason);
 
231
                return;
 
232
        }
 
233
 
 
234
        /* We handed over the connection so we're done here */
 
235
        if (wrepl_conn->tstream == NULL) {
 
236
            return;
 
237
        }
 
238
 
 
239
        /* Invalid WINS-Replication packet, we just ignore it */
 
240
        if (call == NULL) {
 
241
                goto noreply;
 
242
        }
 
243
 
 
244
        call->out_iov[0].iov_base = (char *) call->out.data;
 
245
        call->out_iov[0].iov_len = call->out.length;
 
246
 
 
247
        subreq = tstream_writev_queue_send(call,
 
248
                                           wrepl_conn->conn->event.ctx,
 
249
                                           wrepl_conn->tstream,
 
250
                                           wrepl_conn->send_queue,
 
251
                                           call->out_iov, 1);
 
252
        if (subreq == NULL) {
 
253
                wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_call_loop: "
 
254
                                "no memory for tstream_writev_queue_send");
 
255
                return;
 
256
        }
 
257
        tevent_req_set_callback(subreq, wreplsrv_call_writev_done, call);
 
258
 
 
259
noreply:
 
260
        /*
 
261
         * The wrepl pdu's has the length as 4 byte (initial_read_size),
 
262
         *  provides the pdu length then.
 
263
         */
 
264
        subreq = tstream_read_pdu_blob_send(wrepl_conn,
 
265
                                            wrepl_conn->conn->event.ctx,
 
266
                                            wrepl_conn->tstream,
 
267
                                            4, /* initial_read_size */
 
268
                                            packet_full_request_u32,
 
269
                                            wrepl_conn);
 
270
        if (subreq == NULL) {
 
271
                wreplsrv_terminate_in_connection(wrepl_conn, "wreplsrv_call_loop: "
 
272
                                "no memory for tstream_read_pdu_blob_send");
 
273
                return;
 
274
        }
 
275
        tevent_req_set_callback(subreq, wreplsrv_call_loop, wrepl_conn);
 
276
}
 
277
 
 
278
static void wreplsrv_call_writev_done(struct tevent_req *subreq)
 
279
{
 
280
        struct wreplsrv_in_call *call = tevent_req_callback_data(subreq,
 
281
                        struct wreplsrv_in_call);
 
282
        int sys_errno;
 
283
        int rc;
 
284
 
 
285
        rc = tstream_writev_queue_recv(subreq, &sys_errno);
 
286
        TALLOC_FREE(subreq);
 
287
        if (rc == -1) {
 
288
                const char *reason;
 
289
 
 
290
                reason = talloc_asprintf(call, "wreplsrv_call_writev_done: "
 
291
                                         "tstream_writev_queue_recv() - %d:%s",
 
292
                                         sys_errno, strerror(sys_errno));
 
293
                if (reason == NULL) {
 
294
                        reason = "wreplsrv_call_writev_done: "
 
295
                                 "tstream_writev_queue_recv() failed";
 
296
                }
 
297
 
 
298
                wreplsrv_terminate_in_connection(call->wreplconn, reason);
 
299
                return;
 
300
        }
 
301
 
106
302
        if (call->terminate_after_send) {
107
 
                struct wreplsrv_in_connection **tas;
108
 
                tas = talloc(packet_out_blob.data, struct wreplsrv_in_connection *);
109
 
                NT_STATUS_HAVE_NO_MEMORY(tas);
110
 
                *tas = wreplconn;
111
 
                talloc_set_destructor(tas, terminate_after_send_destructor);
 
303
                wreplsrv_terminate_in_connection(call->wreplconn,
 
304
                                "wreplsrv_in_connection: terminate_after_send");
 
305
                return;
112
306
        }
113
307
 
114
 
        status = packet_send(wreplconn->packet, packet_out_blob);
115
 
        NT_STATUS_NOT_OK_RETURN(status);
116
 
 
117
308
        talloc_free(call);
118
 
        return NT_STATUS_OK;
119
309
}
120
310
 
121
311
/*
122
 
  called when the socket becomes readable
 
312
  called on a tcp recv
123
313
*/
124
314
static void wreplsrv_recv(struct stream_connection *conn, uint16_t flags)
125
315
{
126
 
        struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private_data,
127
 
                                                                   struct wreplsrv_in_connection);
128
 
 
129
 
        packet_recv(wreplconn->packet);
 
316
        struct wreplsrv_in_connection *wrepl_conn = talloc_get_type(conn->private_data,
 
317
                                                        struct wreplsrv_in_connection);
 
318
        /* this should never be triggered! */
 
319
        DEBUG(0,("Terminating connection - '%s'\n", "wrepl_recv: called"));
 
320
        wreplsrv_terminate_in_connection(wrepl_conn, "wrepl_recv: called");
130
321
}
131
322
 
132
323
/*
133
 
  called when the socket becomes writable
 
324
  called when we can write to a connection
134
325
*/
135
326
static void wreplsrv_send(struct stream_connection *conn, uint16_t flags)
136
327
{
137
 
        struct wreplsrv_in_connection *wreplconn = talloc_get_type(conn->private_data,
138
 
                                                                   struct wreplsrv_in_connection);
139
 
        packet_queue_run(wreplconn->packet);
140
 
}
141
 
 
142
 
/*
143
 
  handle socket recv errors
144
 
*/
145
 
static void wreplsrv_recv_error(void *private_data, NTSTATUS status)
146
 
{
147
 
        struct wreplsrv_in_connection *wreplconn = talloc_get_type(private_data,
148
 
                                                                   struct wreplsrv_in_connection);
149
 
        wreplsrv_terminate_in_connection(wreplconn, nt_errstr(status));
150
 
}
151
 
 
152
 
/*
153
 
  called when we get a new connection
154
 
*/
155
 
static void wreplsrv_accept(struct stream_connection *conn)
156
 
{
157
 
        struct wreplsrv_service *service = talloc_get_type(conn->private_data, struct wreplsrv_service);
158
 
        struct wreplsrv_in_connection *wreplconn;
159
 
        struct socket_address *peer_ip;
160
 
 
161
 
        wreplconn = talloc_zero(conn, struct wreplsrv_in_connection);
162
 
        if (!wreplconn) {
163
 
                stream_terminate_connection(conn, "wreplsrv_accept: out of memory");
164
 
                return;
165
 
        }
166
 
 
167
 
        wreplconn->packet = packet_init(wreplconn);
168
 
        if (!wreplconn->packet) {
169
 
                wreplsrv_terminate_in_connection(wreplconn, "wreplsrv_accept: out of memory");
170
 
                return;
171
 
        }
172
 
        packet_set_private(wreplconn->packet, wreplconn);
173
 
        packet_set_socket(wreplconn->packet, conn->socket);
174
 
        packet_set_callback(wreplconn->packet, wreplsrv_recv_request);
175
 
        packet_set_full_request(wreplconn->packet, packet_full_request_u32);
176
 
        packet_set_error_handler(wreplconn->packet, wreplsrv_recv_error);
177
 
        packet_set_event_context(wreplconn->packet, conn->event.ctx);
178
 
        packet_set_fde(wreplconn->packet, conn->event.fde);
179
 
        packet_set_serialise(wreplconn->packet);
180
 
 
181
 
        wreplconn->conn         = conn;
182
 
        wreplconn->service      = service;
183
 
 
184
 
        peer_ip = socket_get_peer_addr(conn->socket, wreplconn);
185
 
        if (!peer_ip) {
186
 
                wreplsrv_terminate_in_connection(wreplconn, "wreplsrv_accept: could not obtain peer IP from kernel");
187
 
                return;
188
 
        }
189
 
 
190
 
        wreplconn->partner      = wreplsrv_find_partner(service, peer_ip->addr);
191
 
 
192
 
        conn->private_data = wreplconn;
193
 
 
194
 
        irpc_add_name(conn->msg_ctx, "wreplsrv_connection");
 
328
        struct wreplsrv_in_connection *wrepl_conn = talloc_get_type(conn->private_data,
 
329
                                                        struct wreplsrv_in_connection);
 
330
        /* this should never be triggered! */
 
331
        DEBUG(0,("Terminating connection - '%s'\n", "wrepl_send: called"));
 
332
        wreplsrv_terminate_in_connection(wrepl_conn, "wrepl_send: called");
195
333
}
196
334
 
197
335
static const struct stream_server_ops wreplsrv_stream_ops = {
205
343
  called when we get a new connection
206
344
*/
207
345
NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
208
 
                                      struct socket_context *sock,
209
 
                                      struct packet_context *packet,
 
346
                                      uint32_t peer_assoc_ctx,
 
347
                                      struct tstream_context **stream,
210
348
                                      struct wreplsrv_in_connection **_wrepl_in)
211
349
{
212
350
        struct wreplsrv_service *service = partner->service;
213
351
        struct wreplsrv_in_connection *wrepl_in;
214
352
        const struct model_ops *model_ops;
215
353
        struct stream_connection *conn;
 
354
        struct tevent_req *subreq;
216
355
        NTSTATUS status;
217
356
 
218
357
        /* within the wrepl task we want to be a single process, so
219
358
           ask for the single process model ops and pass these to the
220
359
           stream_setup_socket() call. */
221
 
        model_ops = process_model_startup(service->task->event_ctx, "single");
 
360
        model_ops = process_model_startup("single");
222
361
        if (!model_ops) {
223
362
                DEBUG(0,("Can't find 'single' process model_ops"));
224
363
                return NT_STATUS_INTERNAL_ERROR;
229
368
 
230
369
        wrepl_in->service       = service;
231
370
        wrepl_in->partner       = partner;
 
371
        wrepl_in->tstream       = talloc_move(wrepl_in, stream);
 
372
        wrepl_in->assoc_ctx.peer_ctx = peer_assoc_ctx;
232
373
 
233
 
        status = stream_new_connection_merge(service->task->event_ctx, service->task->lp_ctx, model_ops,
234
 
                                             sock, &wreplsrv_stream_ops, service->task->msg_ctx,
235
 
                                             wrepl_in, &conn);
 
374
        status = stream_new_connection_merge(service->task->event_ctx,
 
375
                                             service->task->lp_ctx,
 
376
                                             model_ops,
 
377
                                             &wreplsrv_stream_ops,
 
378
                                             service->task->msg_ctx,
 
379
                                             wrepl_in,
 
380
                                             &conn);
236
381
        NT_STATUS_NOT_OK_RETURN(status);
237
382
 
238
383
        /*
242
387
        wrepl_in->conn          = conn;
243
388
        talloc_steal(conn, wrepl_in);
244
389
 
 
390
        wrepl_in->send_queue = tevent_queue_create(wrepl_in, "wreplsrv_in_connection_merge");
 
391
        if (wrepl_in->send_queue == NULL) {
 
392
                stream_terminate_connection(conn,
 
393
                                            "wreplsrv_in_connection_merge: out of memory");
 
394
                return NT_STATUS_NO_MEMORY;
 
395
        }
 
396
 
245
397
        /*
246
 
         * now update the packet handling callback,...
 
398
         * The wrepl pdu's has the length as 4 byte (initial_read_size),
 
399
         * packet_full_request_u32 provides the pdu length then.
247
400
         */
248
 
        wrepl_in->packet        = talloc_steal(wrepl_in, packet);
249
 
        packet_set_private(wrepl_in->packet, wrepl_in);
250
 
        packet_set_socket(wrepl_in->packet, conn->socket);
251
 
        packet_set_callback(wrepl_in->packet, wreplsrv_recv_request);
252
 
        packet_set_full_request(wrepl_in->packet, packet_full_request_u32);
253
 
        packet_set_error_handler(wrepl_in->packet, wreplsrv_recv_error);
254
 
        packet_set_event_context(wrepl_in->packet, conn->event.ctx);
255
 
        packet_set_fde(wrepl_in->packet, conn->event.fde);
256
 
        packet_set_serialise(wrepl_in->packet);
 
401
        subreq = tstream_read_pdu_blob_send(wrepl_in,
 
402
                                            wrepl_in->conn->event.ctx,
 
403
                                            wrepl_in->tstream,
 
404
                                            4, /* initial_read_size */
 
405
                                            packet_full_request_u32,
 
406
                                            wrepl_in);
 
407
        if (subreq == NULL) {
 
408
                wreplsrv_terminate_in_connection(wrepl_in, "wreplsrv_in_connection_merge: "
 
409
                                "no memory for tstream_read_pdu_blob_send");
 
410
                return NT_STATUS_NO_MEMORY;
 
411
        }
 
412
        tevent_req_set_callback(subreq, wreplsrv_call_loop, wrepl_in);
257
413
 
258
414
        *_wrepl_in = wrepl_in;
 
415
 
259
416
        return NT_STATUS_OK;
260
417
}
261
418
 
273
430
        /* within the wrepl task we want to be a single process, so
274
431
           ask for the single process model ops and pass these to the
275
432
           stream_setup_socket() call. */
276
 
        model_ops = process_model_startup(task->event_ctx, "single");
 
433
        model_ops = process_model_startup("single");
277
434
        if (!model_ops) {
278
435
                DEBUG(0,("Can't find 'single' process model_ops"));
279
436
                return NT_STATUS_INTERNAL_ERROR;
280
437
        }
281
438
 
282
 
        if (lp_interfaces(lp_ctx) && lp_bind_interfaces_only(lp_ctx)) {
 
439
        if (lpcfg_interfaces(lp_ctx) && lpcfg_bind_interfaces_only(lp_ctx)) {
283
440
                int num_interfaces;
284
441
                int i;
285
442
                struct interface *ifaces;
286
443
 
287
 
                load_interfaces(task, lp_interfaces(lp_ctx), &ifaces);
 
444
                load_interfaces(task, lpcfg_interfaces(lp_ctx), &ifaces);
288
445
 
289
446
                num_interfaces = iface_count(ifaces);
290
447
 
294
451
                */
295
452
                for(i = 0; i < num_interfaces; i++) {
296
453
                        address = iface_n_ip(ifaces, i);
297
 
                        status = stream_setup_socket(task->event_ctx, 
298
 
                                                     task->lp_ctx, model_ops, 
 
454
                        status = stream_setup_socket(task, task->event_ctx,
 
455
                                                     task->lp_ctx, model_ops,
299
456
                                                     &wreplsrv_stream_ops,
300
457
                                                     "ipv4", address, &port, 
301
 
                                                      lp_socket_options(task->lp_ctx), 
 
458
                                                      lpcfg_socket_options(task->lp_ctx),
302
459
                                                     service);
303
460
                        if (!NT_STATUS_IS_OK(status)) {
304
461
                                DEBUG(0,("stream_setup_socket(address=%s,port=%u) failed - %s\n",
307
464
                        }
308
465
                }
309
466
        } else {
310
 
                address = lp_socket_address(lp_ctx);
311
 
                status = stream_setup_socket(task->event_ctx, task->lp_ctx, 
 
467
                address = lpcfg_socket_address(lp_ctx);
 
468
                status = stream_setup_socket(task, task->event_ctx, task->lp_ctx,
312
469
                                             model_ops, &wreplsrv_stream_ops,
313
 
                                             "ipv4", address, &port, lp_socket_options(task->lp_ctx), 
 
470
                                             "ipv4", address, &port, lpcfg_socket_options(task->lp_ctx),
314
471
                                             service);
315
472
                if (!NT_STATUS_IS_OK(status)) {
316
473
                        DEBUG(0,("stream_setup_socket(address=%s,port=%u) failed - %s\n",