Exemplo n.º 1
0
bool torture_libsmbclient_options(struct torture_context *tctx)
{
	SMBCCTX *ctx;

	ctx = smbc_new_context();
	torture_assert(tctx, ctx, "failed to get new context");
	torture_assert(tctx, smbc_init_context(ctx), "failed to init context");

	TEST_OPTION_INT(OptionDebugToStderr, true);
	TEST_OPTION_INT(OptionFullTimeNames, true);
	TEST_OPTION_INT(OptionOpenShareMode, SMBC_SHAREMODE_DENY_ALL);
	/* FIXME: OptionUserData */
	TEST_OPTION_INT(OptionSmbEncryptionLevel, SMBC_ENCRYPTLEVEL_REQUEST);
	TEST_OPTION_INT(OptionCaseSensitive, false);
	TEST_OPTION_INT(OptionBrowseMaxLmbCount, 2);
	TEST_OPTION_INT(OptionUrlEncodeReaddirEntries, true);
	TEST_OPTION_INT(OptionOneSharePerServer, true);
	TEST_OPTION_INT(OptionUseKerberos, false);
	TEST_OPTION_INT(OptionFallbackAfterKerberos, false);
	TEST_OPTION_INT(OptionNoAutoAnonymousLogin, true);
	TEST_OPTION_INT(OptionUseCCache, true);

	smbc_free_context(ctx, 1);

	return true;
}
Exemplo n.º 2
0
Arquivo: ndr.c Projeto: Arkhont/samba
static bool test_guid_from_string(struct torture_context *tctx)
{
	struct GUID g1, exp;
	torture_assert_ntstatus_ok(tctx,
				   GUID_from_string("00000001-0002-0003-0405-060708090a0b", &g1),
				   "invalid return code");
	exp.time_low = 1;
	exp.time_mid = 2;
	exp.time_hi_and_version = 3;
	exp.clock_seq[0] = 4;
	exp.clock_seq[1] = 5;
	exp.node[0] = 6;
	exp.node[1] = 7;
	exp.node[2] = 8;
	exp.node[3] = 9;
	exp.node[4] = 10;
	exp.node[5] = 11;
	torture_assert(tctx, GUID_equal(&g1, &exp), "UUID parsed incorrectly");
	torture_assert_ntstatus_ok(tctx,
				   GUID_from_string("{00000001-0002-0003-0405-060708090a0b}", &g1),
				   "invalid return code");
	torture_assert(tctx, GUID_equal(&g1, &exp), "UUID parsed incorrectly");

	return true;
}
Exemplo n.º 3
0
static bool test_afdgets(struct torture_context *tctx)
{
	int fd;
	char *line;
	TALLOC_CTX *mem_ctx = tctx;
	bool ret = false;
	
	torture_assert(tctx, file_save(TEST_FILENAME, (const void *)TEST_DATA, 
							 strlen(TEST_DATA)),
				   "saving file");

	fd = open(TEST_FILENAME, O_RDONLY);
	
	torture_assert(tctx, fd != -1, "opening file");

	line = afdgets(fd, mem_ctx, 8);
	torture_assert_goto(tctx, strcmp(line, TEST_LINE1) == 0, ret, done,
			    "line 1 mismatch");

	line = afdgets(fd, mem_ctx, 8);
	torture_assert_goto(tctx, strcmp(line, TEST_LINE2) == 0, ret, done,
			    "line 2 mismatch");

	line = afdgets(fd, mem_ctx, 8);
	torture_assert_goto(tctx, strcmp(line, TEST_LINE3) == 0, ret, done,
			    "line 3 mismatch");
	ret = true;
done:
	close(fd);

	unlink(TEST_FILENAME);
	return ret;
}
Exemplo n.º 4
0
static bool test_Lookup_simple(struct torture_context *tctx,
			       struct dcerpc_pipe *p)
{
	NTSTATUS status;
	struct epm_Lookup r;
	struct policy_handle entry_handle;
	uint32_t num_ents = 0;
	struct dcerpc_binding_handle *h = p->binding_handle;

	ZERO_STRUCT(entry_handle);

	torture_comment(tctx, "Testing epm_Lookup\n");

	/* get all elements */
	r.in.inquiry_type = RPC_C_EP_ALL_ELTS;
	r.in.object = NULL;
	r.in.interface_id = NULL;
	r.in.vers_option = RPC_C_VERS_ALL;

