summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2007-02-24 12:40:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:10 -0500
commit56c1d7e5078ca6b79bb286f458956b5f49c83e81 (patch)
treef59e13e33a7dbd9ff81ced5dbf1fd23ff469d6ac /source3/nsswitch
parentd43dbee7133e069f0f34d6adea8d8b4ac0268797 (diff)
downloadsamba-56c1d7e5078ca6b79bb286f458956b5f49c83e81.tar.gz
samba-56c1d7e5078ca6b79bb286f458956b5f49c83e81.tar.bz2
samba-56c1d7e5078ca6b79bb286f458956b5f49c83e81.zip
r21525: Go ahead and checkin the mlock() & memalign() fixes so
others don't get stuck with the winbindd hang. Still waiting on additional confirmation from Guenther that this fixes thes issues he was observing as well. But it's been running in my local tree for a day without problems. (This used to be commit 0d2b80c6c4a744b05a0efdec352cddccc430e0c4)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbindd_cred_cache.c30
-rw-r--r--source3/nsswitch/winbindd_nss.h2
2 files changed, 10 insertions, 22 deletions
diff --git a/source3/nsswitch/winbindd_cred_cache.c b/source3/nsswitch/winbindd_cred_cache.c
index 8dc8fab4ac..bd2798d68b 100644
--- a/source3/nsswitch/winbindd_cred_cache.c
+++ b/source3/nsswitch/winbindd_cred_cache.c
@@ -482,29 +482,21 @@ static NTSTATUS store_memory_creds(struct WINBINDD_MEMORY_CREDS *memcredp, const
memcredp->len += strlen(pass)+1;
}
- /* On non-linux platforms, mlock()'d memory must be aligned on
- a page boundary so allocate a bit more so we can offset
- enough */
-
- memcredp->len += psize;
-
- memcredp->buffer = (unsigned char*)TALLOC_ZERO(memcredp, memcredp->len);
-
- if (!memcredp->buffer) {
+ /* On non-linux platforms, mlock()'d memory must be aligned */
+
+ memcredp->nt_hash = SMB_MEMALIGN_ARRAY(unsigned char*, psize,
+ memcredp->len);
+ if (!memcredp->nt_hash) {
return NT_STATUS_NO_MEMORY;
}
-
-
- /* point the nt_hash at the page boundary in the buffer */
+ memset( memcredp->nt_hash, 0x0, memcredp->len );
- memcredp->nt_hash = memcredp->buffer +
- (psize - ((uint32)memcredp->buffer % psize));
memcredp->lm_hash = memcredp->nt_hash + NT_HASH_LEN;
#ifdef DEBUG_PASSWORD
DEBUG(10,("mlocking memory: %p\n", memcredp->nt_hash));
#endif
- if ((mlock(memcredp->nt_hash, memcredp->len-psize)) == -1) {
+ if ((mlock(memcredp->nt_hash, memcredp->len)) == -1) {
DEBUG(0,("failed to mlock memory: %s (%d)\n",
strerror(errno), errno));
return map_nt_error_from_unix(errno);
@@ -536,15 +528,13 @@ static NTSTATUS delete_memory_creds(struct WINBINDD_MEMORY_CREDS *memcredp)
#if !defined(HAVE_MUNLOCK)
return NT_STATUS_OK;
#else
- int psize = getpagesize();
-
- if (munlock(memcredp->buffer, memcredp->len - psize) == -1) {
+ if (munlock(memcredp->nt_hash, memcredp->len) == -1) {
DEBUG(0,("failed to munlock memory: %s (%d)\n",
strerror(errno), errno));
return map_nt_error_from_unix(errno);
}
- memset(memcredp->buffer, '\0', memcredp->len);
- TALLOC_FREE(memcredp->buffer);
+ memset(memcredp->nt_hash, '\0', memcredp->len);
+ SAFE_FREE(memcredp->nt_hash);
memcredp->nt_hash = NULL;
memcredp->lm_hash = NULL;
memcredp->pass = NULL;
diff --git a/source3/nsswitch/winbindd_nss.h b/source3/nsswitch/winbindd_nss.h
index 919575d957..b6c262e466 100644
--- a/source3/nsswitch/winbindd_nss.h
+++ b/source3/nsswitch/winbindd_nss.h
@@ -469,8 +469,6 @@ struct WINBINDD_MEMORY_CREDS {
uid_t uid;
int ref_count;
size_t len;
- unsigned char *buffer; /* buffer block containing the
- following 3 */
unsigned char *nt_hash; /* Base pointer for the following 2 */
unsigned char *lm_hash;
char *pass;