[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Tue Mar 16 15:38:01 MDT 2010
The branch, master has been updated
via 2b4ce9a... s3: Make login_cache_write take a pointer
via 276b1aa... s3: Make login_cache_read take a pointer, avoid a malloc
via 13a278c... s3: Remove a typedef
via 02d7cdc... s3: Fix some nonempty blank lines
from 0d8ab38... s3: fix buildwarning in smbta-util.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 2b4ce9a73f6b041f3cc69125e45b9f61e0155ff5
Author: Volker Lendecke <vl at samba.org>
Date: Tue Mar 16 22:22:21 2010 +0100
s3: Make login_cache_write take a pointer
commit 276b1aa1891df2a31e8c65b04f41b0a0ebb57335
Author: Volker Lendecke <vl at samba.org>
Date: Tue Mar 16 22:18:52 2010 +0100
s3: Make login_cache_read take a pointer, avoid a malloc
commit 13a278c1b901cadef7e09d1dc6a89d935ebb73ea
Author: Volker Lendecke <vl at samba.org>
Date: Tue Mar 16 22:08:37 2010 +0100
s3: Remove a typedef
commit 02d7cdc671e27b5ed717c4c0e088b8457caa6e4a
Author: Volker Lendecke <vl at samba.org>
Date: Tue Mar 16 22:23:06 2010 +0100
s3: Fix some nonempty blank lines
-----------------------------------------------------------------------
Summary of changes:
source3/include/passdb.h | 4 +-
source3/include/proto.h | 5 ++-
source3/passdb/login_cache.c | 49 ++++++++++++++++++-----------------------
source3/passdb/pdb_ldap.c | 21 ++++++++---------
4 files changed, 37 insertions(+), 42 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/passdb.h b/source3/include/passdb.h
index 9be2a69..3ebf72d 100644
--- a/source3/include/passdb.h
+++ b/source3/include/passdb.h
@@ -104,12 +104,12 @@ enum pdb_value_state {
#define IS_SAM_DEFAULT(x, flag) (pdb_get_init_flags(x, flag) == PDB_DEFAULT)
/* cache for bad password lockout data, to be used on replicated SAMs */
-typedef struct logon_cache_struct {
+struct login_cache {
time_t entry_timestamp;
uint32 acct_ctrl;
uint16 bad_password_count;
time_t bad_password_time;
-} LOGIN_CACHE;
+};
#define SAMU_BUFFER_V0 0
#define SAMU_BUFFER_V1 1
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6e210de..ad95863 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4409,8 +4409,9 @@ char* get_string_param( const char* param );
bool login_cache_init(void);
bool login_cache_shutdown(void);
-LOGIN_CACHE * login_cache_read(struct samu *sampass);
-bool login_cache_write(const struct samu *sampass, LOGIN_CACHE entry);
+bool login_cache_read(struct samu *sampass, struct login_cache *entry);
+bool login_cache_write(const struct samu *sampass,
+ const struct login_cache *entry);
bool login_cache_delentry(const struct samu *sampass);
/* The following definitions come from passdb/lookup_sid.c */
diff --git a/source3/passdb/login_cache.c b/source3/passdb/login_cache.c
index 5630372..cf6c796 100644
--- a/source3/passdb/login_cache.c
+++ b/source3/passdb/login_cache.c
@@ -2,17 +2,17 @@
Unix SMB/CIFS implementation.
struct samu local cache for
Copyright (C) Jim McDonough (jmcd at us.ibm.com) 2004.
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -31,7 +31,7 @@ static TDB_CONTEXT *cache;
bool login_cache_init(void)
{
char* cache_fname = NULL;
-
+
/* skip file open if it's already opened */
if (cache) return True;
@@ -63,24 +63,24 @@ bool login_cache_shutdown(void)
}
/* if we can't read the cache, oh well, no need to return anything */
-LOGIN_CACHE * login_cache_read(struct samu *sampass)
+bool login_cache_read(struct samu *sampass, struct login_cache *entry)
{
char *keystr;
TDB_DATA databuf;
- 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,11 +88,6 @@ LOGIN_CACHE * login_cache_read(struct samu *sampass)
databuf = tdb_fetch_bystring(cache, keystr);
SAFE_FREE(keystr);
- if (!(entry = SMB_MALLOC_P(LOGIN_CACHE))) {
- 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,
@@ -101,9 +96,8 @@ 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. */
@@ -115,16 +109,17 @@ 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, LOGIN_CACHE entry)
+bool login_cache_write(const struct samu *sampass,
+ const struct login_cache *entry)
{
char *keystr;
TDB_DATA databuf;
bool ret;
uint32_t entry_timestamp;
- uint32_t bad_password_time = (uint32_t)entry.bad_password_time;
+ uint32_t bad_password_time = entry->bad_password_time;
if (!login_cache_init())
return False;
@@ -144,19 +139,19 @@ bool login_cache_write(const struct samu *sampass, LOGIN_CACHE entry)
databuf.dsize =
tdb_pack(NULL, 0, SAM_CACHE_FORMAT,
entry_timestamp,
- entry.acct_ctrl,
- entry.bad_password_count,
+ entry->acct_ctrl,
+ entry->bad_password_count,
bad_password_time);
databuf.dptr = SMB_MALLOC_ARRAY(uint8, databuf.dsize);
if (!databuf.dptr) {
SAFE_FREE(keystr);
return False;
}
-
+
if (tdb_pack(databuf.dptr, databuf.dsize, SAM_CACHE_FORMAT,
entry_timestamp,
- entry.acct_ctrl,
- entry.bad_password_count,
+ entry->acct_ctrl,
+ entry->bad_password_count,
bad_password_time)
!= databuf.dsize) {
SAFE_FREE(keystr);
@@ -174,7 +169,7 @@ bool login_cache_delentry(const struct samu *sampass)
{
int ret;
char *keystr;
-
+
if (!login_cache_init())
return False;
@@ -191,7 +186,7 @@ bool login_cache_delentry(const struct samu *sampass)
DEBUG(9, ("About to delete entry for %s\n", keystr));
ret = tdb_delete_bystring(cache, keystr);
DEBUG(9, ("tdb_delete returned %d\n", ret));
-
+
SAFE_FREE(keystr);
return ret == 0;
}
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index d079262..4ff718e 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;
- 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;
}
@@ -1511,7 +1510,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
DEBUG(7, ("bad password count is reset, deleting login cache entry for %s\n", pdb_get_nt_username(sampass)));
login_cache_delentry(sampass);
} else {
- LOGIN_CACHE cache_entry;
+ struct login_cache cache_entry;
cache_entry.entry_timestamp = time(NULL);
cache_entry.acct_ctrl = pdb_get_acct_ctrl(sampass);
@@ -1519,7 +1518,7 @@ static bool init_ldap_from_sam (struct ldapsam_privates *ldap_state,
cache_entry.bad_password_time = badtime;
DEBUG(7, ("Updating bad password count and time in login cache\n"));
- login_cache_write(sampass, cache_entry);
+ login_cache_write(sampass, &cache_entry);
}
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list