Ignore:
Timestamp:
May 13, 2014, 11:39:04 AM (11 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update trunk to 3.6.23

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/winbindd/winbindd_msrpc.c

    r745 r862  
    3636#define DBGC_CLASS DBGC_WINBIND
    3737
     38static NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
     39                                      struct winbindd_domain *domain,
     40                                      uint32_t num_names,
     41                                      const char **names,
     42                                      const char ***domains,
     43                                      struct dom_sid **sids,
     44                                      enum lsa_SidType **types);
    3845
    3946/* Query display info for a domain.  This returns enough information plus a
     
    738745                   care of freeing the temporary arrays later on. */
    739746
    740                 if (tmp_names.count != tmp_types.count) {
    741                         return NT_STATUS_UNSUCCESSFUL;
     747                if (tmp_names.count != num_lookup_rids) {
     748                        return NT_STATUS_INVALID_NETWORK_RESPONSE;
     749                }
     750                if (tmp_types.count != num_lookup_rids) {
     751                        return NT_STATUS_INVALID_NETWORK_RESPONSE;
    742752                }
    743753
     
    745755                        if (tmp_types.ids[r] == SID_NAME_UNKNOWN) {
    746756                                continue;
     757                        }
     758                        if (total_names >= *num_names) {
     759                                break;
    747760                        }
    748761                        (*names)[total_names] = fill_domain_username_talloc(
     
    938951
    939952        status = cm_connect_lsa(domain, tmp_ctx, &lsa_pipe, &lsa_policy);
    940         if (!NT_STATUS_IS_OK(status))
    941                 return status;
     953        if (!NT_STATUS_IS_OK(status)) {
     954                goto done;
     955        }
    942956
    943957        status = rpc_trusted_domains(tmp_ctx,
     
    10571071        return status;
    10581072}
    1059 
    1060 typedef NTSTATUS (*lookup_sids_fn_t)(struct dcerpc_binding_handle *h,
    1061                                      TALLOC_CTX *mem_ctx,
    1062                                      struct policy_handle *pol,
    1063                                      int num_sids,
    1064                                      const struct dom_sid *sids,
    1065                                      char ***pdomains,
    1066                                      char ***pnames,
    1067                                      enum lsa_SidType **ptypes,
    1068                                      NTSTATUS *result);
    10691073
    10701074NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
     
    10821086        struct policy_handle lsa_policy;
    10831087        unsigned int orig_timeout;
    1084         lookup_sids_fn_t lookup_sids_fn = dcerpc_lsa_lookup_sids;
    1085 
    1086         if (domain->can_do_ncacn_ip_tcp) {
    1087                 status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
    1088                 if (NT_STATUS_IS_OK(status)) {
    1089                         lookup_sids_fn = dcerpc_lsa_lookup_sids3;
    1090                         goto lookup;
    1091                 }
    1092                 domain->can_do_ncacn_ip_tcp = false;
    1093         }
    1094         status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
    1095 
     1088        bool use_lookupsids3 = false;
     1089        bool retried = false;
     1090
     1091 connect:
     1092        status = cm_connect_lsat(domain, mem_ctx, &cli, &lsa_policy);
    10961093        if (!NT_STATUS_IS_OK(status)) {
    10971094                return status;
    10981095        }
    10991096
    1100  lookup:
    11011097        b = cli->binding_handle;
     1098
     1099        if (cli->transport->transport == NCACN_IP_TCP) {
     1100                use_lookupsids3 = true;
     1101        }
    11021102
    11031103        /*
     
    11081108        orig_timeout = dcerpc_binding_handle_set_timeout(b, 35000);
    11091109
    1110         status = lookup_sids_fn(b,
    1111                                 mem_ctx,
    1112                                 &lsa_policy,
    1113                                 num_sids,
    1114                                 sids,
    1115                                 domains,
    1116                                 names,
    1117                                 types,
    1118                                 &result);
     1110        status = dcerpc_lsa_lookup_sids_generic(b,
     1111                                                mem_ctx,
     1112                                                &lsa_policy,
     1113                                                num_sids,
     1114                                                sids,
     1115                                                domains,
     1116                                                names,
     1117                                                types,
     1118                                                use_lookupsids3,
     1119                                                &result);
    11191120
    11201121        /* And restore our original timeout. */
     
    11221123
    11231124        if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
    1124             NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) {
     1125            NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR) ||
     1126            NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_ACCESS_DENIED)) {
    11251127                /*
    11261128                 * This can happen if the schannel key is not
     
    11301132                 */
    11311133                invalidate_cm_connection(&domain->conn);
     1134                domain->can_do_ncacn_ip_tcp = domain->active_directory;
     1135                if (!retried) {
     1136                        retried = true;
     1137                        goto connect;
     1138                }
    11321139                status = NT_STATUS_ACCESS_DENIED;
    11331140        }
     
    11441151}
    11451152
    1146 typedef NTSTATUS (*lookup_names_fn_t)(struct dcerpc_binding_handle *h,
    1147                                       TALLOC_CTX *mem_ctx,
    1148                                       struct policy_handle *pol,
     1153static NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
     1154                                      struct winbindd_domain *domain,
    11491155                                      uint32_t num_names,
    11501156                                      const char **names,
    1151                                       const char ***dom_names,
    1152                                       enum lsa_LookupNamesLevel level,
     1157                                      const char ***domains,
    11531158                                      struct dom_sid **sids,
    1154                                       enum lsa_SidType **types,
    1155                                       NTSTATUS *result);
    1156 
    1157 NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
    1158                                struct winbindd_domain *domain,
    1159                                uint32_t num_names,
    1160                                const char **names,
    1161                                const char ***domains,
    1162                                struct dom_sid **sids,
    1163                                enum lsa_SidType **types)
     1159                                      enum lsa_SidType **types)
    11641160{
    11651161        NTSTATUS status;
     
    11691165        struct policy_handle lsa_policy;
    11701166        unsigned int orig_timeout = 0;
    1171         lookup_names_fn_t lookup_names_fn = dcerpc_lsa_lookup_names;
    1172 
    1173         if (domain->can_do_ncacn_ip_tcp) {
    1174                 status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
    1175                 if (NT_STATUS_IS_OK(status)) {
    1176                         lookup_names_fn = dcerpc_lsa_lookup_names4;
    1177                         goto lookup;
    1178                 }
    1179                 domain->can_do_ncacn_ip_tcp = false;
    1180         }
    1181         status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
    1182 
     1167        bool use_lookupnames4 = false;
     1168        bool retried = false;
     1169
     1170 connect:
     1171        status = cm_connect_lsat(domain, mem_ctx, &cli, &lsa_policy);
    11831172        if (!NT_STATUS_IS_OK(status)) {
    11841173                return status;
    11851174        }
    11861175
    1187  lookup:
    11881176        b = cli->binding_handle;
     1177
     1178        if (cli->transport->transport == NCACN_IP_TCP) {
     1179                use_lookupnames4 = true;
     1180        }
    11891181
    11901182        /*
     
    11951187        orig_timeout = dcerpc_binding_handle_set_timeout(b, 35000);
    11961188
    1197         status = lookup_names_fn(b,
    1198                                  mem_ctx,
    1199                                  &lsa_policy,
    1200                                  num_names,
    1201                                  (const char **) names,
    1202                                  domains,
    1203                                  1,
    1204                                  sids,
    1205                                  types,
    1206                                  &result);
     1189        status = dcerpc_lsa_lookup_names_generic(b,
     1190                                                 mem_ctx,
     1191                                                 &lsa_policy,
     1192                                                 num_names,
     1193                                                 (const char **) names,
     1194                                                 domains,
     1195                                                 1,
     1196                                                 sids,
     1197                                                 types,
     1198                                                 use_lookupnames4,
     1199                                                 &result);
    12071200
    12081201        /* And restore our original timeout. */
     
    12101203
    12111204        if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
    1212             NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) {
     1205            NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR) ||
     1206            NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_ACCESS_DENIED)) {
    12131207                /*
    12141208                 * This can happen if the schannel key is not
     
    12181212                 */
    12191213                invalidate_cm_connection(&domain->conn);
     1214                if (!retried) {
     1215                        retried = true;
     1216                        goto connect;
     1217                }
    12201218                status = NT_STATUS_ACCESS_DENIED;
    12211219        }
Note: See TracChangeset for help on using the changeset viewer.