	r.in.entry_handle = &entry_handle;
	r.in.max_ents = 10;

	r.out.entry_handle = &entry_handle;
	r.out.num_ents = &num_ents;

	do {
		int i;

		status = dcerpc_epm_Lookup_r(h, tctx, &r);
		if (!NT_STATUS_IS_OK(status) ||
		    r.out.result != EPMAPPER_STATUS_OK) {
			break;
		}

		torture_comment(tctx,
				"epm_Lookup returned %d events, entry_handle: %s\n",
				*r.out.num_ents,
				GUID_string(tctx, &entry_handle.uuid));

		for (i = 0; i < *r.out.num_ents; i++) {
			torture_comment(tctx,
					"\n  Found '%s'\n",
					r.out.entries[i].annotation);

			display_tower(tctx, &r.out.entries[i].tower->tower);
		}
	} while (NT_STATUS_IS_OK(status) &&
		 r.out.result == EPMAPPER_STATUS_OK &&
		 *r.out.num_ents == r.in.max_ents &&
		 !ndr_policy_handle_empty(&entry_handle));

	torture_assert_ntstatus_ok(tctx, status, "epm_Lookup failed");
	torture_assert(tctx, r.out.result == EPMAPPER_STATUS_NO_MORE_ENTRIES, "epm_Lookup failed");

	torture_assert(tctx,
		       ndr_policy_handle_empty(&entry_handle),
		       "epm_Lookup failed - The policy handle should be emtpy.");

	return true;
}
static bool whoami_sid_parse(void *mem_ctx,
		struct torture_context *torture,
		DATA_BLOB *data, size_t *offset,
		struct dom_sid **psid)
{
	size_t remain = data->length - *offset;
	int i;

	*psid = talloc_zero(mem_ctx, struct dom_sid);
	torture_assert(torture, *psid != NULL, "out of memory");

	torture_assert(torture, remain >= 8,
			"invalid SID format");

        (*psid)->sid_rev_num = CVAL(data->data, *offset);
        (*psid)->num_auths = CVAL(data->data, *offset + 1);
        memcpy((*psid)->id_auth, data->data + *offset + 2, 6);

	(*offset) += 8;
	remain = data->length - *offset;

	torture_assert(torture, remain >= ((*psid)->num_auths * 4),
			"invalid sub_auth byte count");
	torture_assert(torture, (*psid)->num_auths >= 0,
			"invalid sub_auth value");
	torture_assert(torture, (*psid)->num_auths <= 15,
			"invalid sub_auth value");

        for (i = 0; i < (*psid)->num_auths; i++) {
                (*psid)->sub_auths[i] = IVAL(data->data, *offset);
		(*offset) += 4;
	}

	return true;
}
Exemplo n.º 6
0
static bool test_file_load_save(struct torture_context *tctx)
{
	size_t len;
	char *data;
	TALLOC_CTX *mem_ctx = tctx;
	
	torture_assert(tctx, file_save(TEST_FILENAME, TEST_DATA, strlen(TEST_DATA)),
				   "saving file");

	torture_assert_file_contains_text(tctx, TEST_FILENAME, TEST_DATA, 
								      "file contents");

	data = file_load(TEST_FILENAME, &len, 0, mem_ctx);
	torture_assert(tctx, data, "loading file");

	torture_assert_int_equal(tctx, len, strlen(TEST_DATA), "Length");
	
	torture_assert_mem_equal(tctx, data, TEST_DATA, len, "Contents");

	data = file_load(TEST_FILENAME, &len, 5, mem_ctx);

	torture_assert_int_equal(tctx, len, 5, "Length");

	torture_assert_mem_equal(tctx, data, TEST_DATA, len, "Contents");

	unlink(TEST_FILENAME);
	return true;
}
Exemplo n.º 7
0
static bool test_free_ref_null_context(void)
{
	void *p1, *p2, *p3;
	int ret;

	talloc_disable_null_tracking();
	p1 = talloc_new(NULL);
	p2 = talloc_new(NULL);

	p3 = talloc_reference(p2, p1);
	torture_assert("reference", p3 == p1, "failed: reference on null");

	ret = talloc_free(p1);
	torture_assert("ref free with null parent", ret == 0, "failed: free with null parent");
	talloc_free(p2);

	talloc_enable_null_tracking_no_autofree();
	p1 = talloc_new(NULL);
	p2 = talloc_new(NULL);

	p3 = talloc_reference(p2, p1);
	torture_assert("reference", p3 == p1, "failed: reference on null");

	ret = talloc_free(p1);
	torture_assert("ref free with null tracked parent", ret == 0, "failed: free with null parent");
	talloc_free(p2);

	return true;
}
Exemplo n.º 8
0
static bool witness_GetInterfaceList_check(struct torture_context *tctx,
					   struct witness_GetInterfaceList *r)
{
	struct witness_interfaceList *l;

