Ignore:
Timestamp:
Apr 25, 2007, 9:44:55 AM (14 years ago)
Author:
Paul Smedley
Message:

Code updated to Samba 3.0.25rc2 level

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/samba/source/nsswitch/idmap_cache.c

    r26 r30  
    366366/* search the cahce for the SID an return a mapping if found *
    367367 *
    368  * 3 cases are possible
     368 * 4 cases are possible
    369369 *
    370370 * 1 map found
     
    374374 * 3 negative cache found
    375375 *      in this case id->status = ID_UNMAPPED and NT_STATUS_OK is returned
    376  *
    377  * As a special case if the cache is expired NT_STATUS_SYNCHRONIZATION_REQUIRED
    378  * is returned instead of NT_STATUS_OK. In this case revalidation of the cache
    379  * is needed.
     376 * 4 map found but timer expired
     377 *      in this case id->status = ID_EXPIRED and NT_STATUS_SYNCHRONIZATION_REQUIRED
     378 *      is returned. In this case revalidation of the cache is needed.
    380379 */
    381380
     
    384383        NTSTATUS ret;
    385384        TDB_DATA keybuf, databuf;
    386         time_t t;
     385        time_t t, now;
    387386        char *sidkey;
    388387        char *endptr;
    389388
    390         /* make sure it is marked as not mapped by default */
     389        /* make sure it is marked as unknown by default */
    391390        id->status = ID_UNKNOWN;
    392391       
     
    414413        }
    415414
     415        now = time(NULL);
     416
    416417        /* check it is not negative */
    417418        if (strcmp("IDMAP/NEGATIVE", endptr+1) != 0) {
    418                
     419
    419420                DEBUG(10, ("Returning %s cache entry: key = %s, value = %s, "
    420                            "timeout = %s", t > time(NULL) ? "valid" :
     421                           "timeout = %s", t > now ? "valid" :
    421422                           "expired", sidkey, endptr+1, ctime(&t)));
    422423
     
    432433                /* here ret == NT_STATUS_OK and id->status = ID_MAPPED */
    433434
    434                 if (t <= time(NULL)) {
    435                         /* If we've been told to be offline - stay in
    436                            that state... */
    437                         if (lp_winbind_offline_logon() &&
    438                             get_global_winbindd_state_offline())
    439                         {
    440                                 DEBUG(10,("idmap_cache_map_sid: winbindd is "
    441                                           "globally offline.\n"));
    442                         } else {
    443                                 /* We're expired, set an error code
    444                                    for upper layer */
    445                                 ret = NT_STATUS_SYNCHRONIZATION_REQUIRED;
    446                         }                       
     435                if (t <= now) {
     436       
     437                        /* we have it, but it is expired */
     438                        id->status = ID_EXPIRED;
     439                               
     440                        /* We're expired, set an error code
     441                           for upper layer */
     442                        ret = NT_STATUS_SYNCHRONIZATION_REQUIRED;
    447443                }
    448444        } else {
    449                 if (t <= time(NULL)) {
    450                         /* If we've been told to be offline - stay in
    451                            that state... */
    452                         if (lp_winbind_offline_logon() &&
    453                             get_global_winbindd_state_offline())
    454                         {
    455                                 DEBUG(10,("idmap_cache_map_sid: winbindd is "
    456                                           "globally offline.\n"));
    457                         } else {                               
    458                                 /* We're expired, delete the entry and return
    459                                    not mapped */
    460                                 tdb_delete(cache->tdb, keybuf);
    461                                 ret = NT_STATUS_NONE_MAPPED;
    462                         }                       
     445                if (t <= now) {
     446                        /* We're expired, delete the NEGATIVE entry and return
     447                           not mapped */
     448                        tdb_delete(cache->tdb, keybuf);
     449                        ret = NT_STATUS_NONE_MAPPED;
    463450                } else {
    464451                        /* this is not mapped as it was a negative cache hit */
     
    484471 * 3 negative cache found
    485472 *      in this case id->status = ID_UNMAPPED and NT_STATUS_OK is returned
    486  *
    487  * As a special case if the cache is expired NT_STATUS_SYNCHRONIZATION_REQUIRED
    488  * is returned instead of NT_STATUS_OK. In this case revalidation of the cache
    489  * is needed.
     473 * 4 map found but timer expired
     474 *      in this case id->status = ID_EXPIRED and NT_STATUS_SYNCHRONIZATION_REQUIRED
     475 *      is returned. In this case revalidation of the cache is needed.
    490476 */
    491477
     
    494480        NTSTATUS ret;
    495481        TDB_DATA keybuf, databuf;
    496         time_t t;
     482        time_t t, now;
    497483        char *idkey;
    498484        char *endptr;
    499485
    500         /* make sure it is marked as not mapped by default */
     486        /* make sure it is marked as unknown by default */
    501487        id->status = ID_UNKNOWN;
    502488       
     
    524510        }
    525511
     512        now = time(NULL);
     513
    526514        /* check it is not negative */
    527515        if (strcmp("IDMAP/NEGATIVE", endptr+1) != 0) {
    528516               
    529517                DEBUG(10, ("Returning %s cache entry: key = %s, value = %s, "
    530                            "timeout = %s", t > time(NULL) ? "valid" :
     518                           "timeout = %s", t > now ? "valid" :
    531519                           "expired", idkey, endptr+1, ctime(&t)));
    532520
     
    540528                }
    541529
    542                 /* here ret == NT_STATUS_OK and id->mapped = True */
    543 
    544                 if (t <= time(NULL)) {
    545                         /* If we've been told to be offline - stay in
    546                            that state... */
    547                         if (lp_winbind_offline_logon() &&
    548                             get_global_winbindd_state_offline())
    549                         {
    550                                 DEBUG(10,("idmap_cache_map_sid: winbindd is "
    551                                           "globally offline.\n"));
    552                         } else {
    553                                 /* We're expired, set an error code
    554                                    for upper layer */
    555                                 ret = NT_STATUS_SYNCHRONIZATION_REQUIRED;
    556                         }                       
     530                /* here ret == NT_STATUS_OK and id->mapped = ID_MAPPED */
     531
     532                if (t <= now) {
     533
     534                        /* we have it, but it is expired */
     535                        id->status = ID_EXPIRED;
     536
     537                        /* We're expired, set an error code
     538                           for upper layer */
     539                        ret = NT_STATUS_SYNCHRONIZATION_REQUIRED;
    557540                }
    558541        } else {
    559                 if (t <= time(NULL)) {
    560                         /* If we've been told to be offline - stay in
    561                            that state... */
    562                         if (lp_winbind_offline_logon() &&
    563                             get_global_winbindd_state_offline())
    564                         {
    565                                 DEBUG(10,("idmap_cache_map_sid: winbindd is "
    566                                           "globally offline.\n"));
    567                         } else {
    568                                 /* We're expired, delete the entry and
    569                                    return not mapped */
    570                                 tdb_delete(cache->tdb, keybuf);
    571                                 ret = NT_STATUS_NONE_MAPPED;
    572                         }                       
     542                if (t <= now) {
     543                        /* We're expired, delete the NEGATIVE entry and return
     544                           not mapped */
     545                        tdb_delete(cache->tdb, keybuf);
     546                        ret = NT_STATUS_NONE_MAPPED;
    573547                } else {
    574                         /* this is not mapped is it was a negative cache hit */
     548                        /* this is not mapped as it was a negative cache hit */
    575549                        id->status = ID_UNMAPPED;
    576550                        ret = NT_STATUS_OK;
Note: See TracChangeset for help on using the changeset viewer.