1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

initialization fixes

This commit is contained in:
Gerald Carter 0001-01-01 00:00:00 +00:00
parent 8135ea08b3
commit 54fd3992c3
2 changed files with 51 additions and 2 deletions

View File

@ -933,7 +933,11 @@ BOOL pdb_set_nt_passwd (SAM_ACCOUNT *sampass, const uint8 pwd[NT_HASH_LEN], enum
data_blob_clear_free(&sampass->private.nt_pw); data_blob_clear_free(&sampass->private.nt_pw);
sampass->private.nt_pw = data_blob(pwd, NT_HASH_LEN); if (pwd) {
sampass->private.nt_pw = data_blob(pwd, NT_HASH_LEN);
} else {
sampass->private.nt_pw = data_blob(NULL, 0);
}
return pdb_set_init_flags(sampass, PDB_NTPASSWD, flag); return pdb_set_init_flags(sampass, PDB_NTPASSWD, flag);
} }
@ -949,7 +953,11 @@ BOOL pdb_set_lanman_passwd (SAM_ACCOUNT *sampass, const uint8 pwd[LM_HASH_LEN],
data_blob_clear_free(&sampass->private.lm_pw); data_blob_clear_free(&sampass->private.lm_pw);
sampass->private.lm_pw = data_blob(pwd, LM_HASH_LEN); if (pwd) {
sampass->private.lm_pw = data_blob(pwd, LM_HASH_LEN);
} else {
sampass->private.lm_pw = data_blob(NULL, 0);
}
return pdb_set_init_flags(sampass, PDB_LMPASSWD, flag); return pdb_set_init_flags(sampass, PDB_LMPASSWD, flag);
} }

View File

@ -36,6 +36,44 @@ static void lazy_initialize_passdb(void)
static struct pdb_init_function_entry *pdb_find_backend_entry(const char *name); static struct pdb_init_function_entry *pdb_find_backend_entry(const char *name);
/*******************************************************************
Clean up uninitialised passwords. The only way to tell
that these values are not 'real' is that they do not
have a valid last set time. Instead, the value is fixed at 0.
Therefore we use that as the key for 'is this a valid password'.
However, it is perfectly valid to have a 'default' last change
time, such LDAP with a missing attribute would produce.
********************************************************************/
static void pdb_force_pw_initialization(SAM_ACCOUNT *pass)
{
const char *lm_pwd, *nt_pwd;
/* only reset a password if the last set time has been
explicitly been set to zero. A default last set time
is ignored */
if ( (pdb_get_init_flags(pass, PDB_PASSLASTSET) != PDB_DEFAULT)
&& (pdb_get_pass_last_set_time(pass) == 0) )
{
if (pdb_get_init_flags(pass, PDB_LMPASSWD) != PDB_DEFAULT)
{
lm_pwd = pdb_get_lanman_passwd(pass);
if (lm_pwd)
pdb_set_lanman_passwd(pass, NULL, PDB_SET);
}
if (pdb_get_init_flags(pass, PDB_NTPASSWD) != PDB_DEFAULT)
{
nt_pwd = pdb_get_nt_passwd(pass);
if (nt_pwd)
pdb_set_nt_passwd(pass, NULL, PDB_SET);
}
}
return;
}
NTSTATUS smb_register_passdb(int version, const char *name, pdb_init_function init) NTSTATUS smb_register_passdb(int version, const char *name, pdb_init_function init)
{ {
struct pdb_init_function_entry *entry = backends; struct pdb_init_function_entry *entry = backends;
@ -141,6 +179,7 @@ static NTSTATUS context_getsampwent(struct pdb_context *context, SAM_ACCOUNT *us
context->pwent_methods->setsampwent(context->pwent_methods, False); context->pwent_methods->setsampwent(context->pwent_methods, False);
} }
user->methods = context->pwent_methods; user->methods = context->pwent_methods;
pdb_force_pw_initialization(user);
return ret; return ret;
} }
@ -156,6 +195,7 @@ static NTSTATUS context_getsampwnam(struct pdb_context *context, SAM_ACCOUNT *sa
curmethods = context->pdb_methods; curmethods = context->pdb_methods;
while (curmethods){ while (curmethods){
if (NT_STATUS_IS_OK(ret = curmethods->getsampwnam(curmethods, sam_acct, username))) { if (NT_STATUS_IS_OK(ret = curmethods->getsampwnam(curmethods, sam_acct, username))) {
pdb_force_pw_initialization(sam_acct);
sam_acct->methods = curmethods; sam_acct->methods = curmethods;
return ret; return ret;
} }
@ -179,6 +219,7 @@ static NTSTATUS context_getsampwsid(struct pdb_context *context, SAM_ACCOUNT *sa
while (curmethods){ while (curmethods){
if (NT_STATUS_IS_OK(ret = curmethods->getsampwsid(curmethods, sam_acct, sid))) { if (NT_STATUS_IS_OK(ret = curmethods->getsampwsid(curmethods, sam_acct, sid))) {
pdb_force_pw_initialization(sam_acct);
sam_acct->methods = curmethods; sam_acct->methods = curmethods;
return ret; return ret;
} }