static bool test_del_value(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; uint32_t type; uint8_t d[] = { 0x42, 0x00, 0x00, 0x00 }; DATA_BLOB db = { d, 4 }; error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, db); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_key_del_value(mem_ctx, subkey, "Answer"); torture_assert_werr_ok(tctx, error, "deleting value"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &db); torture_assert_werr_equal(tctx, error, WERR_BADFILE, "getting value"); error = hive_key_del_value(mem_ctx, subkey, "Answer"); torture_assert_werr_equal(tctx, error, WERR_BADFILE, "deleting value"); return true; }
static bool test_del_value(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; char data[4]; uint32_t type; DATA_BLOB value; SIVAL(data, 0, 42); error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, data_blob_talloc(mem_ctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_key_del_value(subkey, "Answer"); torture_assert_werr_ok(tctx, error, "deleting value"); error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value); torture_assert_werr_equal(tctx, error, WERR_BADFILE, "getting value"); error = hive_key_del_value(subkey, "Answer"); torture_assert_werr_equal(tctx, error, WERR_BADFILE, "deleting value"); return true; }
static bool test_ControlService(struct torture_context *tctx, struct dcerpc_pipe *p) { struct svcctl_ControlService r; struct policy_handle h, s; struct SERVICE_STATUS service_status; struct dcerpc_binding_handle *b = p->binding_handle; if (!test_OpenSCManager(b, tctx, &h)) return false; if (!test_OpenService(b, tctx, &h, TORTURE_DEFAULT_SERVICE, &s)) return false; r.in.handle = &s; r.in.control = 0; r.out.service_status = &service_status; torture_assert_ntstatus_ok(tctx, dcerpc_svcctl_ControlService_r(b, tctx, &r), "ControlService failed!"); torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PARAM, "ControlService failed!"); if (!test_CloseServiceHandle(b, tctx, &s)) return false; if (!test_CloseServiceHandle(b, tctx, &h)) return false; return true; }
static bool test_StartServiceW(struct torture_context *tctx, struct dcerpc_pipe *p) { struct svcctl_StartServiceW r; struct policy_handle h, s; struct dcerpc_binding_handle *b = p->binding_handle; if (!test_OpenSCManager(b, tctx, &h)) return false; if (!test_OpenService(b, tctx, &h, TORTURE_DEFAULT_SERVICE, &s)) return false; r.in.handle = &s; r.in.NumArgs = 0; r.in.Arguments = NULL; torture_assert_ntstatus_ok(tctx, dcerpc_svcctl_StartServiceW_r(b, tctx, &r), "StartServiceW failed!"); torture_assert_werr_equal(tctx, r.out.result, WERR_SERVICE_ALREADY_RUNNING, "StartServiceW failed!"); if (!test_CloseServiceHandle(b, tctx, &s)) return false; if (!test_CloseServiceHandle(b, tctx, &h)) return false; return true; }
static bool test_NetrWkstaTransportAdd(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetrWkstaTransportAdd r; struct wkssvc_NetWkstaTransportInfo0 info0; uint32_t parm_err = 0; struct dcerpc_binding_handle *b = p->binding_handle; ZERO_STRUCT(info0); info0.quality_of_service = 0xffff; info0.vc_count = 0; info0.name = SMBTORTURE_TRANSPORT_NAME; info0.address = "000000000000"; info0.wan_link = 0x400; r.in.server_name = dcerpc_server_name(p); r.in.level = 0; r.in.info0 = &info0; r.in.parm_err = r.out.parm_err = &parm_err; torture_comment(tctx, "Testing NetrWkstaTransportAdd level 0\n"); status = dcerpc_wkssvc_NetrWkstaTransportAdd_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrWkstaTransportAdd failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PARAM, "NetrWkstaTransportAdd level 0 failed"); return true; }
static bool test_RestoreGUID_emptyrequest(struct torture_context *tctx, struct dcerpc_pipe *p) { struct dcerpc_binding_handle *b = p->binding_handle; DATA_BLOB out_blob; if (p->conn->security_state.auth_info != NULL && p->conn->security_state.auth_info->auth_level == 6) { struct bkrp_BackupKey *r = createRestoreGUIDStruct(tctx, p, 3, &out_blob, false, false, false, true, false, false, true); torture_assert_int_equal(tctx, r != NULL, 1, "Error while creating the restoreGUID struct"); r->in.data_in = talloc(tctx, uint8_t); r->in.data_in_len = 0; r->in.param = 0; torture_assert_ntstatus_ok(tctx, dcerpc_bkrp_BackupKey_r(b, tctx, r), "Restore GUID"); out_blob.length = *r->out.data_out_len; torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM, "Bad error code on wrong has in access check"); } else { struct bkrp_BackupKey *r = createRetreiveBackupKeyGUIDStruct(tctx, p, 2, &out_blob); torture_assert_ntstatus_equal(tctx, dcerpc_bkrp_BackupKey_r(b, tctx, r), NT_STATUS_ACCESS_DENIED, "Get GUID"); } return true; }
static bool test_PNP_GetDeviceListSize(struct torture_context *tctx, struct dcerpc_pipe *p) { struct dcerpc_binding_handle *b = p->binding_handle; struct PNP_GetDeviceListSize r; uint32_t size = 0; r.in.devicename = NULL; r.in.flags = CM_GETIDLIST_FILTER_SERVICE; r.out.size = &size; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceListSize_r(b, tctx, &r), "PNP_GetDeviceListSize"); torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER, "PNP_GetDeviceListSize"); r.in.devicename = "Spooler"; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceListSize_r(b, tctx, &r), "PNP_GetDeviceListSize"); torture_assert_werr_ok(tctx, r.out.result, "PNP_GetDeviceListSize"); return true; }
static bool test_NetrGetJoinableOus2(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetrGetJoinableOus2 r; uint32_t num_ous = 0; const char **ous = NULL; struct dcerpc_binding_handle *b = p->binding_handle; r.in.server_name = dcerpc_server_name(p); r.in.domain_name = lpcfg_workgroup(tctx->lp_ctx); r.in.Account = NULL; r.in.EncryptedPassword = NULL; r.in.num_ous = r.out.num_ous = &num_ous; r.out.ous = &ous; torture_comment(tctx, "Testing NetrGetJoinableOus2\n"); status = dcerpc_wkssvc_NetrGetJoinableOus2_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrGetJoinableOus2 failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_RPC_E_REMOTE_DISABLED, "NetrGetJoinableOus2 failed"); return true; }
static bool test_NetrJoinDomain(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetrJoinDomain r; struct cli_credentials *creds = cmdline_credentials; const char *user = cli_credentials_get_username(creds); const char *admin_account = NULL; struct dcerpc_binding_handle *b = p->binding_handle; admin_account = talloc_asprintf(tctx, "%s\\%s", lpcfg_workgroup(tctx->lp_ctx), user); r.in.server_name = dcerpc_server_name(p); r.in.domain_name = lpcfg_dnsdomain(tctx->lp_ctx); r.in.account_ou = NULL; r.in.Account = admin_account; r.in.password = NULL; r.in.join_flags = 0; torture_comment(tctx, "Testing NetrJoinDomain\n"); status = dcerpc_wkssvc_NetrJoinDomain_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrJoinDomain failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED, "NetrJoinDomain failed"); return true; }
static bool test_NetrValidateName2(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetrValidateName2 r; uint16_t levels[] = {0,1,2,3,4,5}; int i; struct dcerpc_binding_handle *b = p->binding_handle; for (i=0; i<ARRAY_SIZE(levels); i++) { r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.name = lpcfg_workgroup(tctx->lp_ctx); r.in.Account = NULL; r.in.EncryptedPassword = NULL; r.in.name_type = levels[i]; torture_comment(tctx, "Testing NetrValidateName2 level %u\n", r.in.name_type); status = dcerpc_wkssvc_NetrValidateName2_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrValidateName2 failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_RPC_E_REMOTE_DISABLED, "NetrValidateName2 failed"); } return true; }
/* Check that we are able to receive the certificate of the DCs * used for client wrap version of the backup key protocol */ static bool test_RetreiveBackupKeyGUID(struct torture_context *tctx, struct dcerpc_pipe *p) { struct dcerpc_binding_handle *b = p->binding_handle; DATA_BLOB out_blob; struct bkrp_BackupKey *r = createRetreiveBackupKeyGUIDStruct(tctx, p, 2, &out_blob); if (r == NULL) { return false; } if (p->conn->security_state.auth_info != NULL && p->conn->security_state.auth_info->auth_level == 6) { torture_assert_ntstatus_ok(tctx, dcerpc_bkrp_BackupKey_r(b, tctx, r), "Get GUID"); out_blob.length = *r->out.data_out_len; torture_assert_werr_equal(tctx, r->out.result, WERR_OK, "Wrong dce/rpc error code"); } else { torture_assert_ntstatus_equal(tctx, dcerpc_bkrp_BackupKey_r(b, tctx, r), NT_STATUS_ACCESS_DENIED, "Get GUID"); } return true; }
static bool test_NetrUseGetInfo_level(struct torture_context *tctx, struct dcerpc_pipe *p, const char *use_name, uint32_t level, WERROR werr) { NTSTATUS status; struct wkssvc_NetrUseGetInfo r; union wkssvc_NetrUseGetInfoCtr ctr; struct dcerpc_binding_handle *b = p->binding_handle; ZERO_STRUCT(ctr); r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.use_name = use_name; r.in.level = level; r.out.ctr = &ctr; status = dcerpc_wkssvc_NetrUseGetInfo_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrUseGetInfo failed"); torture_assert_werr_equal(tctx, r.out.result, werr, "NetrUseGetInfo failed"); return true; }
static bool test_dir_refuses_null_location(struct torture_context *tctx) { torture_assert_werr_equal(tctx, WERR_INVALID_PARAM, reg_open_directory(NULL, NULL, NULL), "reg_open_directory accepts NULL location"); return true; }
static bool test_RestoreGUID(struct torture_context *tctx, struct dcerpc_pipe *p) { enum ndr_err_code ndr_err; struct dcerpc_binding_handle *b = p->binding_handle; DATA_BLOB out_blob; struct bkrp_client_side_unwrapped resp; if (p->conn->security_state.auth_info != NULL && p->conn->security_state.auth_info->auth_level == 6) { struct bkrp_BackupKey *r = createRestoreGUIDStruct(tctx, p, 2, &out_blob, false, false, false, false, false, false, false); torture_assert_ntstatus_ok(tctx, dcerpc_bkrp_BackupKey_r(b, tctx, r), "Restore GUID"); out_blob.length = *r->out.data_out_len; ndr_err = ndr_pull_struct_blob(&out_blob, tctx, &resp, (ndr_pull_flags_fn_t)ndr_pull_bkrp_client_side_unwrapped); torture_assert_int_equal(tctx, NDR_ERR_CODE_IS_SUCCESS(ndr_err), 1, "Unable to unmarshall bkrp_client_side_unwrapped"); torture_assert_werr_equal(tctx, r->out.result, WERR_OK, "Restore GUID"); torture_assert_str_equal(tctx, (char*)resp.secret.data, secret, "Wrong secret"); } else { struct bkrp_BackupKey *r = createRetreiveBackupKeyGUIDStruct(tctx, p, 2, &out_blob); torture_assert_ntstatus_equal(tctx, dcerpc_bkrp_BackupKey_r(b, tctx, r), NT_STATUS_ACCESS_DENIED, "Get GUID"); } return true; }
static bool test_witness_UnRegister_with_handle(struct torture_context *tctx, struct dcerpc_pipe *p, struct policy_handle *context_handle) { struct dcerpc_binding_handle *b = p->binding_handle; struct witness_UnRegister r; r.in.context_handle = *context_handle; torture_assert_ntstatus_ok(tctx, dcerpc_witness_UnRegister_r(b, tctx, &r), "UnRegister failed"); torture_assert_werr_ok(tctx, r.out.result, "UnRegister failed"); /* make sure we are not able/allowed to reuse context handles after they * have been unregistered */ torture_assert_ntstatus_ok(tctx, dcerpc_witness_UnRegister_r(b, tctx, &r), "UnRegister failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PARAMETER, "UnRegister failed"); return true; }
static bool test_GetPrinterData(struct torture_context *tctx, struct dcerpc_binding_handle *b, struct policy_handle *handle, const char *value_name, WERROR expected_werr, uint32_t expected_value) { NTSTATUS status; struct spoolss_GetPrinterData gpd; uint32_t needed; enum winreg_Type type; uint8_t *data = talloc_zero_array(tctx, uint8_t, 4); torture_comment(tctx, "Testing GetPrinterData(%s).\n", value_name); gpd.in.handle = handle; gpd.in.value_name = value_name; gpd.in.offered = 4; gpd.out.needed = &needed; gpd.out.type = &type; gpd.out.data = data; status = dcerpc_spoolss_GetPrinterData_r(b, tctx, &gpd); torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed."); torture_assert_werr_equal(tctx, gpd.out.result, expected_werr, "GetPrinterData did not return expected error value."); if (W_ERROR_IS_OK(expected_werr)) { uint32_t value = IVAL(data, 0); torture_assert_int_equal(tctx, value, expected_value, talloc_asprintf(tctx, "GetPrinterData for %s did not return expected value.", value_name)); } return true; }
static bool test_NetrUseAdd(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetrUseAdd r; struct wkssvc_NetrUseInfo0 info0; struct wkssvc_NetrUseInfo1 info1; union wkssvc_NetrUseGetInfoCtr *ctr; uint32_t parm_err = 0; struct dcerpc_binding_handle *b = p->binding_handle; ctr = talloc(tctx, union wkssvc_NetrUseGetInfoCtr); ZERO_STRUCT(info0); info0.local = SMBTORTURE_USE_NAME; info0.remote = "\\\\localhost\\c$"; ctr->info0 = &info0; r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.level = 0; r.in.ctr = ctr; r.in.parm_err = r.out.parm_err = &parm_err; torture_comment(tctx, "Testing NetrUseAdd level %u\n", r.in.level); status = dcerpc_wkssvc_NetrUseAdd_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrUseAdd failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_UNKNOWN_LEVEL, "NetrUseAdd failed"); ZERO_STRUCT(r); ZERO_STRUCT(info1); info1.local = SMBTORTURE_USE_NAME; info1.remote = "\\\\localhost\\sysvol"; info1.password = NULL; ctr->info1 = &info1; r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.level = 1; r.in.ctr = ctr; r.in.parm_err = r.out.parm_err = &parm_err; torture_comment(tctx, "Testing NetrUseAdd level %u\n", r.in.level); status = dcerpc_wkssvc_NetrUseAdd_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrUseAdd failed"); torture_assert_werr_ok(tctx, r.out.result, "NetrUseAdd failed"); return true; }
static bool test_PNP_GetDeviceList(struct torture_context *tctx, struct dcerpc_pipe *p) { struct dcerpc_binding_handle *b = p->binding_handle; struct PNP_GetDeviceList r; uint16_t *buffer = NULL; uint32_t length = 0; buffer = talloc_array(tctx, uint16_t, 0); r.in.filter = NULL; r.in.flags = CM_GETIDLIST_FILTER_SERVICE; r.in.length = &length; r.out.length = &length; r.out.buffer = buffer; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceList_r(b, tctx, &r), "PNP_GetDeviceList failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER, "PNP_GetDeviceList failed"); r.in.filter = "Spooler"; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceList_r(b, tctx, &r), "PNP_GetDeviceList failed"); if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) { struct PNP_GetDeviceListSize s; s.in.devicename = "Spooler"; s.in.flags = CM_GETIDLIST_FILTER_SERVICE; s.out.size = &length; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceListSize_r(b, tctx, &s), "PNP_GetDeviceListSize failed"); torture_assert_werr_ok(tctx, s.out.result, "PNP_GetDeviceListSize failed"); } buffer = talloc_array(tctx, uint16_t, length); r.in.length = &length; r.out.length = &length; r.out.buffer = buffer; torture_assert_ntstatus_ok(tctx, dcerpc_PNP_GetDeviceList_r(b, tctx, &r), "PNP_GetDeviceList failed"); torture_assert_werr_ok(tctx, r.out.result, "PNP_GetDeviceList failed"); return true; }
static bool test_netprintqgetinfo(struct torture_context *tctx, struct smbcli_state *cli) { struct rap_NetPrintQGetInfo r; struct rap_NetPrintQEnum r_enum; int i, p; uint16_t levels[] = { 0, 1, 2, 3, 4, 5 }; r.in.level = 0; r.in.bufsize = 0; r.in.PrintQueueName = ""; torture_assert_ntstatus_ok(tctx, smbcli_rap_netprintqgetinfo(cli->tree, tctx, &r), "smbcli_rap_netprintqgetinfo failed"); torture_assert_werr_equal(tctx, W_ERROR(r.out.status), WERR_INVALID_PARAMETER, "smbcli_rap_netprintqgetinfo failed"); r_enum.in.level = 5; r_enum.in.bufsize = 8192; torture_assert_ntstatus_ok(tctx, smbcli_rap_netprintqenum(cli->tree, tctx, &r_enum), "failed to enum printq"); torture_assert_werr_ok(tctx, W_ERROR(r_enum.out.status), "failed to enum printq"); for (p=0; p < r_enum.out.count; p++) { for (i=0; i < ARRAY_SIZE(levels); i++) { r.in.level = levels[i]; r.in.bufsize = 8192; r.in.PrintQueueName = r_enum.out.info[p].info5.PrintQueueName; torture_comment(tctx, "Testing rap_NetPrintQGetInfo(%s) level %d\n", r.in.PrintQueueName, r.in.level); torture_assert_ntstatus_ok(tctx, smbcli_rap_netprintqgetinfo(cli->tree, tctx, &r), "smbcli_rap_netprintqgetinfo failed"); torture_assert_werr_ok(tctx, W_ERROR(r.out.status), "smbcli_rap_netprintqgetinfo failed"); switch (r.in.level) { case 0: printf("%s\n", r.out.info.info0.PrintQName); break; } } } return true; }
static bool test_del_nonexistant_key(struct torture_context *tctx, const void *test_data) { const struct hive_key *root = (const struct hive_key *)test_data; WERROR error = hive_key_del(tctx, root, "bla"); torture_assert_werr_equal(tctx, error, WERR_BADFILE, "invalid return code"); return true; }
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; }
static bool querymultiplevalues_out_check(struct torture_context *tctx, struct winreg_QueryMultipleValues *r) { torture_assert_str_equal(tctx, r->out.values_out[0].ve_valuename->name, "HOMEPATH", "name"); torture_assert_int_equal(tctx, r->out.values_out[0].ve_type, 0, "type"); torture_assert_int_equal(tctx, r->out.values_out[0].ve_valuelen, 0, "length"); /* FIXME: r->out.buffer */ torture_assert_int_equal(tctx, *r->out.buffer_size, 76, "buffer size"); torture_assert_werr_equal(tctx, r->out.result, WERR_MORE_DATA, "return code"); return true; }
static bool test_QueryServiceObjectSecurity(struct torture_context *tctx, struct dcerpc_pipe *p) { struct svcctl_QueryServiceObjectSecurity r; struct policy_handle h, s; uint8_t *buffer; uint32_t needed; if (!test_OpenSCManager(p, tctx, &h)) return false; if (!test_OpenService(p, tctx, &h, TORTURE_DEFAULT_SERVICE, &s)) return false; r.in.handle = &s; r.in.security_flags = 0; r.in.offered = 0; r.out.buffer = NULL; r.out.needed = &needed; torture_assert_ntstatus_ok(tctx, dcerpc_svcctl_QueryServiceObjectSecurity(p, tctx, &r), "QueryServiceObjectSecurity failed!"); torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PARAM, "QueryServiceObjectSecurity failed!"); r.in.security_flags = SECINFO_DACL; torture_assert_ntstatus_ok(tctx, dcerpc_svcctl_QueryServiceObjectSecurity(p, tctx, &r), "QueryServiceObjectSecurity failed!"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { r.in.offered = needed; buffer = talloc_array(tctx, uint8_t, needed); r.out.buffer = buffer; torture_assert_ntstatus_ok(tctx, dcerpc_svcctl_QueryServiceObjectSecurity(p, tctx, &r), "QueryServiceObjectSecurity failed!"); } torture_assert_werr_ok(tctx, r.out.result, "QueryServiceObjectSecurity failed!"); if (!test_CloseServiceHandle(p, tctx, &s)) return false; if (!test_CloseServiceHandle(p, tctx, &h)) return false; return true; }
static bool test_NetrWkstaUserGetInfo(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetrWkstaUserGetInfo r; union wkssvc_NetrWkstaUserInfo info; const char *dom = lpcfg_workgroup(tctx->lp_ctx); struct cli_credentials *creds = cmdline_credentials; const char *user = cli_credentials_get_username(creds); int i; struct dcerpc_binding_handle *b = p->binding_handle; const struct { const char *unknown; uint32_t level; WERROR result; } tests[] = { { NULL, 0, WERR_NO_SUCH_LOGON_SESSION }, { NULL, 1, WERR_NO_SUCH_LOGON_SESSION }, { NULL, 1101, WERR_OK }, { dom, 0, WERR_INVALID_PARAM }, { dom, 1, WERR_INVALID_PARAM }, { dom, 1101, WERR_INVALID_PARAM }, { user, 0, WERR_INVALID_PARAM }, { user, 1, WERR_INVALID_PARAM }, { user, 1101, WERR_INVALID_PARAM }, }; for (i=0; i<ARRAY_SIZE(tests); i++) { r.in.unknown = tests[i].unknown; r.in.level = tests[i].level; r.out.info = &info; torture_comment(tctx, "Testing NetrWkstaUserGetInfo level %u\n", r.in.level); status = dcerpc_wkssvc_NetrWkstaUserGetInfo_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrWkstaUserGetInfo failed"); torture_assert_werr_equal(tctx, r.out.result, tests[i].result, "NetrWkstaUserGetInfo failed"); } return true; }
static bool test_NetrLogonDomainNameDel(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetrLogonDomainNameDel r; struct dcerpc_binding_handle *b = p->binding_handle; r.in.domain_name = lpcfg_workgroup(tctx->lp_ctx); torture_comment(tctx, "Testing NetrLogonDomainNameDel\n"); status = dcerpc_wkssvc_NetrLogonDomainNameDel_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrLogonDomainNameDel failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED, "NetrLogonDomainNameDel failed"); return true; }
static bool test_del_key(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; error = hive_key_add_name(mem_ctx, root, "Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_del(mem_ctx, root, "Nested Key"); torture_assert_werr_ok(tctx, error, "reg_key_del"); error = hive_key_del(mem_ctx, root, "Nested Key"); torture_assert_werr_equal(tctx, error, WERR_BADFILE, "reg_key_del"); return true; }
static bool test_openprinter_handle(struct torture_context *tctx, struct dcerpc_pipe *p, const char *name, const char *printername, const char *username, uint32_t access_mask, WERROR expected_result, struct policy_handle *handle) { struct spoolss_OpenPrinterEx r; struct spoolss_UserLevel1 level1; struct dcerpc_binding_handle *b = p->binding_handle; level1.size = 28; level1.client = talloc_asprintf(tctx, "\\\\%s", "smbtorture"); level1.user = username; level1.build = 1381; level1.major = 3; level1.minor = 0; level1.processor= 0; r.in.printername = printername; r.in.datatype = NULL; r.in.devmode_ctr.devmode= NULL; r.in.access_mask = access_mask; r.in.userlevel_ctr.level = 1; r.in.userlevel_ctr.user_info.level1 = &level1; r.out.handle = handle; torture_comment(tctx, "Testing OpenPrinterEx(%s) with access_mask 0x%08x (%s)\n", r.in.printername, r.in.access_mask, name); torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_OpenPrinterEx_r(b, tctx, &r), "OpenPrinterEx failed"); torture_assert_werr_equal(tctx, r.out.result, expected_result, talloc_asprintf(tctx, "OpenPrinterEx(%s) as '%s' with access_mask: 0x%08x (%s) failed", r.in.printername, username, r.in.access_mask, name)); return true; }
static bool test_list_values(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; char data[4]; uint32_t type; DATA_BLOB value; const char *name; int data_val = 42; SIVAL(data, 0, data_val); error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, data_blob_talloc(mem_ctx, data, sizeof(data))); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, &type, &value); torture_assert_werr_ok(tctx, error, "getting value"); torture_assert_str_equal(tctx, name, "Answer", "value name"); torture_assert_int_equal(tctx, value.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); torture_assert_int_equal(tctx, data_val, IVAL(value.data, 0), "value data"); error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &value); torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, "getting missing value"); return true; }
static bool test_NetrRenameMachineInDomain(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetrRenameMachineInDomain r; struct dcerpc_binding_handle *b = p->binding_handle; r.in.server_name = dcerpc_server_name(p); r.in.NewMachineName = SMBTORTURE_MACHINE_NAME; r.in.Account = NULL; r.in.password = NULL; r.in.RenameOptions = 0; torture_comment(tctx, "Testing NetrRenameMachineInDomain\n"); status = dcerpc_wkssvc_NetrRenameMachineInDomain_r(b, tctx, &r); torture_assert_ntstatus_ok(tctx, status, "NetrRenameMachineInDomain failed"); torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED, "NetrRenameMachineInDomain failed"); return true; }
static bool test_list_values(struct torture_context *tctx, const void *test_data) { WERROR error; struct hive_key *subkey; const struct hive_key *root = (const struct hive_key *)test_data; TALLOC_CTX *mem_ctx = tctx; uint32_t type; uint8_t d[] = { 0x42, 0x00, 0x00, 0x00 }; DATA_BLOB db = { d, 4 }, data; const char *name; error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL, NULL, &subkey); torture_assert_werr_ok(tctx, error, "hive_key_add_name"); error = hive_key_set_value(subkey, "Answer", REG_DWORD, db); torture_assert_werr_ok(tctx, error, "hive_key_set_value"); error = hive_get_value_by_index(mem_ctx, subkey, 0, &name, &type, &data); torture_assert_werr_ok(tctx, error, "getting value"); torture_assert_str_equal(tctx, name, "Answer", "value name"); torture_assert_int_equal(tctx, data.length, 4, "value length"); torture_assert_int_equal(tctx, type, REG_DWORD, "value type"); torture_assert_mem_equal(tctx, data.data, db.data, 4, "value data"); error = hive_get_value_by_index(mem_ctx, subkey, 1, &name, &type, &data); torture_assert_werr_equal(tctx, error, WERR_NO_MORE_ITEMS, "getting missing value"); return true; }