summaryrefslogtreecommitdiff
path: root/source/nsswitch/idmap_ad.c
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-02-08 17:02:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:50 -0500
commit7e1a84b7226fb8dcd5d34c64a3478a6d886a9a91 (patch)
tree889d4bf55b8b13de330867db8c93f1e4e7bb8427 /source/nsswitch/idmap_ad.c
parente7e44554bf7c61020e2c5c652e3f8f37a296d3aa (diff)
downloadsamba-7e1a84b7226fb8dcd5d34c64a3478a6d886a9a91.tar.gz
r21240: Fix longstanding Bug #4009.
For the winbind cached ADS LDAP connection handling (ads_cached_connection()) we were (incorrectly) assuming that the service ticket lifetime equaled the tgt lifetime. For setups where the service ticket just lives 10 minutes, we were leaving hundreds of LDAP connections in CLOSE_WAIT state, until we fail to service entirely with "Too many open files". Also sequence_number() in winbindd_ads.c needs to delete the cached LDAP connection after the ads_do_search_retry() has failed to submit the search request (although the bind succeeded (returning an expired service ticket that we cannot delete from the memory cred cache - this will get fixed later)). Guenther
Diffstat (limited to 'source/nsswitch/idmap_ad.c')
-rw-r--r--source/nsswitch/idmap_ad.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/nsswitch/idmap_ad.c b/source/nsswitch/idmap_ad.c
index a0ed0847657..fee53a0539e 100644
--- a/source/nsswitch/idmap_ad.c
+++ b/source/nsswitch/idmap_ad.c
@@ -64,16 +64,23 @@ static ADS_STRUCT *ad_idmap_cached_connection_internal(void)
struct in_addr dc_ip;
if (ad_idmap_ads != NULL) {
+
+ time_t expire;
+ time_t now = time(NULL);
+
ads = ad_idmap_ads;
+ expire = MIN(ads->auth.tgt_expire, ads->auth.tgs_expire);
+
/* check for a valid structure */
+ DEBUG(7, ("Current tickets expire in %d seconds (at %d, time is now %d)\n",
+ (uint32)expire-(uint32)now, (uint32) expire, (uint32) now));
- DEBUG(7, ("Current tickets expire at %d, time is now %d\n",
- (uint32) ads->auth.expire, (uint32) time(NULL)));
- if ( ads->config.realm && (ads->auth.expire > time(NULL))) {
+ if ( ads->config.realm && (expire > time(NULL))) {
return ads;
} else {
/* we own this ADS_STRUCT so make sure it goes away */
+ DEBUG(7,("Deleting expired krb5 credential cache\n"));
ads->is_mine = True;
ads_destroy( &ads );
ads_kdestroy(WINBIND_CCACHE_NAME);