Changeset 228 for branches/samba-3.2.x/source/libnet/libnet_samsync.c
- Timestamp:
- May 26, 2009, 9:44:50 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/libnet/libnet_samsync.c
r139 r228 33 33 static NTSTATUS fix_user(TALLOC_CTX *mem_ctx, 34 34 DATA_BLOB *session_key, 35 bool rid_crypt,36 35 enum netr_SamDatabaseID database_id, 37 36 struct netr_DELTA_ENUM *delta) … … 42 41 struct samr_Password lm_hash; 43 42 struct samr_Password nt_hash; 43 44 44 45 if (rid_crypt) { 46 if (user->lm_password_present) { 45 memset(zero_buf, '\0', sizeof(zero_buf)); 46 47 /* Note that win2000 may send us all zeros 48 * for the hashes if it doesn't 49 * think this channel is secure enough. */ 50 if (user->lm_password_present) { 51 if (memcmp(user->lmpassword.hash, zero_buf, 16) != 0) { 47 52 sam_pwd_hash(rid, user->lmpassword.hash, lm_hash.hash, 0); 48 user->lmpassword = lm_hash; 53 } else { 54 memset(lm_hash.hash, '\0', sizeof(lm_hash.hash)); 49 55 } 56 57 50 58 51 if (user->nt_password_present) { 59 if (user->nt_password_present) { 60 if (memcmp(user->ntpassword.hash, zero_buf, 16) != 0) { 52 61 sam_pwd_hash(rid, user->ntpassword.hash, nt_hash.hash, 0); 53 user->ntpassword = nt_hash; 62 } else { 63 memset(nt_hash.hash, '\0', sizeof(nt_hash.hash)); 54 64 } 65 55 66 } 56 67 … … 72 83 } 73 84 85 86 87 74 88 if (keys.keys.keys2.lmpassword.length == 16) { 75 if (rid_crypt) { 89 if (memcmp(keys.keys.keys2.lmpassword.pwd.hash, 90 zero_buf, 16) != 0) { 76 91 sam_pwd_hash(rid, 77 92 keys.keys.keys2.lmpassword.pwd.hash, 78 93 lm_hash.hash, 0); 79 user->lmpassword = lm_hash;80 94 } else { 81 user->lmpassword = keys.keys.keys2.lmpassword.pwd;95 ; 82 96 } 97 83 98 user->lm_password_present = true; 84 99 } 85 100 if (keys.keys.keys2.ntpassword.length == 16) { 86 if (rid_crypt) { 101 if (memcmp(keys.keys.keys2.ntpassword.pwd.hash, 102 zero_buf, 16) != 0) { 87 103 sam_pwd_hash(rid, 88 keys.keys.keys2.ntpassword.pwd.hash, 89 nt_hash.hash, 0); 90 user->ntpassword = nt_hash; 104 keys.keys.keys2.ntpassword.pwd.hash, 105 nt_hash.hash, 0); 91 106 } else { 92 user->ntpassword = keys.keys.keys2.ntpassword.pwd;107 ; 93 108 } 109 94 110 user->nt_password_present = true; 95 111 } … … 129 145 static NTSTATUS samsync_fix_delta(TALLOC_CTX *mem_ctx, 130 146 DATA_BLOB *session_key, 131 bool rid_crypt,132 147 enum netr_SamDatabaseID database_id, 133 148 struct netr_DELTA_ENUM *delta) … … 140 155 status = fix_user(mem_ctx, 141 156 session_key, 142 rid_crypt,143 157 database_id, 144 158 delta); …
