[SCM] Samba Shared Repository - branch master updated
Günther Deschner
gd at samba.org
Thu Apr 22 18:18:48 MDT 2010
The branch, master has been updated
via f6bdfd9... s4-smbtorture: test both 32bit and 64bit driver uploads in RPC-SPOOLSS-DRIVER.
via 74592f4... s4-smbtorture: allow to upload and later remove printer driver files in RPC-SPOOLSS-DRIVER.
from 29775e3... s4-smbtorture: add RPC-SPOOLSS-DRIVER test.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit f6bdfd94239baede6b485ca45ee8365f33fd3008
Author: Günther Deschner <gd at samba.org>
Date: Fri Apr 23 01:58:02 2010 +0200
s4-smbtorture: test both 32bit and 64bit driver uploads in RPC-SPOOLSS-DRIVER.
Guenther
commit 74592f47f5f4d7646527d5788eadf2c6ebc7e950
Author: Günther Deschner <gd at samba.org>
Date: Thu Apr 22 18:47:27 2010 +0200
s4-smbtorture: allow to upload and later remove printer driver files in RPC-SPOOLSS-DRIVER.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source4/torture/rpc/spoolss.c | 338 +++++++++++++++++++++++++++++++++++------
1 files changed, 289 insertions(+), 49 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 72bee6f..c046f18 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -32,6 +32,11 @@
#include "torture/rpc/torture_rpc.h"
#include "param/param.h"
#include "lib/registry/registry.h"
+#include "libcli/libcli.h"
+#include "libcli/raw/raw_proto.h"
+#include "libcli/resolve/resolve.h"
+#include "lib/cmdline/popt_common.h"
+#include "system/filesys.h"
#define TORTURE_WELLKNOWN_PRINTER "torture_wkn_printer"
#define TORTURE_PRINTER "torture_printer"
@@ -82,6 +87,7 @@ struct torture_driver_context {
const char *environment;
} remote;
struct spoolss_AddDriverInfo8 info8;
+ bool ex;
};
#define COMPARE_STRING(tctx, c,r,e) \
@@ -7053,67 +7059,225 @@ static bool fillup_printserver_info(struct torture_context *tctx,
"failed to close printserver");
torture_assert(tctx,
- test_GetPrinterDriverDirectory_getdir(tctx, b, server_name_slash, d->remote.environment, &d->remote.driver_directory),
+ test_GetPrinterDriverDirectory_getdir(tctx, b, server_name_slash,
+ d->local.environment ? d->local.environment : d->remote.environment,
+ &d->remote.driver_directory),
"failed to get driver directory");
return true;
}
-static bool test_add_driver(struct torture_context *tctx,
- struct dcerpc_pipe *p,
- void *private_data)
+static const char *driver_directory_dir(const char *driver_directory)
{
- struct torture_driver_context *d =
- (struct torture_driver_context *)talloc_get_type_abort(private_data, struct torture_driver_context);
- bool ret = true;
- struct dcerpc_binding_handle *b = p->binding_handle;
- const char *server_name_slash = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
- uint32_t levels[] = { 1, 2, 3, 4, 6, 8 };
- int i;
- struct spoolss_AddDriverInfo8 info8;
+ char *p;
+
+ p = strrchr(driver_directory, '\\');
+ if (p) {
+ return p+1;
+ }
+
+ return NULL;
+}
+
+static const char *driver_directory_share(struct torture_context *tctx,
+ const char *driver_directory)
+{
+ const char *p;
+ char *tok;
+
+ if (driver_directory[0] == '\\' && driver_directory[1] == '\\') {
+ driver_directory += 2;
+ }
+
+ p = talloc_strdup(tctx, driver_directory);
torture_assert(tctx,
- fillup_printserver_info(tctx, p, d),
- "failed to fillup printserver info");
+ next_token_talloc(tctx, &p, &tok, "\\"),
+ "cannot explode uri");
+ torture_assert(tctx,
+ next_token_talloc(tctx, &p, &tok, "\\"),
+ "cannot explode uri");
- info8.version = d->info8.version;
- info8.driver_name = TORTURE_DRIVER;
- info8.architecture = d->remote.environment;
- info8.driver_path = d->info8.driver_path;
- info8.data_file = d->info8.data_file;
- info8.config_file = d->info8.config_file;
+ return tok;
+}
- for (i=0; i < ARRAY_SIZE(levels); i++) {
+static bool upload_printer_driver_file(struct torture_context *tctx,
+ struct smbcli_state *cli,
+ struct torture_driver_context *d,
+ const char *file_name)
+{
+ XFILE *f;
+ int fnum;
+ uint8_t *buf;
+ int maxwrite = 64512;
+ off_t nread = 0;
+ size_t start = 0;
+ const char *remote_dir = driver_directory_dir(d->remote.driver_directory);
+ const char *local_name = talloc_asprintf(tctx, "%s/%s", d->local.driver_directory, file_name);
+ const char *remote_name = talloc_asprintf(tctx, "%s\\%s", remote_dir, file_name);
- torture_comment(tctx,
- "Testing PrinterDriver '%s' add & delete level %d\n",
- info8.driver_name, levels[i]);
+ torture_comment(tctx, "Uploading %s to %s\n", local_name, remote_name);
- ret &= test_PrinterDriver_args(tctx, b, server_name_slash, levels[i], &info8, 0, 0, 0, false);
+ fnum = smbcli_open(cli->tree, remote_name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
+ if (fnum == -1) {
+ torture_fail(tctx, talloc_asprintf(tctx, "failed to open remote file: %s\n", remote_name));
}
- info8.driver_path = talloc_asprintf(tctx, "%s\\%s", d->remote.driver_directory, d->info8.driver_path);
- info8.data_file = talloc_asprintf(tctx, "%s\\%s", d->remote.driver_directory, d->info8.data_file);
- info8.config_file = talloc_asprintf(tctx, "%s\\%s", d->remote.driver_directory, d->info8.config_file);
+ f = x_fopen(local_name, O_RDONLY, 0);
+ if (f == NULL) {
+ torture_fail(tctx, talloc_asprintf(tctx, "failed to open local file: %s\n", local_name));
+ }
- for (i=0; i < ARRAY_SIZE(levels); i++) {
+ buf = talloc_array(tctx, uint8_t, maxwrite);
+ if (!buf) {
+ return false;
+ }
- torture_comment(tctx,
- "Testing PrinterDriver '%s' add & delete level %d (full unc paths)\n",
- info8.driver_name, levels[i]);
+ while (!x_feof(f)) {
+ int n = maxwrite;
+ int ret;
+
+ if ((n = x_fread(buf, 1, n, f)) < 1) {
+ if((n == 0) && x_feof(f))
+ break; /* Empty local file. */
+
+ torture_warning(tctx,
+ "failed to read file: %s\n", strerror(errno));
+ break;
+ }
+
+ ret = smbcli_write(cli->tree, fnum, 0, buf, nread + start, n);
+
+ if (n != ret) {
+ torture_warning(tctx,
+ "failed to write file: %s\n", smbcli_errstr(cli->tree));
+ break;
+ }
- ret &= test_PrinterDriver_args(tctx, b, server_name_slash, levels[i], &info8, 0, 0, 0, false);
+ nread += n;
}
- return ret;
+ x_fclose(f);
+
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_close(cli->tree, fnum),
+ "failed to close file");
+
+ return true;
}
-static bool test_add_driver_ex(struct torture_context *tctx,
- struct dcerpc_pipe *p,
- void *private_data)
+static bool connect_printer_driver_share(struct torture_context *tctx,
+ const char *server_name,
+ const char *share_name,
+ struct smbcli_state **cli)
+{
+ struct smbcli_options smb_options;
+ struct smbcli_session_options smb_session_options;
+
+ torture_comment(tctx, "Connecting printer driver share\n");
+
+ lp_smbcli_options(tctx->lp_ctx, &smb_options);
+ lp_smbcli_session_options(tctx->lp_ctx, &smb_session_options);
+
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_full_connection(tctx, cli, server_name,
+ lp_smb_ports(tctx->lp_ctx),
+ share_name, NULL,
+ lp_socket_options(tctx->lp_ctx),
+ cmdline_credentials,
+ lp_resolve_context(tctx->lp_ctx),
+ tctx->ev,
+ &smb_options,
+ &smb_session_options,
+ lp_iconv_convenience(tctx->lp_ctx),
+ lp_gensec_settings(tctx, tctx->lp_ctx)),
+ "failed to open driver share");
+
+ return true;
+}
+
+static bool upload_printer_driver(struct torture_context *tctx,
+ const char *server_name,
+ struct torture_driver_context *d)
+{
+ struct smbcli_state *cli;
+ const char *share_name = driver_directory_share(tctx, d->remote.driver_directory);
+
+ torture_assert(tctx,
+ connect_printer_driver_share(tctx, server_name, share_name, &cli),
+ "failed to connect to driver share");
+
+ torture_comment(tctx, "Uploading printer driver files to \\\\%s\\%s\n",
+ server_name, share_name);
+
+ torture_assert(tctx,
+ upload_printer_driver_file(tctx, cli, d, d->info8.driver_path),
+ "failed to upload driver_path");
+ torture_assert(tctx,
+ upload_printer_driver_file(tctx, cli, d, d->info8.data_file),
+ "failed to upload data_file");
+ torture_assert(tctx,
+ upload_printer_driver_file(tctx, cli, d, d->info8.config_file),
+ "failed to upload config_file");
+
+ talloc_free(cli);
+
+ return true;
+}
+
+static bool remove_printer_driver_file(struct torture_context *tctx,
+ struct smbcli_state *cli,
+ struct torture_driver_context *d,
+ const char *file_name)
+{
+ const char *remote_name;
+ const char *remote_dir = driver_directory_dir(d->remote.driver_directory);
+
+ remote_name = talloc_asprintf(tctx, "%s\\%s", remote_dir, file_name);
+
+ torture_comment(tctx, "Removing %s\n", remote_name);
+
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_unlink(cli->tree, remote_name),
+ "failed to unlink");
+
+ return true;
+}
+
+static bool remove_printer_driver(struct torture_context *tctx,
+ const char *server_name,
+ struct torture_driver_context *d)
+{
+ struct smbcli_state *cli;
+ const char *share_name = driver_directory_share(tctx, d->remote.driver_directory);
+
+ torture_assert(tctx,
+ connect_printer_driver_share(tctx, server_name, share_name, &cli),
+ "failed to connect to driver share");
+
+ torture_comment(tctx, "Removing printer driver files from \\\\%s\\%s\n",
+ server_name, share_name);
+
+ torture_assert(tctx,
+ remove_printer_driver_file(tctx, cli, d, d->info8.driver_path),
+ "failed to remove driver_path");
+ torture_assert(tctx,
+ remove_printer_driver_file(tctx, cli, d, d->info8.data_file),
+ "failed to remove data_file");
+ torture_assert(tctx,
+ remove_printer_driver_file(tctx, cli, d, d->info8.config_file),
+ "failed to remove config_file");
+
+ talloc_free(cli);
+
+ return true;
+
+}
+
+static bool test_add_driver_arg(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct torture_driver_context *d)
{
- struct torture_driver_context *d =
- (struct torture_driver_context *)talloc_get_type_abort(private_data, struct torture_driver_context);
bool ret = true;
struct dcerpc_binding_handle *b = p->binding_handle;
const char *server_name_slash = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
@@ -7123,13 +7287,20 @@ static bool test_add_driver_ex(struct torture_context *tctx,
uint32_t add_flags = APD_COPY_NEW_FILES;
uint32_t delete_flags = 0;
+ torture_comment(tctx, "Testing PrinterDriver%s '%s' for environment '%s'\n",
+ d->ex ? "Ex" : "", d->info8.driver_name, d->local.environment);
+
torture_assert(tctx,
fillup_printserver_info(tctx, p, d),
"failed to fillup printserver info");
+ torture_assert(tctx,
+ upload_printer_driver(tctx, dcerpc_server_name(p), d),
+ "failed to upload printer driver");
+
info8.version = d->info8.version;
- info8.driver_name = TORTURE_DRIVER_EX;
- info8.architecture = d->remote.environment;
+ info8.driver_name = d->info8.driver_name;
+ info8.architecture = d->local.environment;
info8.driver_path = d->info8.driver_path;
info8.data_file = d->info8.data_file;
info8.config_file = d->info8.config_file;
@@ -7137,10 +7308,10 @@ static bool test_add_driver_ex(struct torture_context *tctx,
for (i=0; i < ARRAY_SIZE(levels); i++) {
torture_comment(tctx,
- "Testing PrinterDriverEx '%s' add & delete level %d\n",
- info8.driver_name, levels[i]);
+ "Testing PrinterDriver%s '%s' add & delete level %d\n",
+ d->ex ? "Ex" : "", info8.driver_name, levels[i]);
- ret &= test_PrinterDriver_args(tctx, b, server_name_slash, levels[i], &info8, add_flags, delete_flags, d->info8.version, true);
+ ret &= test_PrinterDriver_args(tctx, b, server_name_slash, levels[i], &info8, add_flags, delete_flags, d->info8.version, d->ex);
}
info8.driver_path = talloc_asprintf(tctx, "%s\\%s", d->remote.driver_directory, d->info8.driver_path);
@@ -7150,15 +7321,81 @@ static bool test_add_driver_ex(struct torture_context *tctx,
for (i=0; i < ARRAY_SIZE(levels); i++) {
torture_comment(tctx,
- "Testing PrinterDriverEx '%s' add & delete level %d (full unc paths)\n",
- info8.driver_name, levels[i]);
+ "Testing PrinterDriver%s '%s' add & delete level %d (full unc paths)\n",
+ d->ex ? "Ex" : "", info8.driver_name, levels[i]);
- ret &= test_PrinterDriver_args(tctx, b, server_name_slash, levels[i], &info8, add_flags, delete_flags, d->info8.version, true);
+ ret &= test_PrinterDriver_args(tctx, b, server_name_slash, levels[i], &info8, add_flags, delete_flags, d->info8.version, d->ex);
}
+ torture_assert(tctx,
+ remove_printer_driver(tctx, dcerpc_server_name(p), d),
+ "failed to remove printer driver");
+
+ torture_comment(tctx, "\n");
+
return ret;
}
+static bool test_add_driver_ex_64(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ void *private_data)
+{
+ struct torture_driver_context *d =
+ (struct torture_driver_context *)talloc_get_type_abort(private_data, struct torture_driver_context);
+
+ d->local.environment = talloc_strdup(d, "Windows x64");
+ d->local.driver_directory = talloc_strdup(d, "/usr/share/cups/drivers/x64");
+ d->info8.driver_name = TORTURE_DRIVER_EX;
+ d->ex = true;
+
+ return test_add_driver_arg(tctx, p, d);
+}
+
+static bool test_add_driver_ex_32(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ void *private_data)
+{
+ struct torture_driver_context *d =
+ (struct torture_driver_context *)talloc_get_type_abort(private_data, struct torture_driver_context);
+
+ d->local.environment = talloc_strdup(d, "Windows NT x86");
+ d->local.driver_directory = talloc_strdup(d, "/usr/share/cups/drivers/i386");
+ d->info8.driver_name = TORTURE_DRIVER_EX;
+ d->ex = true;
+
+ return test_add_driver_arg(tctx, p, d);
+}
+
+static bool test_add_driver_64(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ void *private_data)
+{
+ struct torture_driver_context *d =
+ (struct torture_driver_context *)talloc_get_type_abort(private_data, struct torture_driver_context);
+
+ d->local.environment = talloc_strdup(d, "Windows x64");
+ d->local.driver_directory = talloc_strdup(d, "/usr/share/cups/drivers/x64");
+ d->info8.driver_name = TORTURE_DRIVER;
+ d->ex = false;
+
+ return test_add_driver_arg(tctx, p, d);
+}
+
+static bool test_add_driver_32(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ void *private_data)
+{
+ struct torture_driver_context *d =
+ (struct torture_driver_context *)talloc_get_type_abort(private_data, struct torture_driver_context);
+
+ d->local.environment = talloc_strdup(d, "Windows NT x86");
+ d->local.driver_directory = talloc_strdup(d, "/usr/share/cups/drivers/i386");
+ d->info8.driver_name = TORTURE_DRIVER;
+ d->ex = false;
+
+ return test_add_driver_arg(tctx, p, d);
+}
+
struct torture_suite *torture_rpc_spoolss_driver(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-DRIVER");
@@ -7176,8 +7413,11 @@ struct torture_suite *torture_rpc_spoolss_driver(TALLOC_CTX *mem_ctx)
t->info8.data_file = talloc_strdup(t, "cups6.ppd");
t->info8.config_file = talloc_strdup(t, "cupsui6.dll");
- torture_rpc_tcase_add_test_ex(tcase, "add_driver", test_add_driver, t);
- torture_rpc_tcase_add_test_ex(tcase, "add_driver_ex", test_add_driver_ex, t);
+ torture_rpc_tcase_add_test_ex(tcase, "add_driver_64", test_add_driver_64, t);
+ torture_rpc_tcase_add_test_ex(tcase, "add_driver_ex_64", test_add_driver_ex_64, t);
+
+ torture_rpc_tcase_add_test_ex(tcase, "add_driver_32", test_add_driver_32, t);
+ torture_rpc_tcase_add_test_ex(tcase, "add_driver_ex_32", test_add_driver_ex_32, t);
return suite;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list