예제 #1
0
BOOL torture_listshares(struct torture_context *torture)
{
	struct libnet_ListShares share;
	NTSTATUS  status;
	uint32_t levels[] = { 0, 1, 2, 501, 502 };
	int i;
	BOOL ret = True;
	struct libnet_context* libnetctx;
	const char *binding;
	struct dcerpc_binding *bind;
	TALLOC_CTX *mem_ctx;

	mem_ctx = talloc_init("test_listshares");
	binding = torture_setting_string(torture, "binding", NULL);
	status = dcerpc_parse_binding(mem_ctx, binding, &bind);
	if (!NT_STATUS_IS_OK(status)) {
		printf("Error while parsing the binding string\n");
		ret = False;
		goto done;
	}

	libnetctx = libnet_context_init(NULL);
	if (!libnetctx) {
		printf("Couldn't allocate libnet context\n");
		ret = False;
		goto done;
	}

	libnetctx->cred = cmdline_credentials;
	
	printf("Testing libnet_ListShare\n");
	
	share.in.server_name = talloc_asprintf(mem_ctx, "%s", bind->host);

	for (i = 0; i < ARRAY_SIZE(levels); i++) {
		share.in.level = levels[i];
		printf("testing libnet_ListShare level %u\n", share.in.level);

		status = libnet_ListShares(libnetctx, mem_ctx, &share);
		if (!NT_STATUS_IS_OK(status)) {
			printf("libnet_ListShare level %u failed - %s\n", share.in.level, share.out.error_string);
			ret = False;
			goto done;
		}

		printf("listing shares:\n");
		test_displayshares(share);
	}

done:
	talloc_free(mem_ctx);
	return ret;
}
예제 #2
0
bool torture_listshares(struct torture_context *torture)
{
	struct libnet_ListShares share;
	NTSTATUS  status;
	uint32_t levels[] = { 0, 1, 2, 501, 502 };
	int i;
	bool ret = true;
	struct libnet_context* libnetctx;
	struct dcerpc_binding *binding;
	TALLOC_CTX *mem_ctx;

	mem_ctx = talloc_init("test_listshares");
	status = torture_rpc_binding(torture, &binding);
	if (!NT_STATUS_IS_OK(status)) {
		ret = false;
		goto done;
	}

	libnetctx = libnet_context_init(torture->ev, torture->lp_ctx);
	if (!libnetctx) {
		torture_comment(torture, "Couldn't allocate libnet context\n");
		ret = false;
		goto done;
	}

	libnetctx->cred = popt_get_cmdline_credentials();

	torture_comment(torture, "Testing libnet_ListShare\n");

	share.in.server_name = dcerpc_binding_get_string_option(binding, "host");

	for (i = 0; i < ARRAY_SIZE(levels); i++) {
		share.in.level = levels[i];
		torture_comment(torture, "Testing libnet_ListShare level %u\n", share.in.level);

		status = libnet_ListShares(libnetctx, mem_ctx, &share);
		if (!NT_STATUS_IS_OK(status)) {
			torture_comment(torture, "libnet_ListShare level %u failed - %s\n", share.in.level, share.out.error_string);
			ret = false;
			goto done;
		}

		torture_comment(torture, "listing shares:\n");
		test_displayshares(torture, share);
	}

done:
	talloc_free(mem_ctx);
	return ret;
}