diff options
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/libnet/libnet_BecomeDC.c | 112 | ||||
-rw-r--r-- | source4/torture/local/torture.c | 12 | ||||
-rw-r--r-- | source4/torture/raw/oplock.c | 321 | ||||
-rw-r--r-- | source4/torture/util.h | 10 | ||||
-rw-r--r-- | source4/torture/util_provision.c | 305 | ||||
-rw-r--r-- | source4/torture/util_smb.c | 6 |
6 files changed, 379 insertions, 387 deletions
diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c index 9566f5ee29..3f8edd40e8 100644 --- a/source4/torture/libnet/libnet_BecomeDC.c +++ b/source4/torture/libnet/libnet_BecomeDC.c @@ -56,16 +56,9 @@ struct test_become_dc_state { struct drsuapi_DsReplicaObjectListItemEx *last_object; } schema_part; - struct { - const char *samdb_ldb; - const char *domaindn_ldb; - const char *configdn_ldb; - const char *schemadn_ldb; - const char *secrets_ldb; - const char *templates_ldb; - const char *secrets_keytab; - const char *dns_keytab; - } path; + const char *targetdir; + + struct loadparm_context *lp_ctx; }; static NTSTATUS test_become_dc_prepare_db(void *private_data, @@ -73,6 +66,14 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data, { struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state); struct provision_settings settings; + NTSTATUS status; + bool ok; + struct loadparm_context *lp_ctx = loadparm_init(s); + char *smbconf; + + if (!lp_ctx) { + return NT_STATUS_NO_MEMORY; + } settings.dns_name = p->dest_dsa->dns_name; settings.site_name = p->dest_dsa->site_name; @@ -80,21 +81,46 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data, settings.domain_dn_str = p->domain->dn_str; settings.config_dn_str = p->forest->config_dn_str; settings.schema_dn_str = p->forest->schema_dn_str; - settings.invocation_id = &p->dest_dsa->invocation_id; settings.netbios_name = p->dest_dsa->netbios_name; settings.realm = torture_join_dom_dns_name(s->tj); settings.domain = torture_join_dom_netbios_name(s->tj); - settings.ntds_guid = &p->dest_dsa->ntds_guid; - settings.ntds_dn_str = p->dest_dsa->ntds_dn_str; settings.machine_password = cli_credentials_get_password(s->machine_account); - settings.samdb_ldb = s->path.samdb_ldb; - settings.secrets_ldb = s->path.secrets_ldb; - settings.secrets_keytab = s->path.secrets_keytab; - settings.schemadn_ldb = s->path.schemadn_ldb; - settings.configdn_ldb = s->path.configdn_ldb; - settings.domaindn_ldb = s->path.domaindn_ldb; - - return provision_bare(s, s->tctx->lp_ctx, &settings); + settings.targetdir = s->targetdir; + + status = provision_bare(s, s->lp_ctx, &settings); + + smbconf = talloc_asprintf(lp_ctx, "%s/%s", s->targetdir, "/etc/smb.conf"); + + ok = lp_load(lp_ctx, smbconf); + if (!ok) { + DEBUG(0,("Failed load freshly generated smb.conf '%s'\n", smbconf)); + return NT_STATUS_INVALID_PARAMETER; + } + + s->ldb = ldb_wrap_connect(s, lp_ctx, lp_sam_url(lp_ctx), + system_session(s, lp_ctx), + NULL, 0, NULL); + if (!s->ldb) { + DEBUG(0,("Failed to open '%s'\n", lp_sam_url(lp_ctx))); + return NT_STATUS_INTERNAL_DB_ERROR; + } + + ok = samdb_set_ntds_invocation_id(s->ldb, &p->dest_dsa->invocation_id); + if (!ok) { + DEBUG(0,("Failed to set cached ntds invocationId\n")); + return NT_STATUS_FOOBAR; + } + ok = samdb_set_ntds_objectGUID(s->ldb, &p->dest_dsa->ntds_guid); + if (!ok) { + DEBUG(0,("Failed to set cached ntds objectGUID\n")); + return NT_STATUS_FOOBAR; + } + + s->lp_ctx = lp_ctx; + + return NT_STATUS_OK; + + } static NTSTATUS test_become_dc_check_options(void *private_data, @@ -140,6 +166,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s, struct ldb_val prefixMap_val; struct ldb_message_element *prefixMap_el; struct ldb_val schemaInfo_val; + char *sam_ldb_path; uint32_t i; int ret; bool ok; @@ -325,13 +352,14 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s, talloc_free(s->ldb); /* this also free's the s->schema, because dsdb_set_schema() steals it */ s->schema = NULL; - DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", s->path.samdb_ldb)); - s->ldb = ldb_wrap_connect(s, s->tctx->lp_ctx, s->path.samdb_ldb, + sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb"); + DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", sam_ldb_path)); + s->ldb = ldb_wrap_connect(s, s->tctx->lp_ctx, sam_ldb_path, system_session(s, s->tctx->lp_ctx), NULL, 0, NULL); if (!s->ldb) { DEBUG(0,("Failed to open '%s'\n", - s->path.samdb_ldb)); + sam_ldb_path)); return NT_STATUS_INTERNAL_DB_ERROR; } @@ -392,7 +420,8 @@ static NTSTATUS test_become_dc_schema_chunk(void *private_data, } if (!s->schema) { - s->self_made_schema = talloc_zero(s, struct dsdb_schema); + s->self_made_schema = dsdb_new_schema(s, lp_iconv_convenience(s->lp_ctx)); + NT_STATUS_HAVE_NO_MEMORY(s->self_made_schema); status = dsdb_load_oid_mappings_drsuapi(s->self_made_schema, mapping_ctr); @@ -564,33 +593,24 @@ bool torture_net_become_dc(struct torture_context *torture) struct ldb_message *msg; int ldb_ret; uint32_t i; + char *sam_ldb_path; + + char *location = NULL; + torture_assert_ntstatus_ok(torture, torture_temp_dir(torture, "libnet_BecomeDC", &location), + "torture_temp_dir should return NT_STATUS_OK" ); s = talloc_zero(torture, struct test_become_dc_state); if (!s) return false; s->tctx = torture; + s->lp_ctx = torture->lp_ctx; s->netbios_name = lp_parm_string(torture->lp_ctx, NULL, "become dc", "smbtorture dc"); if (!s->netbios_name || !s->netbios_name[0]) { s->netbios_name = "smbtorturedc"; } - s->path.samdb_ldb = talloc_asprintf(s, "%s_samdb.ldb", s->netbios_name); - if (!s->path.samdb_ldb) return false; - s->path.domaindn_ldb = talloc_asprintf(s, "%s_domain.ldb", s->netbios_name); - if (!s->path.domaindn_ldb) return false; - s->path.configdn_ldb = talloc_asprintf(s, "%s_config.ldb", s->netbios_name); - if (!s->path.configdn_ldb) return false; - s->path.schemadn_ldb = talloc_asprintf(s, "%s_schema.ldb", s->netbios_name); - if (!s->path.schemadn_ldb) return false; - s->path.secrets_ldb = talloc_asprintf(s, "%s_secrets.ldb", s->netbios_name); - if (!s->path.secrets_ldb) return false; - s->path.templates_ldb = talloc_asprintf(s, "%s_templates.ldb", s->netbios_name); - if (!s->path.templates_ldb) return false; - s->path.secrets_keytab = talloc_asprintf(s, "%s_secrets.keytab", s->netbios_name); - if (!s->path.secrets_keytab) return false; - s->path.dns_keytab = talloc_asprintf(s, "%s_dns.keytab", s->netbios_name); - if (!s->path.dns_keytab) return false; + s->targetdir = location; /* Join domain as a member server. */ s->tj = torture_join_domain(torture, s->netbios_name, @@ -664,13 +684,14 @@ bool torture_net_become_dc(struct torture_context *torture) talloc_free(s->ldb); /* this also free's the s->schema, because dsdb_set_schema() steals it */ s->schema = NULL; - DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", s->path.samdb_ldb)); - s->ldb = ldb_wrap_connect(s, torture->lp_ctx, s->path.samdb_ldb, - system_session(s, torture->lp_ctx), + sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb"); + DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", sam_ldb_path)); + s->ldb = ldb_wrap_connect(s, s->lp_ctx, sam_ldb_path, + system_session(s, s->lp_ctx), NULL, 0, NULL); if (!s->ldb) { DEBUG(0,("Failed to open '%s'\n", - s->path.samdb_ldb)); + sam_ldb_path)); ret = false; goto cleanup; } @@ -682,6 +703,7 @@ bool torture_net_become_dc(struct torture_context *torture) goto cleanup; } + /* Make sure we get this from the command line */ if (lp_parm_bool(torture->lp_ctx, NULL, "become dc", "do not unjoin", false)) { talloc_free(s); return ret; diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c index 3273015347..bb6e21ed4f 100644 --- a/source4/torture/local/torture.c +++ b/source4/torture/local/torture.c @@ -43,6 +43,9 @@ static bool test_provision(struct torture_context *tctx) { NTSTATUS status; struct provision_settings settings; + char *location = NULL; + torture_assert_ntstatus_ok(tctx, torture_temp_dir(tctx, "torture_provision", &location), + "torture_temp_dir should return NT_STATUS_OK" ); settings.dns_name = "example.com"; settings.site_name = "SOME-SITE-NAME"; @@ -57,14 +60,7 @@ static bool test_provision(struct torture_context *tctx) settings.ntds_guid = NULL; settings.ntds_dn_str = NULL; settings.machine_password = "geheim"; - settings.samdb_ldb = NULL; - settings.secrets_ldb = NULL; - settings.secrets_keytab = NULL; - settings.schemadn_ldb = NULL; - settings.configdn_ldb = NULL; - settings.domaindn_ldb = NULL; - settings.templates_ldb = NULL; - settings.dns_keytab = NULL; + settings.targetdir = location; status = provision_bare(tctx, tctx->lp_ctx, &settings); diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 8a7489c84e..1926b12128 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -24,6 +24,9 @@ #include "libcli/libcli.h" #include "torture/util.h" #include "lib/events/events.h" +#include "param/param.h" +#include "lib/cmdline/popt_common.h" +#include "libcli/resolve/resolve.h" #define CHECK_VAL(v, correct) do { \ if ((v) != (correct)) { \ @@ -68,16 +71,30 @@ static struct { /* a handler function for oplock break requests. Ack it as a break to level II if possible */ -static bool oplock_handler_ack_to_levelII(struct smbcli_transport *transport, - uint16_t tid, uint16_t fnum, - uint8_t level, void *private) +static bool oplock_handler_ack_to_given(struct smbcli_transport *transport, + uint16_t tid, uint16_t fnum, + uint8_t level, void *private) { struct smbcli_tree *tree = (struct smbcli_tree *)private; + const char *name; + break_info.fnum = fnum; break_info.level = level; break_info.count++; - printf("Acking to level II in oplock handler\n"); + switch (level) { + case OPLOCK_BREAK_TO_LEVEL_II: + name = "level II"; + break; + case OPLOCK_BREAK_TO_NONE: + name = "none"; + break; + default: + name = "unknown"; + break_info.failures++; + } + printf("Acking to %s [0x%02X] in oplock handler\n", + name, level); return smbcli_oplock_ack(tree, fnum, level); } @@ -153,6 +170,32 @@ static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t ti return true; } +static bool open_connection_no_level2_oplocks(struct torture_context *tctx, + struct smbcli_state **c) +{ + NTSTATUS status; + + struct smbcli_options options; + + lp_smbcli_options(tctx->lp_ctx, &options); + + options.use_level2_oplocks = false; + + status = smbcli_full_connection(tctx, c, + torture_setting_string(tctx, "host", NULL), + lp_smb_ports(tctx->lp_ctx), + torture_setting_string(tctx, "share", NULL), + NULL, cmdline_credentials, + lp_resolve_context(tctx->lp_ctx), + tctx->ev, &options); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to open connection - %s\n", nt_errstr(status)); + return false; + } + + return true; +} + static bool test_raw_oplock_exclusive1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { const char *fname = BASEDIR "\\test_exclusive1.dat"; @@ -169,7 +212,7 @@ static bool test_raw_oplock_exclusive1(struct torture_context *tctx, struct smbc /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -234,7 +277,7 @@ static bool test_raw_oplock_exclusive2(struct torture_context *tctx, struct smbc /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -329,7 +372,7 @@ static bool test_raw_oplock_exclusive3(struct torture_context *tctx, struct smbc /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -398,7 +441,7 @@ static bool test_raw_oplock_exclusive4(struct torture_context *tctx, struct smbc /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -417,7 +460,7 @@ static bool test_raw_oplock_exclusive4(struct torture_context *tctx, struct smbc torture_comment(tctx, "open with exclusive oplock\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; status = smb_raw_open(cli1->tree, tctx, &io); @@ -462,8 +505,8 @@ static bool test_raw_oplock_exclusive5(struct torture_context *tctx, struct smbc /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); - smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -482,7 +525,7 @@ static bool test_raw_oplock_exclusive5(struct torture_context *tctx, struct smbc torture_comment(tctx, "open with exclusive oplock\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; @@ -537,7 +580,7 @@ static bool test_raw_oplock_exclusive6(struct torture_context *tctx, struct smbc smbcli_unlink(cli1->tree, fname1); smbcli_unlink(cli1->tree, fname2); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -610,7 +653,7 @@ static bool test_raw_oplock_batch1(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -694,7 +737,7 @@ static bool test_raw_oplock_batch2(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -772,7 +815,7 @@ static bool test_raw_oplock_batch3(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -836,7 +879,7 @@ static bool test_raw_oplock_batch4(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -855,7 +898,7 @@ static bool test_raw_oplock_batch4(struct torture_context *tctx, struct smbcli_s torture_comment(tctx, "a self read should not cause a break\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -899,7 +942,7 @@ static bool test_raw_oplock_batch5(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -918,7 +961,7 @@ static bool test_raw_oplock_batch5(struct torture_context *tctx, struct smbcli_s torture_comment(tctx, "a 2nd open should give a break\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -964,7 +1007,7 @@ static bool test_raw_oplock_batch6(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -983,8 +1026,8 @@ static bool test_raw_oplock_batch6(struct torture_context *tctx, struct smbcli_s torture_comment(tctx, "a 2nd open should give a break to level II if the first open allowed shared read\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); - smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli2->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_WRITE; io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; @@ -1044,7 +1087,7 @@ static bool test_raw_oplock_batch7(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1114,7 +1157,7 @@ static bool test_raw_oplock_batch8(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1133,7 +1176,7 @@ static bool test_raw_oplock_batch8(struct torture_context *tctx, struct smbcli_s torture_comment(tctx, "open with batch oplock\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -1183,7 +1226,7 @@ static bool test_raw_oplock_batch9(struct torture_context *tctx, struct smbcli_s /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1215,7 +1258,7 @@ static bool test_raw_oplock_batch9(struct torture_context *tctx, struct smbcli_s torture_comment(tctx, "Subsequent normal open should break oplock on attribute only open to level II\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -1234,8 +1277,8 @@ static bool test_raw_oplock_batch9(struct torture_context *tctx, struct smbcli_s torture_comment(tctx, "third oplocked open should grant level2 without break\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); - smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli2->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; @@ -1288,7 +1331,7 @@ static bool test_raw_oplock_batch10(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1319,7 +1362,7 @@ static bool test_raw_oplock_batch10(struct torture_context *tctx, struct smbcli_ CHECK_VAL(break_info.failures, 0); CHECK_VAL(io.ntcreatex.out.oplock_level, 0); - smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli2->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -1397,7 +1440,7 @@ static bool test_raw_oplock_batch11(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1418,7 +1461,7 @@ static bool test_raw_oplock_batch11(struct torture_context *tctx, struct smbcli_ torture_comment(tctx, "Test if setpathinfo set EOF breaks oplocks.\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -1472,7 +1515,7 @@ static bool test_raw_oplock_batch12(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1493,7 +1536,7 @@ static bool test_raw_oplock_batch12(struct torture_context *tctx, struct smbcli_ torture_comment(tctx, "Test if setpathinfo allocation size breaks oplocks.\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -1546,8 +1589,8 @@ static bool test_raw_oplock_batch13(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); - smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1566,7 +1609,7 @@ static bool test_raw_oplock_batch13(struct torture_context *tctx, struct smbcli_ torture_comment(tctx, "open with batch oplock\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | @@ -1624,7 +1667,7 @@ static bool test_raw_oplock_batch14(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1643,7 +1686,7 @@ static bool test_raw_oplock_batch14(struct torture_context *tctx, struct smbcli_ torture_comment(tctx, "open with batch oplock\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -1700,7 +1743,7 @@ static bool test_raw_oplock_batch15(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1721,7 +1764,7 @@ static bool test_raw_oplock_batch15(struct torture_context *tctx, struct smbcli_ torture_comment(tctx, "Test if qpathinfo all info breaks a batch oplock (should not).\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -1772,8 +1815,8 @@ static bool test_raw_oplock_batch16(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); - smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1792,7 +1835,7 @@ static bool test_raw_oplock_batch16(struct torture_context *tctx, struct smbcli_ torture_comment(tctx, "open with batch oplock\n"); ZERO_STRUCT(break_info); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | @@ -1854,7 +1897,7 @@ static bool test_raw_oplock_batch17(struct torture_context *tctx, struct smbcli_ smbcli_unlink(cli1->tree, fname1); smbcli_unlink(cli1->tree, fname2); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -1932,7 +1975,7 @@ static bool test_raw_oplock_batch18(struct torture_context *tctx, struct smbcli_ smbcli_unlink(cli1->tree, fname1); smbcli_unlink(cli1->tree, fname2); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -2016,7 +2059,7 @@ static bool test_raw_oplock_batch19(struct torture_context *tctx, struct smbcli_ smbcli_unlink(cli1->tree, fname2); smbcli_unlink(cli1->tree, fname3); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -2118,7 +2161,7 @@ static bool test_raw_oplock_batch20(struct torture_context *tctx, struct smbcli_ smbcli_unlink(cli1->tree, fname2); smbcli_unlink(cli1->tree, fname3); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -2244,7 +2287,7 @@ static bool test_raw_oplock_batch21(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -2301,13 +2344,10 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_ NTSTATUS status; bool ret = true; union smb_open io; - union smb_unlink unl; uint16_t fnum=0, fnum2=0; - char c = 0; struct timeval tv; int timeout = torture_setting_int(tctx, "oplocktimeout", 30); int te; - ssize_t wr; if (torture_setting_bool(tctx, "samba3", false)) { torture_skip(tctx, "BACHT22 disabled against samba3\n"); @@ -2320,7 +2360,7 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_ /* cleanup */ smbcli_unlink(cli1->tree, fname); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); /* base ntcreatex parms @@ -2369,7 +2409,7 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_ torture_comment(tctx, "a 2nd open shoud succeed after the oplock release without break\n"); tv = timeval_current(); - smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); status = smb_raw_open(cli1->tree, tctx, &io); CHECK_STATUS(tctx, status, NT_STATUS_OK); CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); @@ -2390,6 +2430,173 @@ done: return ret; } +static bool test_raw_oplock_batch23(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + const char *fname = BASEDIR "\\test_batch23.dat"; + NTSTATUS status; + bool ret = true; + union smb_open io; + uint16_t fnum=0, fnum2=0,fnum3=0; + struct smbcli_state *cli3 = NULL; + + if (torture_setting_bool(tctx, "samba3", false)) { + torture_skip(tctx, "BACHT23 disabled against samba3\n"); + } + + if (!torture_setup_dir(cli1, BASEDIR)) { + return false; + } + + /* cleanup */ + smbcli_unlink(cli1->tree, fname); + + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + + ret = open_connection_no_level2_oplocks(tctx, &cli3); + CHECK_VAL(ret, true); + + /* + base ntcreatex parms + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = fname; + + torture_comment(tctx, "a open and ask for a batch oplock\n"); + ZERO_STRUCT(break_info); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); + smbcli_oplock_handler(cli3->transport, oplock_handler_ack_to_given, cli3->tree); + + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_WRITE; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | + NTCREATEX_FLAGS_REQUEST_OPLOCK | + NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + status = smb_raw_open(cli1->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); + + ZERO_STRUCT(break_info); + + torture_comment(tctx, "a 2nd open without level2 oplock support should generate a break to level2\n"); + status = smb_raw_open(cli3->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum3 = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN); + + CHECK_VAL(break_info.count, 1); + CHECK_VAL(break_info.fnum, fnum); + CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); + CHECK_VAL(break_info.failures, 0); + + ZERO_STRUCT(break_info); + + torture_comment(tctx, "a 3rd open with level2 oplock support should not generate a break\n"); + status = smb_raw_open(cli2->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum2 = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); + + CHECK_VAL(break_info.count, 0); + + smbcli_close(cli1->tree, fnum); + smbcli_close(cli2->tree, fnum2); + smbcli_close(cli3->tree, fnum3); + +done: + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + smb_raw_exit(cli3->session); + smbcli_deltree(cli1->tree, BASEDIR); + return ret; +} + +static bool test_raw_oplock_batch24(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + const char *fname = BASEDIR "\\test_batch24.dat"; + NTSTATUS status; + bool ret = true; + union smb_open io; + uint16_t fnum2=0,fnum3=0; + struct smbcli_state *cli3 = NULL; + + if (!torture_setup_dir(cli1, BASEDIR)) { + return false; + } + + /* cleanup */ + smbcli_unlink(cli1->tree, fname); + + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + + ret = open_connection_no_level2_oplocks(tctx, &cli3); + CHECK_VAL(ret, true); + + /* + base ntcreatex parms + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = fname; + + torture_comment(tctx, "a open without level support and ask for a batch oplock\n"); + ZERO_STRUCT(break_info); + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); + smbcli_oplock_handler(cli3->transport, oplock_handler_ack_to_given, cli3->tree); + + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_WRITE; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | + NTCREATEX_FLAGS_REQUEST_OPLOCK | + NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + status = smb_raw_open(cli3->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum3 = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); + + ZERO_STRUCT(break_info); + + torture_comment(tctx, "a 2nd open with level2 oplock support should generate a break to none\n"); + status = smb_raw_open(cli2->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum2 = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); + + CHECK_VAL(break_info.count, 1); + CHECK_VAL(break_info.fnum, fnum3); + CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE); + CHECK_VAL(break_info.failures, 0); + + smbcli_close(cli3->tree, fnum3); + smbcli_close(cli2->tree, fnum2); + +done: + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + smb_raw_exit(cli3->session); + smbcli_deltree(cli1->tree, BASEDIR); + return ret; +} + /* basic testing of oplocks */ @@ -2425,6 +2632,8 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx) torture_suite_add_2smb_test(suite, "BATCH20", test_raw_oplock_batch20); torture_suite_add_2smb_test(suite, "BATCH21", test_raw_oplock_batch21); torture_suite_add_2smb_test(suite, "BATCH22", test_raw_oplock_batch22); + torture_suite_add_2smb_test(suite, "BATCH23", test_raw_oplock_batch23); + torture_suite_add_2smb_test(suite, "BATCH24", test_raw_oplock_batch24); return suite; } diff --git a/source4/torture/util.h b/source4/torture/util.h index c5219a5aaa..477a828120 100644 --- a/source4/torture/util.h +++ b/source4/torture/util.h @@ -29,19 +29,13 @@ struct provision_settings { const char *schema_dn_str; const struct GUID *invocation_id; const char *netbios_name; + const char *host_ip; const char *realm; const char *domain; const struct GUID *ntds_guid; const char *ntds_dn_str; const char *machine_password; - const char *samdb_ldb; - const char *secrets_ldb; - const char *secrets_keytab; - const char *schemadn_ldb; - const char *configdn_ldb; - const char *domaindn_ldb; - const char *templates_ldb; - const char *dns_keytab; + const char *targetdir; }; NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, diff --git a/source4/torture/util_provision.c b/source4/torture/util_provision.c index 2a1e9256f5..d7c8f479e6 100644 --- a/source4/torture/util_provision.c +++ b/source4/torture/util_provision.c @@ -18,206 +18,22 @@ */ #include "includes.h" -#include "dsdb/samdb/samdb.h" -#include "lib/appweb/ejs/ejs.h" -#include "lib/appweb/ejs/ejsInternal.h" -#include "scripting/ejs/smbcalls.h" #include "auth/auth.h" #include "lib/ldb_wrap.h" #include "torture/util.h" -static EjsId eid; -static int ejs_error; - -static void test_ejs_exception(const char *reason) -{ - Ejs *ep = ejsPtr(eid); - ejsSetErrorMsg(eid, "%s", reason); - fprintf(stderr, "%s", ep->error); - ejs_error = 127; -} - -static int test_run_ejs(char *script) -{ - EjsHandle handle = 0; - MprVar result; - char *emsg; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - struct MprVar *return_var; - - mprSetCtx(mem_ctx); - - if (ejsOpen(NULL, NULL, NULL) != 0) { - d_printf("ejsOpen(): unable to initialise EJS subsystem\n"); - ejs_error = 127; - goto failed; - } - - smb_setup_ejs_functions(test_ejs_exception); - - if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) { - d_printf("smbscript: ejsOpenEngine(): unable to initialise an EJS engine\n"); - ejs_error = 127; - goto failed; - } - - mprSetVar(ejsGetGlobalObject(eid), "ARGV", mprList("ARGV", NULL)); - - /* run the script */ - if (ejsEvalScript(eid, script, &result, &emsg) == -1) { - d_printf("smbscript: ejsEvalScript(): %s\n", emsg); - if (ejs_error == 0) ejs_error = 127; - goto failed; - } - - return_var = ejsGetReturnValue(eid); - ejs_error = mprVarToNumber(return_var); - -failed: - ejsClose(); - talloc_free(mem_ctx); - return ejs_error; -} - -static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx, - struct loadparm_context *lp_ctx, - struct provision_settings *settings) -{ - char *ejs; - int ret; - bool ok; - struct ldb_context *ldb; - - DEBUG(0,("Provision for Become-DC test using EJS\n")); - - DEBUG(0,("New Server[%s] in Site[%s]\n", settings->dns_name, - settings->site_name)); - - DEBUG(0,("DSA Instance [%s]\n" - "\tobjectGUID[%s]\n" - "\tinvocationId[%s]\n", - settings->ntds_dn_str, - GUID_string(mem_ctx, settings->ntds_guid), - GUID_string(mem_ctx, settings->invocation_id))); - - DEBUG(0,("Pathes under PRIVATEDIR[%s]\n" - "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n", - lp_private_dir(lp_ctx), - settings->samdb_ldb, - settings->secrets_ldb, - settings->secrets_keytab)); - - DEBUG(0,("Schema Partition[%s => %s]\n", - settings->schema_dn_str, settings->schemadn_ldb)); - - DEBUG(0,("Config Partition[%s => %s]\n", - settings->config_dn_str, settings->configdn_ldb)); - - DEBUG(0,("Domain Partition[%s => %s]\n", - settings->domain_dn_str, settings->domaindn_ldb)); - - ejs = talloc_asprintf(mem_ctx, - "libinclude(\"base.js\");\n" - "libinclude(\"provision.js\");\n" - "\n" - "function message() { print(vsprintf(arguments)); }\n" - "\n" - "var subobj = provision_guess();\n" - "subobj.ROOTDN = \"%s\";\n" - "subobj.DOMAINDN = \"%s\";\n" - "subobj.DOMAINDN_LDB = \"%s\";\n" - "subobj.CONFIGDN = \"%s\";\n" - "subobj.CONFIGDN_LDB = \"%s\";\n" - "subobj.SCHEMADN = \"%s\";\n" - "subobj.SCHEMADN_LDB = \"%s\";\n" - "subobj.HOSTNAME = \"%s\";\n" - "subobj.REALM = \"%s\";\n" - "subobj.DOMAIN = \"%s\";\n" - "subobj.DEFAULTSITE = \"%s\";\n" - "\n" - "subobj.KRBTGTPASS = \"_NOT_USED_\";\n" - "subobj.MACHINEPASS = \"%s\";\n" - "subobj.ADMINPASS = \"_NOT_USED_\";\n" - "\n" - "var paths = provision_default_paths(subobj);\n" - "paths.samdb = \"%s\";\n" - "paths.secrets = \"%s\";\n" - "paths.templates = \"%s\";\n" - "paths.keytab = \"%s\";\n" - "paths.dns_keytab = \"%s\";\n" - "\n" - "var system_session = system_session();\n" - "\n" - "var ok = provision_become_dc(subobj, message, true, paths, system_session);\n" - "assert(ok);\n" - "\n" - "return 0;\n", - settings->root_dn_str, /* subobj.ROOTDN */ - settings->domain_dn_str, /* subobj.DOMAINDN */ - settings->domaindn_ldb, /* subobj.DOMAINDN_LDB */ - settings->config_dn_str, /* subobj.CONFIGDN */ - settings->configdn_ldb, /* subobj.CONFIGDN_LDB */ - settings->schema_dn_str, /* subobj.SCHEMADN */ - settings->schemadn_ldb, /* subobj.SCHEMADN_LDB */ - settings->netbios_name, /* subobj.HOSTNAME */ - settings->realm,/* subobj.REALM */ - settings->domain,/* subobj.DOMAIN */ - settings->site_name, /* subobj.DEFAULTSITE */ - settings->machine_password,/* subobj.MACHINEPASS */ - settings->samdb_ldb, /* paths.samdb */ - settings->templates_ldb, /* paths.templates */ - settings->secrets_ldb, /* paths.secrets */ - settings->secrets_keytab, /* paths.keytab */ - settings->dns_keytab); /* paths.dns_keytab */ - NT_STATUS_HAVE_NO_MEMORY(ejs); - - ret = test_run_ejs(ejs); - if (ret != 0) { - DEBUG(0,("Failed to run ejs script: %d:\n%s", - ret, ejs)); - talloc_free(ejs); - return NT_STATUS_FOOBAR; - } - talloc_free(ejs); - - DEBUG(0,("Open the SAM LDB with system credentials: %s\n", - settings->samdb_ldb)); - - ldb = ldb_wrap_connect(mem_ctx, lp_ctx, settings->samdb_ldb, - system_session(mem_ctx, lp_ctx), - NULL, 0, NULL); - if (!ldb) { - DEBUG(0,("Failed to open '%s'\n", - settings->samdb_ldb)); - return NT_STATUS_INTERNAL_DB_ERROR; - } - - ok = samdb_set_ntds_invocation_id(ldb, settings->invocation_id); - if (!ok) { - DEBUG(0,("Failed to set cached ntds invocationId\n")); - return NT_STATUS_FOOBAR; - } - ok = samdb_set_ntds_objectGUID(ldb, settings->ntds_guid); - if (!ok) { - DEBUG(0,("Failed to set cached ntds objectGUID\n")); - return NT_STATUS_FOOBAR; - } - - return NT_STATUS_OK; -} - #include "param/param.h" #include <Python.h> #include "scripting/python/modules.h" -static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx, - struct loadparm_context *lp_ctx, - struct provision_settings *settings) +NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, + struct provision_settings *settings) { bool ok; PyObject *provision_mod, *provision_dict, *provision_fn, *result, *parameters; struct ldb_context *ldb; - + char *sam_ldb_path; + DEBUG(0,("Provision for Become-DC test using python\n")); py_load_samba_modules(); @@ -239,10 +55,10 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx, return NT_STATUS_UNSUCCESSFUL; } - provision_fn = PyDict_GetItemString(provision_dict, "provision"); + provision_fn = PyDict_GetItemString(provision_dict, "provision_become_dc"); if (provision_fn == NULL) { PyErr_Print(); - DEBUG(0, ("Unable to get provision function\n")); + DEBUG(0, ("Unable to get provision_become_dc function\n")); return NT_STATUS_UNSUCCESSFUL; } @@ -256,56 +72,45 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx, settings->ntds_guid == NULL?"None":GUID_string(mem_ctx, settings->ntds_guid), settings->invocation_id == NULL?"None":GUID_string(mem_ctx, settings->invocation_id))); - DEBUG(0,("Pathes under PRIVATEDIR[%s]\n" - "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n", - lp_private_dir(lp_ctx), - settings->samdb_ldb, - settings->secrets_ldb, - settings->secrets_keytab)); - - DEBUG(0,("Schema Partition[%s => %s]\n", - settings->schema_dn_str, settings->schemadn_ldb)); - - DEBUG(0,("Config Partition[%s => %s]\n", - settings->config_dn_str, settings->configdn_ldb)); - - DEBUG(0,("Domain Partition[%s => %s]\n", - settings->domain_dn_str, settings->domaindn_ldb)); - + DEBUG(0,("Pathes under targetdir[%s]\n", + settings->targetdir)); parameters = PyDict_New(); PyDict_SetItemString(parameters, "rootdn", PyString_FromString(settings->root_dn_str)); - if (settings->domaindn_ldb != NULL) - PyDict_SetItemString(parameters, "domaindn_ldb", - PyString_FromString(settings->domaindn_ldb)); - if (settings->config_dn_str != NULL) - PyDict_SetItemString(parameters, "configdn", - PyString_FromString(settings->config_dn_str)); - if (settings->configdn_ldb != NULL) - PyDict_SetItemString(parameters, "configdn_ldb", - PyString_FromString(settings->configdn_ldb)); - if (settings->schema_dn_str != NULL) - PyDict_SetItemString(parameters, "schema_dn_str", - PyString_FromString(settings->schema_dn_str)); - if (settings->schemadn_ldb != NULL) - PyDict_SetItemString(parameters, "schemadn_ldb", - PyString_FromString(settings->schemadn_ldb)); + if (settings->targetdir != NULL) + PyDict_SetItemString(parameters, "targetdir", + PyString_FromString(settings->targetdir)); + PyDict_SetItemString(parameters, "setup_dir", + PyString_FromString("setup")); PyDict_SetItemString(parameters, "hostname", PyString_FromString(settings->netbios_name)); - PyDict_SetItemString(parameters, "sitename", - PyString_FromString(settings->site_name)); + PyDict_SetItemString(parameters, "domain", + PyString_FromString(settings->domain)); + PyDict_SetItemString(parameters, "realm", + PyString_FromString(settings->realm)); + if (settings->root_dn_str) + PyDict_SetItemString(parameters, "rootdn", + PyString_FromString(settings->root_dn_str)); + + if (settings->domain_dn_str) + PyDict_SetItemString(parameters, "domaindn", + PyString_FromString(settings->domain_dn_str)); + + if (settings->schema_dn_str) + PyDict_SetItemString(parameters, "schemadn", + PyString_FromString(settings->schema_dn_str)); + + if (settings->config_dn_str) + PyDict_SetItemString(parameters, "configdn", + PyString_FromString(settings->config_dn_str)); + + if (settings->site_name) + PyDict_SetItemString(parameters, "sitename", + PyString_FromString(settings->site_name)); + PyDict_SetItemString(parameters, "machinepass", - PyString_FromString(settings->machine_password)); - if (settings->samdb_ldb != NULL) - PyDict_SetItemString(parameters, "samdb", - PyString_FromString(settings->samdb_ldb)); - if (settings->secrets_ldb != NULL) - PyDict_SetItemString(parameters, "secrets_ldb", - PyString_FromString(settings->secrets_ldb)); - if (settings->secrets_keytab != NULL) - PyDict_SetItemString(parameters, "secrets_keytab", - PyString_FromString(settings->secrets_keytab)); + PyString_FromString(settings->machine_password)); result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters); @@ -317,39 +122,5 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx, return NT_STATUS_UNSUCCESSFUL; } - DEBUG(0,("Open the SAM LDB with system credentials: %s\n", - settings->samdb_ldb)); - - ldb = ldb_wrap_connect(mem_ctx, lp_ctx, settings->samdb_ldb, - system_session(mem_ctx, lp_ctx), - NULL, 0, NULL); - if (!ldb) { - DEBUG(0,("Failed to open '%s'\n", settings->samdb_ldb)); - return NT_STATUS_INTERNAL_DB_ERROR; - } - - ok = samdb_set_ntds_invocation_id(ldb, settings->invocation_id); - if (!ok) { - DEBUG(0,("Failed to set cached ntds invocationId\n")); - return NT_STATUS_FOOBAR; - } - ok = samdb_set_ntds_objectGUID(ldb, settings->ntds_guid); - if (!ok) { - DEBUG(0,("Failed to set cached ntds objectGUID\n")); - return NT_STATUS_FOOBAR; - } - return NT_STATUS_OK; } - -NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, - struct provision_settings *settings) -{ - if (getenv("PROVISION_EJS")) { - return provision_bare_ejs(mem_ctx, lp_ctx, settings); - } else { - return provision_bare_py(mem_ctx, lp_ctx, settings); - } -} - - diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index ddf7b85c63..ba62f3789c 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -478,6 +478,9 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx, lp_smbcli_options(tctx->lp_ctx, &options); + options.use_oplocks = torture_setting_bool(tctx, "use_oplocks", true); + options.use_level2_oplocks = torture_setting_bool(tctx, "use_level2_oplocks", true); + status = smbcli_full_connection(mem_ctx, c, hostname, lp_smb_ports(tctx->lp_ctx), sharename, NULL, @@ -489,9 +492,6 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx, return false; } - (*c)->transport->options.use_oplocks = torture_setting_bool(tctx, "use_oplocks", false); - (*c)->transport->options.use_level2_oplocks = torture_setting_bool(tctx, "use_level2_oplocks", false); - return true; } |