summaryrefslogtreecommitdiff
path: root/source4/torture/rpc
diff options
context:
space:
mode:
authorJustin Stephenson <jstephen@redhat.com>2018-10-15 17:02:03 -0400
committerBjoern Jacke <bjacke@samba.org>2019-01-28 15:44:19 +0100
commit669b135b49db0bb7e89dfe44073ae9dd70500f97 (patch)
tree62afc51f6eafe9ede4d09bff31ce6e4a12b67653 /source4/torture/rpc
parent38967fd954bf143bc2496b03bd1fdbbefffc4421 (diff)
downloadsamba-669b135b49db0bb7e89dfe44073ae9dd70500f97.tar.gz
s4:torture: Uninstall driver and cleanup
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>
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r--source4/torture/rpc/iremotewinspool_driver.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/source4/torture/rpc/iremotewinspool_driver.c b/source4/torture/rpc/iremotewinspool_driver.c
index 96272b9e6fd..0045818e7ff 100644
--- a/source4/torture/rpc/iremotewinspool_driver.c
+++ b/source4/torture/rpc/iremotewinspool_driver.c
@@ -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;