diff options
author | Andrew Bartlett <abartlet@samba.org> | 2001-09-26 11:23:08 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2001-09-26 11:23:08 +0000 |
commit | dc62feccb6c5998639a39907b5049ecba576ec11 (patch) | |
tree | 86a85ddeadd93a6a365816d18ba65c318357b37a | |
parent | 6744ca0a369ef85858b6e1a129649cd175187e51 (diff) | |
download | samba-dc62feccb6c5998639a39907b5049ecba576ec11.tar.gz samba-dc62feccb6c5998639a39907b5049ecba576ec11.tar.bz2 samba-dc62feccb6c5998639a39907b5049ecba576ec11.zip |
Add a new interface pdb_set_plaintext_passwd() to the passdb. This simply
interfaces to the existing set NT and LM functions, but ensures we always do it
in the same way.
This also allows for the possibility for the unix password sync code to be
hidden behind the passdb interface as some stage.
(This used to be commit 33e3591b2db377e720ec484872e2cbe7343350b1)
-rw-r--r-- | source3/passdb/passdb.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index 9cc5c5abaa..bc8272f97c 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -769,8 +769,6 @@ BOOL local_password_change(char *user_name, int local_flags, struct passwd *pwd = NULL; SAM_ACCOUNT *sam_pass=NULL; SAM_ACCOUNT *new_sam_acct=NULL; - uchar new_p16[16]; - uchar new_nt_p16[16]; *err_str = '\0'; *msg_str = '\0'; @@ -789,9 +787,6 @@ account without a valid local system user.\n", user_name); } } - /* Calculate the MD4 hash (NT compatible) of the new password. */ - nt_lm_owf_gen(new_passwd, new_nt_p16, new_p16); - /* Get the smb passwd entry for this user */ pdb_init_sam(&sam_pass); if(!pdb_getsampwnam(sam_pass, user_name)) { @@ -827,8 +822,7 @@ account without a valid local system user.\n", user_name); else { /* set the passwords here. if we get to here it means we have a valid, active account */ - pdb_set_lanman_passwd (new_sam_acct, new_p16); - pdb_set_nt_passwd (new_sam_acct, new_nt_p16); + pdb_set_plaintext_passwd (new_sam_acct, new_passwd); } if (pdb_add_sam_account(new_sam_acct)) { @@ -854,8 +848,7 @@ account without a valid local system user.\n", user_name); pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)|ACB_DISABLED); } else if (local_flags & LOCAL_ENABLE_USER) { if(pdb_get_lanman_passwd(sam_pass) == NULL) { - pdb_set_lanman_passwd (sam_pass, new_p16); - pdb_set_nt_passwd (sam_pass, new_nt_p16); + pdb_set_plaintext_passwd (new_sam_acct, new_passwd); } pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_DISABLED)); } else if (local_flags & LOCAL_SET_NO_PASSWORD) { @@ -877,8 +870,7 @@ account without a valid local system user.\n", user_name); if ((pdb_get_lanman_passwd(sam_pass)==NULL) && (pdb_get_acct_ctrl(sam_pass)&ACB_DISABLED)) pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_DISABLED)); pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_PWNOTREQ)); - pdb_set_lanman_passwd (sam_pass, new_p16); - pdb_set_nt_passwd (sam_pass, new_nt_p16); + pdb_set_plaintext_passwd (new_sam_acct, new_passwd); } if(local_flags & LOCAL_DELETE_USER) { @@ -1506,6 +1498,29 @@ BOOL pdb_set_lanman_passwd (SAM_ACCOUNT *sampass, uint8 *pwd) return True; } +/********************************************************************* + Set the user's PLAINTEXT password. Used as an interface to the above. + ********************************************************************/ + +BOOL pdb_set_plaintext_passwd (SAM_ACCOUNT *sampass, char *plaintext) +{ + uchar new_lanman_p16[16]; + uchar new_nt_p16[16]; + + if (!sampass || !plaintext) + return False; + + nt_lm_owf_gen (plaintext, new_nt_p16, new_lanman_p16); + + if (!pdb_set_nt_passwd (sampass, new_nt_p16)) + return False; + + if (!pdb_set_lanman_passwd (sampass, new_lanman_p16)) + return False; + + return True; +} + BOOL pdb_set_unknown_3 (SAM_ACCOUNT *sampass, uint32 unkn) { if (!sampass) |