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

Update 3.2 branch to 3.2.4

Location:
branches/samba-3.2.x/source/winbindd
Files:
10 edited

Legend:

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

    r141 r204  
    7676        } } while(0)
    7777
    78 static struct idmap_methods *get_methods(struct idmap_backend *be,
    79                                          const char *name)
     78static struct idmap_methods *get_methods(const char *name)
    8079{
    8180        struct idmap_backend *b;
    8281
    83         for (b = be; b; b = b->next) {
     82        for (b = backends; b; b = b->next) {
    8483                if (strequal(b->name, name)) {
    8584                        return b->methods;
     
    9089}
    9190
    92 static struct idmap_alloc_methods *get_alloc_methods(
    93                                                 struct idmap_alloc_backend *be,
    94                                                 const char *name)
     91static struct idmap_alloc_methods *get_alloc_methods(const char *name)
    9592{
    9693        struct idmap_alloc_backend *b;
    9794
    98         for (b = be; b; b = b->next) {
     95        for (b = alloc_backends; b; b = b->next) {
    9996                if (strequal(b->name, name)) {
    10097                        return b->methods;
     
    141138        }
    142139
    143         test = get_methods(backends, name);
     140        test = get_methods(name);
    144141        if (test) {
    145142                DEBUG(0,("Idmap module %s already registered!\n", name));
     
    194191        }
    195192
    196         test = get_alloc_methods(alloc_backends, name);
     193        test = get_alloc_methods(name);
    197194        if (test) {
    198195                DEBUG(0,("idmap_alloc module %s already registered!\n", name));
     
    455452
    456453                /* get the backend methods for this domain */
    457                 dom->methods = get_methods(backends, parm_backend);
     454                dom->methods = get_methods(parm_backend);
    458455
    459456                if ( ! dom->methods) {
    460457                        ret = smb_probe_module("idmap", parm_backend);
    461458                        if (NT_STATUS_IS_OK(ret)) {
    462                                 dom->methods = get_methods(backends,
    463                                                            parm_backend);
     459                                dom->methods = get_methods(parm_backend);
    464460                        }
    465461                }
     
    542538
    543539                /* get the backend methods for this domain */
    544                 dom->methods = get_methods(backends, compat_backend);
    545 
     540                dom->methods = get_methods(compat_backend);
    546541                if ( ! dom->methods) {
    547542                        ret = smb_probe_module("idmap", compat_backend);
    548543                        if (NT_STATUS_IS_OK(ret)) {
    549                                 dom->methods = get_methods(backends,
    550                                                            compat_backend);
     544                                dom->methods = get_methods(compat_backend);
    551545                        }
    552546                }
     
    607601                dom->readonly = True;
    608602
    609                 /* get the backend methods for passdb */
    610                 dom->methods = get_methods(backends, "nss");
     603                /* get the backend methods for nss */
     604                dom->methods = get_methods("nss");
    611605
    612606                /* (the nss module is always statically linked) */
     
    664658
    665659        /* get the backend methods for passdb */
    666         dom->methods = get_methods(backends, "passdb");
     660        dom->methods = get_methods("passdb");
    667661
    668662        /* (the passdb module is always statically linked) */
     
    756750                IDMAP_CHECK_ALLOC(idmap_alloc_ctx);
    757751
    758                 idmap_alloc_ctx->methods = get_alloc_methods(alloc_backends,
    759                                                              alloc_backend);
     752                idmap_alloc_ctx->methods = get_alloc_methods(alloc_backend);
    760753                if ( ! idmap_alloc_ctx->methods) {
    761754                        ret = smb_probe_module("idmap", alloc_backend);
    762755                        if (NT_STATUS_IS_OK(ret)) {
    763756                                idmap_alloc_ctx->methods =
    764                                         get_alloc_methods(alloc_backends,
    765                                                           alloc_backend);
     757                                        get_alloc_methods(alloc_backend);
    766758                        }
    767759                }
  • branches/samba-3.2.x/source/winbindd/idmap_ad.c

    r133 r204  
    749749{
    750750        ADS_STRUCT *ads_internal = NULL;
     751        const char *attrs[] = {NULL, /* attr_homedir */
     752                               NULL, /* attr_shell */
     753                               NULL, /* attr_gecos */
     754                               NULL, /* attr_gidnumber */
     755                               NULL };
     756        char *filter = NULL;
     757        LDAPMessage *msg_internal = NULL;
     758        ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
     759        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
     760        char *sidstr = NULL;
    751761
    752762        /* Only do query if we are online */
     
    760770        ads_internal = ad_idmap_cached_connection();
    761771
    762         if ( !ads_internal || !ad_schema )
     772        if ( !ads_internal || !ad_schema ) {
    763773                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
    764        
    765         if ( !homedir || !shell || !gecos )
     774        }
     775
     776        if (!sid || !homedir || !shell || !gecos) {
    766777                return NT_STATUS_INVALID_PARAMETER;
    767 
    768         *homedir = ads_pull_string( ads, ctx, msg, ad_schema->posix_homedir_attr );
    769         *shell   = ads_pull_string( ads, ctx, msg, ad_schema->posix_shell_attr );
    770         *gecos   = ads_pull_string( ads, ctx, msg, ad_schema->posix_gecos_attr );
    771        
    772         if ( gid ) {           
    773                 if ( !ads_pull_uint32(ads, msg, ad_schema->posix_gidnumber_attr, gid ) )
    774                         *gid = (uint32)-1;             
    775         }
    776                
    777         return NT_STATUS_OK;
     778        }
     779
     780        /* See if we can use the ADS connection struct swe were given */
     781
     782        if (ads) {
     783                *homedir = ads_pull_string( ads, ctx, msg, ad_schema->posix_homedir_attr );
     784                *shell   = ads_pull_string( ads, ctx, msg, ad_schema->posix_shell_attr );
     785                *gecos   = ads_pull_string( ads, ctx, msg, ad_schema->posix_gecos_attr );
     786
     787                if (gid) {
     788                        if ( !ads_pull_uint32(ads, msg, ad_schema->posix_gidnumber_attr, gid ) )
     789                                *gid = (uint32)-1;
     790                }
     791
     792                nt_status = NT_STATUS_OK;
     793                goto done;
     794        }
     795
     796        /* Have to do our own query */
     797
     798        attrs[0] = ad_schema->posix_homedir_attr;
     799        attrs[1] = ad_schema->posix_shell_attr;
     800        attrs[2] = ad_schema->posix_gecos_attr;
     801        attrs[3] = ad_schema->posix_gidnumber_attr;
     802
     803        sidstr = sid_binstring(sid);
     804        filter = talloc_asprintf(ctx, "(objectSid=%s)", sidstr);
     805        SAFE_FREE(sidstr);
     806
     807        if (!filter) {
     808                nt_status = NT_STATUS_NO_MEMORY;
     809                goto done;
     810        }
     811
     812        ads_status = ads_search_retry(ads_internal, &msg_internal, filter, attrs);
     813        if (!ADS_ERR_OK(ads_status)) {
     814                nt_status = ads_ntstatus(ads_status);
     815                goto done;
     816        }
     817
     818        *homedir = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_homedir_attr);
     819        *shell   = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_shell_attr);
     820        *gecos   = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_gecos_attr);
     821
     822        if (gid) {
     823                if (!ads_pull_uint32(ads_internal, msg_internal, ad_schema->posix_gidnumber_attr, gid))
     824                        *gid = (uint32)-1;
     825        }
     826
     827        nt_status = NT_STATUS_OK;
     828
     829done:
     830        if (msg_internal) {
     831                ads_msgfree(ads_internal, msg_internal);
     832        }
     833
     834        return nt_status;
    778835}
    779836
  • branches/samba-3.2.x/source/winbindd/winbindd.c

    r141 r204  
    554554        }
    555555
    556         SAFE_FREE(state->request.extra_data.data);
    557556        SAFE_FREE(state->response.extra_data.data);
    558557
     
    589588static void request_finished(struct winbindd_cli_state *state)
    590589{
     590        /* Make sure request.extra_data is freed when finish processing a request */
     591        SAFE_FREE(state->request.extra_data.data);
    591592        setup_async_write(&state->fd_event, &state->response,
    592593                          sizeof(state->response), response_main_sent, state);
  • branches/samba-3.2.x/source/winbindd/winbindd_ads.c

    r141 r204  
    12261226                        struct winbindd_domain d;
    12271227                       
     1228                        ZERO_STRUCT(d);
     1229
    12281230                        /* drop external trusts if this is not our primary
    12291231                           domain.  This means that the returned number of
     
    12551257                                sid_copy( &d.sid, trusts.array[i].sid);
    12561258                        } else {
    1257                                 sid_copy(&(*dom_sids)[ret_count], &global_sid_NULL);
     1259                                sid_copy(&d.sid, &global_sid_NULL);
    12581260                        }
    12591261
  • branches/samba-3.2.x/source/winbindd/winbindd_cache.c

    r141 r204  
    22662266                                struct netr_SamInfo3 *info3)
    22672267{
     2268        DOM_SID sid;
     2269        fstring key_str, sid_string;
    22682270        struct winbind_cache *cache;
    22692271
     
    22792281
    22802282        cache = get_cache(domain);
    2281         netsamlogon_clear_cached_user(cache->tdb, info3);
     2283
     2284        if (!cache->tdb) {
     2285                return;
     2286        }
     2287
     2288        sid_copy(&sid, info3->base.domain_sid);
     2289        sid_append_rid(&sid, info3->base.rid);
     2290
     2291        /* Clear U/SID cache entry */
     2292        fstr_sprintf(key_str, "U/%s", sid_to_fstring(sid_string, &sid));
     2293        DEBUG(10, ("wcache_invalidate_samlogon: clearing %s\n", key_str));
     2294        tdb_delete(cache->tdb, string_tdb_data(key_str));
     2295
     2296        /* Clear UG/SID cache entry */
     2297        fstr_sprintf(key_str, "UG/%s", sid_to_fstring(sid_string, &sid));
     2298        DEBUG(10, ("wcache_invalidate_samlogon: clearing %s\n", key_str));
     2299        tdb_delete(cache->tdb, string_tdb_data(key_str));
     2300
     2301        /* Samba/winbindd never needs this. */
     2302        netsamlogon_clear_cached_user(info3);
    22822303}
    22832304
  • 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        /*
  • branches/samba-3.2.x/source/winbindd/winbindd_group.c

    r138 r204  
    597597                        DEBUG(10, ("buf_len + %d = %d\n", len + 1, buf_len));
    598598                } else {
    599                         DEBUG(10, ("appending %s at ndx %d\n", names[i], buf_ndx));
    600                         safe_strcpy(&buf[buf_ndx], names[i], len);
     599                        DEBUG(10, ("appending %s at ndx %d\n",
     600                                   names[i], buf_ndx));
     601                        parse_add_domuser(&buf[buf_ndx], names[i], &len);
    601602                        buf_ndx += len;
    602603                        buf[buf_ndx] = ',';
  • branches/samba-3.2.x/source/winbindd/winbindd_pam.c

    r141 r204  
    16001600                }
    16011601
     1602                wcache_invalidate_samlogon(find_domain_from_name(name_domain), info3);
    16021603                netsamlogon_cache_store(name_user, info3);
    1603                 wcache_invalidate_samlogon(find_domain_from_name(name_domain), info3);
    16041604
    16051605                /* save name_to_sid info as early as possible (only if
     
    19421942        if (NT_STATUS_IS_OK(result)) {
    19431943
     1944                wcache_invalidate_samlogon(find_domain_from_name(name_domain), info3);
    19441945                netsamlogon_cache_store(name_user, info3);
    1945                 wcache_invalidate_samlogon(find_domain_from_name(name_domain), info3);
    19461946
    19471947                /* Check if the user is in the right group */
  • branches/samba-3.2.x/source/winbindd/winbindd_proto.h

    r141 r204  
    547547bool parse_domain_user_talloc(TALLOC_CTX *mem_ctx, const char *domuser,
    548548                              char **domain, char **user);
     549void parse_add_domuser(void *buf, char *domuser, int *len);
    549550bool canonicalize_username(fstring username_inout, fstring domain, fstring user);
    550551void fill_domain_username(fstring name, const char *domain, const char *user, bool can_assume);
  • branches/samba-3.2.x/source/winbindd/winbindd_util.c

    r149 r204  
    11051105}
    11061106
     1107/* add a domain user name to a buffer */
     1108void parse_add_domuser(void *buf, char *domuser, int *len)
     1109{
     1110        fstring domain;
     1111        char *p, *user;
     1112
     1113        user = domuser;
     1114        p = strchr(domuser, *lp_winbind_separator());
     1115
     1116        if (p) {
     1117
     1118                fstrcpy(domain, domuser);
     1119                domain[PTR_DIFF(p, domuser)] = 0;
     1120                p++;
     1121
     1122                if (assume_domain(domain)) {
     1123
     1124                        user = p;
     1125                        *len -= (PTR_DIFF(p, domuser));
     1126                }
     1127        }
     1128
     1129        safe_strcpy(buf, user, *len);
     1130}
     1131
    11071132/* Ensure an incoming username from NSS is fully qualified. Replace the
    11081133   incoming fstring with DOMAIN <separator> user. Returns the same
Note: See TracChangeset for help on using the changeset viewer.