]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:torture: Uninstall driver and cleanup
authorJustin Stephenson <jstephen@redhat.com>
Mon, 15 Oct 2018 21:02:03 +0000 (17:02 -0400)
committerBjoern Jacke <bjacke@samba.org>
Mon, 28 Jan 2019 14:44:19 +0000 (15:44 +0100)
Uninstall and remove the print driver packages to cleanup
after the install. Cleanup and remove smb directory created
inside print$.

Signed-off-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Bjoern Jacke <bjacke@samba.org>
source4/torture/rpc/iremotewinspool_driver.c

index 96272b9e6fd86d5cafd4895a08b75ec494d5b6a2..0045818e7ff67f3fca1896e729ee3a7491a4270a 100644 (file)
@@ -275,6 +275,61 @@ done:
        return ok;
 }
 
+/* Uninstall the previously installed print driver */
+static bool test_uninstall_printer_driver(struct torture_context *tctx,
+                                         struct test_iremotewinspool_context *ctx)
+{
+       struct dcerpc_pipe *p = ctx->iremotewinspool_pipe;
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct winspool_AsyncDeletePrinterDriverEx r;
+       bool ok = true;
+       NTSTATUS status;
+
+       r.in.pName = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+
+       r.in.pDriverName = talloc_strdup(tctx, ctx->dinfo->driver_name);
+       torture_assert_not_null_goto(tctx, r.in.pDriverName, ok, done, "Cannot allocate memory");
+
+       r.in.pEnvironment = SPOOLSS_ARCHITECTURE_x64;
+
+       r.in.dwDeleteFlag = 0;
+       r.in.dwVersionNum = 0;
+
+       status = dcerpc_winspool_AsyncDeletePrinterDriverEx_r(b, tctx, &r);
+       torture_assert_ntstatus_ok_goto(tctx, status, ok, done, "AsyncDeletePrinterDriverEx failed");
+
+       torture_assert_werr_ok(tctx, r.out.result, "AsyncDeletePrinterDriverEx failed");
+done:
+
+       return ok;
+}
+
+/* Remove the leftover print driver package files from the driver store */
+static bool test_remove_driver_package(struct torture_context *tctx,
+                                      struct test_iremotewinspool_context *ctx)
+{
+       struct dcerpc_pipe *p = ctx->iremotewinspool_pipe;
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct winspool_AsyncDeletePrinterDriverPackage r;
+       bool ok = true;
+       NTSTATUS status;
+
+       r.in.pszServer = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
+       torture_assert_not_null_goto(tctx, r.in.pszServer, ok, done, "Cannot allocate memory");
+
+       r.in.pszInfPath = ctx->dinfo->uploaded_inf_path;
+
+       r.in.pszEnvironment = SPOOLSS_ARCHITECTURE_x64;
+
+       status = dcerpc_winspool_AsyncDeletePrinterDriverPackage_r(b, tctx, &r);
+       torture_assert_ntstatus_ok_goto(tctx, status, ok, done, "AsyncDeletePrinterPackage failed");
+
+       torture_assert_hresult_ok(tctx, r.out.result, "AsyncDeletePrinterDriverPackage failed");
+done:
+
+       return ok;
+}
+
 static bool test_winreg_iremotewinspool_openhklm(struct torture_context *tctx,
                                                 struct dcerpc_binding_handle *winreg_bh,
                                                 struct policy_handle *_hklm_handle)
@@ -575,6 +630,9 @@ static bool torture_rpc_iremotewinspool_drv_teardown_common(struct torture_conte
        smbcli_deltree(t->dinfo->cli->tree, t->dinfo->print_upload_guid_dir);
        smb_raw_exit(t->dinfo->cli->session);
 
+       test_uninstall_printer_driver(tctx, t);
+       test_remove_driver_package(tctx, t);
+
        test_AsyncClosePrinter_byhandle(tctx, t, t->iremotewinspool_pipe, &t->server_handle);
 
        return true;