r19152: A simple consistency check for enumprinters
authorVolker Lendecke <vlendec@samba.org>
Fri, 6 Oct 2006 18:50:48 +0000 (18:50 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:20:44 +0000 (14:20 -0500)
(This used to be commit 593b17c8e5678949d8b41d241f522ffb20c6640f)

source4/torture/rpc/samba3rpc.c

index 1e859e1ff84fcf2a5c8f27b2bca45d9a4f8acd64..8bfbad22e538314bb2150fe12494f9a0e51274a7 100644 (file)
@@ -2230,7 +2230,7 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree,
 }
 
 static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
-                        int level)
+                        int level, int *num_printers)
 {
        struct spoolss_EnumPrinters r;
        NTSTATUS status;
@@ -2273,6 +2273,8 @@ static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe,
                return False;
        }
 
+       *num_printers = r.out.count;
+
        return True;
 }
 
@@ -2506,10 +2508,20 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture)
                }
        }
 
-       if (!enumprinters(mem_ctx, p, 1)) {
-               d_printf("(%s) enumprinters failed\n", __location__);
-               talloc_free(mem_ctx);
-               return False;
+       {
+               int num_enumerated;
+               if (!enumprinters(mem_ctx, p, 1, &num_enumerated)) {
+                       d_printf("(%s) enumprinters failed\n", __location__);
+                       talloc_free(mem_ctx);
+                       return False;
+               }
+               if (num_printers != num_enumerated) {
+                       d_printf("(%s) netshareenum gave %d printers, "
+                                "enumprinters gave %d\n", __location__,
+                                num_printers, num_enumerated);
+                       talloc_free(mem_ctx);
+                       return False;
+               }
        }
 
        talloc_free(mem_ctx);