From 798fbb45e3eadbfdd5f17396a331c33ba6010d03 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Tue, 2 Aug 2005 22:25:42 +0000 Subject: r8954: Use binding string to specify host rather than share path, as we use rpc call here after all. Also, safely exit (freeing memory context) in case of any error. rafal (This used to be commit be2584df1d167f3e8ef600a926979f081e72c6a9) --- source4/torture/libnet/libnet_share.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c index 058158226b..d0214a102a 100644 --- a/source4/torture/libnet/libnet_share.c +++ b/source4/torture/libnet/libnet_share.c @@ -114,18 +114,31 @@ BOOL torture_listshares(void) int i; BOOL ret = True; struct libnet_context* libnetctx; - const char* host; + const char *binding, *host; + struct dcerpc_binding *bind; TALLOC_CTX *mem_ctx; mem_ctx = talloc_init("test_listshares"); - host = lp_parm_string(-1, "torture", "host"); + binding = lp_parm_string(-1, "torture", "binding"); + 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", host); + share.in.server_name = talloc_asprintf(mem_ctx, "%s", bind->host); for (i = 0; i < ARRAY_SIZE(levels); i++) { share.in.level = levels[i]; @@ -135,12 +148,15 @@ BOOL torture_listshares(void) if (!NT_STATUS_IS_OK(status)) { printf("libnet_ListShare level %u failed - %s\n", share.in.level, nt_errstr(status)); ret = False; + goto done; } printf("listing shares:\n"); test_displayshares(share); } +done: + talloc_free(mem_ctx); return ret; } -- cgit