	torture_assert(tctx, r->out.interface_list, "r->out.interface_list");

	l = *(r->out.interface_list);

	torture_assert_int_equal(tctx, l->num_interfaces, 2, "l->num_interfaces");
	torture_assert(tctx, l->interfaces, "l->interfaces");

	torture_assert_str_equal(tctx, l->interfaces[0].group_name, "NODE2", "l->interfaces[0].group_name");
	torture_assert_int_equal(tctx, l->interfaces[0].version, -1, "l->interfaces[0].version");
	torture_assert_int_equal(tctx, l->interfaces[0].state, 1, "l->interfaces[0].state");
	torture_assert_str_equal(tctx, l->interfaces[0].ipv4, "192.168.3.44", "l->interfaces[0].state");
	torture_assert_int_equal(tctx, l->interfaces[0].flags, 5, "l->interfaces[0].flags");

	torture_assert_str_equal(tctx, l->interfaces[1].group_name, "NODE1", "l->interfaces[0].group_name");
	torture_assert_int_equal(tctx, l->interfaces[1].version, -1, "l->interfaces[0].version");
	torture_assert_int_equal(tctx, l->interfaces[1].state, 1, "l->interfaces[0].state");
	torture_assert_str_equal(tctx, l->interfaces[1].ipv4, "192.168.3.45", "l->interfaces[0].state");
	torture_assert_int_equal(tctx, l->interfaces[1].flags, 1, "l->interfaces[0].flags");
	torture_assert_werr_ok(tctx, r->out.result, "r->out.result");

	return true;
}
Exemplo n.º 9
0
static bool test_netprintq(struct torture_context *tctx,
			   struct smbcli_state *cli)
{
	struct rap_NetPrintQEnum r;
	int i;

	r.in.level = 5;
	r.in.bufsize = 8192;

	torture_assert_ntstatus_ok(tctx,
		smbcli_rap_netprintqenum(cli->tree, tctx, &r),
		"failed to enum printq");
	torture_assert_werr_ok(tctx, W_ERROR(r.out.status),
		"failed to enum printq");

	for (i=0; i < r.out.count; i++) {

		const char *printqname = r.out.info[i].info5.PrintQueueName;

		torture_assert(tctx,
			test_netprintq_pause(tctx, cli, printqname),
			"failed to pause print queue");

		torture_assert(tctx,
			test_netprintq_resume(tctx, cli, printqname),
			"failed to resume print queue");
	}

