Ignore:
Timestamp:
May 26, 2009, 9:44:50 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.6

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

Legend:

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

    r133 r228  
    236236
    237237        status = idmap_tdb2_open_perm_db();
    238         NT_STATUS_NOT_OK_RETURN(status);
     238        if (!NT_STATUS_IS_OK(status)) {
     239                return status;
     240        }
    239241
    240242        /* Get current high water mark */
     
    298300        uint32_t hwm;
    299301        uint32_t high_hwm;
     302        NTSTATUS status;
     303
     304        status = idmap_tdb2_open_perm_db();
     305        if (!NT_STATUS_IS_OK(status)) {
     306                return status;
     307        }
    300308
    301309        /* Get current high water mark */
     
    553561        TDB_DATA data;
    554562        char *keystr;
     563        NTSTATUS status;
     564
     565        status = idmap_tdb2_open_perm_db();
     566        if (!NT_STATUS_IS_OK(status)) {
     567                return status;
     568        }
    555569
    556570        if (!ctx || !map) {
     
    648662        char *keystr;
    649663        unsigned long rec_id = 0;
     664        NTSTATUS status;
     665
     666        status = idmap_tdb2_open_perm_db();
     667        if (!NT_STATUS_IS_OK(status)) {
     668                return status;
     669        }
    650670
    651671        if ((keystr = sid_string_talloc(ctx, map->sid)) == NULL) {
  • branches/samba-3.2.x/source/winbindd/winbindd.c

    r204 r228  
    746746static void remove_client(struct winbindd_cli_state *state)
    747747{
     748        char c = 0;
     749
    748750        /* It's a dead client - hold a funeral */
    749751       
     
    751753                return;
    752754        }
    753                
     755
     756        /* tell client, we are closing ... */
     757        write(state->sock, &c, sizeof(c));
     758
    754759        /* Close socket */
    755760               
  • branches/samba-3.2.x/source/winbindd/winbindd_ads.c

    r204 r228  
    402402}
    403403
     404/* convert a single name to a sid in a domain - use rpc methods */
     405static NTSTATUS name_to_sid(struct winbindd_domain *domain,
     406                            TALLOC_CTX *mem_ctx,
     407                            enum winbindd_cmd orig_cmd,
     408                            const char *domain_name,
     409                            const char *name,
     410                            DOM_SID *sid,
     411                            enum lsa_SidType *type)
     412{
     413        return reconnect_methods.name_to_sid(domain, mem_ctx, orig_cmd,
     414                                             domain_name, name,
     415                                             sid, type);
     416}
     417
     418/* convert a domain SID to a user or group name - use rpc methods */
     419static NTSTATUS sid_to_name(struct winbindd_domain *domain,
     420                            TALLOC_CTX *mem_ctx,
     421                            const DOM_SID *sid,
     422                            char **domain_name,
     423                            char **name,
     424                            enum lsa_SidType *type)
     425{
     426        return reconnect_methods.sid_to_name(domain, mem_ctx, sid,
     427                                             domain_name, name, type);
     428}
     429
     430/* convert a list of rids to names - use rpc methods */
     431static NTSTATUS rids_to_names(struct winbindd_domain *domain,
     432                              TALLOC_CTX *mem_ctx,
     433                              const DOM_SID *sid,
     434                              uint32 *rids,
     435                              size_t num_rids,
     436                              char **domain_name,
     437                              char ***names,
     438                              enum lsa_SidType **types)
     439{
     440        return reconnect_methods.rids_to_names(domain, mem_ctx, sid,
     441                                               rids, num_rids,
     442                                               domain_name, names, types);
     443}
     444
    404445/* If you are looking for "dn_lookup": Yes, it used to be here!
    405446 * It has gone now since it was a major speed bottleneck in
     
    642683static NTSTATUS lookup_usergroups_memberof(struct winbindd_domain *domain,
    643684                                           TALLOC_CTX *mem_ctx,
    644                                            const char *user_dn, 
     685                                           const char *user_dn,
    645686                                           DOM_SID *primary_group,
    646                                            size_t *p_num_groups, DOM_SID **user_sids)
     687                                           size_t *p_num_groups,
     688                                           DOM_SID **user_sids)
    647689{
    648690        ADS_STATUS rc;
     
    653695        DOM_SID *group_sids = NULL;
    654696        int i;
    655         char **strings;
    656         size_t num_strings = 0;
     697        char **strings = NULL;
     698        size_t num_strings = 0, num_sids = 0;
    657699
    658700
     
    660702
    661703        if ( !winbindd_can_contact_domain( domain ) ) {
    662                 DEBUG(10,("lookup_usergroups_memberof: No incoming trust for domain %s\n",
    663                           domain->name));               
     704                DEBUG(10,("lookup_usergroups_memberof: No incoming trust for "
     705                          "domain %s\n", domain->name));
    664706                return NT_STATUS_OK;
    665707        }
     
    669711        if (!ads) {
    670712                domain->last_status = NT_STATUS_SERVER_DISABLED;
    671                 goto done;
    672         }
    673 
    674         rc = ads_search_retry_extended_dn_ranged(ads, mem_ctx, user_dn, attrs, 
    675                                                  ADS_EXTENDED_DN_HEX_STRING, 
     713                return NT_STATUS_UNSUCCESSFUL;
     714        }
     715
     716        rc = ads_search_retry_extended_dn_ranged(ads, mem_ctx, user_dn, attrs,
     717                                                 ADS_EXTENDED_DN_HEX_STRING,
    676718                                                 &strings, &num_strings);
    677719
    678720        if (!ADS_ERR_OK(rc)) {
    679                 DEBUG(1,("lookup_usergroups_memberof ads_search member=%s: %s\n",
    680                         user_dn, ads_errstr(rc)));
     721                DEBUG(1,("lookup_usergroups_memberof ads_search "
     722                        "member=%s: %s\n", user_dn, ads_errstr(rc)));
    681723                return ads_ntstatus(rc);
    682724        }
    683        
     725
    684726        *user_sids = NULL;
    685727        num_groups = 0;
     
    694736        group_sids = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_strings + 1);
    695737        if (!group_sids) {
    696                 TALLOC_FREE(strings);
    697738                status = NT_STATUS_NO_MEMORY;
    698739                goto done;
     
    700741
    701742        for (i=0; i<num_strings; i++) {
    702 
    703                 if (!ads_get_sid_from_extended_dn(mem_ctx, strings[i],
    704                                                   ADS_EXTENDED_DN_HEX_STRING,
    705                                                   &(group_sids)[i])) {
    706                         TALLOC_FREE(group_sids);
    707                         TALLOC_FREE(strings);
    708                         status = NT_STATUS_NO_MEMORY;
    709                         goto done;
    710                 }
     743                rc = ads_get_sid_from_extended_dn(mem_ctx, strings[i],
     744                                                  ADS_EXTENDED_DN_HEX_STRING,
     745                                                  &(group_sids)[i]);
     746                if (!ADS_ERR_OK(rc)) {
     747                        /* ignore members without SIDs */
     748                        if (NT_STATUS_EQUAL(ads_ntstatus(rc),
     749                            NT_STATUS_NOT_FOUND)) {
     750                                continue;
     751                        }
     752                        else {
     753                                status = ads_ntstatus(rc);
     754                                goto done;
     755                        }
     756                }
     757                num_sids++;
    711758        }
    712759
     
    717764        }
    718765
    719         for (i=0; i<num_strings; i++) {
     766        for (i=0; i<num_sids; i++) {
    720767
    721768                /* ignore Builtin groups from ADS - Guenther */
     
    729776                        goto done;
    730777                }
    731        
     778
    732779        }
    733780
     
    735782        status = (*user_sids != NULL) ? NT_STATUS_OK : NT_STATUS_NO_MEMORY;
    736783
    737         DEBUG(3,("ads lookup_usergroups (memberof) succeeded for dn=%s\n", user_dn));
     784        DEBUG(3,("ads lookup_usergroups (memberof) succeeded for dn=%s\n",
     785                user_dn));
     786
    738787done:
     788        TALLOC_FREE(strings);
    739789        TALLOC_FREE(group_sids);
    740790
     
    895945}
    896946
     947/* Lookup aliases a user is member of - use rpc methods */
     948static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
     949                                   TALLOC_CTX *mem_ctx,
     950                                   uint32 num_sids, const DOM_SID *sids,
     951                                   uint32 *num_aliases, uint32 **alias_rids)
     952{
     953        return reconnect_methods.lookup_useraliases(domain, mem_ctx,
     954                                                    num_sids, sids,
     955                                                    num_aliases,
     956                                                    alias_rids);
     957}
     958
    897959/*
    898960  find the members of a group, given a group rid and domain
     
    900962static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
    901963                                TALLOC_CTX *mem_ctx,
    902                                 const DOM_SID *group_sid, uint32 *num_names, 
    903                                 DOM_SID **sid_mem, char ***names, 
     964                                const DOM_SID *group_sid, uint32 *num_names,
     965                                DOM_SID **sid_mem, char ***names,
    904966                                uint32 **name_types)
    905967{
     
    922984        TALLOC_CTX *tmp_ctx = NULL;
    923985
    924         DEBUG(10,("ads: lookup_groupmem %s sid=%s\n", domain->name, 
     986        DEBUG(10,("ads: lookup_groupmem %s sid=%s\n", domain->name,
    925987                  sid_string_dbg(group_sid)));
    926988
     
    936998        if ( !winbindd_can_contact_domain( domain ) ) {
    937999                DEBUG(10,("lookup_groupmem: No incoming trust for domain %s\n",
    938                           domain->name));               
     1000                          domain->name));
    9391001                return NT_STATUS_OK;
    9401002        }
    9411003
    9421004        ads = ads_cached_connection(domain);
    943        
     1005
    9441006        if (!ads) {
    9451007                domain->last_status = NT_STATUS_SERVER_DISABLED;
     
    9531015
    9541016        /* search for all members of the group */
    955         if (!(ldap_exp = talloc_asprintf(tmp_ctx, "(objectSid=%s)", 
    956                                          sidbinstr))) 
     1017        if (!(ldap_exp = talloc_asprintf(tmp_ctx, "(objectSid=%s)",
     1018                                         sidbinstr)))
    9571019        {
    9581020                SAFE_FREE(sidbinstr);
     
    9671029        args.critical = True;
    9681030
    969         rc = ads_ranged_search(ads, tmp_ctx, LDAP_SCOPE_SUBTREE, ads->config.bind_path, 
     1031        rc = ads_ranged_search(ads, tmp_ctx, LDAP_SCOPE_SUBTREE, ads->config.bind_path,
    9701032                               ldap_exp, &args, "member", &members, &num_members);
    9711033
     
    9741036                status = NT_STATUS_UNSUCCESSFUL;
    9751037                goto done;
    976         } 
    977        
     1038        }
     1039
    9781040        DEBUG(10, ("ads lookup_groupmem: got %d sids via extended dn call\n", (int)num_members));
    979        
     1041
    9801042        /* Now that we have a list of sids, we need to get the
    9811043         * lists of names and name_types belonging to these sids.
    982          * even though conceptually not quite clean,  we use the 
    983          * RPC call lsa_lookup_sids for this since it can handle a 
     1044         * even though conceptually not quite clean,  we use the
     1045         * RPC call lsa_lookup_sids for this since it can handle a
    9841046         * list of sids. ldap calls can just resolve one sid at a time.
    9851047         *
     
    9891051         * we try to resolve as many sids as possible from the
    9901052         * cache. Only the rest is passed to the lsa_lookup_sids call. */
    991        
     1053
    9921054        if (num_members) {
    9931055                (*sid_mem) = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_members);
     
    10161078                DOM_SID sid;
    10171079
    1018                 if (!ads_get_sid_from_extended_dn(tmp_ctx, members[i], args.val, &sid)) {
    1019                         status = NT_STATUS_INVALID_PARAMETER;
    1020                         goto done;
    1021                 }
    1022                 if (lookup_cached_sid(mem_ctx, &sid, &domain_name, &name, &name_type)) {
     1080                rc = ads_get_sid_from_extended_dn(tmp_ctx, members[i], args.val,
     1081                    &sid);
     1082                if (!ADS_ERR_OK(rc)) {
     1083                        if (NT_STATUS_EQUAL(ads_ntstatus(rc),
     1084                            NT_STATUS_NOT_FOUND)) {
     1085                                /* Group members can be objects, like Exchange
     1086                                 * Public Folders, that don't have a SID.  Skip
     1087                                 * them. */
     1088                                continue;
     1089                        }
     1090                        else {
     1091                                status = ads_ntstatus(rc);
     1092                                goto done;
     1093                        }
     1094                }
     1095                if (lookup_cached_sid(mem_ctx, &sid, &domain_name, &name,
     1096                    &name_type)) {
    10231097                        DEBUG(10,("ads: lookup_groupmem: got sid %s from "
    10241098                                  "cache\n", sid_string_dbg(&sid)));
    10251099                        sid_copy(&(*sid_mem)[*num_names], &sid);
    1026                         (*names)[*num_names] = talloc_asprintf(*names, "%s%c%s",
    1027                                                                domain_name,
    1028                                                                *lp_winbind_separator(),
    1029                                                                name );
     1100                        (*names)[*num_names] = fill_domain_username_talloc(
     1101                                                        *names,
     1102                                                        domain_name,
     1103                                                        name,
     1104                                                        true);
    10301105
    10311106                        (*name_types)[*num_names] = name_type;
     
    10521127                }
    10531128
    1054                 status = rpccli_lsa_lookup_sids(cli, tmp_ctx, 
     1129                status = rpccli_lsa_lookup_sids(cli, tmp_ctx,
    10551130                                                &lsa_policy,
    1056                                                 num_nocache, 
    1057                                                 sid_mem_nocache, 
    1058                                                 &domains_nocache, 
    1059                                                 &names_nocache, 
     1131                                                num_nocache,
     1132                                                sid_mem_nocache,
     1133                                                &domains_nocache,
     1134                                                &names_nocache,
    10601135                                                &name_types_nocache);
    10611136
     1137                if (!(NT_STATUS_IS_OK(status) ||
     1138                      NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED) ||
     1139                      NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)))
     1140                {
     1141                        DEBUG(1, ("lsa_lookupsids call failed with %s "
     1142                                  "- retrying...\n", nt_errstr(status)));
     1143
     1144                        status = cm_connect_lsa(domain, tmp_ctx, &cli,
     1145                                                &lsa_policy);
     1146
     1147                        if (!NT_STATUS_IS_OK(status)) {
     1148                                goto done;
     1149                        }
     1150
     1151                        status = rpccli_lsa_lookup_sids(cli, tmp_ctx,
     1152                                                        &lsa_policy,
     1153                                                        num_nocache,
     1154                                                        sid_mem_nocache,
     1155                                                        &domains_nocache,
     1156                                                        &names_nocache,
     1157                                                        &name_types_nocache);
     1158                }
     1159
    10621160                if (NT_STATUS_IS_OK(status) ||
    1063                     NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) 
     1161                    NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED))
    10641162                {
    1065                         /* Copy the entries over from the "_nocache" arrays 
    1066                          * to the result arrays, skipping the gaps the 
     1163                        /* Copy the entries over from the "_nocache" arrays
     1164                         * to the result arrays, skipping the gaps the
    10671165                         * lookup_sids call left. */
    10681166                        for (i=0; i < num_nocache; i++) {
    1069                                 if (((names_nocache)[i] != NULL) && 
    1070                                     ((name_types_nocache)[i] != SID_NAME_UNKNOWN)) 
     1167                                if (((names_nocache)[i] != NULL) &&
     1168                                    ((name_types_nocache)[i] != SID_NAME_UNKNOWN))
    10711169                                {
    10721170                                        sid_copy(&(*sid_mem)[*num_names],
    10731171                                                 &sid_mem_nocache[i]);
    1074                                         (*names)[*num_names] = talloc_asprintf( *names,
    1075                                                                                 "%s%c%s",
    1076                                                                                 domains_nocache[i],
    1077                                                                                 *lp_winbind_separator(),
    1078                                                                                 names_nocache[i] );
     1172                                        (*names)[*num_names] =
     1173                                                fill_domain_username_talloc(
     1174                                                        *names,
     1175                                                        domains_nocache[i],
     1176                                                        names_nocache[i],
     1177                                                        true);
    10791178                                        (*name_types)[*num_names] = name_types_nocache[i];
    10801179                                        (*num_names)++;
     
    11471246        }
    11481247        return ads_ntstatus(rc);
     1248}
     1249
     1250/* find the lockout policy of a domain - use rpc methods */
     1251static NTSTATUS lockout_policy(struct winbindd_domain *domain,
     1252                               TALLOC_CTX *mem_ctx,
     1253                               struct samr_DomInfo12 *policy)
     1254{
     1255        return reconnect_methods.lockout_policy(domain, mem_ctx, policy);
     1256}
     1257
     1258/* find the password policy of a domain - use rpc methods */
     1259static NTSTATUS password_policy(struct winbindd_domain *domain,
     1260                                TALLOC_CTX *mem_ctx,
     1261                                struct samr_DomInfo1 *policy)
     1262{
     1263        return reconnect_methods.password_policy(domain, mem_ctx, policy);
    11491264}
    11501265
     
    13391454        enum_dom_groups,
    13401455        enum_local_groups,
    1341         msrpc_name_to_sid,
    1342         msrpc_sid_to_name,
    1343         msrpc_rids_to_names,
     1456        name_to_sid,
     1457        sid_to_name,
     1458        rids_to_names,
    13441459        query_user,
    13451460        lookup_usergroups,
    1346         msrpc_lookup_useraliases,
     1461        lookup_useraliases,
    13471462        lookup_groupmem,
    13481463        sequence_number,
    1349         msrpc_lockout_policy,
    1350         msrpc_password_policy,
     1464        lockout_policy,
     1465        password_policy,
    13511466        trusted_domains,
    13521467};
  • branches/samba-3.2.x/source/winbindd/winbindd_async.c

    r138 r228  
    367367/********************************************************************
    368368 The lookup name call first contacts a DC in its own domain
    369  and fallbacks to contact a DC in the forest in our domain doesn't
     369 and fallbacks to contact a DC if the forest in our domain doesn't
    370370 know the name.
    371371********************************************************************/
  • branches/samba-3.2.x/source/winbindd/winbindd_cm.c

    r204 r228  
    10101010        /* Make sure there's no duplicates in the list */
    10111011        for (i=0; i<*num; i++)
    1012                 if (addr_equal(&(*dcs)[i].ss, pss))
     1012                if (sockaddr_equal(&(*dcs)[i].ss, pss))
    10131013                        return False;
    10141014
  • branches/samba-3.2.x/source/winbindd/winbindd_dual.c

    r141 r228  
    121121        SMB_ASSERT(continuation != NULL);
    122122
     123        DEBUG(10, ("Sending request to child pid %d (domain=%s)\n",
     124                (int)child->pid,
     125                (child->domain != NULL) ? child->domain->name : "''"));
     126
    123127        state = TALLOC_P(mem_ctx, struct winbindd_async_request);
    124128
     
    197201        TALLOC_FREE(state->reply_timeout_event);
    198202
    199         SMB_ASSERT(state->child_pid != (pid_t)0);
    200 
    201         /* If not already reaped, send kill signal to child. */
    202         if (state->child->pid == state->child_pid) {
     203        /* If child exists and is not already reaped,
     204           send kill signal to child. */
     205
     206        if ((state->child->pid != (pid_t)0) &&
     207                        (state->child->pid != (pid_t)-1) &&
     208                        (state->child->pid == state->child_pid)) {
    203209                kill(state->child_pid, SIGTERM);
    204210
     
    295301        }
    296302
     303        /*
     304         * This may be a reschedule, so we might
     305         * have an existing timeout event pending on
     306         * the first entry in the child->requests list
     307         * (we only send one request at a time).
     308         * Ensure we free it before we reschedule.
     309         * Bug #5814, from hargagan <shargagan@novell.com>.
     310         * JRA.
     311         */
     312
     313        TALLOC_FREE(request->reply_timeout_event);
     314
    297315        if ((child->pid == 0) && (!fork_domain_child(child))) {
    298                 /* Cancel all outstanding requests */
     316                /* fork_domain_child failed.
     317                   Cancel all outstanding requests */
    299318
    300319                while (request != NULL) {
    301320                        /* request might be free'd in the continuation */
    302321                        struct winbindd_async_request *next = request->next;
    303                         request->continuation(request->private_data, False);
     322
     323                        async_request_fail(request);
    304324                        request = next;
    305325                }
     
    487507        child->event.flags = 0;
    488508        child->pid = 0;
     509
     510        if (child->requests) {
     511                /*
     512                 * schedule_async_request() will also
     513                 * clear this event but the call is
     514                 * idempotent so it doesn't hurt to
     515                 * cover all possible future code
     516                 * paths. JRA.
     517                 */
     518                TALLOC_FREE(child->requests->reply_timeout_event);
     519        }
    489520
    490521        schedule_async_request(child);
     
    11181149                set_domain_online_request(child->domain);
    11191150
    1120                 if (primary_domain != child->domain) {
     1151                if (primary_domain && (primary_domain != child->domain)) {
    11211152                        /* We need to talk to the primary
    11221153                         * domain as well as the trusted
  • branches/samba-3.2.x/source/winbindd/winbindd_group.c

    r204 r228  
    3636        fstring name;
    3737
    38         fill_domain_username(name, domain, user, True);
     38        if (domain != NULL) {
     39                fill_domain_username(name, domain, user, True);
     40        } else {
     41                fstrcpy(name, user);
     42        }
    3943        safe_strcat(name, ",", sizeof(name)-1);
    4044        string_append(pp_members, name);
     
    135139                }
    136140
    137                 add_member(domain->name, names[i], pp_members, p_num_members);
     141                add_member(NULL, names[i], pp_members, p_num_members);
    138142        }
    139143
     
    332336}
    333337
     338static void sort_unique_list(char ***list, uint32 *n_list)
     339{
     340        uint32_t i;
     341
     342        /* search for duplicates for sorting and looking for matching
     343           neighbors */
     344
     345        qsort(*list, *n_list, sizeof(char*), QSORT_CAST namecmp);
     346
     347        for (i=1; i < *n_list; i++) {
     348                if (strcmp((*list)[i-1], (*list)[i]) == 0) {
     349                        memmove(&((*list)[i-1]), &((*list)[i]),
     350                                 sizeof(char*)*((*n_list)-i));
     351                        (*n_list)--;
     352                }
     353        }
     354}
     355
    334356static NTSTATUS add_names_to_list( TALLOC_CTX *ctx,
    335357                                   char ***list, uint32 *n_list,
     
    361383        for ( i=*n_list, j=0; i<n_new_list; i++, j++ ) {
    362384                new_list[i] = talloc_strdup( new_list, names[j] );
    363         }
    364 
    365         /* search for duplicates for sorting and looking for matching
    366            neighbors */
    367        
    368         qsort( new_list, n_new_list, sizeof(char*), QSORT_CAST namecmp );
    369        
    370         for ( i=1; i<n_new_list; i++ ) {
    371                 if ( strcmp( new_list[i-1], new_list[i] ) == 0 ) {                     
    372                         memmove( &new_list[i-1], &new_list[i],
    373                                  sizeof(char*)*(n_new_list-i) );
    374                         n_new_list--;
    375                 }
    376385        }
    377386
     
    528537
    529538        /* Real work goes here.  Create a list of group names to
    530            expand startign with the initial one.  Pass that to
     539           expand starting with the initial one.  Pass that to
    531540           expand_groups() which returns a list of more group names
    532541           to expand.  Do this up to the max search depth. */
     
    577586        }
    578587        TALLOC_FREE( glist );   
    579          
     588
     589        sort_unique_list(&names, &num_names);
     590
    580591        DEBUG(10, ("looked up %d names\n", num_names));
    581592
     
    697708        /* Get info for the domain */
    698709
    699         if ((domain = find_domain_from_name(name_domain)) == NULL) {
     710        if ((domain = find_domain_from_name_noinit(name_domain)) == NULL) {
    700711                DEBUG(3, ("could not get domain sid for domain %s\n",
    701712                          name_domain));
     
    730741
    731742static void getgrsid_sid2gid_recv(void *private_data, bool success, gid_t gid)
    732         {
     743{
    733744        struct getgrsid_state *s =
    734745                (struct getgrsid_state *)private_data;
     
    780791
    781792        request_ok(s->state);   
    782         }
     793}
    783794
    784795static void getgrsid_lookupsid_recv( void *private_data, bool success,
     
    805816                request_error(s->state);
    806817                return;
    807 }
     818        }
    808819
    809820        if ( (s->group_name = talloc_asprintf( s->state->mem_ctx,
     
    812823                                               *lp_winbind_separator(),
    813824                                               name)) == NULL )
    814 {
     825        {
    815826                DEBUG(1, ("getgrsid_lookupsid_recv: talloc_asprintf() Failed!\n"));
    816827                request_error(s->state);
     
    822833        winbindd_sid2gid_async(s->state->mem_ctx, &s->group_sid,
    823834                               getgrsid_sid2gid_recv, s);
    824         }
     835}
    825836
    826837static void winbindd_getgrsid( struct winbindd_cli_state *state, const DOM_SID group_sid )
    827         {
     838{
    828839        struct getgrsid_state *s;
    829840
  • branches/samba-3.2.x/source/winbindd/winbindd_pam.c

    r204 r228  
    18331833        if (state->request.data.auth_crap.lm_resp_len > sizeof(state->request.data.auth_crap.lm_resp)
    18341834                || state->request.data.auth_crap.nt_resp_len > sizeof(state->request.data.auth_crap.nt_resp)) {
    1835                 DEBUG(0, ("winbindd_pam_auth_crap: invalid password length %u/%u\n",
    1836                           state->request.data.auth_crap.lm_resp_len,
    1837                           state->request.data.auth_crap.nt_resp_len));
    1838                 result = NT_STATUS_INVALID_PARAMETER;
    1839                 goto done;
     1835                if (!state->request.flags & WBFLAG_BIG_NTLMV2_BLOB ||
     1836                     state->request.extra_len != state->request.data.auth_crap.nt_resp_len) {
     1837                        DEBUG(0, ("winbindd_pam_auth_crap: invalid password length %u/%u\n",
     1838                                  state->request.data.auth_crap.lm_resp_len,
     1839                                  state->request.data.auth_crap.nt_resp_len));
     1840                                  result = NT_STATUS_INVALID_PARAMETER;
     1841                        goto done;
     1842                }
    18401843        }
    18411844
    18421845        lm_resp = data_blob_talloc(state->mem_ctx, state->request.data.auth_crap.lm_resp,
    18431846                                        state->request.data.auth_crap.lm_resp_len);
    1844         nt_resp = data_blob_talloc(state->mem_ctx, state->request.data.auth_crap.nt_resp,
    1845                                         state->request.data.auth_crap.nt_resp_len);
     1847
     1848        if (state->request.flags & WBFLAG_BIG_NTLMV2_BLOB) {
     1849                nt_resp = data_blob_talloc(state->mem_ctx,
     1850                                           state->request.extra_data.data,
     1851                                           state->request.data.auth_crap.nt_resp_len);
     1852        } else {
     1853                nt_resp = data_blob_talloc(state->mem_ctx,
     1854                                           state->request.data.auth_crap.nt_resp,
     1855                                           state->request.data.auth_crap.nt_resp_len);
     1856        }
    18461857
    18471858        /* what domain should we contact? */
  • branches/samba-3.2.x/source/winbindd/winbindd_passdb.c

    r149 r228  
    268268
    269269        if ( !pdb_getsampwsid( user, user_sid ) ) {
     270                TALLOC_FREE( user );
    270271                return NT_STATUS_NO_SUCH_USER;
    271272        }
     
    639640                        continue;
    640641                }
    641                 if (!((*names)[i] = talloc_strdup((*names),
     642                if (!((*names)[num_mapped] = talloc_strdup((*names),
    642643                                                  lsa_names[i].name))) {
    643644                        TALLOC_FREE(tmp_ctx);
     
    645646                }
    646647
    647                 (*name_types)[i] = lsa_names[i].type;
     648                (*name_types)[num_mapped] = lsa_names[i].type;
    648649
    649650                num_mapped += 1;
  • branches/samba-3.2.x/source/winbindd/winbindd_proto.h

    r204 r228  
    447447/* The following definitions come from winbindd/winbindd_rpc.c  */
    448448
    449 NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
    450                            TALLOC_CTX *mem_ctx,
    451                            enum winbindd_cmd original_cmd,
    452                            const char *domain_name,
    453                            const char *name,
    454                            DOM_SID *sid,
    455                            enum lsa_SidType *type);
    456 NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain,
    457                             TALLOC_CTX *mem_ctx,
    458                             const DOM_SID *sid,
    459                             char **domain_name,
    460                             char **name,
    461                             enum lsa_SidType *type);
    462 NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
    463                              TALLOC_CTX *mem_ctx,
    464                              const DOM_SID *sid,
    465                              uint32 *rids,
    466                              size_t num_rids,
    467                              char **domain_name,
    468                              char ***names,
    469                              enum lsa_SidType **types);
    470 NTSTATUS msrpc_lookup_useraliases(struct winbindd_domain *domain,
    471                                   TALLOC_CTX *mem_ctx,
    472                                   uint32 num_sids, const DOM_SID *sids,
    473                                   uint32 *num_aliases, uint32 **alias_rids);
    474 NTSTATUS msrpc_lockout_policy(struct winbindd_domain *domain,
    475                               TALLOC_CTX *mem_ctx,
    476                               struct samr_DomInfo12 *lockout_policy);
    477 NTSTATUS msrpc_password_policy(struct winbindd_domain *domain,
    478                                TALLOC_CTX *mem_ctx,
    479                                struct samr_DomInfo1 *password_policy);
    480449
    481450/* The following definitions come from winbindd/winbindd_sid.c  */
     
    550519bool canonicalize_username(fstring username_inout, fstring domain, fstring user);
    551520void fill_domain_username(fstring name, const char *domain, const char *user, bool can_assume);
     521char *fill_domain_username_talloc(TALLOC_CTX *mem_ctx,
     522                                  const char *domain,
     523                                  const char *user,
     524                                  bool can_assume);
    552525const char *get_winbind_pipe_dir(void) ;
    553526char *get_winbind_priv_pipe_dir(void) ;
  • branches/samba-3.2.x/source/winbindd/winbindd_rpc.c

    r133 r228  
    266266
    267267/* convert a single name to a sid in a domain */
    268 NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
    269                            TALLOC_CTX *mem_ctx,
    270                            enum winbindd_cmd original_cmd,
    271                            const char *domain_name,
    272                            const char *name,
    273                            DOM_SID *sid,
    274                            enum lsa_SidType *type)
     268static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
     269                                  TALLOC_CTX *mem_ctx,
     270                                  enum winbindd_cmd original_cmd,
     271                                  const char *domain_name,
     272                                  const char *name,
     273                                  DOM_SID *sid,
     274                                  enum lsa_SidType *type)
    275275{
    276276        NTSTATUS result;
     
    320320  convert a domain SID to a user or group name
    321321*/
    322 NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain,
    323                             TALLOC_CTX *mem_ctx,
    324                             const DOM_SID *sid,
    325                             char **domain_name,
    326                             char **name,
    327                             enum lsa_SidType *type)
     322static NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain,
     323                                  TALLOC_CTX *mem_ctx,
     324                                  const DOM_SID *sid,
     325                                  char **domain_name,
     326                                  char **name,
     327                                  enum lsa_SidType *type)
    328328{
    329329        char **domains;
     
    363363}
    364364
    365 NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
    366                              TALLOC_CTX *mem_ctx,
    367                              const DOM_SID *sid,
    368                              uint32 *rids,
    369                              size_t num_rids,
    370                              char **domain_name,
    371                              char ***names,
    372                              enum lsa_SidType **types)
     365static NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
     366                                    TALLOC_CTX *mem_ctx,
     367                                    const DOM_SID *sid,
     368                                    uint32 *rids,
     369                                    size_t num_rids,
     370                                    char **domain_name,
     371                                    char ***names,
     372                                    enum lsa_SidType **types)
    373373{
    374374        char **domains;
     
    603603}
    604604
    605 NTSTATUS msrpc_lookup_useraliases(struct winbindd_domain *domain,
    606                                   TALLOC_CTX *mem_ctx,
    607                                   uint32 num_sids, const DOM_SID *sids,
    608                                   uint32 *num_aliases, uint32 **alias_rids)
     605static NTSTATUS msrpc_lookup_useraliases(struct winbindd_domain *domain,
     606                                         TALLOC_CTX *mem_ctx,
     607                                         uint32 num_sids, const DOM_SID *sids,
     608                                         uint32 *num_aliases,
     609                                         uint32 **alias_rids)
    609610{
    610611        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     
    821822
    822823                for (r=0; r<tmp_names.count; r++) {
    823                         (*names)[i+r] = CONST_DISCARD(char *, tmp_names.names[r].string);
     824                        (*names)[i+r] = fill_domain_username_talloc(mem_ctx,
     825                                                domain->name,
     826                                                tmp_names.names[r].string,
     827                                                true);
    824828                        (*name_types)[i+r] = tmp_types.ids[r];
    825829                }
     
    10661070
    10671071/* find the lockout policy for a domain */
    1068 NTSTATUS msrpc_lockout_policy(struct winbindd_domain *domain,
    1069                               TALLOC_CTX *mem_ctx,
    1070                               struct samr_DomInfo12 *lockout_policy)
     1072static NTSTATUS msrpc_lockout_policy(struct winbindd_domain *domain,
     1073                                     TALLOC_CTX *mem_ctx,
     1074                                     struct samr_DomInfo12 *lockout_policy)
    10711075{
    10721076        NTSTATUS result;
     
    11071111
    11081112/* find the password policy for a domain */
    1109 NTSTATUS msrpc_password_policy(struct winbindd_domain *domain,
    1110                                TALLOC_CTX *mem_ctx,
    1111                                struct samr_DomInfo1 *password_policy)
     1113static NTSTATUS msrpc_password_policy(struct winbindd_domain *domain,
     1114                                      TALLOC_CTX *mem_ctx,
     1115                                      struct samr_DomInfo1 *password_policy)
    11121116{
    11131117        NTSTATUS result;
  • branches/samba-3.2.x/source/winbindd/winbindd_user.c

    r141 r228  
    385385        /* Get info for the domain */
    386386
    387         domain = find_domain_from_name(domname);
     387        domain = find_domain_from_name_noinit(domname);
    388388
    389389        if (domain == NULL) {
  • branches/samba-3.2.x/source/winbindd/winbindd_util.c

    r204 r228  
    110110        struct winbindd_domain *domain;
    111111        const char *alternative_name = NULL;
    112        
     112        const char **ignored_domains, **dom;
     113
     114        ignored_domains = lp_parm_string_list(-1, "winbind", "ignore domains", NULL);
     115        for (dom=ignored_domains; dom && *dom; dom++) {
     116                if (gen_fnmatch(*dom, domain_name) == 0) {
     117                        DEBUG(2,("Ignoring domain '%s'\n", domain_name));
     118                        return NULL;
     119                }
     120        }
     121
    113122        /* ignore alt_name if we are not in an AD domain */
    114        
     123
    115124        if ( (lp_security() == SEC_ADS) && alt_name && *alt_name) {
    116125                alternative_name = alt_name;
    117126        }
    118        
     127
    119128        /* We can't call domain_list() as this function is called from
    120129           init_domain_list() and we'll get stuck in a loop. */
     
    403412                }
    404413
     414                if (d == NULL) {
     415                        continue;
     416                }
     417
    405418                DEBUG(10,("rescan_forest_root_trusts: Following trust path "
    406419                          "for domain tree root %s (%s)\n",
     
    466479                                                        &cache_methods,
    467480                                                        &dom_list[i].sid );
     481                        }
     482
     483                        if (d == NULL) {
     484                                continue;
    468485                        }
    469486                       
     
    10251042
    10261043        while(temp != NULL) {
    1027                 struct getent_state *next;
     1044                struct getent_state *next = temp->next;
    10281045
    10291046                /* Free sam entries then list entry */
     
    10311048                SAFE_FREE(state->sam_entries);
    10321049                DLIST_REMOVE(state, state);
    1033                 next = temp->next;
    10341050
    10351051                SAFE_FREE(temp);
     
    11271143        }
    11281144
    1129         safe_strcpy(buf, user, *len);
     1145        safe_strcpy((char *)buf, user, *len);
    11301146}
    11311147
     
    11801196}
    11811197
     1198/**
     1199 * talloc version of fill_domain_username()
     1200 * return NULL on talloc failure.
     1201 */
     1202char *fill_domain_username_talloc(TALLOC_CTX *mem_ctx,
     1203                                  const char *domain,
     1204                                  const char *user,
     1205                                  bool can_assume)
     1206{
     1207        char *tmp_user, *name;
     1208
     1209        tmp_user = talloc_strdup(mem_ctx, user);
     1210        strlower_m(tmp_user);
     1211
     1212        if (can_assume && assume_domain(domain)) {
     1213                name = tmp_user;
     1214        } else {
     1215                name = talloc_asprintf(mem_ctx, "%s%c%s",
     1216                                       domain,
     1217                                       *lp_winbind_separator(),
     1218                                       tmp_user);
     1219                TALLOC_FREE(tmp_user);
     1220        }
     1221
     1222        return name;
     1223}
     1224
    11821225/*
    11831226 * Winbindd socket accessor functions
Note: See TracChangeset for help on using the changeset viewer.