Ignore:
Timestamp:
Nov 29, 2012, 1:59:04 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9

Location:
trunk/server/source3/winbindd
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/winbindd/idmap_autorid.c

    r745 r751  
    3535
    3636#define HWM "NEXT RANGE"
     37#define ALLOC_HWM_UID "NEXT ALLOC UID"
     38#define ALLOC_HWM_GID "NEXT ALLOC GID"
     39#define ALLOC_RANGE "ALLOC"
    3740#define CONFIGKEY "CONFIG"
    3841
     
    4447
    4548struct autorid_domain_config {
    46         struct dom_sid sid;
     49        fstring sid;
    4750        uint32_t domainnum;
    4851        struct autorid_global_config *globalcfg;
     
    5760        NTSTATUS ret;
    5861        uint32_t domainnum, hwm;
    59         fstring sidstr;
    6062        char *numstr;
    6163        struct autorid_domain_config *cfg;
    6264
    6365        cfg = (struct autorid_domain_config *)private_data;
    64         dom_sid_string_buf(&(cfg->sid), sidstr, sizeof(sidstr));
    65 
    66         if (!dbwrap_fetch_uint32(db, sidstr, &domainnum)) {
    67                 DEBUG(10, ("Acquiring new range for domain %s\n", sidstr));
     66
     67        if (!dbwrap_fetch_uint32(db, cfg->sid, &domainnum)) {
     68                DEBUG(10, ("Acquiring new range for domain %s\n", cfg->sid));
    6869
    6970                /* fetch the current HWM */
     
    9192
    9293                /* store away the new mapping in both directions */
    93                 ret = dbwrap_trans_store_uint32(db, sidstr, domainnum);
     94                ret = dbwrap_trans_store_uint32(db, cfg->sid, domainnum);
    9495                if (!NT_STATUS_IS_OK(ret)) {
    9596                        DEBUG(1, ("Fatal error while storing new "
     
    105106
    106107                ret = dbwrap_trans_store_bystring(db, numstr,
    107                                                   string_term_tdb_data(sidstr),
    108                                                   TDB_INSERT);
     108                                string_term_tdb_data(cfg->sid), TDB_INSERT);
     109
    109110                talloc_free(numstr);
    110111                if (!NT_STATUS_IS_OK(ret)) {
     
    114115                }
    115116                DEBUG(5, ("Acquired new range #%d for domain %s\n",
    116                           domainnum, sidstr));
    117         }
    118 
    119         DEBUG(10, ("Using range #%d for domain %s\n", domainnum, sidstr));
     117                          domainnum, cfg->sid));
     118        }
     119
     120        DEBUG(10, ("Using range #%d for domain %s\n", domainnum, cfg->sid));
    120121        cfg->domainnum = domainnum;
    121122
     
    165166                          "domain mapping, ignoring mapping request\n",
    166167                          map->xid.id, range));
     168                TALLOC_FREE(data.dptr);
     169                map->status = ID_UNKNOWN;
     170                return NT_STATUS_OK;
     171        }
     172
     173        if (strncmp((const char *)data.dptr,
     174                    ALLOC_RANGE,
     175                    strlen(ALLOC_RANGE)) == 0) {
     176                /* this is from the alloc range, there is no mapping back */
     177                DEBUG(5, ("id %d belongs to alloc range, cannot map back\n",
     178                          map->xid.id));
     179                TALLOC_FREE(data.dptr);
    167180                map->status = ID_UNKNOWN;
    168181                return NT_STATUS_OK;
     
    275288                struct autorid_domain_config domaincfg;
    276289                uint32_t rid;
     290                struct dom_sid domainsid;
    277291
    278292                ZERO_STRUCT(domaincfg);
    279293
    280                 sid_copy(&domaincfg.sid, ids[i]->sid);
    281                 if (!sid_split_rid(&domaincfg.sid, &rid)) {
     294                sid_copy(&domainsid, ids[i]->sid);
     295                if (!sid_split_rid(&domainsid, &rid)) {
    282296                        DEBUG(4, ("Could not determine domain SID from %s, "
    283297                                  "ignoring mapping request\n",
     
    290304                 */
    291305                domain = wcache_tdc_fetch_domainbysid(talloc_tos(),
    292                                                       &domaincfg.sid);
     306                                                      &domainsid);
    293307                if (domain == NULL) {
    294308                        DEBUG(10, ("Ignoring unknown domain sid %s\n",
    295                                    sid_string_dbg(&domaincfg.sid)));
     309                                   sid_string_dbg(&domainsid)));
    296310                        continue;
    297311                }
     
    299313
    300314                domaincfg.globalcfg = global;
     315                sid_to_fstring(domaincfg.sid, &domainsid);
    301316
    302317                ret = dbwrap_trans_do(autorid_db,
     
    327342}
    328343
     344/* initialize the given HWM to 0 if it does not exist yet */
     345static NTSTATUS idmap_autorid_init_hwm(const char *hwm) {
     346
     347        NTSTATUS status;
     348        int32_t hwmval;
     349
     350        hwmval = dbwrap_fetch_int32(autorid_db, hwm);
     351        if ((hwmval < 0))  {
     352                status = dbwrap_trans_store_int32(autorid_db, hwm, 0);
     353                if (!NT_STATUS_IS_OK(status)) {
     354                        DEBUG(0,
     355                              ("Unable to initialise HWM (%s) in autorid "
     356                               "database: %s\n", hwm, nt_errstr(status)));
     357                        return NT_STATUS_INTERNAL_DB_ERROR;
     358                }
     359        }
     360
     361        return NT_STATUS_OK;
     362}
     363
    329364/*
    330365 * open and initialize the database which stores the ranges for the domains
     
    332367static NTSTATUS idmap_autorid_db_init(void)
    333368{
    334         int32_t hwm;
     369        NTSTATUS status;
    335370
    336371        if (autorid_db) {
     
    350385
    351386        /* Initialize high water mark for the currently used range to 0 */
    352         hwm = dbwrap_fetch_int32(autorid_db, HWM);
    353         if ((hwm < 0)) {
    354                 if (!NT_STATUS_IS_OK
    355                     (dbwrap_trans_store_int32(autorid_db, HWM, 0))) {
    356                         DEBUG(0,
    357                               ("Unable to initialise HWM in autorid "
    358                                "database\n"));
    359                         return NT_STATUS_INTERNAL_DB_ERROR;
    360                 }
    361         }
    362 
    363         return NT_STATUS_OK;
     387
     388        status = idmap_autorid_init_hwm(HWM);
     389        NT_STATUS_NOT_OK_RETURN(status);
     390
     391        status = idmap_autorid_init_hwm(ALLOC_HWM_UID);
     392        NT_STATUS_NOT_OK_RETURN(status);
     393
     394        status = idmap_autorid_init_hwm(ALLOC_HWM_GID);
     395
     396        return status;
    364397}
    365398
     
    542575}
    543576
     577static NTSTATUS idmap_autorid_allocate_id(struct idmap_domain *dom,
     578                                          struct unixid *xid) {
     579
     580        NTSTATUS ret;
     581        struct autorid_global_config *globalcfg;
     582        struct autorid_domain_config domaincfg;
     583        uint32_t hwm;
     584        const char *hwmkey;
     585
     586        if (!strequal(dom->name, "*")) {
     587                DEBUG(3, ("idmap_autorid_allocate_id: "
     588                          "Refusing creation of mapping for domain'%s'. "
     589                          "Currently only supported for the default "
     590                          "domain \"*\".\n",
     591                           dom->name));
     592                return NT_STATUS_NOT_IMPLEMENTED;
     593        }
     594
     595        if ((xid->type != ID_TYPE_UID) && (xid->type != ID_TYPE_GID)) {
     596                return NT_STATUS_INVALID_PARAMETER;
     597        }
     598
     599
     600        globalcfg = talloc_get_type(dom->private_data,
     601                                    struct autorid_global_config);
     602
     603        /* fetch the range for the allocation pool */
     604
     605        ZERO_STRUCT(domaincfg);
     606
     607        domaincfg.globalcfg = globalcfg;
     608        fstrcpy(domaincfg.sid, ALLOC_RANGE);
     609
     610        ret = dbwrap_trans_do(autorid_db,
     611                              idmap_autorid_get_domainrange,
     612                              &domaincfg);
     613        if (!NT_STATUS_IS_OK(ret)) {
     614                DEBUG(3, ("Could not determine range for allocation pool, "
     615                          "check previous messages for reason\n"));
     616                return ret;
     617        }
     618
     619        /* fetch the current HWM */
     620        hwmkey = (xid->type==ID_TYPE_UID)?ALLOC_HWM_UID:ALLOC_HWM_GID;
     621
     622        if (!dbwrap_fetch_uint32(autorid_db, hwmkey, &hwm)) {
     623                DEBUG(1, ("Failed to fetch current allocation HWM value: %s\n",
     624                          nt_errstr(ret)));
     625                return NT_STATUS_INTERNAL_ERROR;
     626        }
     627
     628        if (hwm >= globalcfg->rangesize) {
     629                DEBUG(1, ("allocation range is depleted!\n"));
     630                return NT_STATUS_NO_MEMORY;
     631        }
     632
     633        ret = dbwrap_change_uint32_atomic(autorid_db, hwmkey, &(xid->id), 1);
     634        if (!NT_STATUS_IS_OK(ret)) {
     635                DEBUG(1, ("Fatal error while allocating new ID!\n"));
     636                return ret;
     637        }
     638
     639        xid->id = globalcfg->minvalue +
     640                  globalcfg->rangesize * domaincfg.domainnum +
     641                  xid->id;
     642
     643        DEBUG(10, ("Returned new %s %d from allocation range\n",
     644                   (xid->type==ID_TYPE_UID)?"uid":"gid", xid->id));
     645
     646        return ret;
     647}
     648
    544649/*
    545650  Close the idmap tdb instance
     
    549654        .unixids_to_sids = idmap_autorid_unixids_to_sids,
    550655        .sids_to_unixids = idmap_autorid_sids_to_unixids,
     656        .allocate_id     = idmap_autorid_allocate_id
    551657};
    552658
  • trunk/server/source3/winbindd/idmap_hash/idmap_hash.c

    r745 r751  
    260260static NTSTATUS nss_hash_init(struct nss_domain_entry *e )
    261261{
    262         return be_init(NULL);
     262        return NT_STATUS_OK;
    263263}
    264264
  • trunk/server/source3/winbindd/idmap_tdb2.c

    r745 r751  
    290290                goto failed;
    291291        }
    292         ctx->script = lp_parm_const_string(-1, config_option, "script", "NULL");
     292        ctx->script = lp_parm_const_string(-1, config_option, "script", NULL);
    293293        talloc_free(config_option);
    294294
  • trunk/server/source3/winbindd/wb_group_members.c

    r745 r751  
    210210         */
    211211
    212         if (tevent_req_nterror(req, status)) {
    213                 return;
     212        if (!NT_STATUS_IS_OK(status)) {
     213                if (!NT_STATUS_EQUAL(
     214                            status, NT_STATUS_TRUSTED_DOMAIN_FAILURE)) {
     215                        tevent_req_nterror(req, status);
     216                        return;
     217                }
     218                num_members = 0;
    214219        }
    215220
  • trunk/server/source3/winbindd/wb_lookupsids.c

    r745 r751  
    124124        state->num_sids = num_sids;
    125125
    126         if (num_sids == 0) {
    127                 tevent_req_done(req);
    128                 return tevent_req_post(req, ev);
    129         }
    130 
    131126        state->single_sids = TALLOC_ARRAY(state, uint32_t, num_sids);
    132127        if (tevent_req_nomem(state->single_sids, req)) {
     
    151146                state->res_names, struct lsa_TranslatedName, num_sids);
    152147        if (tevent_req_nomem(state->res_names->names, req)) {
     148                return tevent_req_post(req, ev);
     149        }
     150
     151        if (num_sids == 0) {
     152                tevent_req_done(req);
    153153                return tevent_req_post(req, ev);
    154154        }
  • trunk/server/source3/winbindd/wb_next_pwent.c

    r745 r751  
    3232static void wb_next_pwent_fill_done(struct tevent_req *subreq);
    3333
     34static struct winbindd_domain *wb_next_find_domain(struct winbindd_domain *domain)
     35{
     36        if (domain == NULL) {
     37                domain = domain_list();
     38        } else {
     39                domain = domain->next;
     40        }
     41
     42        if ((domain != NULL)
     43            && sid_check_is_domain(&domain->sid)) {
     44                domain = domain->next;
     45        }
     46
     47        if (domain == NULL) {
     48                return NULL;
     49        }
     50
     51        return domain;
     52}
     53
    3454struct tevent_req *wb_next_pwent_send(TALLOC_CTX *mem_ctx,
    3555                                      struct tevent_context *ev,
     
    5171                TALLOC_FREE(state->gstate->users);
    5272
    53                 if (state->gstate->domain == NULL) {
    54                         state->gstate->domain = domain_list();
    55                 } else {
    56                         state->gstate->domain = state->gstate->domain->next;
    57                 }
    58 
    59                 if ((state->gstate->domain != NULL)
    60                     && sid_check_is_domain(&state->gstate->domain->sid)) {
    61                         state->gstate->domain = state->gstate->domain->next;
    62                 }
    63 
     73                state->gstate->domain = wb_next_find_domain(state->gstate->domain);
    6474                if (state->gstate->domain == NULL) {
    6575                        tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES);
     
    149159        status = wb_fill_pwent_recv(subreq);
    150160        TALLOC_FREE(subreq);
    151         if (tevent_req_nterror(req, status)) {
     161        /*
     162         * When you try to enumerate users with 'getent passwd' and the user
     163         * doesn't have a uid set we should just move on.
     164         */
     165        if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) {
     166                state->gstate->next_user += 1;
     167
     168                if (state->gstate->next_user >= state->gstate->num_users) {
     169                        TALLOC_FREE(state->gstate->users);
     170
     171                        state->gstate->domain = wb_next_find_domain(state->gstate->domain);
     172                        if (state->gstate->domain == NULL) {
     173                                tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES);
     174                                return;
     175                        }
     176
     177                        subreq = wb_query_user_list_send(state, state->ev,
     178                                        state->gstate->domain);
     179                        if (tevent_req_nomem(subreq, req)) {
     180                                return;
     181                        }
     182                        tevent_req_set_callback(subreq, wb_next_pwent_fetch_done, req);
     183                        return;
     184                }
     185
     186                subreq = wb_fill_pwent_send(state,
     187                                            state->ev,
     188                                            &state->gstate->users[state->gstate->next_user],
     189                                            state->pw);
     190                if (tevent_req_nomem(subreq, req)) {
     191                        return;
     192                }
     193                tevent_req_set_callback(subreq, wb_next_pwent_fill_done, req);
     194
     195                return;
     196        } else if (tevent_req_nterror(req, status)) {
    152197                return;
    153198        }
  • trunk/server/source3/winbindd/winbindd.c

    r745 r751  
    6666
    6767        if (lp_loaded()) {
    68                 const char *fname = lp_configfile();
     68                char *fname = lp_configfile();
    6969
    7070                if (file_exist(fname) && !strcsequal(fname,get_dyn_CONFIGFILE())) {
    7171                        set_dyn_CONFIGFILE(fname);
    7272                }
     73                TALLOC_FREE(fname);
    7374        }
    7475
     
    588589        state->cmd_name = "unknown request";
    589590        state->recv_fn = NULL;
     591        state->last_access = time(NULL);
    590592
    591593        /* Process command */
     
    889891
    890892static bool client_is_idle(struct winbindd_cli_state *state) {
    891   return (state->response == NULL &&
     893  return (state->request == NULL &&
     894          state->response == NULL &&
    892895          !state->pwent_state && !state->grent_state);
    893896}
     
    13031306        }
    13041307
     1308        /* We call dump_core_setup one more time because the command line can
     1309         * set the log file or the log-basename and this will influence where
     1310         * cores are stored. Without this call get_dyn_LOGFILEBASE will be
     1311         * the default value derived from build's prefix. For EOM this value
     1312         * is often not related to the path where winbindd is actually run
     1313         * in production.
     1314         */
     1315        dump_core_setup("winbindd");
     1316
    13051317        if (is_daemon && interactive) {
    13061318                d_fprintf(stderr,"\nERROR: "
     
    13411353                exit(1);
    13421354        }
     1355        /* After parsing the configuration file we setup the core path one more time
     1356         * as the log file might have been set in the configuration and cores's
     1357         * path is by default basename(lp_logfile()).
     1358         */
     1359        dump_core_setup("winbindd");
    13431360
    13441361        /* Initialise messaging system */
  • trunk/server/source3/winbindd/winbindd_ads.c

    r745 r751  
    189189
    190190        rc = ads_search_retry(ads, &res, "(objectCategory=user)", attrs);
    191         if (!ADS_ERR_OK(rc) || !res) {
     191        if (!ADS_ERR_OK(rc)) {
    192192                DEBUG(1,("query_user_list ads_search: %s\n", ads_errstr(rc)));
     193                status = ads_ntstatus(rc);
     194        } else if (!res) {
     195                DEBUG(1,("query_user_list ads_search returned NULL res\n"));
     196
    193197                goto done;
    194198        }
     
    341345
    342346        rc = ads_search_retry(ads, &res, filter, attrs);
    343         if (!ADS_ERR_OK(rc) || !res) {
     347        if (!ADS_ERR_OK(rc)) {
     348                status = ads_ntstatus(rc);
    344349                DEBUG(1,("enum_dom_groups ads_search: %s\n", ads_errstr(rc)));
     350                goto done;
     351        } else if (!res) {
     352                DEBUG(1,("enum_dom_groups ads_search returned NULL res\n"));
    345353                goto done;
    346354        }
     
    551559        rc = ads_search_retry(ads, &msg, ldap_exp, attrs);
    552560        SAFE_FREE(ldap_exp);
    553         if (!ADS_ERR_OK(rc) || !msg) {
     561        if (!ADS_ERR_OK(rc)) {
    554562                DEBUG(1,("query_user(sid=%s) ads_search: %s\n",
    555563                         sid_string_dbg(sid), ads_errstr(rc)));
    556564                return ads_ntstatus(rc);
     565        } else if (!msg) {
     566                DEBUG(1,("query_user(sid=%s) ads_search returned NULL res\n",
     567                         sid_string_dbg(sid)));
     568                return NT_STATUS_INTERNAL_ERROR;
    557569        }
    558570
     
    663675        rc = ads_search_retry(ads, &res, ldap_exp, group_attrs);
    664676
    665         if (!ADS_ERR_OK(rc) || !res) {
     677        if (!ADS_ERR_OK(rc)) {
    666678                DEBUG(1,("lookup_usergroups ads_search member=%s: %s\n", user_dn, ads_errstr(rc)));
    667679                return ads_ntstatus(rc);
    668         }
     680        } else if (!res) {
     681                DEBUG(1,("lookup_usergroups ads_search returned NULL res\n"));
     682                return NT_STATUS_INTERNAL_ERROR;
     683        }
     684
    669685
    670686        count = ads_count_replies(ads, res);
  • trunk/server/source3/winbindd/winbindd_cache.c

    r745 r751  
    3939#define DBGC_CLASS DBGC_WINBIND
    4040
    41 #define WINBINDD_CACHE_VERSION 2
     41#define WINBINDD_CACHE_VER1 1 /* initial db version */
     42#define WINBINDD_CACHE_VER2 2 /* second version with timeouts for NDR entries */
     43
     44#define WINBINDD_CACHE_VERSION WINBINDD_CACHE_VER2
    4245#define WINBINDD_CACHE_VERSION_KEYSTR "WINBINDD_CACHE_VERSION"
    4346
     
    40824085}
    40834086
     4087static int wbcache_update_centry_fn(TDB_CONTEXT *tdb,
     4088                                    TDB_DATA key,
     4089                                    TDB_DATA data,
     4090                                    void *state)
     4091{
     4092        uint64_t ctimeout;
     4093        TDB_DATA blob;
     4094
     4095        if (is_non_centry_key(key)) {
     4096                return 0;
     4097        }
     4098
     4099        if (data.dptr == NULL || data.dsize == 0) {
     4100                if (tdb_delete(tdb, key) < 0) {
     4101                        DEBUG(0, ("tdb_delete for [%s] failed!\n",
     4102                                  key.dptr));
     4103                        return 1;
     4104                }
     4105        }
     4106
     4107        /* add timeout to blob (uint64_t) */
     4108        blob.dsize = data.dsize + 8;
     4109
     4110        blob.dptr = SMB_XMALLOC_ARRAY(uint8_t, blob.dsize);
     4111        if (blob.dptr == NULL) {
     4112                return 1;
     4113        }
     4114        memset(blob.dptr, 0, blob.dsize);
     4115
     4116        /* copy status and seqnum */
     4117        memcpy(blob.dptr, data.dptr, 8);
     4118
     4119        /* add timeout */
     4120        ctimeout = lp_winbind_cache_time() + time(NULL);
     4121        SBVAL(blob.dptr, 8, ctimeout);
     4122
     4123        /* copy the rest */
     4124        memcpy(blob.dptr + 16, data.dptr + 8, data.dsize - 8);
     4125
     4126        if (tdb_store(tdb, key, blob, TDB_REPLACE) < 0) {
     4127                DEBUG(0, ("tdb_store to update [%s] failed!\n",
     4128                          key.dptr));
     4129                SAFE_FREE(blob.dptr);
     4130                return 1;
     4131        }
     4132
     4133        SAFE_FREE(blob.dptr);
     4134        return 0;
     4135}
     4136
     4137static bool wbcache_upgrade_v1_to_v2(TDB_CONTEXT *tdb)
     4138{
     4139        int rc;
     4140
     4141        DEBUG(1, ("Upgrade to version 2 of the winbindd_cache.tdb\n"));
     4142
     4143        rc = tdb_traverse(tdb, wbcache_update_centry_fn, NULL);
     4144        if (rc < 0) {
     4145                return false;
     4146        }
     4147
     4148        return true;
     4149}
     4150
    40844151/***********************************************************************
    40854152 Try and validate every entry in the winbindd cache. If we fail here,
     
    40924159        const char *tdb_path = cache_path("winbindd_cache.tdb");
    40934160        TDB_CONTEXT *tdb = NULL;
     4161        uint32_t vers_id;
     4162        bool ok;
    40944163
    40954164        DEBUG(10, ("winbindd_validate_cache: replacing panic function\n"));
    40964165        smb_panic_fn = validate_panic;
    4097 
    40984166
    40994167        tdb = tdb_open_log(tdb_path,
     
    41104178                goto done;
    41114179        }
     4180
     4181        /* Version check and upgrade code. */
     4182        if (!tdb_fetch_uint32(tdb, WINBINDD_CACHE_VERSION_KEYSTR, &vers_id)) {
     4183                DEBUG(10, ("Fresh database\n"));
     4184                tdb_store_uint32(tdb, WINBINDD_CACHE_VERSION_KEYSTR, WINBINDD_CACHE_VERSION);
     4185                vers_id = WINBINDD_CACHE_VERSION;
     4186        }
     4187
     4188        if (vers_id != WINBINDD_CACHE_VERSION) {
     4189                if (vers_id == WINBINDD_CACHE_VER1) {
     4190                        ok = wbcache_upgrade_v1_to_v2(tdb);
     4191                        if (!ok) {
     4192                                DEBUG(10, ("winbindd_validate_cache: upgrade to version 2 failed.\n"));
     4193                                unlink(tdb_path);
     4194                                goto done;
     4195                        }
     4196
     4197                        tdb_store_uint32(tdb,
     4198                                         WINBINDD_CACHE_VERSION_KEYSTR,
     4199                                         WINBINDD_CACHE_VERSION);
     4200                        vers_id = WINBINDD_CACHE_VER2;
     4201                }
     4202        }
     4203
    41124204        tdb_close(tdb);
    41134205
     
    48044896                }
    48054897                entry_timeout = BVAL(data.dptr, 4);
    4806                 if (entry_timeout > time(NULL)) {
     4898                if (time(NULL) > entry_timeout) {
    48074899                        DEBUG(10, ("Entry has timed out\n"));
    48084900                        goto fail;
  • trunk/server/source3/winbindd/winbindd_cm.c

    r745 r751  
    11861186
    11871187                ads_destroy( &ads );
     1188                return false;
    11881189        }
    11891190#endif
    11901191
    1191         status = nbt_getdc(winbind_messaging_context(), pss, domain->name,
     1192        status = nbt_getdc(winbind_messaging_context(), 10, pss, domain->name,
    11921193                           &domain->sid, nt_version, mem_ctx, &nt_version,
    11931194                           &dc_name, NULL);
     
    17691770        }
    17701771
    1771         if (!winbindd_can_contact_domain(domain)) {
    1772                 invalidate_cm_connection(&domain->conn);
    1773                 domain->initialized = True;
    1774                 return NT_STATUS_OK;
    1775         }
    1776 
    17771772        if (connection_ok(domain)) {
    17781773                if (!domain->initialized) {
     
    19271922                                 domain->active_directory ? "" : "NOT "));
    19281923
     1924                        domain->can_do_ncacn_ip_tcp = domain->active_directory;
     1925                        domain->can_do_validation6 = domain->active_directory;
    19291926
    19301927                        domain->initialized = True;
  • trunk/server/source3/winbindd/winbindd_cred_cache.c

    r745 r751  
    491491                            const char *service,
    492492                            const char *username,
     493                            const char *pass,
    493494                            const char *realm,
    494495                            uid_t uid,
     
    592593
    593594                        DEBUG(10,("add_ccache_to_list: added krb5_ticket handler\n"));
    594                 }
     595
     596                }
     597
     598                /*
     599                 * If we're set up to renew our krb5 tickets, we must
     600                 * cache the credentials in memory for the ticket
     601                 * renew function (or increase the reference count
     602                 * if we're logging in more than once). Fix inspired
     603                 * by patch from Ian Gordon <ian.gordon@strath.ac.uk>
     604                 * for bugid #9098.
     605                 */
     606
     607                ntret = winbindd_add_memory_creds(username, uid, pass);
     608                DEBUG(10, ("winbindd_add_memory_creds returned: %s\n",
     609                        nt_errstr(ntret)));
    595610
    596611                return NT_STATUS_OK;
     
    675690                "added ccache [%s] for user [%s] to the list\n",
    676691                ccname, username));
     692
     693        if (entry->event) {
     694                /*
     695                 * If we're set up to renew our krb5 tickets, we must
     696                 * cache the credentials in memory for the ticket
     697                 * renew function. Fix inspired by patch from
     698                 * Ian Gordon <ian.gordon@strath.ac.uk> for
     699                 * bugid #9098.
     700                 */
     701
     702                ntret = winbindd_add_memory_creds(username, uid, pass);
     703                DEBUG(10, ("winbindd_add_memory_creds returned: %s\n",
     704                        nt_errstr(ntret)));
     705        }
    677706
    678707        return NT_STATUS_OK;
  • trunk/server/source3/winbindd/winbindd_dual.c

    r745 r751  
    4444extern struct winbindd_methods cache_methods;
    4545
     46static struct winbindd_child *winbindd_children = NULL;
     47
    4648/* Read some data from a client connection */
    4749
     
    172174                close(state->child->sock);
    173175                state->child->sock = -1;
     176                DLIST_REMOVE(winbindd_children, state->child);
    174177                tevent_req_error(req, err);
    175178                return;
     
    489492        SMB_ASSERT(child->binding_handle != NULL);
    490493}
    491 
    492 static struct winbindd_child *winbindd_children = NULL;
    493494
    494495void winbind_child_died(pid_t pid)
     
    13301331                close(fdpair[0]);
    13311332
    1332                 nread = read(fdpair[1], &status, sizeof(status));
     1333                nread = sys_read(fdpair[1], &status, sizeof(status));
    13331334                if (nread != sizeof(status)) {
    13341335                        DEBUG(1, ("fork_domain_child: Could not read child status: "
     
    13611362        status = winbindd_reinit_after_fork(child, child->logfilename);
    13621363
    1363         nwritten = write(state.sock, &status, sizeof(status));
     1364        nwritten = sys_write(state.sock, &status, sizeof(status));
    13641365        if (nwritten != sizeof(status)) {
    13651366                DEBUG(1, ("fork_domain_child: Could not write status: "
  • trunk/server/source3/winbindd/winbindd_group.c

    r414 r751  
    3636        fstring full_group_name;
    3737        char *mapped_name = NULL;
    38         struct winbindd_domain *domain = find_domain_from_name_noinit(dom_name);
     38        struct winbindd_domain *domain;
    3939        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
     40
     41        domain = find_domain_from_name_noinit(dom_name);
     42        if (domain == NULL) {
     43                DEBUG(0, ("Failed to find domain '%s'. "
     44                          "Check connection to trusted domains!\n",
     45                          dom_name));
     46                return false;
     47        }
    4048
    4149        nt_status = normalize_name_map(mem_ctx, domain, gr_name,
     
    116124
    117125        res = talloc_dict_traverse(members, getgr_calc_memberlen, &c);
    118         if (res != 0) {
     126        if (res == -1) {
    119127                DEBUG(5, ("talloc_dict_traverse failed\n"));
    120128                return NT_STATUS_INTERNAL_ERROR;
     
    129137
    130138        res = talloc_dict_traverse(members, getgr_unparse_members, &m);
    131         if (res != 0) {
     139        if (res == -1) {
    132140                DEBUG(5, ("talloc_dict_traverse failed\n"));
    133141                TALLOC_FREE(m.buf);
  • trunk/server/source3/winbindd/winbindd_pam.c

    r745 r751  
    307307                                      &token->sids,
    308308                                      &token->num_sids,
    309                                       true, false);
     309                                      true);
    310310        if (!NT_STATUS_IS_OK(status)) {
    311311                TALLOC_FREE(frame);
     
    641641                                            service,
    642642                                            user,
     643                                            pass,
    643644                                            realm,
    644645                                            uid,
     
    958959                                                            service,
    959960                                                            state->request->data.auth.user,
     961                                                            state->request->data.auth.pass,
    960962                                                            domain->alt_name,
    961963                                                            uid,
     
    10791081                                  state->request->data.auth.user, name_domain, name_user, name_domain));
    10801082
    1081                         contact_domain = find_our_domain();
     1083                        result =  NT_STATUS_NO_SUCH_USER;
     1084                        goto done;
    10821085                }
    10831086        }
     
    11661169                        DEBUG(3,("could not open handle to NETLOGON pipe (error: %s)\n",
    11671170                                  nt_errstr(result)));
     1171                        if (NT_STATUS_EQUAL(result, NT_STATUS_IO_TIMEOUT)) {
     1172                                if (attempts > 0) {
     1173                                        DEBUG(3, ("This is the second problem for this "
     1174                                                "particular call, forcing the close of "
     1175                                                "this connection\n"));
     1176                                        invalidate_cm_connection(&domain->conn);
     1177                                } else {
     1178                                        DEBUG(3, ("First call to cm_connect_netlogon "
     1179                                                "has timed out, retrying\n"));
     1180                                        continue;
     1181                                }
     1182                        }
    11681183                        return result;
    11691184                }
     
    12211236                }
    12221237
    1223                 if (domain->can_do_samlogon_ex) {
     1238                if (domain->can_do_samlogon_ex && domain->can_do_validation6) {
    12241239                        result = rpccli_netlogon_sam_network_logon_ex(
    12251240                                        netlogon_pipe,
    12261241                                        mem_ctx,
    1227                                         0,
     1242                                        logon_parameters,
     1243                                        server,         /* server name */
     1244                                        username,       /* user name */
     1245                                        domainname,     /* target domain */
     1246                                        workstation,    /* workstation */
     1247                                        chal,
     1248                                        6,
     1249                                        lm_response,
     1250                                        nt_response,
     1251                                        info3);
     1252                } else {
     1253                        result = rpccli_netlogon_sam_network_logon(
     1254                                        netlogon_pipe,
     1255                                        mem_ctx,
     1256                                        logon_parameters,
    12281257                                        server,         /* server name */
    12291258                                        username,       /* user name */
     
    12351264                                        nt_response,
    12361265                                        info3);
    1237                 } else {
    1238                         result = rpccli_netlogon_sam_network_logon(
    1239                                         netlogon_pipe,
    1240                                         mem_ctx,
    1241                                         0,
    1242                                         server,         /* server name */
    1243                                         username,       /* user name */
    1244                                         domainname,     /* target domain */
    1245                                         workstation,    /* workstation */
    1246                                         chal,
    1247                                         domain->can_do_validation6 ? 6 : 3,
    1248                                         lm_response,
    1249                                         nt_response,
    1250                                         info3);
    12511266                }
    12521267
     
    13091324
    13101325                if ( NT_STATUS_EQUAL(result, NT_STATUS_ACCESS_DENIED) ) {
    1311                         DEBUG(3,("winbindd_pam_auth: sam_logon returned "
     1326                        DEBUG(3,("winbind_samlogon_retry_loop: sam_logon returned "
    13121327                                 "ACCESS_DENIED.  Maybe the trust account "
    13131328                                "password was changed and we didn't know it. "
     
    13201335        } while ( (attempts < 2) && retry );
    13211336
     1337        if (NT_STATUS_EQUAL(result, NT_STATUS_IO_TIMEOUT)) {
     1338                DEBUG(3,("winbind_samlogon_retry_loop: sam_network_logon(ex) "
     1339                                "returned NT_STATUS_IO_TIMEOUT after the retry."
     1340                                "Killing connections to domain %s\n",
     1341                        domainname));
     1342                invalidate_cm_connection(&domain->conn);
     1343        }
    13221344        return result;
    13231345}
     
    20862108        }
    20872109
     2110        /*
     2111         * Remove any mlock'ed memory creds in the child
     2112         * we might be using for krb5 ticket renewal.
     2113         */
     2114
     2115        winbindd_delete_memory_creds(state->request->data.logoff.user);
     2116
    20882117#else
    20892118        result = NT_STATUS_NOT_SUPPORTED;
  • trunk/server/source3/winbindd/winbindd_proto.h

    r745 r751  
    189189                            const char *service,
    190190                            const char *username,
     191                            const char *password,
    191192                            const char *realm,
    192193                            uid_t uid,
  • trunk/server/source3/winbindd/winbindd_sids_to_xids.c

    r745 r751  
    124124                                           struct id_map *map)
    125125{
    126         uid_t uid;
    127         gid_t gid;
    128         bool expired;
     126        bool is_online = is_domain_online(find_our_domain());
     127        gid_t gid = (gid_t)-1;
     128        bool gid_expired = false;
     129        bool gid_cached = false;
     130        bool gid_negative = false;
     131        uid_t uid = (uid_t)-1;
     132        bool uid_expired = false;
     133        bool uid_cached = false;
     134        bool uid_negative = false;
    129135
    130136        if (!winbindd_use_idmap_cache()) {
    131137                return false;
    132138        }
     139
    133140        /*
    134141         * SIDS_TO_XIDS is primarily used to resolve the user's group
    135142         * sids. So we check groups before users.
    136143         */
    137         if (idmap_cache_find_sid2gid(sid, &gid, &expired)) {
    138                 if (expired && is_domain_offline(find_our_domain())) {
    139                         return false;
    140                 }
     144        gid_cached = idmap_cache_find_sid2gid(sid, &gid, &gid_expired);
     145        if (!is_online) {
     146                gid_expired = false;
     147        }
     148        if (gid_cached && !gid_expired) {
     149                if (gid != (gid_t)-1) {
     150                        map->sid = sid;
     151                        map->xid.id = gid;
     152                        map->xid.type = ID_TYPE_GID;
     153                        map->status = ID_MAPPED;
     154                        return true;
     155                }
     156                gid_negative = true;
     157        }
     158        uid_cached = idmap_cache_find_sid2uid(sid, &uid, &uid_expired);
     159        if (!is_online) {
     160                uid_expired = false;
     161        }
     162        if (uid_cached && !uid_expired) {
     163                if (uid != (uid_t)-1) {
     164                        map->sid = sid;
     165                        map->xid.id = uid;
     166                        map->xid.type = ID_TYPE_UID;
     167                        map->status = ID_MAPPED;
     168                        return true;
     169                }
     170                uid_negative = true;
     171        }
     172
     173        /*
     174         * Here we know that we only have negative
     175         * or no entries.
     176         *
     177         * All valid cases already returned to the caller.
     178         */
     179
     180        if (gid_negative && uid_negative) {
    141181                map->sid = sid;
    142                 map->xid.id = gid;
     182                map->xid.id = UINT32_MAX;
     183                map->xid.type = ID_TYPE_NOT_SPECIFIED;
     184                map->status = ID_MAPPED;
     185                return true;
     186        }
     187
     188        if (gid_negative) {
     189                map->sid = sid;
     190                map->xid.id = gid; /* this is (gid_t)-1 */
    143191                map->xid.type = ID_TYPE_GID;
    144192                map->status = ID_MAPPED;
    145193                return true;
    146194        }
    147         if (idmap_cache_find_sid2uid(sid, &uid, &expired)) {
    148                 if (expired && is_domain_online(find_our_domain())) {
    149                         return false;
    150                 }
     195
     196        if (uid_negative) {
    151197                map->sid = sid;
    152                 map->xid.id = uid;
     198                map->xid.id = uid; /* this is (uid_t)-1 */
    153199                map->xid.type = ID_TYPE_UID;
    154200                map->status = ID_MAPPED;
    155201                return true;
    156202        }
     203
    157204        return false;
    158205}
    159 
    160206
    161207static void winbindd_sids_to_xids_lookupsids_done(struct tevent_req *subreq)
     
    257303        for (i=0; i<state->num_sids; i++) {
    258304                char type;
    259                 uint64_t unix_id = (uint64_t)-1;
     305                uint32_t unix_id = UINT32_MAX;
    260306                bool found = true;
    261307
    262308                if (state->cached[i].sid != NULL) {
    263309                        unix_id = state->cached[i].xid.id;
    264                         if (state->cached[i].xid.type == ID_TYPE_UID) {
     310
     311                        switch (state->cached[i].xid.type) {
     312                        case ID_TYPE_UID:
    265313                                type = 'U';
    266                         } else {
     314                                break;
     315                        case ID_TYPE_GID:
    267316                                type = 'G';
     317                                break;
     318                        default:
     319                                found = false;
     320                                break;
    268321                        }
    269322                } else {
    270323                        unix_id = state->ids.ids[num_non_cached].unix_id;
    271                         if (unix_id == -1) {
    272                                 found = false;
    273                         }
     324
    274325                        switch(state->ids.ids[num_non_cached].type) {
    275326                        case WBC_ID_TYPE_UID:
     
    287338                        default:
    288339                                found = false;
     340                                break;
    289341                        }
    290342                        num_non_cached += 1;
     343                }
     344
     345                if (unix_id == UINT32_MAX) {
     346                        found = false;
    291347                }
    292348
  • trunk/server/source3/winbindd/winbindd_util.c

    r745 r751  
    10341034        }
    10351035
    1036         /* Skip Domain local groups outside our domain.
    1037            We'll get these from the getsidaliases() RPC call. */
     1036        /*
     1037         * Before bug #7843 the "Domain Local" groups were added with a
     1038         * lookupuseraliases call, but this isn't done anymore for our domain
     1039         * so we need to resolve resource groups here.
     1040         *
     1041         * When to use Resource Groups:
     1042         * http://technet.microsoft.com/en-us/library/cc753670%28v=WS.10%29.aspx
     1043         */
    10381044        status = sid_array_from_info3(mem_ctx, info3,
    10391045                                      user_sids,
    10401046                                      &num_groups,
    1041                                       false, true);
     1047                                      false);
    10421048
    10431049        if (!NT_STATUS_IS_OK(status)) {
Note: See TracChangeset for help on using the changeset viewer.