	return true;
}
Exemplo n.º 10
0
static bool test_cmp(struct torture_context *tctx)
{
	DATA_BLOB a = data_blob_string_const("bla");
	DATA_BLOB b = data_blob_string_const("blae");
	torture_assert(tctx, data_blob_cmp(&a, &b) != 0, "cmp different");
	torture_assert(tctx, data_blob_cmp(&a, &a) == 0, "cmp self");
	return true;
}
Exemplo n.º 11
0
static bool test_null_time(struct torture_context *tctx)
{
	torture_assert(tctx, null_time(0), "0");
	torture_assert(tctx, null_time(0xFFFFFFFF), "0xFFFFFFFF");
	torture_assert(tctx, null_time(-1), "-1");
	torture_assert(tctx, !null_time(42), "42");
	return true;
}
Exemplo n.º 12
0
static bool test_set_cmdline(struct torture_context *tctx)
{
	struct loadparm_context *lp_ctx = loadparm_init(tctx);
	torture_assert(tctx, lpcfg_set_cmdline(lp_ctx, "workgroup", "werkgroep"), "lpcfg_set_cmdline failed");
	torture_assert(tctx, lpcfg_do_global_parameter(lp_ctx, "workgroup", "barbla"), "lpcfg_set_option failed");
	torture_assert_str_equal(tctx, "WERKGROEP", lpcfg_workgroup(lp_ctx), "workgroup");
	return true;
}
Exemplo n.º 13
0
static bool test_strhasupper(struct torture_context *tctx)
{
	torture_assert(tctx, strhasupper("B"), "one up char");
	torture_assert(tctx, strhasupper("aB"), "one low, one up char");
	torture_assert(tctx, !strhasupper("a"), "one low char");
	torture_assert(tctx, !strhasupper(""), "empty string");
	torture_assert(tctx, !strhasupper("3"), "one digit");
	return true;
}
Exemplo n.º 14
0
static bool test_server_role_member_specified3(struct torture_context *tctx)
{
	struct loadparm_context *lp_ctx = loadparm_init(tctx);
	torture_assert(tctx, lpcfg_set_option(lp_ctx, "server role=member"), "lpcfg_set_option failed");
	torture_assert(tctx, lpcfg_set_option(lp_ctx, "security=ads"), "lpcfg_set_option failed");
	torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_DOMAIN_MEMBER, "ROLE should be member");
	torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_ADS, "security should be ads");
	return true;
}
Exemplo n.º 15
0
static bool test_server_role_dc_domain_logons_and_not_master(struct torture_context *tctx)
{
	struct loadparm_context *lp_ctx = loadparm_init(tctx);
	torture_assert(tctx, lpcfg_set_option(lp_ctx, "domain logons=true"), "lpcfg_set_option failed");
	torture_assert(tctx, lpcfg_set_option(lp_ctx, "domain master=false"), "lpcfg_set_option failed");
	torture_assert_int_equal(tctx, lpcfg_server_role(lp_ctx), ROLE_DOMAIN_BDC, "ROLE should be BDC");
	torture_assert_int_equal(tctx, lpcfg_security(lp_ctx), SEC_USER, "security should be user");
	return true;
}
Exemplo n.º 16
0
/*
  test realloc
*/
static bool test_realloc(void)
{
	void *root, *p1, *p2;

	printf("test: realloc\n# REALLOC\n");

	root = talloc_new(NULL);

	p1 = talloc_size(root, 10);
	CHECK_SIZE("realloc", p1, 10);

	p1 = talloc_realloc_size(NULL, p1, 20);
	CHECK_SIZE("realloc", p1, 20);

	talloc_new(p1);

	p2 = talloc_realloc_size(p1, NULL, 30);

	talloc_new(p1);

	p2 = talloc_realloc_size(p1, p2, 40);

	CHECK_SIZE("realloc", p2, 40);
	CHECK_SIZE("realloc", root, 60);
	CHECK_BLOCKS("realloc", p1, 4);

	p1 = talloc_realloc_size(NULL, p1, 20);
	CHECK_SIZE("realloc", p1, 60);

	talloc_increase_ref_count(p2);
	torture_assert("realloc", talloc_realloc_size(NULL, p2, 5) == NULL,
		"failed: talloc_realloc() on a referenced pointer should fail\n");
	CHECK_BLOCKS("realloc", p1, 4);

	talloc_realloc_size(NULL, p2, 0);
	talloc_realloc_size(NULL, p2, 0);
	CHECK_BLOCKS("realloc", p1, 4);
	talloc_realloc_size(p1, p2, 0);
	CHECK_BLOCKS("realloc", p1, 3);

	torture_assert("realloc", talloc_realloc_size(NULL, p1, 0x7fffffff) == NULL,
		"failed: oversize talloc should fail\n");

	talloc_realloc_size(NULL, p1, 0);
	CHECK_BLOCKS("realloc", root, 4);
	talloc_realloc_size(root, p1, 0);
	CHECK_BLOCKS("realloc", root, 1);

	CHECK_SIZE("realloc", root, 0);

	talloc_free(root);

	printf("success: realloc\n");

	return true;
}
Exemplo n.º 17
0
static bool test_wbc_users(struct torture_context *tctx)
{
    const char *domain_name = NULL;
    uint32_t num_users;
    const char **users;
    int i;
    struct wbcInterfaceDetails *details;

    torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
                          "%s", "wbcInterfaceDetails failed");

    domain_name = talloc_strdup(tctx, details->netbios_domain);
    wbcFreeMemory(details);

    torture_assert_wbc_ok(tctx, wbcListUsers(domain_name, &num_users, &users),
                          "%s", "wbcListUsers failed");
    torture_assert(tctx, !(num_users > 0 && !users),
                   "wbcListUsers returned invalid results");

    for (i=0; i < MIN(num_users,100); i++) {

        struct wbcDomainSid sid, *sids;
        enum wbcSidType name_type;
        char *domain;
        char *name;
        char *sid_string;
        uint32_t num_sids;

        torture_assert_wbc_ok(tctx, wbcLookupName(domain_name, users[i], &sid, &name_type),
                              "wbcLookupName of %s failed", users[i]);
        torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER,
                                 "wbcLookupName expected WBC_SID_NAME_USER");
        wbcSidToString(&sid, &sid_string);
        torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type),
                              "wbcLookupSid of %s failed", sid_string);
        torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER,
                                 "wbcLookupSid of expected WBC_SID_NAME_USER");
        torture_assert(tctx, name,
                       "wbcLookupSid returned no name");
        wbcFreeMemory(domain);
        wbcFreeMemory(name);
        torture_assert_wbc_ok(tctx, wbcLookupUserSids(&sid, true, &num_sids, &sids),
                              "wbcLookupUserSids of %s failed", sid_string);
        torture_assert_wbc_ok(
            tctx, wbcGetDisplayName(&sid, &domain, &name,
                                    &name_type),
            "wbcGetDisplayName of %s failed", sid_string);
        wbcFreeMemory(domain);
        wbcFreeMemory(name);
        wbcFreeMemory(sids);
        wbcFreeMemory(sid_string);
    }
    wbcFreeMemory(users);

    return true;
}
Exemplo n.º 18
0
static bool test_lp_parm_double(struct torture_context *tctx)
{
	struct loadparm_context *lp_ctx = loadparm_init(tctx);
	torture_assert(tctx, lpcfg_set_option(lp_ctx, "some:thing=3.4"), "lpcfg_set_option failed");
	torture_assert(tctx, lpcfg_parm_double(lp_ctx, NULL, "some", "thing", 2.0) == 3.4,
				 "invalid parametric option");
	torture_assert(tctx, lpcfg_parm_double(lp_ctx, NULL, "some", "bla", 2.0) == 2.0,
				 "invalid parametric option");
	return true;
}
Exemplo n.º 19
0
static bool enumkey_out_check(struct torture_context *tctx, struct winreg_EnumKey *r)
{
	torture_assert_int_equal(tctx, r->out.name->size, 1044, "name size");
	torture_assert_int_equal(tctx, r->out.name->length, 8, "name len");
	torture_assert(tctx, r->out.keyclass != NULL, "keyclass pointer");
	torture_assert(tctx, r->out.keyclass->name == NULL, "keyclass");
	torture_assert(tctx, r->out.last_changed_time != NULL, "last_changed_time pointer");
	/* FIXME: *last_changed_time */
	return true;
}
Exemplo n.º 20
0
static bool enumkey_in_check(struct torture_context *tctx, struct winreg_EnumKey *r)
{
	torture_assert_int_equal(tctx, r->in.enum_index, 0, "enum index");
	torture_assert_int_equal(tctx, r->in.name->size, 1044, "name size");
	torture_assert_int_equal(tctx, r->in.name->length, 0, "name len");
	torture_assert(tctx, r->in.keyclass != NULL, "keyclass pointer");
	torture_assert(tctx, r->in.keyclass->name == NULL, "keyclass");
	torture_assert(tctx, r->in.last_changed_time != NULL, "last_changed_time != NULL");
	return true;
}
Exemplo n.º 21
0
static bool notifychangekeyvalue_in_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
{
	torture_assert_int_equal(tctx, r->in.watch_subtree, 1, "watch subtree");
	torture_assert_int_equal(tctx, r->in.notify_filter, 0, "notify filter");
	torture_assert_int_equal(tctx, r->in.unknown, 0, "unknown");
	torture_assert(tctx, r->in.string1.name == NULL, "string1");
	torture_assert(tctx, r->in.string2.name == NULL, "string2");
	torture_assert_int_equal(tctx, r->in.unknown2, 0, "unknown2");
	return true;
}
Exemplo n.º 22
0
static bool createkey_out_check(struct torture_context *tctx, 
								  struct winreg_CreateKey *r)
{
	torture_assert(tctx, GUID_all_zero(&r->out.new_handle->uuid), "new_handle");
	torture_assert(tctx, r->out.action_taken == NULL, "action_taken pointer");
	torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM, 
							  "return code");

	return true;
}
Exemplo n.º 23
0
static bool test_lp_parm_bool(struct torture_context *tctx)
{
	struct loadparm_context *lp_ctx = loadparm_init(tctx);
	torture_assert(tctx, lpcfg_set_option(lp_ctx, "some:thing=true"), "lpcfg_set_option failed");
	torture_assert(tctx, lpcfg_parm_bool(lp_ctx, NULL, "some", "thing", false) == true,
				 "invalid parametric option");
	torture_assert(tctx, lpcfg_parm_bool(lp_ctx, NULL, "some", "bla", true) == true,
				 "invalid parametric option");
	return true;
}
Exemplo n.º 24
0
/*
  This test checks that 

  1) the server does not allow an unlink on a file that is open
*/
BOOL torture_unlinktest(struct torture_context *tctx, struct smbcli_state *cli)
{
	const char *fname = BASEDIR "\\unlink.tst";
	int fnum;
	BOOL correct = True;
	union smb_open io;
	NTSTATUS status;

	torture_assert(tctx, torture_setup_dir(cli, BASEDIR), 
				   talloc_asprintf(tctx, "Failed setting up %s", BASEDIR));

	cli->session->pid = 1;

	torture_comment(tctx, "Opening a file\n");

	fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
	torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli->tree)));

	torture_comment(tctx, "Unlinking a open file\n");

	torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname)),
		"server allowed unlink on an open file");
	
	correct = check_error(__location__, cli, ERRDOS, ERRbadshare, 
				      NT_STATUS_SHARING_VIOLATION);

	smbcli_close(cli->tree, fnum);
	smbcli_unlink(cli->tree, fname);

	torture_comment(tctx, "testing unlink after ntcreatex with DELETE access\n");

	io.ntcreatex.level = RAW_OPEN_NTCREATEX;
	io.ntcreatex.in.root_fid = 0;
	io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
	io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
	io.ntcreatex.in.file_attr = 0;
	io.ntcreatex.in.alloc_size = 0;
	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION;
	io.ntcreatex.in.security_flags = 0;
	io.ntcreatex.in.fname = fname;
	io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE;
	io.ntcreatex.in.access_mask  = SEC_RIGHTS_FILE_ALL;

	status = smb_raw_open(cli->tree, cli, &io);
	torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "failed to open %s", fname));

	torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname)),
		"server allowed unlink on an open file");

	correct = check_error(__location__, cli, ERRDOS, ERRbadshare, 
				      NT_STATUS_SHARING_VIOLATION);

	return correct;
}
Exemplo n.º 25
0
static bool queryinfokey_out_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
{
	torture_assert(tctx, r->out.classname != NULL, "class out");
	torture_assert(tctx, r->out.classname->name != NULL, "class out name");
	torture_assert_str_equal(tctx, r->out.classname->name, "", "class out name");
	torture_assert_int_equal(tctx, *r->out.num_subkeys, 0, "num subkeys");
	torture_assert_int_equal(tctx, *r->out.max_subkeylen, 0, "subkey length");
	torture_assert_int_equal(tctx, *r->out.max_classlen, 140, "subkey size");
	torture_assert_werr_ok(tctx, r->out.result, "return code");
	return true;
}
Exemplo n.º 26
0
static bool test_next_token_quote_wrong(struct torture_context *tctx)
{
	const char *teststr = "\"foo bar bla";
	char buf[20];
	torture_assert(tctx, next_token(&teststr, buf, " ", 20), "finding token works");
	torture_assert_str_equal(tctx, buf, "foo bar bla", "token matches");
	torture_assert_str_equal(tctx, teststr, "", "ptr modified correctly");

	torture_assert(tctx, !next_token(&teststr, buf, " ", 20), "finding token doesn't work");
	return true;
}
Exemplo n.º 27
0
static bool jobenum_in_check(struct torture_context *tctx, 
							 struct atsvc_JobEnum *r)
{
	torture_assert(tctx, r->in.servername != NULL, "servername ptr");
	torture_assert_str_equal(tctx, r->in.servername, "WIN2KDC1", "servername");
	torture_assert_int_equal(tctx, r->in.ctr->entries_read, 0, "ctr entries read");
	torture_assert(tctx, r->in.ctr->first_entry == NULL, "ctr entries first_entry");
	torture_assert_int_equal(tctx, r->in.preferred_max_len, -1, "preferred max len");
	torture_assert(tctx, r->in.resume_handle != NULL, "resume handle ptr");
	torture_assert_int_equal(tctx, *r->in.resume_handle, 0, "resume handle");
	return true;
}
Exemplo n.º 28
0
static bool createkey_in_check(struct torture_context *tctx, 
								  struct winreg_CreateKey *r)
{
	torture_assert_str_equal(tctx, r->in.name.name, "spottyfoot", "name");
	torture_assert(tctx, r->in.keyclass.name == NULL, "keyclass");
	torture_assert_int_equal(tctx, r->in.options, 0, "option");
	torture_assert_int_equal(tctx, r->in.access_mask, 0x2000000, "access mask");
	torture_assert(tctx, r->in.secdesc == NULL, "secdesc");
	torture_assert(tctx, r->in.action_taken == NULL, "action_taken");

