Changeset 740 for vendor/current/source4/torture/rpc/lsa_lookup.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified vendor/current/source4/torture/rpc/lsa_lookup.c ¶
r414 r740 20 20 21 21 #include "includes.h" 22 #include "torture/torture.h" 23 #include "lib/events/events.h" 24 #include "libnet/libnet_join.h" 25 #include "torture/rpc/rpc.h" 22 #include "torture/rpc/torture_rpc.h" 26 23 #include "librpc/gen_ndr/ndr_lsa_c.h" 27 24 #include "libcli/security/security.h" 28 25 29 static bool open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, 26 static bool open_policy(struct torture_context *tctx, 27 struct dcerpc_binding_handle *b, 30 28 struct policy_handle **handle) 31 29 { … … 33 31 struct lsa_QosInfo qos; 34 32 struct lsa_OpenPolicy2 r; 35 NTSTATUS status; 36 37 *handle = talloc(mem_ctx, struct policy_handle); 33 34 *handle = talloc(tctx, struct policy_handle); 38 35 if (!*handle) { 39 36 return false; … … 57 54 r.out.handle = *handle; 58 55 59 status = dcerpc_lsa_OpenPolicy2(p, mem_ctx, &r); 60 61 return NT_STATUS_IS_OK(status); 62 } 63 64 static bool get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, 56 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenPolicy2_r(b, tctx, &r), 57 "OpenPolicy2 failed"); 58 59 return NT_STATUS_IS_OK(r.out.result); 60 } 61 62 static bool get_domainsid(struct torture_context *tctx, 63 struct dcerpc_binding_handle *b, 65 64 struct policy_handle *handle, 66 65 struct dom_sid **sid) … … 68 67 struct lsa_QueryInfoPolicy r; 69 68 union lsa_PolicyInformation *info = NULL; 70 NTSTATUS status;71 69 72 70 r.in.level = LSA_POLICY_INFO_DOMAIN; … … 74 72 r.out.info = &info; 75 73 76 status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r); 77 if (!NT_STATUS_IS_OK(status)) return false; 74 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryInfoPolicy_r(b, tctx, &r), 75 "QueryInfoPolicy failed"); 76 torture_assert_ntstatus_ok(tctx, r.out.result, "QueryInfoPolicy failed"); 78 77 79 78 *sid = info->domain.sid; … … 81 80 } 82 81 83 static NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, uint16_t level, 84 struct dcerpc_pipe *p, 82 static NTSTATUS lookup_sids(struct torture_context *tctx, 83 uint16_t level, 84 struct dcerpc_binding_handle *b, 85 85 struct policy_handle *handle, 86 86 struct dom_sid **sids, uint32_t num_sids, … … 92 92 uint32_t count = 0; 93 93 uint32_t i; 94 NTSTATUS status; 94 95 95 96 names->count = 0; … … 97 98 98 99 sidarray.num_sids = num_sids; 99 sidarray.sids = talloc_array( mem_ctx, struct lsa_SidPtr, num_sids);100 sidarray.sids = talloc_array(tctx, struct lsa_SidPtr, num_sids); 100 101 101 102 for (i=0; i<num_sids; i++) { … … 112 113 r.out.domains = &domains; 113 114 114 return dcerpc_lsa_LookupSids(p, mem_ctx, &r); 115 } 116 117 static const char *sid_type_lookup(enum lsa_SidType r) 118 { 119 switch (r) { 120 case SID_NAME_USE_NONE: return "SID_NAME_USE_NONE"; break; 121 case SID_NAME_USER: return "SID_NAME_USER"; break; 122 case SID_NAME_DOM_GRP: return "SID_NAME_DOM_GRP"; break; 123 case SID_NAME_DOMAIN: return "SID_NAME_DOMAIN"; break; 124 case SID_NAME_ALIAS: return "SID_NAME_ALIAS"; break; 125 case SID_NAME_WKN_GRP: return "SID_NAME_WKN_GRP"; break; 126 case SID_NAME_DELETED: return "SID_NAME_DELETED"; break; 127 case SID_NAME_INVALID: return "SID_NAME_INVALID"; break; 128 case SID_NAME_UNKNOWN: return "SID_NAME_UNKNOWN"; break; 129 case SID_NAME_COMPUTER: return "SID_NAME_COMPUTER"; break; 130 } 131 return "Invalid sid type\n"; 132 } 133 134 static bool test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, 115 status = dcerpc_lsa_LookupSids_r(b, tctx, &r); 116 if (!NT_STATUS_IS_OK(status)) { 117 return status; 118 } 119 return r.out.result; 120 } 121 122 static bool test_lookupsids(struct torture_context *tctx, 123 struct dcerpc_binding_handle *b, 135 124 struct policy_handle *handle, 136 125 struct dom_sid **sids, uint32_t num_sids, … … 143 132 bool ret = true; 144 133 145 status = lookup_sids( mem_ctx, level, p, handle, sids, num_sids,134 status = lookup_sids(tctx, level, b, handle, sids, num_sids, 146 135 &names); 147 136 if (!NT_STATUS_EQUAL(status, expected_result)) { … … 161 150 printf("In level %d, for sid %s expected %s, " 162 151 "got %s\n", level, 163 dom_sid_string( mem_ctx, sids[i]),152 dom_sid_string(tctx, sids[i]), 164 153 sid_type_lookup(types[i]), 165 154 sid_type_lookup(names.names[i].sid_type)); … … 170 159 } 171 160 172 static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_ pipe *p,161 static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_binding_handle *b, 173 162 struct policy_handle *handle, 174 163 struct dom_sid **sid) … … 177 166 uint32_t resume_handle = 0; 178 167 struct lsa_DomainList domains; 179 NTSTATUS status;180 168 int i; 181 169 … … 186 174 r.out.resume_handle = &resume_handle; 187 175 188 status = dcerpc_lsa_EnumTrustDom(p, tctx, &r); 189 190 if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) 176 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumTrustDom_r(b, tctx, &r), 177 "EnumTrustDom failed"); 178 179 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_NO_MORE_ENTRIES)) 191 180 torture_fail(tctx, "no trusts"); 192 181 … … 207 196 q.out.info = &info; 208 197 209 status = dcerpc_lsa_QueryTrustedDomainInfoBySid(p, tctx, &q); 210 if (!NT_STATUS_IS_OK(status)) continue; 198 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryTrustedDomainInfoBySid_r(b, tctx, &q), 199 "QueryTrustedDomainInfoBySid failed"); 200 if (!NT_STATUS_IS_OK(q.out.result)) continue; 211 201 212 202 if ((info->info_ex.trust_direction & 2) && … … 228 218 bool ret = true; 229 219 struct policy_handle *handle; 230 struct dom_sid *dom_sid ;231 struct dom_sid *trusted_sid ;220 struct dom_sid *dom_sid = NULL; 221 struct dom_sid *trusted_sid = NULL; 232 222 struct dom_sid *sids[NUM_SIDS]; 223 struct dcerpc_binding_handle *b; 233 224 234 225 status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc); … … 236 227 torture_fail(torture, "unable to connect to table"); 237 228 } 238 239 ret &= open_policy(torture, p, &handle); 229 b = p->binding_handle; 230 231 ret &= open_policy(torture, b, &handle); 240 232 if (!ret) return false; 241 233 242 ret &= get_domainsid(torture, p, handle, &dom_sid);234 ret &= get_domainsid(torture, b, handle, &dom_sid); 243 235 if (!ret) return false; 244 236 245 ret &= get_downleveltrust(torture, p, handle, &trusted_sid);237 ret &= get_downleveltrust(torture, b, handle, &trusted_sid); 246 238 if (!ret) return false; 247 239 … … 258 250 sids[7] = dom_sid_add_rid(torture, trusted_sid, 512); 259 251 260 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 0,252 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 0, 261 253 NT_STATUS_INVALID_PARAMETER, NULL); 262 254 … … 267 259 SID_NAME_DOMAIN, SID_NAME_DOM_GRP }; 268 260 269 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 1,261 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 1, 270 262 NT_STATUS_OK, types); 271 263 } … … 277 269 SID_NAME_DOMAIN, SID_NAME_DOM_GRP, 278 270 SID_NAME_DOMAIN, SID_NAME_DOM_GRP }; 279 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 2,271 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 2, 280 272 STATUS_SOME_UNMAPPED, types); 281 273 } … … 287 279 SID_NAME_DOMAIN, SID_NAME_DOM_GRP, 288 280 SID_NAME_UNKNOWN, SID_NAME_UNKNOWN }; 289 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 3,281 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 3, 290 282 STATUS_SOME_UNMAPPED, types); 291 283 } … … 297 289 SID_NAME_DOMAIN, SID_NAME_DOM_GRP, 298 290 SID_NAME_UNKNOWN, SID_NAME_UNKNOWN }; 299 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 4,291 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 4, 300 292 STATUS_SOME_UNMAPPED, types); 301 293 } 302 294 303 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 5,295 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 5, 304 296 NT_STATUS_NONE_MAPPED, NULL); 305 297 … … 310 302 SID_NAME_DOMAIN, SID_NAME_DOM_GRP, 311 303 SID_NAME_UNKNOWN, SID_NAME_UNKNOWN }; 312 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 6,304 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 6, 313 305 STATUS_SOME_UNMAPPED, types); 314 306 } 315 307 316 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 7,308 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 7, 317 309 NT_STATUS_INVALID_PARAMETER, NULL); 318 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 8,310 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 8, 319 311 NT_STATUS_INVALID_PARAMETER, NULL); 320 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 9,312 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 9, 321 313 NT_STATUS_INVALID_PARAMETER, NULL); 322 ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 10,314 ret &= test_lookupsids(torture, b, handle, sids, NUM_SIDS, 10, 323 315 NT_STATUS_INVALID_PARAMETER, NULL); 324 316 … … 341 333 342 334 uint32_t i; 343 NTSTATUS status;344 335 const char *dom_sid = "S-1-5-21-1111111111-2222222222-3333333333"; 345 336 const char *dom_admin_sid; 346 347 if (!open_policy(tctx, p, &handle)) { 337 struct dcerpc_binding_handle *b = p->binding_handle; 338 339 if (!open_policy(tctx, b, &handle)) { 348 340 return false; 349 341 } … … 374 366 r.out.domains = &domains; 375 367 376 status = dcerpc_lsa_LookupSids(p, tctx, &r); 377 378 torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NONE_MAPPED, 368 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupSids_r(b, tctx, &r), 369 "LookupSids failed"); 370 371 torture_assert_ntstatus_equal(tctx, r.out.result, NT_STATUS_NONE_MAPPED, 379 372 "unexpected error code"); 380 373 … … 405 398 struct torture_rpc_tcase *tcase; 406 399 407 suite = torture_suite_create(mem_ctx, " LSA-LOOKUPSIDS");400 suite = torture_suite_create(mem_ctx, "lsa.lookupsids"); 408 401 tcase = torture_suite_add_rpc_iface_tcase(suite, "lsa", 409 402 &ndr_table_lsarpc);
Note:
See TracChangeset
for help on using the changeset viewer.