Changeset 862 for trunk/server/source3/rpc_server/samr
- Timestamp:
- May 13, 2014, 11:39:04 AM (11 years ago)
- Location:
- trunk/server
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 860
- Property svn:mergeinfo changed
-
trunk/server/source3/rpc_server/samr/srv_samr_chgpasswd.c
r745 r862 74 74 75 75 #if defined(HAVE_GRANTPT) 76 #if defined(HAVE_POSIX_OPENPT) 77 master = posix_openpt(O_RDWR|O_NOCTTY); 78 #else 76 79 /* Try to open /dev/ptmx. If that fails, fall through to old method. */ 77 if ((master = sys_open("/dev/ptmx", O_RDWR, 0)) >= 0) { 80 master = sys_open("/dev/ptmx", O_RDWR, 0); 81 #endif 82 if (master >= 0) { 78 83 grantpt(master); 79 84 unlockpt(master); … … 1102 1107 NTSTATUS nt_status; 1103 1108 bool ret = false; 1109 bool updated_badpw = false; 1110 NTSTATUS update_login_attempts_status; 1104 1111 1105 1112 if (!(sampass = samu_new(NULL))) { … … 1115 1122 TALLOC_FREE(sampass); 1116 1123 return NT_STATUS_NO_SUCH_USER; 1124 } 1125 1126 /* Quit if the account was locked out. */ 1127 if (pdb_get_acct_ctrl(sampass) & ACB_AUTOLOCK) { 1128 DEBUG(3,("check_sam_security: Account for user %s was locked out.\n", user)); 1129 TALLOC_FREE(sampass); 1130 return NT_STATUS_ACCOUNT_LOCKED_OUT; 1117 1131 } 1118 1132 … … 1125 1139 &new_passwd); 1126 1140 1141 /* 1142 * Notify passdb backend of login success/failure. If not 1143 * NT_STATUS_OK the backend doesn't like the login 1144 */ 1145 update_login_attempts_status = pdb_update_login_attempts(sampass, 1146 NT_STATUS_IS_OK(nt_status)); 1147 1148 if (!NT_STATUS_IS_OK(nt_status)) { 1149 bool increment_bad_pw_count = false; 1150 1151 if (NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD) && 1152 (pdb_get_acct_ctrl(sampass) & ACB_NORMAL) && 1153 NT_STATUS_IS_OK(update_login_attempts_status)) 1154 { 1155 increment_bad_pw_count = true; 1156 } 1157 1158 if (increment_bad_pw_count) { 1159 pdb_increment_bad_password_count(sampass); 1160 updated_badpw = true; 1161 } else { 1162 pdb_update_bad_password_count(sampass, 1163 &updated_badpw); 1164 } 1165 } else { 1166 1167 if ((pdb_get_acct_ctrl(sampass) & ACB_NORMAL) && 1168 (pdb_get_bad_password_count(sampass) > 0)){ 1169 pdb_set_bad_password_count(sampass, 0, PDB_CHANGED); 1170 pdb_set_bad_password_time(sampass, 0, PDB_CHANGED); 1171 updated_badpw = true; 1172 } 1173 } 1174 1175 if (updated_badpw) { 1176 NTSTATUS update_status; 1177 become_root(); 1178 update_status = pdb_update_sam_account(sampass); 1179 unbecome_root(); 1180 1181 if (!NT_STATUS_IS_OK(update_status)) { 1182 DEBUG(1, ("Failed to modify entry: %s\n", 1183 nt_errstr(update_status))); 1184 } 1185 } 1186 1127 1187 if (!NT_STATUS_IS_OK(nt_status)) { 1128 1188 TALLOC_FREE(sampass); -
trunk/server/source3/rpc_server/samr/srv_samr_nt.c
r751 r862 1707 1707 1708 1708 /**************************************************************** 1709 _samr_ChangePasswordUser 1709 _samr_ChangePasswordUser. 1710 1711 So old it is just not worth implementing 1712 because it does not supply a plaintext and so we can't do password 1713 complexity checking and cannot update other services that use a 1714 plaintext password via passwd chat/pam password change/ldap password 1715 sync. 1710 1716 ****************************************************************/ 1711 1717 … … 1713 1719 struct samr_ChangePasswordUser *r) 1714 1720 { 1715 NTSTATUS status; 1716 bool ret = false; 1717 struct samr_user_info *uinfo; 1718 struct samu *pwd; 1719 struct samr_Password new_lmPwdHash, new_ntPwdHash, checkHash; 1720 struct samr_Password lm_pwd, nt_pwd; 1721 1722 uinfo = policy_handle_find(p, r->in.user_handle, 1723 SAMR_USER_ACCESS_SET_PASSWORD, NULL, 1724 struct samr_user_info, &status); 1725 if (!NT_STATUS_IS_OK(status)) { 1726 return status; 1727 } 1728 1729 DEBUG(5,("_samr_ChangePasswordUser: sid:%s\n", 1730 sid_string_dbg(&uinfo->sid))); 1731 1732 if (!(pwd = samu_new(NULL))) { 1733 return NT_STATUS_NO_MEMORY; 1734 } 1735 1736 become_root(); 1737 ret = pdb_getsampwsid(pwd, &uinfo->sid); 1738 unbecome_root(); 1739 1740 if (!ret) { 1741 TALLOC_FREE(pwd); 1742 return NT_STATUS_WRONG_PASSWORD; 1743 } 1744 1745 { 1746 const uint8_t *lm_pass, *nt_pass; 1747 1748 lm_pass = pdb_get_lanman_passwd(pwd); 1749 nt_pass = pdb_get_nt_passwd(pwd); 1750 1751 if (!lm_pass || !nt_pass) { 1752 status = NT_STATUS_WRONG_PASSWORD; 1753 goto out; 1754 } 1755 1756 memcpy(&lm_pwd.hash, lm_pass, sizeof(lm_pwd.hash)); 1757 memcpy(&nt_pwd.hash, nt_pass, sizeof(nt_pwd.hash)); 1758 } 1759 1760 /* basic sanity checking on parameters. Do this before any database ops */ 1761 if (!r->in.lm_present || !r->in.nt_present || 1762 !r->in.old_lm_crypted || !r->in.new_lm_crypted || 1763 !r->in.old_nt_crypted || !r->in.new_nt_crypted) { 1764 /* we should really handle a change with lm not 1765 present */ 1766 status = NT_STATUS_INVALID_PARAMETER_MIX; 1767 goto out; 1768 } 1769 1770 /* decrypt and check the new lm hash */ 1771 D_P16(lm_pwd.hash, r->in.new_lm_crypted->hash, new_lmPwdHash.hash); 1772 D_P16(new_lmPwdHash.hash, r->in.old_lm_crypted->hash, checkHash.hash); 1773 if (memcmp(checkHash.hash, lm_pwd.hash, 16) != 0) { 1774 status = NT_STATUS_WRONG_PASSWORD; 1775 goto out; 1776 } 1777 1778 /* decrypt and check the new nt hash */ 1779 D_P16(nt_pwd.hash, r->in.new_nt_crypted->hash, new_ntPwdHash.hash); 1780 D_P16(new_ntPwdHash.hash, r->in.old_nt_crypted->hash, checkHash.hash); 1781 if (memcmp(checkHash.hash, nt_pwd.hash, 16) != 0) { 1782 status = NT_STATUS_WRONG_PASSWORD; 1783 goto out; 1784 } 1785 1786 /* The NT Cross is not required by Win2k3 R2, but if present 1787 check the nt cross hash */ 1788 if (r->in.cross1_present && r->in.nt_cross) { 1789 D_P16(lm_pwd.hash, r->in.nt_cross->hash, checkHash.hash); 1790 if (memcmp(checkHash.hash, new_ntPwdHash.hash, 16) != 0) { 1791 status = NT_STATUS_WRONG_PASSWORD; 1792 goto out; 1793 } 1794 } 1795 1796 /* The LM Cross is not required by Win2k3 R2, but if present 1797 check the lm cross hash */ 1798 if (r->in.cross2_present && r->in.lm_cross) { 1799 D_P16(nt_pwd.hash, r->in.lm_cross->hash, checkHash.hash); 1800 if (memcmp(checkHash.hash, new_lmPwdHash.hash, 16) != 0) { 1801 status = NT_STATUS_WRONG_PASSWORD; 1802 goto out; 1803 } 1804 } 1805 1806 if (!pdb_set_nt_passwd(pwd, new_ntPwdHash.hash, PDB_CHANGED) || 1807 !pdb_set_lanman_passwd(pwd, new_lmPwdHash.hash, PDB_CHANGED)) { 1808 status = NT_STATUS_ACCESS_DENIED; 1809 goto out; 1810 } 1811 1812 status = pdb_update_sam_account(pwd); 1813 out: 1814 TALLOC_FREE(pwd); 1815 1816 return status; 1721 return NT_STATUS_NOT_IMPLEMENTED; 1817 1722 } 1818 1723
Note:
See TracChangeset
for help on using the changeset viewer.