s4-smbtorture: support spoolss_ReplyClosePrinter server call in RPC-SPOOLSS-NOTIFY.
authorGünther Deschner <gd@samba.org>
Mon, 18 Jan 2010 23:27:50 +0000 (00:27 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 19 Jan 2010 13:14:30 +0000 (14:14 +0100)
A handle obtained with spoolss_ReplyOpenPrinter will be closed with
spoolss_ReplyClosePrinter when we call spoolss_ClosePrinter on the remote side.

Guenther

source4/torture/rpc/spoolss_notify.c

index 3d37781cb54f7b2da69342667f6293fd43cd3dd5..c6ff706374c73a766e7405a18730404f6fe3134c 100644 (file)
@@ -95,6 +95,22 @@ static WERROR _spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call,
        return WERR_OK;
 }
 
+static WERROR _spoolss_ReplyClosePrinter(struct dcesrv_call_state *dce_call,
+                                        TALLOC_CTX *mem_ctx,
+                                        struct spoolss_ReplyClosePrinter *r)
+{
+       DEBUG(1,("_spoolss_ReplyClosePrinter\n"));
+
+       NDR_PRINT_IN_DEBUG(spoolss_ReplyClosePrinter, r);
+
+       ZERO_STRUCTP(r->out.handle);
+       r->out.result = WERR_OK;
+
+       NDR_PRINT_OUT_DEBUG(spoolss_ReplyClosePrinter, r);
+
+       return WERR_OK;
+}
+
 static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
 {
        uint16_t opnum = dce_call->pkt.u.request.opnum;
@@ -112,6 +128,11 @@ static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_
                r2->out.result = _spoolss_ReplyOpenPrinter(dce_call, mem_ctx, r2);
                break;
        }
+       case 60: {
+               struct spoolss_ReplyClosePrinter *r2 = (struct spoolss_ReplyClosePrinter *)r;
+               r2->out.result = _spoolss_ReplyClosePrinter(dce_call, mem_ctx, r2);
+               break;
+       }
 
        default:
                dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
@@ -210,6 +231,7 @@ static bool test_RFFPCNEx(struct torture_context *tctx,
        struct dcesrv_endpoint *e;
        struct spoolss_NotifyOption t1;
        struct spoolss_ClosePrinter cp;
+       struct received_packet *rp;
 
        struct policy_handle handle;
        const char *address;
@@ -313,9 +335,21 @@ static bool test_RFFPCNEx(struct torture_context *tctx,
        status = dcerpc_spoolss_ClosePrinter(p, tctx, &cp);
        torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed");
 
-       /* We should've had an incoming packet 58 (ReplyOpenPrinter) */
+       /* We should've had an incoming packet 58 (ReplyOpenPrinter) or 60
+        * (ReplyClosePrinter) */
+
        torture_assert(tctx, received_packets != NULL, "no packets received");
-       torture_assert_int_equal(tctx, received_packets->opnum, 58, "invalid opnum");
+
+       for (rp = received_packets; rp; rp = rp->next) {
+               switch (rp->opnum) {
+               case 58:
+               case 60:
+                       continue;
+               default:
+                       torture_fail(tctx,
+                               talloc_asprintf(tctx, "unexpected packet opnum %d received", rp->opnum));
+               }
+       }
 
        /* Shut down DCE/RPC server */
        talloc_free(dce_ctx);