Changeset 745 for trunk/server/librpc/rpc
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 3 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/librpc/rpc/binding.c
r414 r745 24 24 25 25 #include "includes.h" 26 #include "../../lib/util/util_net.h" 26 27 #include "librpc/gen_ndr/ndr_epmapper.h" 27 28 #include "librpc/gen_ndr/ndr_misc.h" 28 29 #include "librpc/rpc/dcerpc.h" 30 #include "rpc_common.h" 31 29 32 #undef strcasecmp 33 #undef strncasecmp 30 34 31 35 #define MAX_PROTSEQ 10 … … 86 90 {"smb2", DCERPC_SMB2}, 87 91 {"hdrsign", DCERPC_HEADER_SIGNING}, 88 {"ndr64", DCERPC_NDR64} 92 {"ndr64", DCERPC_NDR64}, 93 {"localaddress", DCERPC_LOCALADDRESS} 89 94 }; 90 95 … … 114 119 } else { /* IPX */ 115 120 return talloc_asprintf(mem_ctx, "IPX:%s", 116 data_blob_hex_string (mem_ctx, &epm_floor->rhs.uuid.unknown));121 data_blob_hex_string_upper(mem_ctx, &epm_floor->rhs.uuid.unknown)); 117 122 } 118 123 … … 220 225 for (i=0;i<ARRAY_SIZE(ncacn_options);i++) { 221 226 if (b->flags & ncacn_options[i].flag) { 222 s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name); 227 if (ncacn_options[i].flag == DCERPC_LOCALADDRESS && b->localaddress) { 228 s = talloc_asprintf_append_buffer(s, ",%s=%s", ncacn_options[i].name, 229 b->localaddress); 230 } else { 231 s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name); 232 } 223 233 if (!s) return NULL; 224 234 } … … 240 250 int i, j, comma_count; 241 251 242 b = talloc (mem_ctx, struct dcerpc_binding);252 b = talloc_zero(mem_ctx, struct dcerpc_binding); 243 253 if (!b) { 244 254 return NT_STATUS_NO_MEMORY; … … 313 323 b->assoc_group_id = 0; 314 324 b->endpoint = NULL; 325 b->localaddress = NULL; 315 326 316 327 if (!options) { … … 339 350 for (i=0;b->options[i];i++) { 340 351 for (j=0;j<ARRAY_SIZE(ncacn_options);j++) { 341 if (strcasecmp(ncacn_options[j].name, b->options[i]) == 0) { 352 size_t opt_len = strlen(ncacn_options[j].name); 353 if (strncasecmp(ncacn_options[j].name, b->options[i], opt_len) == 0) { 342 354 int k; 355 char c = b->options[i][opt_len]; 356 357 if (ncacn_options[j].flag == DCERPC_LOCALADDRESS && c == '=') { 358 b->localaddress = talloc_strdup(b, &b->options[i][opt_len+1]); 359 } else if (c != 0) { 360 continue; 361 } 362 343 363 b->flags |= ncacn_options[j].flag; 344 364 for (k=i;b->options[k];k++) { … … 376 396 uint16_t if_version=0; 377 397 378 ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx , NULL);398 ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx); 379 399 if (ndr == NULL) { 380 400 talloc_free(mem_ctx); … … 404 424 static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax) 405 425 { 406 struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx, NULL); 426 DATA_BLOB blob; 427 struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx); 407 428 408 429 ndr->flags |= LIBNDR_FLAG_NOALIGN; … … 411 432 ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version); 412 433 413 return ndr_push_blob(ndr); 434 blob = ndr_push_blob(ndr); 435 talloc_steal(mem_ctx, blob.data); 436 talloc_free(ndr); 437 return blob; 438 } 439 440 static bool dcerpc_floor_pack_rhs_if_version_data( 441 TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax, 442 DATA_BLOB *pblob) 443 { 444 DATA_BLOB blob; 445 struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx); 446 enum ndr_err_code ndr_err; 447 448 if (ndr == NULL) { 449 return false; 450 } 451 452 ndr->flags |= LIBNDR_FLAG_NOALIGN; 453 454 ndr_err = ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version >> 16); 455 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 456 return false; 457 } 458 459 blob = ndr_push_blob(ndr); 460 talloc_steal(mem_ctx, blob.data); 461 talloc_free(ndr); 462 *pblob = blob; 463 return true; 414 464 } 415 465 … … 608 658 } 609 659 610 _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 611 struct epm_tower *tower,612 struct dcerpc_binding **b_out)660 _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 661 struct epm_tower *tower, 662 struct dcerpc_binding **b_out) 613 663 { 614 664 NTSTATUS status; 615 665 struct dcerpc_binding *binding; 616 666 617 binding = talloc(mem_ctx, struct dcerpc_binding); 667 /* 668 * A tower needs to have at least 4 floors to carry useful 669 * information. Floor 3 is the transport identifier which defines 670 * how many floors are required at least. 671 */ 672 if (tower->num_floors < 4) { 673 return NT_STATUS_INVALID_PARAMETER; 674 } 675 676 binding = talloc_zero(mem_ctx, struct dcerpc_binding); 618 677 NT_STATUS_HAVE_NO_MEMORY(binding); 619 678 … … 631 690 } 632 691 633 if (tower->num_floors < 1) {634 return NT_STATUS_OK;635 }636 637 692 /* Set object uuid */ 638 693 status = dcerpc_floor_get_lhs_data(&tower->floors[0], &binding->object); 639 694 640 695 if (!NT_STATUS_IS_OK(status)) { 641 DEBUG(1, ("Error pulling object uuid and version: %s", nt_errstr(status))); 696 DEBUG(1, ("Error pulling object uuid and version: %s", nt_errstr(status))); 642 697 return status; 643 698 } … … 649 704 /* Set endpoint */ 650 705 if (tower->num_floors >= 4) { 651 binding->endpoint = dcerpc_floor_get_rhs_data( mem_ctx, &tower->floors[3]);706 binding->endpoint = dcerpc_floor_get_rhs_data(binding, &tower->floors[3]); 652 707 } else { 653 708 binding->endpoint = NULL; … … 656 711 /* Set network address */ 657 712 if (tower->num_floors >= 5) { 658 binding->host = dcerpc_floor_get_rhs_data( mem_ctx, &tower->floors[4]);713 binding->host = dcerpc_floor_get_rhs_data(binding, &tower->floors[4]); 659 714 NT_STATUS_HAVE_NO_MEMORY(binding->host); 660 715 binding->target_hostname = binding->host; … … 662 717 *b_out = binding; 663 718 return NT_STATUS_OK; 719 } 720 721 _PUBLIC_ struct dcerpc_binding *dcerpc_binding_dup(TALLOC_CTX *mem_ctx, 722 const struct dcerpc_binding *b) 723 { 724 struct dcerpc_binding *n; 725 uint32_t count; 726 727 n = talloc_zero(mem_ctx, struct dcerpc_binding); 728 if (n == NULL) { 729 return NULL; 730 } 731 732 n->transport = b->transport; 733 n->object = b->object; 734 n->flags = b->flags; 735 n->assoc_group_id = b->assoc_group_id; 736 737 if (b->host != NULL) { 738 n->host = talloc_strdup(n, b->host); 739 if (n->host == NULL) { 740 talloc_free(n); 741 return NULL; 742 } 743 } 744 745 if (b->target_hostname != NULL) { 746 n->target_hostname = talloc_strdup(n, b->target_hostname); 747 if (n->target_hostname == NULL) { 748 talloc_free(n); 749 return NULL; 750 } 751 } 752 753 if (b->target_principal != NULL) { 754 n->target_principal = talloc_strdup(n, b->target_principal); 755 if (n->target_principal == NULL) { 756 talloc_free(n); 757 return NULL; 758 } 759 } 760 761 if (b->localaddress != NULL) { 762 n->localaddress = talloc_strdup(n, b->localaddress); 763 if (n->localaddress == NULL) { 764 talloc_free(n); 765 return NULL; 766 } 767 } 768 769 if (b->endpoint != NULL) { 770 n->endpoint = talloc_strdup(n, b->endpoint); 771 if (n->endpoint == NULL) { 772 talloc_free(n); 773 return NULL; 774 } 775 } 776 777 for (count = 0; b->options && b->options[count]; count++); 778 779 if (count > 0) { 780 uint32_t i; 781 782 n->options = talloc_array(n, const char *, count + 1); 783 if (n->options == NULL) { 784 talloc_free(n); 785 return NULL; 786 } 787 788 for (i = 0; i < count; i++) { 789 n->options[i] = talloc_strdup(n->options, b->options[i]); 790 if (n->options[i] == NULL) { 791 talloc_free(n); 792 return NULL; 793 } 794 } 795 n->options[count] = NULL; 796 } 797 798 return n; 664 799 } 665 800 … … 692 827 tower->floors[0].lhs.protocol = EPM_PROTOCOL_UUID; 693 828 694 tower->floors[0].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, &binding->object); 695 696 tower->floors[0].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2); 829 tower->floors[0].lhs.lhs_data = dcerpc_floor_pack_lhs_data(tower->floors, &binding->object); 830 831 if (!dcerpc_floor_pack_rhs_if_version_data( 832 tower->floors, &binding->object, 833 &tower->floors[0].rhs.uuid.unknown)) { 834 return NT_STATUS_NO_MEMORY; 835 } 697 836 698 837 /* Floor 1 */ 699 838 tower->floors[1].lhs.protocol = EPM_PROTOCOL_UUID; 700 839 701 tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data( mem_ctx,840 tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(tower->floors, 702 841 &ndr_transfer_syntax); 703 842 704 tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero( mem_ctx, 2);843 tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero(tower->floors, 2); 705 844 706 845 /* Floor 2 to num_protocols */ 707 846 for (i = 0; i < num_protocols; i++) { 708 847 tower->floors[2 + i].lhs.protocol = protseq[i]; 709 tower->floors[2 + i].lhs.lhs_data = data_blob_talloc( mem_ctx, NULL, 0);848 tower->floors[2 + i].lhs.lhs_data = data_blob_talloc(tower->floors, NULL, 0); 710 849 ZERO_STRUCT(tower->floors[2 + i].rhs); 711 dcerpc_floor_set_rhs_data( mem_ctx, &tower->floors[2 + i], "");850 dcerpc_floor_set_rhs_data(tower->floors, &tower->floors[2 + i], ""); 712 851 } 713 852 714 853 /* The 4th floor contains the endpoint */ 715 854 if (num_protocols >= 2 && binding->endpoint) { 716 status = dcerpc_floor_set_rhs_data( mem_ctx, &tower->floors[3], binding->endpoint);855 status = dcerpc_floor_set_rhs_data(tower->floors, &tower->floors[3], binding->endpoint); 717 856 if (NT_STATUS_IS_ERR(status)) { 718 857 return status; … … 722 861 /* The 5th contains the network address */ 723 862 if (num_protocols >= 3 && binding->host) { 724 if (is_ipaddress(binding->host)) { 725 status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4], 863 if (is_ipaddress(binding->host) || 864 (binding->host[0] == '\\' && binding->host[1] == '\\')) { 865 status = dcerpc_floor_set_rhs_data(tower->floors, &tower->floors[4], 726 866 binding->host); 727 867 } else { … … 731 871 a wildcard all-zeros IP for the server to 732 872 fill in */ 733 status = dcerpc_floor_set_rhs_data( mem_ctx, &tower->floors[4],873 status = dcerpc_floor_set_rhs_data(tower->floors, &tower->floors[4], 734 874 "0.0.0.0"); 735 875 } -
trunk/server/librpc/rpc/dcerpc_error.c
r596 r745 22 22 #include "includes.h" 23 23 #include "librpc/rpc/dcerpc.h" 24 #include "rpc_common.h" 24 25 25 26 struct dcerpc_fault_table { … … 30 31 static const struct dcerpc_fault_table dcerpc_faults[] = 31 32 { 32 { "DCERPC_FAULT_OP_RNG_ERROR", DCERPC_FAULT_OP_RNG_ERROR }, 33 { "DCERPC_FAULT_UNK_IF", DCERPC_FAULT_UNK_IF }, 34 { "DCERPC_FAULT_NDR", DCERPC_FAULT_NDR }, 35 { "DCERPC_FAULT_INVALID_TAG", DCERPC_FAULT_INVALID_TAG }, 36 { "DCERPC_FAULT_CONTEXT_MISMATCH", DCERPC_FAULT_CONTEXT_MISMATCH }, 37 { "DCERPC_FAULT_OTHER", DCERPC_FAULT_OTHER }, 38 { "DCERPC_FAULT_ACCESS_DENIED", DCERPC_FAULT_ACCESS_DENIED }, 39 { "DCERPC_FAULT_SEC_PKG_ERROR", DCERPC_FAULT_SEC_PKG_ERROR }, 40 41 { NULL, 0} 33 #define _FAULT_STR(x) { #x , x } 34 _FAULT_STR(DCERPC_NCA_S_COMM_FAILURE), 35 _FAULT_STR(DCERPC_NCA_S_OP_RNG_ERROR), 36 _FAULT_STR(DCERPC_NCA_S_UNKNOWN_IF), 37 _FAULT_STR(DCERPC_NCA_S_WRONG_BOOT_TIME), 38 _FAULT_STR(DCERPC_NCA_S_YOU_CRASHED), 39 _FAULT_STR(DCERPC_NCA_S_PROTO_ERROR), 40 _FAULT_STR(DCERPC_NCA_S_OUT_ARGS_TOO_BIG), 41 _FAULT_STR(DCERPC_NCA_S_SERVER_TOO_BUSY), 42 _FAULT_STR(DCERPC_NCA_S_FAULT_STRING_TOO_LARGE), 43 _FAULT_STR(DCERPC_NCA_S_UNSUPPORTED_TYPE), 44 _FAULT_STR(DCERPC_NCA_S_FAULT_INT_DIV_BY_ZERO), 45 _FAULT_STR(DCERPC_NCA_S_FAULT_ADDR_ERROR), 46 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_DIV_BY_ZERO), 47 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_UNDERFLOW), 48 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_OVERRFLOW), 49 _FAULT_STR(DCERPC_NCA_S_FAULT_INVALID_TAG), 50 _FAULT_STR(DCERPC_NCA_S_FAULT_INVALID_BOUND), 51 _FAULT_STR(DCERPC_NCA_S_FAULT_RPC_VERSION_MISMATCH), 52 _FAULT_STR(DCERPC_NCA_S_FAULT_UNSPEC_REJECT), 53 _FAULT_STR(DCERPC_NCA_S_FAULT_BAD_ACTID), 54 _FAULT_STR(DCERPC_NCA_S_FAULT_WHO_ARE_YOU_FAILED), 55 _FAULT_STR(DCERPC_NCA_S_FAULT_MANAGER_NOT_ENTERED), 56 _FAULT_STR(DCERPC_NCA_S_FAULT_CANCEL), 57 _FAULT_STR(DCERPC_NCA_S_FAULT_ILL_INST), 58 _FAULT_STR(DCERPC_NCA_S_FAULT_FP_ERROR), 59 _FAULT_STR(DCERPC_NCA_S_FAULT_INT_OVERFLOW), 60 _FAULT_STR(DCERPC_NCA_S_UNUSED_1C000011), 61 _FAULT_STR(DCERPC_NCA_S_FAULT_UNSPEC), 62 _FAULT_STR(DCERPC_NCA_S_FAULT_REMOTE_COMM_FAILURE), 63 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_EMPTY), 64 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_CLOSED), 65 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_ORDER), 66 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_DISCIPLINE), 67 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_COMM_ERROR), 68 _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_MEMORY), 69 _FAULT_STR(DCERPC_NCA_S_FAULT_CONTEXT_MISMATCH), 70 _FAULT_STR(DCERPC_NCA_S_FAULT_REMOTE_NO_MEMORY), 71 _FAULT_STR(DCERPC_NCA_S_INVALID_PRES_CONTEXT_ID), 72 _FAULT_STR(DCERPC_NCA_S_UNSUPPORTED_AUTHN_LEVEL), 73 _FAULT_STR(DCERPC_NCA_S_UNUSED_1C00001E), 74 _FAULT_STR(DCERPC_NCA_S_INVALID_CHECKSUM), 75 _FAULT_STR(DCERPC_NCA_S_INVALID_CRC), 76 _FAULT_STR(DCERPC_NCA_S_FAULT_USER_DEFINED), 77 _FAULT_STR(DCERPC_NCA_S_FAULT_TX_OPEN_FAILED), 78 _FAULT_STR(DCERPC_NCA_S_FAULT_CODESET_CONV_ERROR), 79 _FAULT_STR(DCERPC_NCA_S_FAULT_OBJECT_NOT_FOUND), 80 _FAULT_STR(DCERPC_NCA_S_FAULT_NO_CLIENT_STUB), 81 { NULL, 0 } 82 #undef _FAULT_STR 42 83 }; 43 84 … … 45 86 { 46 87 int idx = 0; 88 WERROR werr = W_ERROR(fault_code); 47 89 48 90 while (dcerpc_faults[idx].errstr != NULL) { … … 53 95 } 54 96 55 return talloc_asprintf(mem_ctx, "DCERPC fault 0x%08x", fault_code);97 return win_errstr(werr); 56 98 } 99 100 _PUBLIC_ NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code) 101 { 102 /* TODO: add more mappings */ 103 switch (fault_code) { 104 case DCERPC_FAULT_OP_RNG_ERROR: 105 return NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE; 106 case DCERPC_FAULT_UNK_IF: 107 return NT_STATUS_RPC_UNKNOWN_IF; 108 case DCERPC_FAULT_NDR: 109 return NT_STATUS_RPC_BAD_STUB_DATA; 110 case DCERPC_FAULT_INVALID_TAG: 111 return NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE; 112 case DCERPC_FAULT_CONTEXT_MISMATCH: 113 return NT_STATUS_RPC_SS_CONTEXT_MISMATCH; 114 case DCERPC_FAULT_OTHER: 115 return NT_STATUS_RPC_CALL_FAILED; 116 case DCERPC_FAULT_ACCESS_DENIED: 117 return NT_STATUS_ACCESS_DENIED; 118 case DCERPC_FAULT_SEC_PKG_ERROR: 119 return NT_STATUS_RPC_SEC_PKG_ERROR; 120 } 121 122 return NT_STATUS_RPC_PROTOCOL_ERROR; 123 } 124
Note:
See TracChangeset
for help on using the changeset viewer.