summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2001-09-26 11:51:25 +0000
committerAndrew Bartlett <abartlet@samba.org>2001-09-26 11:51:25 +0000
commitd74d82bddce5d6cf3f554ff014e08f2aeb2c14bc (patch)
tree3c3faf31ede67cca2036d101b8c1354437cfe515 /source3/rpc_server
parent1ef468f805d415e587e2f9a242fa934670ea9330 (diff)
downloadsamba-d74d82bddce5d6cf3f554ff014e08f2aeb2c14bc.tar.gz
samba-d74d82bddce5d6cf3f554ff014e08f2aeb2c14bc.tar.bz2
samba-d74d82bddce5d6cf3f554ff014e08f2aeb2c14bc.zip
Make use of the pdb_set_plaintext_passwd() update to vastly simplify
decode_pw_buffer() and the samr password changing routines. And yes, I know that we can lost some information in the Unicode->UTF->Unicode bit of this, but its worth the code cleanup. This also takes into account the possability of multibyte passwords. Andrew Bartlett (This used to be commit 42402c87d6bcff71b700e497b74d2600d7ce8b95)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_samr_nt.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 4ffd1c85b5..4290e24395 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -2339,9 +2339,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
{
SAM_ACCOUNT *pwd = NULL;
SAM_ACCOUNT *new_pwd = NULL;
- uint8 nt_hash[16];
- uint8 lm_hash[16];
- pstring buf;
+ pstring plaintext_buf;
uint32 len;
uint16 acct_ctrl;
@@ -2366,13 +2364,12 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
copy_id23_to_sam_passwd(new_pwd, id23);
- if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len, nt_hash, lm_hash)) {
+ if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len)) {
pdb_free_sam(new_pwd);
return False;
}
- pdb_set_lanman_passwd (new_pwd, lm_hash);
- pdb_set_nt_passwd (new_pwd, nt_hash);
+ pdb_set_plaintext_passwd (new_pwd, plaintext_buf);
/* if it's a trust account, don't update /etc/passwd */
if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) ||
@@ -2382,13 +2379,13 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
} else {
/* update the UNIX password */
if (lp_unix_password_sync() )
- if(!chgpasswd(pdb_get_username(new_pwd), "", buf, True)) {
+ if(!chgpasswd(pdb_get_username(new_pwd), "", plaintext_buf, True)) {
pdb_free_sam(new_pwd);
return False;
}
}
- memset(buf, 0, sizeof(buf));
+ ZERO_STRUCT(plaintext_buf);
if(!pdb_update_sam_account(new_pwd, True)) {
pdb_free_sam(new_pwd);
@@ -2407,10 +2404,8 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid)
static BOOL set_user_info_pw(char *pass, uint32 rid)
{
SAM_ACCOUNT *pwd = NULL;
- uchar nt_hash[16];
- uchar lm_hash[16];
uint32 len;
- pstring buf;
+ pstring plaintext_buf;
uint16 acct_ctrl;
pdb_init_sam(&pwd);
@@ -2422,15 +2417,14 @@ static BOOL set_user_info_pw(char *pass, uint32 rid)
acct_ctrl = pdb_get_acct_ctrl(pwd);
- memset(buf, 0, sizeof(buf));
+ ZERO_STRUCT(plaintext_buf);
- if (!decode_pw_buffer(pass, buf, 256, &len, nt_hash, lm_hash)) {
+ if (!decode_pw_buffer(pass, plaintext_buf, 256, &len)) {
pdb_free_sam(pwd);
return False;
}
- pdb_set_lanman_passwd (pwd, lm_hash);
- pdb_set_nt_passwd (pwd, nt_hash);
+ pdb_set_plaintext_passwd (pwd, plaintext_buf);
/* if it's a trust account, don't update /etc/passwd */
if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) ||
@@ -2440,13 +2434,13 @@ static BOOL set_user_info_pw(char *pass, uint32 rid)
} else {
/* update the UNIX password */
if (lp_unix_password_sync())
- if(!chgpasswd(pdb_get_username(pwd), "", buf, True)) {
+ if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) {
pdb_free_sam(pwd);
return False;
}
}
- memset(buf, 0, sizeof(buf));
+ ZERO_STRUCT(plaintext_buf);
DEBUG(5,("set_user_info_pw: pdb_update_sam_account()\n"));