This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
BOOL ret = True;
struct libnet_context *ctx;
struct libnet_DomainOpen r;
- struct lsa_Close close;
- struct dcerpc_binding *binding;
+ struct lsa_Close lsa_close;
struct policy_handle h;
- const char *bindstr;
-
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(torture, bindstr, &binding);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
- return False;
- }
+ const char *domain_name;
+
+ /* we're accessing domain controller so the domain name should be
+ passed (it's going to be resolved to dc name and address) instead
+ of specific server name. */
+ domain_name = lp_workgroup();
ctx = libnet_context_init(NULL);
if (ctx == NULL) {
ZERO_STRUCT(r);
r.in.type = DOMAIN_LSA;
- r.in.domain_name = binding->host;
+ r.in.domain_name = domain_name;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
status = libnet_DomainOpen(ctx, torture, &r);
goto done;
}
- ZERO_STRUCT(close);
- close.in.handle = &ctx->lsa.handle;
- close.out.handle = &h;
+ ZERO_STRUCT(lsa_close);
+ lsa_close.in.handle = &ctx->lsa.handle;
+ lsa_close.out.handle = &h;
- status = dcerpc_lsa_Close(ctx->lsa.pipe, ctx, &close);
+ status = dcerpc_lsa_Close(ctx->lsa.pipe, ctx, &lsa_close);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to close domain on lsa service: %s\n", nt_errstr(status));
ret = False;
ctx->lsa.access_mask = access_mask;
ctx->lsa.handle = h;
/* we have to use pipe's event context, otherwise the call will
- hang indefinately */
+ hang indefinitely */
ctx->event_ctx = p->conn->event_ctx;
ZERO_STRUCT(r);
struct event_context *evt_ctx=NULL;
TALLOC_CTX *mem_ctx;
struct policy_handle domain_handle, handle;
- struct lsa_String name;
struct libnet_DomainOpen io;
struct samr_Close r;
+ const char *domain_name;
BOOL ret = True;
mem_ctx = talloc_init("test_domainopen_lsa");
ctx = libnet_context_init(evt_ctx);
ctx->cred = cmdline_credentials;
- name.string = lp_workgroup();
+ /* we're accessing domain controller so the domain name should be
+ passed (it's going to be resolved to dc name and address) instead
+ of specific server name. */
+ domain_name = lp_workgroup();
/*
* Testing synchronous version
printf("opening domain\n");
io.in.type = DOMAIN_SAMR;
- io.in.domain_name = name.string;
+ io.in.domain_name = domain_name;
io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
status = libnet_DomainOpen(ctx, mem_ctx, &io);
{
BOOL ret = True;
NTSTATUS status;
- TALLOC_CTX *mem_ctx=NULL;
+ TALLOC_CTX *mem_ctx = NULL;
struct libnet_context *ctx;
struct lsa_String domain_name;
struct dcerpc_binding *binding;
mem_ctx = talloc_init("torture_domain_close_samr");
status = dcerpc_pipe_connect(mem_ctx, &p, bindstr, &dcerpc_table_samr,
- cmdline_credentials, NULL);
+ ctx->cred, NULL);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server %s: %s\n", bindstr,
nt_errstr(status));
ctx->samr.access_mask = access_mask;
ctx->samr.handle = h;
/* we have to use pipe's event context, otherwise the call will
- hang indefinately */
+ hang indefinitely - this wouldn't be the case if pipe was opened
+ by means of libnet call */
ctx->event_ctx = p->conn->event_ctx;
ZERO_STRUCT(r);
talloc_free(ctx);
return ret;
}
+
+
+BOOL torture_domain_list(struct torture_context *torture)
+{
+ BOOL ret = True;
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx = NULL;
+ const char *bindstr;
+ struct dcerpc_binding *binding;
+ struct libnet_context *ctx;
+ struct libnet_DomainList r;
+ int i;
+
+ bindstr = torture_setting_string(torture, "binding", NULL);
+ status = dcerpc_parse_binding(torture, bindstr, &binding);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("failed to parse binding string\n");
+ return False;
+ }
+
+ ctx = libnet_context_init(NULL);
+ if (ctx == NULL) {
+ d_printf("failed to create libnet context\n");
+ ret = False;
+ goto done;
+ }
+
+ ctx->cred = cmdline_credentials;
+
+ mem_ctx = talloc_init("torture_domain_close_samr");
+
+ /*
+ * querying the domain list using default buffer size
+ */
+
+ ZERO_STRUCT(r);
+ r.in.hostname = binding->host;
+
+ status = libnet_DomainList(ctx, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ ret = False;
+ goto done;
+ }
+
+ d_printf("Received list or domains (everything in one piece):\n");
+
+ for (i = 0; i < r.out.count; i++) {
+ d_printf("Name[%d]: %s\n", i, r.out.domains[i].name);
+ }
+
+ /*
+ * querying the domain list using specified (much smaller) buffer size
+ */
+
+ ctx->samr.buf_size = 32;
+
+ ZERO_STRUCT(r);
+ r.in.hostname = binding->host;
+
+ status = libnet_DomainList(ctx, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ ret = False;
+ goto done;
+ }
+
+ d_printf("Received list or domains (collected in more than one round):\n");
+
+ for (i = 0; i < r.out.count; i++) {
+ d_printf("Name[%d]: %s\n", i, r.out.domains[i].name);
+ }
+
+done:
+ d_printf("\nStatus: %s\n", nt_errstr(status));
+
+ talloc_free(mem_ctx);
+ talloc_free(ctx);
+ return ret;
+}