Changeset 427 for vendor/current/source4
- Timestamp:
- Apr 9, 2010, 3:20:58 PM (15 years ago)
- Location:
- vendor/current/source4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
r414 r427 123 123 * PrintServer PrinterData functions 124 124 */ 125 static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, 126 struct spoolss_GetPrinterData *r) 125 126 static WERROR sptr_PrintServerData(struct ntptr_GenericHandle *server, 127 TALLOC_CTX *mem_ctx, 128 const char *value_name, 129 union spoolss_PrinterData *r, 130 enum winreg_Type *type) 127 131 { 128 132 struct dcerpc_server_info *server_info = lp_dcerpc_server_info(mem_ctx, server->ntptr->lp_ctx); 129 if (strcmp("W3SvcInstalled", r->in.value_name) == 0) {130 * r->out.type = REG_DWORD;131 r-> out.data->value = 0;133 if (strcmp("W3SvcInstalled", value_name) == 0) { 134 *type = REG_DWORD; 135 r->value = 0; 132 136 return WERR_OK; 133 } else if (strcmp("BeepEnabled", r->in.value_name) == 0) {134 * r->out.type = REG_DWORD;135 r-> out.data->value = 0;137 } else if (strcmp("BeepEnabled", value_name) == 0) { 138 *type = REG_DWORD; 139 r->value = 0; 136 140 return WERR_OK; 137 } else if (strcmp("EventLog", r->in.value_name) == 0) {138 * r->out.type = REG_DWORD;139 r-> out.data->value = 0;141 } else if (strcmp("EventLog", value_name) == 0) { 142 *type = REG_DWORD; 143 r->value = 0; 140 144 return WERR_OK; 141 } else if (strcmp("NetPopup", r->in.value_name) == 0) {142 * r->out.type = REG_DWORD;143 r-> out.data->value = 0;145 } else if (strcmp("NetPopup", value_name) == 0) { 146 *type = REG_DWORD; 147 r->value = 0; 144 148 return WERR_OK; 145 } else if (strcmp("NetPopupToComputer", r->in.value_name) == 0) {146 * r->out.type = REG_DWORD;147 r-> out.data->value = 0;149 } else if (strcmp("NetPopupToComputer", value_name) == 0) { 150 *type = REG_DWORD; 151 r->value = 0; 148 152 return WERR_OK; 149 } else if (strcmp("MajorVersion", r->in.value_name) == 0) {150 * r->out.type = REG_DWORD;151 r-> out.data->value = 3;153 } else if (strcmp("MajorVersion", value_name) == 0) { 154 *type = REG_DWORD; 155 r->value = 3; 152 156 return WERR_OK; 153 } else if (strcmp("MinorVersion", r->in.value_name) == 0) {154 * r->out.type = REG_DWORD;155 r-> out.data->value = 0;157 } else if (strcmp("MinorVersion", value_name) == 0) { 158 *type = REG_DWORD; 159 r->value = 0; 156 160 return WERR_OK; 157 } else if (strcmp("DefaultSpoolDirectory", r->in.value_name) == 0) { 158 *r->out.type = REG_SZ; 159 r->out.data->string = "C:\\PRINTERS"; 161 } else if (strcmp("DefaultSpoolDirectory", value_name) == 0) { 162 *type = REG_SZ; 163 r->string = talloc_strdup(mem_ctx, "C:\\PRINTERS"); 164 W_ERROR_HAVE_NO_MEMORY(r->string); 160 165 return WERR_OK; 161 } else if (strcmp("Architecture", r->in.value_name) == 0) { 162 *r->out.type = REG_SZ; 163 r->out.data->string = SPOOLSS_ARCHITECTURE_NT_X86; 166 } else if (strcmp("Architecture", value_name) == 0) { 167 *type = REG_SZ; 168 r->string = talloc_strdup(mem_ctx, SPOOLSS_ARCHITECTURE_NT_X86); 169 W_ERROR_HAVE_NO_MEMORY(r->string); 164 170 return WERR_OK; 165 } else if (strcmp("DsPresent", r->in.value_name) == 0) {166 * r->out.type = REG_DWORD;167 r-> out.data->value = 1;171 } else if (strcmp("DsPresent", value_name) == 0) { 172 *type = REG_DWORD; 173 r->value = 1; 168 174 return WERR_OK; 169 } else if (strcmp("OSVersion", r->in.value_name) == 0) {175 } else if (strcmp("OSVersion", value_name) == 0) { 170 176 DATA_BLOB blob; 171 177 enum ndr_err_code ndr_err; … … 182 188 } 183 189 184 * r->out.type = REG_BINARY;185 r-> out.data->binary = blob;190 *type = REG_BINARY; 191 r->binary = blob; 186 192 return WERR_OK; 187 } else if (strcmp("OSVersionEx", r->in.value_name) == 0) {193 } else if (strcmp("OSVersionEx", value_name) == 0) { 188 194 DATA_BLOB blob; 189 195 enum ndr_err_code ndr_err; … … 205 211 } 206 212 207 * r->out.type = REG_BINARY;208 r-> out.data->binary = blob;213 *type = REG_BINARY; 214 r->binary = blob; 209 215 return WERR_OK; 210 } else if (strcmp("DNSMachineName", r->in.value_name) == 0) {216 } else if (strcmp("DNSMachineName", value_name) == 0) { 211 217 if (!lp_realm(server->ntptr->lp_ctx)) return WERR_INVALID_PARAM; 212 218 213 * r->out.type = REG_SZ;214 r-> out.data->string = talloc_asprintf(mem_ctx, "%s.%s",215 216 217 W_ERROR_HAVE_NO_MEMORY(r-> out.data->string);219 *type = REG_SZ; 220 r->string = talloc_asprintf(mem_ctx, "%s.%s", 221 lp_netbios_name(server->ntptr->lp_ctx), 222 lp_realm(server->ntptr->lp_ctx)); 223 W_ERROR_HAVE_NO_MEMORY(r->string); 218 224 return WERR_OK; 219 225 } 220 226 221 227 return WERR_INVALID_PARAM; 228 } 229 230 static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx, 231 struct spoolss_GetPrinterData *r) 232 { 233 WERROR result; 234 union spoolss_PrinterData data; 235 DATA_BLOB blob; 236 enum ndr_err_code ndr_err; 237 238 result = sptr_PrintServerData(server, mem_ctx, r->in.value_name, &data, r->out.type); 239 if (!W_ERROR_IS_OK(result)) { 240 return result; 241 } 242 243 ndr_err = ndr_push_union_blob(&blob, mem_ctx, lp_iconv_convenience(server->ntptr->lp_ctx), 244 &data, *r->out.type, (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterData); 245 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 246 return WERR_GENERAL_FAILURE; 247 } 248 249 *r->out.needed = blob.length; 250 251 if (r->in.offered >= *r->out.needed) { 252 memcpy(r->out.data, blob.data, blob.length); 253 } 254 255 return WERR_OK; 222 256 } 223 257 -
vendor/current/source4/rpc_server/spoolss/dcesrv_spoolss.c
r414 r427 580 580 W_ERROR_HAVE_NO_MEMORY(r->out.needed); 581 581 582 r->out.data = talloc_zero (mem_ctx, union spoolss_PrinterData);582 r->out.data = talloc_zero_array(mem_ctx, uint8_t, r->in.offered); 583 583 W_ERROR_HAVE_NO_MEMORY(r->out.data); 584 584 … … 599 599 W_ERROR_NOT_OK_RETURN(status); 600 600 601 *r->out.needed = ndr_size_spoolss_PrinterData(r->out.data, *r->out.type, ic, 0);602 601 *r->out.type = SPOOLSS_BUFFER_OK(*r->out.type, REG_NONE); 603 602 r->out.data = SPOOLSS_BUFFER_OK(r->out.data, r->out.data); -
vendor/current/source4/torture/rpc/spoolss.c
r414 r427 29 29 #include "librpc/gen_ndr/ndr_spoolss_c.h" 30 30 #include "param/param.h" 31 #include "lib/registry/registry.h" 31 32 32 33 #define TORTURE_WELLKNOWN_PRINTER "torture_wkn_printer" … … 119 120 120 121 #define CHECK_NEEDED_SIZE_ENUM_LEVEL(fn, info, level, count, ic, needed, align) do { \ 122 if (torture_setting_bool(tctx, "spoolss_check_size", false)) {\ 121 123 uint32_t size = ndr_size_##fn##_info(tctx, ic, level, count, info);\ 122 124 uint32_t round_size = DO_ROUND(size, align);\ … … 125 127 CHECK_ALIGN(size, align);\ 126 128 }\ 129 }\ 127 130 } while(0) 128 131 129 132 #define CHECK_NEEDED_SIZE_ENUM(fn, info, count, ic, needed, align) do { \ 133 if (torture_setting_bool(tctx, "spoolss_check_size", false)) {\ 130 134 uint32_t size = ndr_size_##fn##_info(tctx, ic, count, info);\ 131 135 uint32_t round_size = DO_ROUND(size, align);\ … … 134 138 CHECK_ALIGN(size, align);\ 135 139 }\ 140 }\ 136 141 } while(0) 137 142 138 143 #define CHECK_NEEDED_SIZE_LEVEL(fn, info, level, ic, needed, align) do { \ 144 if (torture_setting_bool(tctx, "spoolss_check_size", false)) {\ 139 145 uint32_t size = ndr_size_##fn(info, level, ic, 0);\ 140 146 uint32_t round_size = DO_ROUND(size, align);\ … … 142 148 torture_warning(tctx, __location__": "#fn" level %d got unexpected needed size: %d, we calculated: %d", level, needed, round_size);\ 143 149 CHECK_ALIGN(size, align);\ 150 }\ 144 151 }\ 145 152 } while(0) … … 2186 2193 const char *value_name, 2187 2194 enum winreg_Type *type_p, 2188 union spoolss_PrinterData *data_p) 2195 uint8_t **data_p, 2196 uint32_t *needed_p) 2189 2197 { 2190 2198 NTSTATUS status; … … 2199 2207 r.out.needed = &needed; 2200 2208 r.out.type = &type; 2201 r.out.data = &data;2209 r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered); 2202 2210 2203 2211 torture_comment(tctx, "Testing GetPrinterData(%s)\n", r.in.value_name); … … 2208 2216 if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { 2209 2217 r.in.offered = needed; 2210 2218 r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered); 2211 2219 status = dcerpc_spoolss_GetPrinterData(p, tctx, &r); 2212 2220 torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed"); … … 2223 2231 2224 2232 if (data_p) { 2225 *data_p = data; 2233 *data_p = r.out.data; 2234 } 2235 2236 if (needed_p) { 2237 *needed_p = needed; 2226 2238 } 2227 2239 … … 2235 2247 const char *value_name, 2236 2248 enum winreg_Type *type_p, 2237 union spoolss_PrinterData *data_p) 2249 uint8_t **data_p, 2250 uint32_t *needed_p) 2238 2251 { 2239 2252 NTSTATUS status; … … 2249 2262 r.out.type = &type; 2250 2263 r.out.needed = &needed; 2251 r.out.data = &data;2264 r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered); 2252 2265 2253 2266 torture_comment(tctx, "Testing GetPrinterDataEx(%s - %s)\n", … … 2265 2278 if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { 2266 2279 r.in.offered = needed; 2280 r.out.data = talloc_zero_array(tctx, uint8_t, r.in.offered); 2267 2281 status = dcerpc_spoolss_GetPrinterDataEx(p, tctx, &r); 2268 2282 torture_assert_ntstatus_ok(tctx, status, "GetPrinterDataEx failed"); … … 2279 2293 2280 2294 if (data_p) { 2281 *data_p = data; 2295 *data_p = r.out.data; 2296 } 2297 2298 if (needed_p) { 2299 *needed_p = needed; 2282 2300 } 2283 2301 … … 2308 2326 for (i=0; i < ARRAY_SIZE(list); i++) { 2309 2327 enum winreg_Type type, type_ex; 2310 union spoolss_PrinterData data, data_ex; 2311 2312 torture_assert(tctx, test_GetPrinterData(tctx, p, handle, list[i], &type, &data), 2328 uint8_t *data, *data_ex; 2329 uint32_t needed, needed_ex; 2330 2331 torture_assert(tctx, test_GetPrinterData(tctx, p, handle, list[i], &type, &data, &needed), 2313 2332 talloc_asprintf(tctx, "GetPrinterData failed on %s\n", list[i])); 2314 torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, "random_string", list[i], &type_ex, &data_ex ),2333 torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, "random_string", list[i], &type_ex, &data_ex, &needed_ex), 2315 2334 talloc_asprintf(tctx, "GetPrinterDataEx failed on %s\n", list[i])); 2316 2335 torture_assert_int_equal(tctx, type, type_ex, "type mismatch"); 2317 switch (type) { 2318 case REG_SZ: 2319 torture_assert_str_equal(tctx, data.string, data_ex.string, "REG_SZ mismatch"); 2320 break; 2321 case REG_DWORD: 2322 torture_assert_int_equal(tctx, data.value, data_ex.value, "REG_DWORD mismatch"); 2323 break; 2324 case REG_BINARY: 2325 torture_assert_data_blob_equal(tctx, data.binary, data_ex.binary, "REG_BINARY mismatch"); 2326 break; 2327 default: 2328 break; 2329 } 2336 torture_assert_int_equal(tctx, needed, needed_ex, "needed mismatch"); 2337 torture_assert_mem_equal(tctx, data, data_ex, needed, "data mismatch"); 2330 2338 } 2331 2339 … … 2380 2388 torture_assert_werr_ok(tctx, r.out.result, "EnumPrinterData failed"); 2381 2389 2382 torture_assert(tctx, test_GetPrinterData(tctx, p, handle, r.out.value_name, NULL, NULL ),2390 torture_assert(tctx, test_GetPrinterData(tctx, p, handle, r.out.value_name, NULL, NULL, NULL), 2383 2391 talloc_asprintf(tctx, "failed to call GetPrinterData for %s\n", r.out.value_name)); 2384 2392 2385 torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", r.out.value_name, NULL, NULL ),2393 torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", r.out.value_name, NULL, NULL, NULL), 2386 2394 talloc_asprintf(tctx, "failed to call GetPrinterDataEx on PrinterDriverData for %s\n", r.out.value_name)); 2387 2395 … … 2526 2534 2527 2535 enum winreg_Type type; 2528 union spoolss_PrinterData data; 2536 uint8_t *data; 2537 DATA_BLOB blob; 2538 uint32_t needed; 2539 2540 torture_assert(tctx, 2541 reg_string_to_val(tctx, lp_iconv_convenience(tctx->lp_ctx), 2542 "REG_SZ", "dog", &r.in.type, &blob), ""); 2529 2543 2530 2544 r.in.handle = handle; 2531 2545 r.in.value_name = values[i]; 2532 2546 r.in.type = REG_SZ; 2533 r.in.data.string = "dog"; 2547 r.in.data = blob.data; 2548 r.in.offered = blob.length; 2534 2549 2535 2550 torture_comment(tctx, "Testing SetPrinterData(%s)\n", … … 2541 2556 torture_assert_werr_ok(tctx, r.out.result, "SetPrinterData failed"); 2542 2557 2543 if (!test_GetPrinterData(tctx, p, handle, r.in.value_name, &type, &data )) {2558 if (!test_GetPrinterData(tctx, p, handle, r.in.value_name, &type, &data, &needed)) { 2544 2559 return false; 2545 2560 } 2546 2561 2547 2562 torture_assert_int_equal(tctx, r.in.type, type, "type mismatch"); 2548 torture_assert_str_equal(tctx, r.in.data.string, data.string, "data mismatch"); 2563 torture_assert_int_equal(tctx, r.in.offered, needed, "size mismatch"); 2564 torture_assert_mem_equal(tctx, blob.data, data, needed, "buffer mismatch"); 2549 2565 2550 2566 if (!test_DeletePrinterData(tctx, p, handle, r.in.value_name)) { … … 2600 2616 enum winreg_Type type; 2601 2617 const char **subkeys; 2602 union spoolss_PrinterData data; 2618 uint8_t *data_out; 2619 uint32_t needed; 2603 2620 2604 2621 r.in.handle = handle; … … 2606 2623 r.in.value_name = value_name; 2607 2624 r.in.type = REG_BINARY; 2608 r.in.data.binary = blob; 2625 r.in.data = blob.data; 2626 r.in.offered = blob.length; 2609 2627 2610 2628 torture_comment(tctx, "Testing SetPrinterDataEx(%s - %s)\n", r.in.key_name, value_name); … … 2615 2633 torture_assert_werr_ok(tctx, r.out.result, "SetPrinterDataEx failed"); 2616 2634 2617 key = talloc_strdup(tctx, r.in.key_name); 2618 2619 if (!test_GetPrinterDataEx(tctx, p, handle, r.in.key_name, value_name, &type, &data)) { 2635 if (!test_GetPrinterDataEx(tctx, p, handle, keys[i], value_name, &type, &data_out, &needed)) { 2620 2636 return false; 2621 2637 } 2622 2638 2623 torture_assert_int_equal(tctx, r.in.type, type, "type mismatch"); 2624 torture_assert_data_blob_equal(tctx, blob, data.binary, "data mismatch"); 2639 torture_assert_int_equal(tctx, type, REG_BINARY, "type mismatch"); 2640 torture_assert_int_equal(tctx, needed, blob.length, "size mismatch"); 2641 torture_assert_mem_equal(tctx, data_out, blob.data, blob.length, "buffer mismatch"); 2642 2643 key = talloc_strdup(tctx, keys[i]); 2625 2644 2626 2645 if (!test_EnumPrinterDataEx(tctx, p, handle, r.in.key_name)) { … … 2673 2692 { 2674 2693 enum winreg_Type type; 2675 union spoolss_PrinterData data; 2694 uint8_t *data; 2695 uint32_t needed; 2676 2696 2677 2697 torture_assert(tctx, 2678 test_GetPrinterData(tctx, p, handle, "ChangeID", &type, &data ),2698 test_GetPrinterData(tctx, p, handle, "ChangeID", &type, &data, &needed), 2679 2699 "failed to call GetPrinterData"); 2680 2700 2681 2701 torture_assert(tctx, type == REG_DWORD, "unexpected type"); 2682 2683 *change_id = data.value; 2702 torture_assert_int_equal(tctx, needed, 4, "unexpected size"); 2703 2704 *change_id = IVAL(data, 0); 2684 2705 2685 2706 return true; … … 2692 2713 { 2693 2714 enum winreg_Type type; 2694 union spoolss_PrinterData data; 2715 uint8_t *data; 2716 uint32_t needed; 2695 2717 2696 2718 torture_assert(tctx, 2697 test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", "ChangeID", &type, &data ),2719 test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", "ChangeID", &type, &data, &needed), 2698 2720 "failed to call GetPrinterData"); 2699 2721 2700 2722 torture_assert(tctx, type == REG_DWORD, "unexpected type"); 2701 2702 *change_id = data.value; 2723 torture_assert_int_equal(tctx, needed, 4, "unexpected size"); 2724 2725 *change_id = IVAL(data, 0); 2703 2726 2704 2727 return true; -
vendor/current/source4/torture/rpc/spoolss_win.c
r414 r427 161 161 uint32_t needed; 162 162 enum winreg_Type type; 163 u nion spoolss_PrinterData data;163 uint8_t *data = talloc_zero_array(tctx, uint8_t, 4); 164 164 165 165 torture_comment(tctx, "Testing GetPrinterData(%s).\n", value_name); … … 169 169 gpd.out.needed = &needed; 170 170 gpd.out.type = &type; 171 gpd.out.data = &data;171 gpd.out.data = data; 172 172 173 173 status = dcerpc_spoolss_GetPrinterData(p, tctx, &gpd); … … 177 177 178 178 if (W_ERROR_IS_OK(expected_werr)) { 179 torture_assert_int_equal(tctx, data.value, 179 uint32_t value = IVAL(data, 0); 180 torture_assert_int_equal(tctx, value, 180 181 expected_value, 181 182 talloc_asprintf(tctx, "GetPrinterData for %s did not return expected value.", value_name));
Note:
See TracChangeset
for help on using the changeset viewer.