summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/passdb/login_cache.c23
-rw-r--r--source3/passdb/pdb_ldap.c17
3 files changed, 17 insertions, 25 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f2ba8e3b24..68a3e5cf7b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4409,7 +4409,7 @@ char* get_string_param( const char* param );
bool login_cache_init(void);
bool login_cache_shutdown(void);
-struct login_cache * login_cache_read(struct samu *sampass);
+bool login_cache_read(struct samu *sampass, struct login_cache *entry);
bool login_cache_write(const struct samu *sampass, struct login_cache entry);
bool login_cache_delentry(const struct samu *sampass);
diff --git a/source3/passdb/login_cache.c b/source3/passdb/login_cache.c
index 6ac6d52a63..2f9f000f11 100644
--- a/source3/passdb/login_cache.c
+++ b/source3/passdb/login_cache.c
@@ -63,24 +63,24 @@ bool login_cache_shutdown(void)
}
/* if we can't read the cache, oh well, no need to return anything */
-struct login_cache * login_cache_read(struct samu *sampass)
+bool login_cache_read(struct samu *sampass, struct login_cache *entry)
{
char *keystr;
TDB_DATA databuf;
- struct login_cache *entry;
uint32_t entry_timestamp = 0, bad_password_time = 0;
- if (!login_cache_init())
- return NULL;
+ if (!login_cache_init()) {
+ return false;
+ }
if (pdb_get_nt_username(sampass) == NULL) {
- return NULL;
+ return false;
}
keystr = SMB_STRDUP(pdb_get_nt_username(sampass));
if (!keystr || !keystr[0]) {
SAFE_FREE(keystr);
- return NULL;
+ return false;
}
DEBUG(7, ("Looking up login cache for user %s\n",
@@ -88,12 +88,6 @@ struct login_cache * login_cache_read(struct samu *sampass)
databuf = tdb_fetch_bystring(cache, keystr);
SAFE_FREE(keystr);
- entry = SMB_MALLOC_P(struct login_cache);
- if (entry == NULL) {
- DEBUG(1, ("Unable to allocate cache entry buffer!\n"));
- SAFE_FREE(databuf.dptr);
- return NULL;
- }
ZERO_STRUCTP(entry);
if (tdb_unpack (databuf.dptr, databuf.dsize, SAM_CACHE_FORMAT,
@@ -102,9 +96,8 @@ struct login_cache * login_cache_read(struct samu *sampass)
&entry->bad_password_count,
&bad_password_time) == -1) {
DEBUG(7, ("No cache entry found\n"));
- SAFE_FREE(entry);
SAFE_FREE(databuf.dptr);
- return NULL;
+ return false;
}
/* Deal with possible 64-bit time_t. */
@@ -116,7 +109,7 @@ struct login_cache * login_cache_read(struct samu *sampass)
DEBUG(5, ("Found login cache entry: timestamp %12u, flags 0x%x, count %d, time %12u\n",
(unsigned int)entry->entry_timestamp, entry->acct_ctrl,
entry->bad_password_count, (unsigned int)entry->bad_password_time));
- return entry;
+ return true;
}
bool login_cache_write(const struct samu *sampass, struct login_cache entry)
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 1e3413e381..b3eb37501c 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -540,7 +540,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
uint32 hours_len;
uint8 hours[MAX_HOURS_LEN];
char *temp = NULL;
- struct login_cache *cache_entry = NULL;
+ struct login_cache cache_entry;
uint32 pwHistLen;
bool expand_explicit = lp_passdb_expand_explicit();
bool ret = false;
@@ -1120,7 +1120,7 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
}
/* see if we have newer updates */
- if (!(cache_entry = login_cache_read(sampass))) {
+ if (!login_cache_read(sampass, &cache_entry)) {
DEBUG (9, ("No cache entry, bad count = %u, bad time = %u\n",
(unsigned int)pdb_get_bad_password_count(sampass),
(unsigned int)pdb_get_bad_password_time(sampass)));
@@ -1130,10 +1130,10 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
DEBUG(7, ("ldap time is %u, cache time is %u, bad time = %u\n",
(unsigned int)ldap_entry_time,
- (unsigned int)cache_entry->entry_timestamp,
- (unsigned int)cache_entry->bad_password_time));
+ (unsigned int)cache_entry.entry_timestamp,
+ (unsigned int)cache_entry.bad_password_time));
- if (ldap_entry_time > cache_entry->entry_timestamp) {
+ if (ldap_entry_time > cache_entry.entry_timestamp) {
/* cache is older than directory , so
we need to delete the entry but allow the
fields to be written out */
@@ -1142,13 +1142,13 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
/* read cache in */
pdb_set_acct_ctrl(sampass,
pdb_get_acct_ctrl(sampass) |
- (cache_entry->acct_ctrl & ACB_AUTOLOCK),
+ (cache_entry.acct_ctrl & ACB_AUTOLOCK),
PDB_SET);
pdb_set_bad_password_count(sampass,
- cache_entry->bad_password_count,
+ cache_entry.bad_password_count,
PDB_SET);
pdb_set_bad_password_time(sampass,
- cache_entry->bad_password_time,
+ cache_entry.bad_password_time,
PDB_SET);
}
@@ -1157,7 +1157,6 @@ static bool init_sam_from_ldap(struct ldapsam_privates *ldap_state,
fn_exit:
TALLOC_FREE(ctx);
- SAFE_FREE(cache_entry);
return ret;
}