dlist: remove unneeded type argument from DLIST_ADD_END()
[samba.git] / source4 / torture / rpc / spoolss_notify.c
1 /*
2    Unix SMB/CIFS implementation.
3    test suite for spoolss rpc notify operations
4
5    Copyright (C) Jelmer Vernooij 2007
6    Copyright (C) Guenther Deschner 2010
7
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 3 of the License, or
11    (at your option) any later version.
12
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.
17
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.
21 */
22
23 #include "includes.h"
24 #include "system/filesys.h"
25 #include "librpc/gen_ndr/ndr_spoolss_c.h"
26 #include "librpc/gen_ndr/ndr_spoolss.h"
27 #include "torture/rpc/torture_rpc.h"
28 #include "rpc_server/dcerpc_server.h"
29 #include "rpc_server/service_rpc.h"
30 #include "smbd/process_model.h"
31 #include "smb_server/smb_server.h"
32 #include "lib/socket/netif.h"
33 #include "ntvfs/ntvfs.h"
34 #include "param/param.h"
35
36 static NTSTATUS spoolss__op_bind(struct dcesrv_call_state *dce_call,
37                                  const struct dcesrv_interface *iface,
38                                  uint32_t if_version)
39 {
40         return NT_STATUS_OK;
41 }
42
43 static void spoolss__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
44 {
45 }
46
47 static NTSTATUS spoolss__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
48 {
49         enum ndr_err_code ndr_err;
50         uint16_t opnum = dce_call->pkt.u.request.opnum;
51
52         dce_call->fault_code = 0;
53
54         if (opnum >= ndr_table_spoolss.num_calls) {
55                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
56                 return NT_STATUS_NET_WRITE_FAULT;
57         }
58
59         *r = talloc_size(mem_ctx, ndr_table_spoolss.calls[opnum].struct_size);
60         NT_STATUS_HAVE_NO_MEMORY(*r);
61
62         /* unravel the NDR for the packet */
63         ndr_err = ndr_table_spoolss.calls[opnum].ndr_pull(pull, NDR_IN, *r);
64         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
65                 dcerpc_log_packet(dce_call->conn->packet_log_dir,
66                                                   &ndr_table_spoolss, opnum, NDR_IN,
67                                   &dce_call->pkt.u.request.stub_and_verifier);
68                 dce_call->fault_code = DCERPC_FAULT_NDR;
69                 return NT_STATUS_NET_WRITE_FAULT;
70         }
71
72         return NT_STATUS_OK;
73 }
74
75 /* Note that received_packets are allocated in talloc_autofree_context(),
76  * because no other context appears to stay around long enough. */
77 static struct received_packet {
78         uint16_t opnum;
79         void *r;
80         struct received_packet *prev, *next;
81 } *received_packets = NULL;
82
83 static WERROR _spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call,
84                                         TALLOC_CTX *mem_ctx,
85                                         struct spoolss_ReplyOpenPrinter *r)
86 {
87         DEBUG(1,("_spoolss_ReplyOpenPrinter\n"));
88
89         NDR_PRINT_IN_DEBUG(spoolss_ReplyOpenPrinter, r);
90
91         r->out.handle = talloc(r, struct policy_handle);
92         r->out.handle->handle_type = 42;
93         r->out.handle->uuid = GUID_random();
94         r->out.result = WERR_OK;
95
96         NDR_PRINT_OUT_DEBUG(spoolss_ReplyOpenPrinter, r);
97
98         return WERR_OK;
99 }
100
101 static WERROR _spoolss_ReplyClosePrinter(struct dcesrv_call_state *dce_call,
102                                          TALLOC_CTX *mem_ctx,
103                                          struct spoolss_ReplyClosePrinter *r)
104 {
105         DEBUG(1,("_spoolss_ReplyClosePrinter\n"));
106
107         NDR_PRINT_IN_DEBUG(spoolss_ReplyClosePrinter, r);
108
109         ZERO_STRUCTP(r->out.handle);
110         r->out.result = WERR_OK;
111
112         NDR_PRINT_OUT_DEBUG(spoolss_ReplyClosePrinter, r);
113
114         return WERR_OK;
115 }
116
117 static WERROR _spoolss_RouterReplyPrinterEx(struct dcesrv_call_state *dce_call,
118                                             TALLOC_CTX *mem_ctx,
119                                             struct spoolss_RouterReplyPrinterEx *r)
120 {
121         DEBUG(1,("_spoolss_RouterReplyPrinterEx\n"));
122
123         NDR_PRINT_IN_DEBUG(spoolss_RouterReplyPrinterEx, r);
124
125         r->out.reply_result = talloc(r, uint32_t);
126         *r->out.reply_result = 0;
127         r->out.result = WERR_OK;
128
129         NDR_PRINT_OUT_DEBUG(spoolss_RouterReplyPrinterEx, r);
130
131         return WERR_OK;
132 }
133
134 static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
135 {
136         uint16_t opnum = dce_call->pkt.u.request.opnum;
137         struct received_packet *rp;
138
139         rp = talloc_zero(talloc_autofree_context(), struct received_packet);
140         rp->opnum = opnum;
141         rp->r = talloc_reference(rp, r);
142
143         DLIST_ADD_END(received_packets, rp);
144
145         switch (opnum) {
146         case 58: {
147                 struct spoolss_ReplyOpenPrinter *r2 = (struct spoolss_ReplyOpenPrinter *)r;
148                 r2->out.result = _spoolss_ReplyOpenPrinter(dce_call, mem_ctx, r2);
149                 break;
150         }
151         case 60: {
152                 struct spoolss_ReplyClosePrinter *r2 = (struct spoolss_ReplyClosePrinter *)r;
153                 r2->out.result = _spoolss_ReplyClosePrinter(dce_call, mem_ctx, r2);
154                 break;
155         }
156         case 66: {
157                 struct spoolss_RouterReplyPrinterEx *r2 = (struct spoolss_RouterReplyPrinterEx *)r;
158                 r2->out.result = _spoolss_RouterReplyPrinterEx(dce_call, mem_ctx, r2);
159                 break;
160         }
161
162         default:
163                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
164                 break;
165         }
166
167         if (dce_call->fault_code != 0) {
168                 dcerpc_log_packet(dce_call->conn->packet_log_dir,
169                                                   &ndr_table_spoolss, opnum, NDR_IN,
170                                   &dce_call->pkt.u.request.stub_and_verifier);
171                 return NT_STATUS_NET_WRITE_FAULT;
172         }
173         return NT_STATUS_OK;
174 }
175
176
177 static NTSTATUS spoolss__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
178 {
179         return NT_STATUS_OK;
180 }
181
182
183 static NTSTATUS spoolss__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
184 {
185         enum ndr_err_code ndr_err;
186         uint16_t opnum = dce_call->pkt.u.request.opnum;
187
188         ndr_err = ndr_table_spoolss.calls[opnum].ndr_push(push, NDR_OUT, r);
189         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
190                 dce_call->fault_code = DCERPC_FAULT_NDR;
191                 return NT_STATUS_NET_WRITE_FAULT;
192         }
193
194         return NT_STATUS_OK;
195 }
196
197 const static struct dcesrv_interface notify_test_spoolss_interface = {
198         .name           = "spoolss",
199         .syntax_id  = {{0x12345678,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xab}},1.0},
200         .bind           = spoolss__op_bind,
201         .unbind         = spoolss__op_unbind,
202         .ndr_pull       = spoolss__op_ndr_pull,
203         .dispatch       = spoolss__op_dispatch,
204         .reply          = spoolss__op_reply,
205         .ndr_push       = spoolss__op_ndr_push
206 };
207
208 static bool spoolss__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
209 {
210         if (notify_test_spoolss_interface.syntax_id.if_version == if_version &&
211                 GUID_equal(&notify_test_spoolss_interface.syntax_id.uuid, uuid)) {
212                 memcpy(iface,&notify_test_spoolss_interface, sizeof(*iface));
213                 return true;
214         }
215
216         return false;
217 }
218
219 static bool spoolss__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
220 {
221         if (strcmp(notify_test_spoolss_interface.name, name)==0) {
222                 memcpy(iface, &notify_test_spoolss_interface, sizeof(*iface));
223                 return true;
224         }
225
226         return false;
227 }
228
229 static NTSTATUS spoolss__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
230 {
231         int i;
232
233         for (i=0;i<ndr_table_spoolss.endpoints->count;i++) {
234                 NTSTATUS ret;
235                 const char *name = ndr_table_spoolss.endpoints->names[i];
236
237                 ret = dcesrv_interface_register(dce_ctx, name, &notify_test_spoolss_interface, NULL);
238                 if (!NT_STATUS_IS_OK(ret)) {
239                         DEBUG(1,("spoolss_op_init_server: failed to register endpoint '%s'\n",name));
240                         return ret;
241                 }
242         }
243
244         return NT_STATUS_OK;
245 }
246
247 static bool test_OpenPrinter(struct torture_context *tctx,
248                              struct dcerpc_pipe *p,
249                              struct policy_handle *handle,
250                              const char *printername)
251 {
252         struct spoolss_OpenPrinter r;
253         struct dcerpc_binding_handle *b = p->binding_handle;
254
255         ZERO_STRUCT(r);
256
257         r.in.printername        = printername;
258         r.in.datatype           = NULL;
259         r.in.devmode_ctr.devmode= NULL;
260         r.in.access_mask        = SEC_FLAG_MAXIMUM_ALLOWED;
261         r.out.handle            = handle;
262
263         torture_comment(tctx, "Testing OpenPrinter(%s)\n", r.in.printername);
264
265         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_OpenPrinter_r(b, tctx, &r),
266                 "OpenPrinter failed");
267         torture_assert_werr_ok(tctx, r.out.result,
268                 "OpenPrinter failed");
269
270         return true;
271 }
272
273 static struct spoolss_NotifyOption *setup_printserver_NotifyOption(struct torture_context *tctx)
274 {
275         struct spoolss_NotifyOption *o;
276
277         o = talloc_zero(tctx, struct spoolss_NotifyOption);
278
279         o->version = 2;
280         o->flags = PRINTER_NOTIFY_OPTIONS_REFRESH;
281
282         o->count = 2;
283         o->types = talloc_zero_array(o, struct spoolss_NotifyOptionType, o->count);
284
285         o->types[0].type = PRINTER_NOTIFY_TYPE;
286         o->types[0].count = 1;
287         o->types[0].fields = talloc_array(o->types, union spoolss_Field, o->types[0].count);
288         o->types[0].fields[0].field = PRINTER_NOTIFY_FIELD_SERVER_NAME;
289
290         o->types[1].type = JOB_NOTIFY_TYPE;
291         o->types[1].count = 1;
292         o->types[1].fields = talloc_array(o->types, union spoolss_Field, o->types[1].count);
293         o->types[1].fields[0].field = JOB_NOTIFY_FIELD_MACHINE_NAME;
294
295         return o;
296 }
297
298 #if 0
299 static struct spoolss_NotifyOption *setup_printer_NotifyOption(struct torture_context *tctx)
300 {
301         struct spoolss_NotifyOption *o;
302
303         o = talloc_zero(tctx, struct spoolss_NotifyOption);
304
305         o->version = 2;
306         o->flags = PRINTER_NOTIFY_OPTIONS_REFRESH;
307
308         o->count = 1;
309         o->types = talloc_zero_array(o, struct spoolss_NotifyOptionType, o->count);
310
311         o->types[0].type = PRINTER_NOTIFY_TYPE;
312         o->types[0].count = 1;
313         o->types[0].fields = talloc_array(o->types, union spoolss_Field, o->types[0].count);
314         o->types[0].fields[0].field = PRINTER_NOTIFY_FIELD_COMMENT;
315
316         return o;
317 }
318 #endif
319
320 static bool test_RemoteFindFirstPrinterChangeNotifyEx(struct torture_context *tctx,
321                                                       struct dcerpc_binding_handle *b,
322                                                       struct policy_handle *handle,
323                                                       const char *address,
324                                                       struct spoolss_NotifyOption *option)
325 {
326         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r;
327         const char *local_machine = talloc_asprintf(tctx, "\\\\%s", address);
328
329         torture_comment(tctx, "Testing RemoteFindFirstPrinterChangeNotifyEx(%s)\n", local_machine);
330
331         r.in.flags = 0;
332         r.in.local_machine = local_machine;
333         r.in.options = 0;
334         r.in.printer_local = 0;
335         r.in.notify_options = option;
336         r.in.handle = handle;
337
338         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx_r(b, tctx, &r),
339                 "RemoteFindFirstPrinterChangeNotifyEx failed");
340         torture_assert_werr_ok(tctx, r.out.result,
341                 "error return code for RemoteFindFirstPrinterChangeNotifyEx");
342
343         return true;
344 }
345
346 static bool test_RouterRefreshPrinterChangeNotify(struct torture_context *tctx,
347                                                   struct dcerpc_binding_handle *b,
348                                                   struct policy_handle *handle,
349                                                   struct spoolss_NotifyOption *options,
350                                                   struct spoolss_NotifyInfo **info)
351 {
352         struct spoolss_RouterRefreshPrinterChangeNotify r;
353
354         torture_comment(tctx, "Testing RouterRefreshPrinterChangeNotify\n");
355
356         r.in.handle = handle;
357         r.in.change_low = 0;
358         r.in.options = options;
359         r.out.info = info;
360
361         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_RouterRefreshPrinterChangeNotify_r(b, tctx, &r),
362                 "RouterRefreshPrinterChangeNotify failed");
363         torture_assert_werr_ok(tctx, r.out.result,
364                 "error return code for RouterRefreshPrinterChangeNotify");
365
366         return true;
367 }
368
369 #if 0
370 static bool test_SetPrinter(struct torture_context *tctx,
371                             struct dcerpc_pipe *p,
372                             struct policy_handle *handle)
373 {
374         union spoolss_PrinterInfo info;
375         struct spoolss_SetPrinter r;
376         struct spoolss_SetPrinterInfo2 info2;
377         struct spoolss_SetPrinterInfoCtr info_ctr;
378         struct spoolss_DevmodeContainer devmode_ctr;
379         struct sec_desc_buf secdesc_ctr;
380         struct dcerpc_binding_handle *b = p->binding_handle;
381
382         torture_assert(tctx, test_GetPrinter_level(tctx, b, handle, 2, &info), "");
383
384         ZERO_STRUCT(devmode_ctr);
385         ZERO_STRUCT(secdesc_ctr);
386
387         info2.servername        = info.info2.servername;
388         info2.printername       = info.info2.printername;
389         info2.sharename         = info.info2.sharename;
390         info2.portname          = info.info2.portname;
391         info2.drivername        = info.info2.drivername;
392         info2.comment           = talloc_asprintf(tctx, "torture_comment %d\n", (int)time(NULL));
393         info2.location          = info.info2.location;
394         info2.devmode_ptr       = NULL;
395         info2.sepfile           = info.info2.sepfile;
396         info2.printprocessor    = info.info2.printprocessor;
397         info2.datatype          = info.info2.datatype;
398         info2.parameters        = info.info2.parameters;
399         info2.secdesc_ptr       = NULL;
400         info2.attributes        = info.info2.attributes;
401         info2.priority          = info.info2.priority;
402         info2.defaultpriority   = info.info2.defaultpriority;
403         info2.starttime         = info.info2.starttime;
404         info2.untiltime         = info.info2.untiltime;
405         info2.status            = info.info2.status;
406         info2.cjobs             = info.info2.cjobs;
407         info2.averageppm        = info.info2.averageppm;
408
409         info_ctr.level = 2;
410         info_ctr.info.info2 = &info2;
411
412         r.in.handle = handle;
413         r.in.info_ctr = &info_ctr;
414         r.in.devmode_ctr = &devmode_ctr;
415         r.in.secdesc_ctr = &secdesc_ctr;
416         r.in.command = 0;
417
418         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_SetPrinter_r(b, tctx, &r), "SetPrinter failed");
419         torture_assert_werr_ok(tctx, r.out.result, "SetPrinter failed");
420
421         return true;
422 }
423 #endif
424
425 static bool test_start_dcerpc_server(struct torture_context *tctx,
426                                      struct tevent_context *event_ctx,
427                                      struct dcesrv_context **dce_ctx_p,
428                                      const char **address_p)
429 {
430         struct dcesrv_endpoint_server ep_server;
431         NTSTATUS status;
432         struct dcesrv_context *dce_ctx;
433         const char *endpoints[] = { "spoolss", NULL };
434         struct dcesrv_endpoint *e;
435         const char *address;
436         struct interface *ifaces;
437
438         ntvfs_init(tctx->lp_ctx);
439
440         /* fill in our name */
441         ep_server.name = "spoolss";
442
443         /* fill in all the operations */
444         ep_server.init_server = spoolss__op_init_server;
445
446         ep_server.interface_by_uuid = spoolss__op_interface_by_uuid;
447         ep_server.interface_by_name = spoolss__op_interface_by_name;
448
449         torture_assert_ntstatus_ok(tctx, dcerpc_register_ep_server(&ep_server),
450                                   "unable to register spoolss server");
451
452         lpcfg_set_cmdline(tctx->lp_ctx, "dcerpc endpoint servers", "spoolss");
453
454         load_interface_list(tctx, tctx->lp_ctx, &ifaces);
455         address = iface_list_first_v4(ifaces);
456
457         torture_comment(tctx, "Listening for callbacks on %s\n", address);
458
459         status = process_model_init(tctx->lp_ctx);
460         torture_assert_ntstatus_ok(tctx, status,
461                                    "unable to initialize process models");
462
463         status = smbsrv_add_socket(tctx, event_ctx, tctx->lp_ctx, process_model_startup("single"), address);
464         torture_assert_ntstatus_ok(tctx, status, "starting smb server");
465
466         status = dcesrv_init_context(tctx, tctx->lp_ctx, endpoints, &dce_ctx);
467         torture_assert_ntstatus_ok(tctx, status,
468                                    "unable to initialize DCE/RPC server");
469
470         for (e=dce_ctx->endpoint_list;e;e=e->next) {
471                 status = dcesrv_add_ep(dce_ctx, tctx->lp_ctx,
472                                        e, tctx->ev, process_model_startup("single"));
473                 torture_assert_ntstatus_ok(tctx, status,
474                                 "unable listen on dcerpc endpoint server");
475         }
476
477         *dce_ctx_p = dce_ctx;
478         *address_p = address;
479
480         return true;
481 }
482
483 static struct received_packet *last_packet(struct received_packet *p)
484 {
485         struct received_packet *tmp;
486         for (tmp = p; tmp->next; tmp = tmp->next) ;;
487         return tmp;
488 }
489
490 static bool test_RFFPCNEx(struct torture_context *tctx,
491                           struct dcerpc_pipe *p)
492 {
493         struct dcesrv_context *dce_ctx;
494         struct policy_handle handle;
495         const char *address;
496         struct received_packet *tmp;
497         struct spoolss_NotifyOption *server_option = setup_printserver_NotifyOption(tctx);
498 #if 0
499         struct spoolss_NotifyOption *printer_option = setup_printer_NotifyOption(tctx);
500 #endif
501         struct dcerpc_binding_handle *b = p->binding_handle;
502         const char *printername = NULL;
503         struct spoolss_NotifyInfo *info = NULL;
504
505         received_packets = NULL;
506
507         /* Start DCE/RPC server */
508         torture_assert(tctx, test_start_dcerpc_server(tctx, tctx->ev, &dce_ctx, &address), "");
509
510         printername     = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
511
512         torture_assert(tctx, test_OpenPrinter(tctx, p, &handle, printername), "");
513         torture_assert(tctx, test_RemoteFindFirstPrinterChangeNotifyEx(tctx, b, &handle, address, server_option), "");
514         torture_assert(tctx, received_packets, "no packets received");
515         torture_assert_int_equal(tctx, received_packets->opnum, NDR_SPOOLSS_REPLYOPENPRINTER,
516                 "no ReplyOpenPrinter packet after RemoteFindFirstPrinterChangeNotifyEx");
517         torture_assert(tctx, test_RouterRefreshPrinterChangeNotify(tctx, b, &handle, NULL, &info), "");
518         torture_assert(tctx, test_RouterRefreshPrinterChangeNotify(tctx, b, &handle, server_option, &info), "");
519         torture_assert(tctx, test_ClosePrinter(tctx, b, &handle), "");
520         tmp = last_packet(received_packets);
521         torture_assert_int_equal(tctx, tmp->opnum, NDR_SPOOLSS_REPLYCLOSEPRINTER,
522                 "no ReplyClosePrinter packet after ClosePrinter");
523 #if 0
524         printername     = talloc_asprintf(tctx, "\\\\%s\\%s", dcerpc_server_name(p), name);
525
526         torture_assert(tctx, test_OpenPrinter(tctx, p, &handle, "Epson AL-2600"), "");
527         torture_assert(tctx, test_RemoteFindFirstPrinterChangeNotifyEx(tctx, p, &handle, address, printer_option), "");
528         tmp = last_packet(received_packets);
529         torture_assert_int_equal(tctx, tmp->opnum, NDR_SPOOLSS_REPLYOPENPRINTER,
530                 "no ReplyOpenPrinter packet after RemoteFindFirstPrinterChangeNotifyEx");
531         torture_assert(tctx, test_RouterRefreshPrinterChangeNotify(tctx, p, &handle, NULL, &info), "");
532         torture_assert(tctx, test_RouterRefreshPrinterChangeNotify(tctx, p, &handle, printer_option, &info), "");
533         torture_assert(tctx, test_SetPrinter(tctx, p, &handle), "");
534         tmp = last_packet(received_packets);
535         torture_assert_int_equal(tctx, tmp->opnum, NDR_SPOOLSS_ROUTERREPLYPRINTEREX,
536                 "no RouterReplyPrinterEx packet after ClosePrinter");
537         torture_assert(tctx, test_ClosePrinter(tctx, p, &handle), "");
538         tmp = last_packet(received_packets);
539         torture_assert_int_equal(tctx, tmp->opnum, NDR_SPOOLSS_REPLYCLOSEPRINTER,
540                 "no ReplyClosePrinter packet after ClosePrinter");
541 #endif
542         /* Shut down DCE/RPC server */
543         talloc_free(dce_ctx);
544
545         return true;
546 }
547
548 /** Test that makes sure that calling ReplyOpenPrinter()
549  * on Samba 4 will cause an irpc broadcast call.
550  */
551 static bool test_ReplyOpenPrinter(struct torture_context *tctx,
552                                   struct dcerpc_pipe *p)
553 {
554         struct spoolss_ReplyOpenPrinter r;
555         struct spoolss_ReplyClosePrinter s;
556         struct policy_handle h;
557         struct dcerpc_binding_handle *b = p->binding_handle;
558
559         if (torture_setting_bool(tctx, "samba3", false)) {
560                 torture_skip(tctx, "skipping ReplyOpenPrinter server implementation test against s3\n");
561         }
562
563         r.in.server_name = "earth";
564         r.in.printer_local = 2;
565         r.in.type = REG_DWORD;
566         r.in.bufsize = 0;
567         r.in.buffer = NULL;
568         r.out.handle = &h;
569
570         torture_assert_ntstatus_ok(tctx,
571                         dcerpc_spoolss_ReplyOpenPrinter_r(b, tctx, &r),
572                         "spoolss_ReplyOpenPrinter call failed");
573
574         torture_assert_werr_ok(tctx, r.out.result, "error return code");
575
576         s.in.handle = &h;
577         s.out.handle = &h;
578
579         torture_assert_ntstatus_ok(tctx,
580                         dcerpc_spoolss_ReplyClosePrinter_r(b, tctx, &s),
581                         "spoolss_ReplyClosePrinter call failed");
582
583         torture_assert_werr_ok(tctx, r.out.result, "error return code");
584
585         return true;
586 }
587
588 struct torture_suite *torture_rpc_spoolss_notify(TALLOC_CTX *mem_ctx)
589 {
590         struct torture_suite *suite = torture_suite_create(mem_ctx, "spoolss.notify");
591
592         struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite,
593                                                         "notify", &ndr_table_spoolss);
594
595         torture_rpc_tcase_add_test(tcase, "testRFFPCNEx", test_RFFPCNEx);
596         torture_rpc_tcase_add_test(tcase, "testReplyOpenPrinter", test_ReplyOpenPrinter);
597
598         return suite;
599 }