Changeset 988 for vendor/current/source3/utils/pdbedit.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/utils/pdbedit.c
r740 r988 56 56 #define BIT_KICKOFFTIME 0x20000000 57 57 #define BIT_DESCRIPTION 0x40000000 58 #define BIT_PWSETNTHASH 0x80000000 58 59 59 60 #define MASK_ALWAYS_GOOD 0x0000001F 60 #define MASK_USER_GOOD 0x 60405FE061 #define MASK_USER_GOOD 0xE0405FE0 61 62 62 63 static int get_sid_from_cli_string(struct dom_sid *sid, const char *str_sid) … … 176 177 static int export_groups (struct pdb_methods *in, struct pdb_methods *out) 177 178 { 178 GROUP_MAP * maps = NULL;179 GROUP_MAP **maps = NULL; 179 180 size_t i, entries = 0; 180 181 NTSTATUS status; … … 189 190 190 191 for (i=0; i<entries; i++) { 191 out->add_group_mapping_entry(out, &(maps[i]));192 } 193 194 SAFE_FREE( maps);192 out->add_group_mapping_entry(out, maps[i]); 193 } 194 195 TALLOC_FREE(maps); 195 196 196 197 return 0; … … 318 319 pdb_sethexhours(temp, hours); 319 320 printf ("Logon hours : %s\n", temp); 321 if (smbpwdstyle){ 322 pdb_sethexpwd(temp, pdb_get_lanman_passwd(sam_pwent), pdb_get_acct_ctrl(sam_pwent)); 323 printf ("LM hash : %s\n", temp); 324 pdb_sethexpwd(temp, pdb_get_nt_passwd(sam_pwent), pdb_get_acct_ctrl(sam_pwent)); 325 printf ("NT hash : %s\n", temp); 326 } 320 327 321 328 } else if (smbpwdstyle) { … … 333 340 nt_passwd, 334 341 pdb_encode_acct_ctrl(pdb_get_acct_ctrl(sam_pwent),NEW_PW_FORMAT_SPACE_PADDED_LEN), 335 (uint32 )convert_time_t_to_uint32_t(pdb_get_pass_last_set_time(sam_pwent)));342 (uint32_t)convert_time_t_to_uint32_t(pdb_get_pass_last_set_time(sam_pwent))); 336 343 } else { 337 344 uid = nametouid(pdb_get_username(sam_pwent)); … … 500 507 const char *user_sid, const char *user_domain, 501 508 const bool badpw, const bool hours, 502 const char *kickoff_time )509 const char *kickoff_time, const char *str_hex_pwd) 503 510 { 504 511 bool updated_autolock = False, updated_badpw = False; … … 602 609 pdb_set_kickoff_time(sam_pwent, value, PDB_CHANGED); 603 610 } 611 if (str_hex_pwd) { 612 unsigned char new_nt_p16[NT_HASH_LEN]; 613 if(strlen(str_hex_pwd) != (NT_HASH_LEN *2)){ 614 fprintf(stderr, "Invalid hash\n"); 615 return -1; 616 } 617 618 pdb_gethexpwd(str_hex_pwd, new_nt_p16); 619 620 if (!pdb_set_nt_passwd (sam_pwent, new_nt_p16 , PDB_CHANGED)) { 621 fprintf(stderr, "Failed to set password from nt-hash\n"); 622 return -1; 623 } 624 625 if (!pdb_set_pass_last_set_time (sam_pwent, time(NULL), PDB_CHANGED)){ 626 fprintf(stderr, "Failed to set last password set time\n"); 627 return -1; 628 } 629 if (!pdb_update_history(sam_pwent, new_nt_p16)){ 630 fprintf(stderr, "Failed to update password history\n"); 631 return -1; 632 } 633 } 604 634 605 635 if (NT_STATUS_IS_OK(pdb_update_sam_account(sam_pwent))) { 606 print_user_info(username, True, False); 636 637 print_user_info(username, True, (str_hex_pwd != NULL )); 607 638 } else { 608 639 fprintf (stderr, "Unable to modify entry!\n"); … … 656 687 } 657 688 658 strlower_m(name); 689 if (!strlower_m(name)) { 690 fprintf(stderr, "strlower_m %s failed\n", name); 691 TALLOC_FREE(sam_pwent); 692 return -1; 693 } 659 694 660 695 ret = pdb_getsampwnam(sam_pwent, name); … … 854 889 } 855 890 856 strlower_m(name); 891 if (!strlower_m(name)) { 892 fprintf(stderr, "strlower_m %s failed\n", name); 893 return -1; 894 } 857 895 858 896 flags = LOCAL_ADD_USER | LOCAL_TRUST_ACCOUNT | LOCAL_SET_PASSWORD; … … 959 997 fprintf (stderr, 960 998 "machine %s does not exist in the passdb\n", name); 961 return -1;962 999 TALLOC_FREE(samaccount); 1000 return -1; 963 1001 } 964 1002 … … 977 1015 **********************************************************/ 978 1016 979 int main (int argc,char **argv)1017 int main(int argc, const char **argv) 980 1018 { 981 1019 static int list_users = False; … … 986 1024 static int delete_user = False; 987 1025 static int modify_user = False; 988 uint32 1026 uint32_t setparms, checkparms; 989 1027 int opt; 990 1028 static char *full_name = NULL; … … 1015 1053 struct pdb_methods *bin, *bout; 1016 1054 static char *kickoff_time = NULL; 1055 static char *str_hex_pwd = NULL; 1017 1056 TALLOC_CTX *frame = talloc_stackframe(); 1018 1057 NTSTATUS status; … … 1052 1091 {"password-from-stdin", 't', POPT_ARG_NONE, &pw_from_stdin, 0, "get password from standard in", NULL}, 1053 1092 {"kickoff-time", 'K', POPT_ARG_STRING, &kickoff_time, 0, "set the kickoff time", NULL}, 1093 {"set-nt-hash", 0, POPT_ARG_STRING, &str_hex_pwd, 0, "set password from nt-hash", NULL}, 1054 1094 POPT_COMMON_SAMBA 1055 1095 POPT_TABLEEND … … 1058 1098 bin = bout = NULL; 1059 1099 1060 load_case_tables();1100 smb_init_locale(); 1061 1101 1062 1102 setup_logging("pdbedit", DEBUG_STDOUT); 1063 1103 1064 pc = poptGetContext(NULL, argc, (const char **)argv, long_options,1104 pc = poptGetContext(NULL, argc, argv, long_options, 1065 1105 POPT_CONTEXT_KEEP_FIRST); 1066 1106 … … 1078 1118 user_name = poptGetArg(pc); 1079 1119 1080 if (!lp_load (get_dyn_CONFIGFILE(),True,False,False,True)) {1120 if (!lp_load_global(get_dyn_CONFIGFILE())) { 1081 1121 fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE()); 1082 1122 exit(1); … … 1112 1152 (hours_reset ? BIT_LOGONHOURS : 0) + 1113 1153 (kickoff_time ? BIT_KICKOFFTIME : 0) + 1154 (str_hex_pwd ? BIT_PWSETNTHASH : 0 ) + 1114 1155 (acct_desc ? BIT_DESCRIPTION : 0); 1156 1115 1157 1116 1158 if (setparms & BIT_BACKEND) { … … 1118 1160 * This way we can use regular pdb functions for default 1119 1161 * operations that do not involve passdb migrations */ 1120 lp_set_ passdb_backend(backend);1162 lp_set_cmdline("passdb backend", backend); 1121 1163 } else { 1122 1164 backend = lp_passdb_backend(); … … 1143 1185 int count; 1144 1186 int i; 1145 account_policy_names_list( &names, &count);1187 account_policy_names_list(talloc_tos(), &names, &count); 1146 1188 fprintf(stderr, "No account policy by that name!\n"); 1147 1189 if (count !=0) { … … 1151 1193 } 1152 1194 } 1153 SAFE_FREE(names);1195 TALLOC_FREE(names); 1154 1196 exit(1); 1155 1197 } … … 1175 1217 1176 1218 if (reset_account_policies) { 1177 if ( !reinit_account_policies()) {1219 if (reinit_account_policies()) { 1178 1220 exit(1); 1179 1221 } … … 1309 1351 user_sid, user_domain, 1310 1352 badpw_reset, hours_reset, 1311 kickoff_time );1353 kickoff_time, str_hex_pwd); 1312 1354 } 1313 1355 }
Note:
See TracChangeset
for help on using the changeset viewer.