/* Unix SMB/CIFS implementation. test suite for srvsvc rpc operations Copyright (C) Stefan (metze) Metzmacher 2003 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 (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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. */ #include "includes.h" #include "librpc/gen_ndr/ndr_srvsvc.h" /**************************/ /* srvsvc_NetCharDev */ /**************************/ static BOOL test_NetCharDevGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *devname) { NTSTATUS status; struct srvsvc_NetCharDevGetInfo r; uint32_t levels[] = {0, 1}; int i; BOOL ret = True; r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); r.in.device_name = devname; for (i=0;icount = 0; r.in.ctr.ctr0->array = NULL; r.in.max_buffer = (uint32)-1; r.in.resume_handle = NULL; for (i=0;icount;j++) { const char *device; device = r.out.ctr.ctr1->array[j].device; if (!test_NetCharDevGetInfo(p, mem_ctx, device)) { ret = False; } if (!test_NetCharDevControl(p, mem_ctx, device)) { ret = False; } } } } return ret; } /**************************/ /* srvsvc_NetCharDevQ */ /**************************/ static BOOL test_NetCharDevQGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *devicequeue) { NTSTATUS status; struct srvsvc_NetCharDevQGetInfo r; uint32_t levels[] = {0, 1}; int i; BOOL ret = True; r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); r.in.queue_name = devicequeue; r.in.user = talloc_asprintf(mem_ctx,"Administrator"); for (i=0;idevice = r.in.queue_name; break; case 1: r.in.info.info1 = talloc(mem_ctx, struct srvsvc_NetCharDevQInfo1); r.in.info.info1->device = r.in.queue_name; r.in.info.info1->priority = 0x000; r.in.info.info1->devices = r.in.queue_name; r.in.info.info1->users = 0x000; r.in.info.info1->num_ahead = 0x000; break; default: break; } r.in.parm_error = &parm_error; status = dcerpc_srvsvc_NetCharDevQSetInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("NetCharDevQSetInfo level %u on devicequeue '%s' failed - %s\n", r.in.level, r.in.queue_name, nt_errstr(status)); ret = False; continue; } if (!W_ERROR_IS_OK(r.out.result)) { printf("NetCharDevQSetInfo level %u on devicequeue '%s' failed - %s\n", r.in.level, r.in.queue_name, win_errstr(r.out.result)); continue; } } return ret; } #endif static BOOL test_NetCharDevQEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; struct srvsvc_NetCharDevQEnum r; struct srvsvc_NetCharDevQCtr0 c0; uint32_t levels[] = {0, 1}; int i; BOOL ret = True; r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); r.in.user = talloc_asprintf(mem_ctx,"%s","Administrator"); r.in.ctr.ctr0 = &c0; r.in.ctr.ctr0->count = 0; r.in.ctr.ctr0->array = NULL; r.in.max_buffer = (uint32)-1; r.in.resume_handle = NULL; for (i=0;icount;j++) { const char *device; device = r.out.ctr.ctr1->array[j].device; if (!test_NetCharDevQGetInfo(p, mem_ctx, device)) { ret = False; } } } } return ret; } /**************************/ /* srvsvc_NetConn */ /**************************/ static BOOL test_NetConnEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; struct srvsvc_NetConnEnum r; struct srvsvc_NetConnCtr0 c0; uint32_t levels[] = {0, 1}; int i; BOOL ret = True; r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); r.in.path = talloc_asprintf(mem_ctx,"%s","ADMIN$"); r.in.ctr.ctr0 = &c0; r.in.ctr.ctr0->count = 0; r.in.ctr.ctr0->array = NULL; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; for (i=0;icount = 0; r.in.ctr.ctr3->array = NULL; r.in.max_buffer = (uint32_t)4096; r.in.resume_handle = NULL; for (i=0;icount = 0; r.in.ctr.ctr0->array = NULL; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; for (i=0;icount;j++) { const char *name; const char *device; name = r.out.ctr.ctr2->array[j].name; if (!test_NetShareGetInfo(p, mem_ctx, name)) { ret = False; } device = r.out.ctr.ctr2->array[j].path; if (!test_NetShareCheck(p, mem_ctx, device)) { ret = False; } } } } return ret; } static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; struct srvsvc_NetShareEnum r; struct srvsvc_NetShareCtr0 c0; uint32_t levels[] = {0, 1, 2, 502}; int i; BOOL ret = True; r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); r.in.ctr.ctr0 = &c0; r.in.ctr.ctr0->count = 0; r.in.ctr.ctr0->array = NULL; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; for (i=0;icount = 0; r.in.ctr.ctr0->array = NULL; r.in.max_buffer = (uint32_t)-1; r.in.resume_handle = NULL; for (i=0;i