Ignore:
Timestamp:
May 20, 2009, 6:46:53 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/winbindd/winbindd_cm.c

    r149 r204  
    847847                        if (NT_STATUS_IS_OK(result)) {
    848848                                /* Ensure creds are stored for NTLMSSP authenticated pipe access. */
    849                                 cli_init_creds(*cli, machine_account, domain->name, machine_password);
     849                                cli_init_creds(*cli, machine_account, lp_workgroup(), machine_password);
    850850                                goto session_setup_done;
    851851                        }
     
    872872                if (NT_STATUS_IS_OK(result)) {
    873873                        /* Ensure creds are stored for NTLMSSP authenticated pipe access. */
    874                         cli_init_creds(*cli, machine_account, domain->name, machine_password);
     874                        cli_init_creds(*cli, machine_account, lp_workgroup(), machine_password);
    875875                        goto session_setup_done;
    876876                }
     
    909909
    910910        /* Fall back to anonymous connection, this might fail later */
     911        DEBUG(10,("cm_prepare_connection: falling back to anonymous "
     912                "connection for DC %s\n",
     913                controller ));
    911914
    912915        if (NT_STATUS_IS_OK(cli_session_setup(*cli, "", NULL, 0,
     
    979982}
    980983
     984/*******************************************************************
     985 Add a dcname and sockaddr_storage pair to the end of a dc_name_ip
     986 array.
     987
     988 Keeps the list unique by not adding duplicate entries.
     989
     990 @param[in] mem_ctx talloc memory context to allocate from
     991 @param[in] domain_name domain of the DC
     992 @param[in] dcname name of the DC to add to the list
     993 @param[in] pss Internet address and port pair to add to the list
     994 @param[in,out] dcs array of dc_name_ip structures to add to
     995 @param[in,out] num_dcs number of dcs returned in the dcs array
     996 @return true if the list was added to, false otherwise
     997*******************************************************************/
     998
    981999static bool add_one_dc_unique(TALLOC_CTX *mem_ctx, const char *domain_name,
    9821000                              const char *dcname, struct sockaddr_storage *pss,
    9831001                              struct dc_name_ip **dcs, int *num)
    9841002{
     1003        int i = 0;
     1004
    9851005        if (!NT_STATUS_IS_OK(check_negative_conn_cache(domain_name, dcname))) {
    9861006                DEBUG(10, ("DC %s was in the negative conn cache\n", dcname));
    9871007                return False;
    9881008        }
     1009
     1010        /* Make sure there's no duplicates in the list */
     1011        for (i=0; i<*num; i++)
     1012                if (addr_equal(&(*dcs)[i].ss, pss))
     1013                        return False;
    9891014
    9901015        *dcs = TALLOC_REALLOC_ARRAY(mem_ctx, *dcs, struct dc_name_ip, (*num)+1);
     
    11181143
    11191144/*******************************************************************
    1120  Retreive a list of IP address for domain controllers.  Fill in
    1121  the dcs[]  with results.
     1145 Retrieve a list of IP addresses for domain controllers.
     1146
     1147 The array is sorted in the preferred connection order.
     1148
     1149 @param[in] mem_ctx talloc memory context to allocate from
     1150 @param[in] domain domain to retrieve DCs for
     1151 @param[out] dcs array of dcs that will be returned
     1152 @param[out] num_dcs number of dcs returned in the dcs array
     1153 @return always true
    11221154*******************************************************************/
    11231155
     
    11351167        is_our_domain = strequal(domain->name, lp_workgroup());
    11361168
     1169        /* If not our domain, get the preferred DC, by asking our primary DC */
    11371170        if ( !is_our_domain
    11381171                && get_dc_name_via_netlogon(domain, dcname, &ss)
    1139                 && add_one_dc_unique(mem_ctx, domain->name, dcname, &ss, dcs, num_dcs) )
     1172                && add_one_dc_unique(mem_ctx, domain->name, dcname, &ss, dcs,
     1173                       num_dcs) )
    11401174        {
    11411175                char addr[INET6_ADDRSTRLEN];
     
    11641198
    11651199                        /* Do the site-specific AD dns lookup first. */
    1166                         get_sorted_dc_list(domain->alt_name, sitename, &ip_list, &iplist_size, True);
    1167 
     1200                        get_sorted_dc_list(domain->alt_name, sitename, &ip_list,
     1201                               &iplist_size, True);
     1202
     1203                        /* Add ips to the DC array.  We don't look up the name
     1204                           of the DC in this function, but we fill in the char*
     1205                           of the ip now to make the failed connection cache
     1206                           work */
    11681207                        for ( i=0; i<iplist_size; i++ ) {
    11691208                                char addr[INET6_ADDRSTRLEN];
     
    11831222                }
    11841223
    1185                 /* Now we add DCs from the main AD dns lookup. */
    1186                 get_sorted_dc_list(domain->alt_name, NULL, &ip_list, &iplist_size, True);
     1224                /* Now we add DCs from the main AD DNS lookup. */
     1225                get_sorted_dc_list(domain->alt_name, NULL, &ip_list,
     1226                        &iplist_size, True);
    11871227
    11881228                for ( i=0; i<iplist_size; i++ ) {
     
    11971237                                        num_dcs);
    11981238                }
     1239
     1240                SAFE_FREE(ip_list);
     1241                iplist_size = 0;
    11991242        }
    12001243
    1201         /* try standard netbios queries if no ADS */
    1202 
    1203         if (iplist_size==0) {
    1204                 get_sorted_dc_list(domain->name, NULL, &ip_list, &iplist_size, False);
    1205         }
    1206 
    1207         /* FIXME!! this is where we should re-insert the GETDC requests --jerry */
    1208 
    1209         /* now add to the dc array.  We'll wait until the last minute
    1210            to look up the name of the DC.  But we fill in the char* for
    1211            the ip now in to make the failed connection cache work */
    1212 
    1213         for ( i=0; i<iplist_size; i++ ) {
    1214                 char addr[INET6_ADDRSTRLEN];
    1215                 print_sockaddr(addr, sizeof(addr),
    1216                                 &ip_list[i].ss);
    1217                 add_one_dc_unique(mem_ctx, domain->name, addr,
    1218                         &ip_list[i].ss, dcs, num_dcs);
    1219         }
    1220 
    1221         SAFE_FREE( ip_list );
     1244        /* Try standard netbios queries if no ADS */
     1245        if (*num_dcs == 0) {
     1246                get_sorted_dc_list(domain->name, NULL, &ip_list, &iplist_size,
     1247                       False);
     1248
     1249                for ( i=0; i<iplist_size; i++ ) {
     1250                        char addr[INET6_ADDRSTRLEN];
     1251                        print_sockaddr(addr, sizeof(addr),
     1252                                        &ip_list[i].ss);
     1253                        add_one_dc_unique(mem_ctx,
     1254                                        domain->name,
     1255                                        addr,
     1256                                        &ip_list[i].ss,
     1257                                        dcs,
     1258                                        num_dcs);
     1259                }
     1260
     1261                SAFE_FREE(ip_list);
     1262                iplist_size = 0;
     1263        }
    12221264
    12231265        return True;
    12241266}
     1267
     1268/*******************************************************************
     1269 Find and make a connection to a DC in the given domain.
     1270
     1271 @param[in] mem_ctx talloc memory context to allocate from
     1272 @param[in] domain domain to find a dc in
     1273 @param[out] dcname NetBIOS or FQDN of DC that's connected to
     1274 @param[out] pss DC Internet address and port
     1275 @param[out] fd fd of the open socket connected to the newly found dc
     1276 @return true when a DC connection is made, false otherwise
     1277*******************************************************************/
    12251278
    12261279static bool find_new_dc(TALLOC_CTX *mem_ctx,
     
    19011954           netlogon pipe. */
    19021955
     1956        if (!domain->conn.netlogon_pipe->dc) {
     1957                return false;
     1958        }
     1959
    19031960        *ppdc = domain->conn.netlogon_pipe->dc;
    19041961        return True;
     
    19261983                goto done;
    19271984        }
     1985
    19281986
    19291987        /*
Note: See TracChangeset for help on using the changeset viewer.