	return true;
}
Exemplo n.º 29
0
static bool torture_rpc_spoolss_access_teardown_common(struct torture_context *tctx, struct torture_access_context *t)
{
    if (t->user.testuser) {
        torture_leave_domain(tctx, t->user.testuser);
    }

    /* remove membership ? */
    if (t->user.num_builtin_memberships) {
    }

    /* remove privs ? */
    if (t->user.num_privs) {
    }

    /* restore sd */
    if (t->user.sd && t->printername) {
        struct policy_handle handle;
        struct spoolss_SetPrinterInfoCtr info_ctr;
        struct spoolss_SetPrinterInfo3 info3;
        struct spoolss_DevmodeContainer devmode_ctr;
        struct sec_desc_buf secdesc_ctr;
        struct dcerpc_pipe *spoolss_pipe;
        struct dcerpc_binding_handle *b;

        torture_assert_ntstatus_ok(tctx,
                                   torture_rpc_connection(tctx, &spoolss_pipe, &ndr_table_spoolss),
                                   "Error connecting to server");

        b = spoolss_pipe->binding_handle;

        ZERO_STRUCT(info_ctr);
        ZERO_STRUCT(info3);
        ZERO_STRUCT(devmode_ctr);
        ZERO_STRUCT(secdesc_ctr);

        info_ctr.level = 3;
        info_ctr.info.info3 = &info3;
        secdesc_ctr.sd = t->sd_orig;

        torture_assert(tctx,
                       test_openprinter_handle(tctx, spoolss_pipe, "", t->printername, "", SEC_FLAG_MAXIMUM_ALLOWED, WERR_OK, &handle),
                       "failed to open printer");

        torture_assert(tctx,
                       test_SetPrinter(tctx, b, &handle, &info_ctr, &devmode_ctr, &secdesc_ctr, 0),
                       "failed to set sd");

        talloc_free(spoolss_pipe);
    }

    return true;
}
Exemplo n.º 30
0
/* Test the rate at which the server will accept connections.  */
bool torture_bench_treeconnect(struct torture_context *tctx)
{
	const char *host = torture_setting_string(tctx, "host", NULL);
	const char *share = torture_setting_string(tctx, "share", NULL);

	int timelimit = torture_setting_int(tctx, "timelimit",
					TIME_LIMIT_SECS);
	int nprocs = torture_setting_int(tctx, "nprocs", 4);

	int *curr_counts = map_count_buffer(nprocs, sizeof(int));
	int *last_counts = talloc_array(NULL, int, nprocs);

	struct timeval now, last, start;
	int i, delta;

	torture_assert(tctx, nprocs > 0, "bad proc count");
	torture_assert(tctx, timelimit > 0, "bad timelimit");
	torture_assert(tctx, curr_counts, "allocation failure");
	torture_assert(tctx, last_counts, "allocation failure");

	start = last = timeval_current();
	for (i = 0; i < nprocs; ++i) {
		fork_tcon_client(tctx, &curr_counts[i], timelimit, host, share);
	}

	while (children_remain()) {

		sleep(1);
		now = timeval_current();

		for (i = 0, delta = 0; i < nprocs; ++i) {
			delta += curr_counts[i] - last_counts[i];
		}

		printf("%u connections/sec\n",
			(unsigned)rate_convert_secs(delta, &last, &now));

		memcpy(last_counts, curr_counts, nprocs * sizeof(int));
		last = timeval_current();
	}

	now = timeval_current();

	for (i = 0, delta = 0; i < nprocs; ++i) {
		delta += curr_counts[i];
	}

	printf("TOTAL: %u connections/sec over %u secs\n",
			(unsigned)rate_convert_secs(delta, &start, &now),
			timelimit);
	return true;
}