Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/utils/pdbedit.c

    r740 r988  
    5656#define BIT_KICKOFFTIME 0x20000000
    5757#define BIT_DESCRIPTION 0x40000000
     58#define BIT_PWSETNTHASH 0x80000000
    5859
    5960#define MASK_ALWAYS_GOOD        0x0000001F
    60 #define MASK_USER_GOOD          0x60405FE0
     61#define MASK_USER_GOOD          0xE0405FE0
    6162
    6263static int get_sid_from_cli_string(struct dom_sid *sid, const char *str_sid)
     
    176177static int export_groups (struct pdb_methods *in, struct pdb_methods *out)
    177178{
    178         GROUP_MAP *maps = NULL;
     179        GROUP_MAP **maps = NULL;
    179180        size_t i, entries = 0;
    180181        NTSTATUS status;
     
    189190
    190191        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);
    195196
    196197        return 0;
     
    318319                pdb_sethexhours(temp, hours);
    319320                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                }       
    320327
    321328        } else if (smbpwdstyle) {
     
    333340                       nt_passwd,
    334341                       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)));
    336343        } else {
    337344                uid = nametouid(pdb_get_username(sam_pwent));
     
    500507                         const char *user_sid, const char *user_domain,
    501508                         const bool badpw, const bool hours,
    502                          const char *kickoff_time)
     509                         const char *kickoff_time, const char *str_hex_pwd)
    503510{
    504511        bool updated_autolock = False, updated_badpw = False;
     
    602609                pdb_set_kickoff_time(sam_pwent, value, PDB_CHANGED);
    603610        }
     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        }
    604634
    605635        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 ));
    607638        } else {
    608639                fprintf (stderr, "Unable to modify entry!\n");
     
    656687        }
    657688
    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        }
    659694
    660695        ret = pdb_getsampwnam(sam_pwent, name);
     
    854889        }
    855890
    856         strlower_m(name);
     891        if (!strlower_m(name)) {
     892                fprintf(stderr, "strlower_m %s failed\n", name);
     893                return -1;
     894        }
    857895
    858896        flags = LOCAL_ADD_USER | LOCAL_TRUST_ACCOUNT | LOCAL_SET_PASSWORD;
     
    959997                fprintf (stderr,
    960998                         "machine %s does not exist in the passdb\n", name);
    961                 return -1;
    962999                TALLOC_FREE(samaccount);
     1000                return -1;
    9631001        }
    9641002
     
    9771015**********************************************************/
    9781016
    979 int main (int argc, char **argv)
     1017int main(int argc, const char **argv)
    9801018{
    9811019        static int list_users = False;
     
    9861024        static int delete_user = False;
    9871025        static int modify_user = False;
    988         uint32  setparms, checkparms;
     1026        uint32_t   setparms, checkparms;
    9891027        int opt;
    9901028        static char *full_name = NULL;
     
    10151053        struct pdb_methods *bin, *bout;
    10161054        static char *kickoff_time = NULL;
     1055        static char *str_hex_pwd = NULL;
    10171056        TALLOC_CTX *frame = talloc_stackframe();
    10181057        NTSTATUS status;
     
    10521091                {"password-from-stdin", 't', POPT_ARG_NONE, &pw_from_stdin, 0, "get password from standard in", NULL},
    10531092                {"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},
    10541094                POPT_COMMON_SAMBA
    10551095                POPT_TABLEEND
     
    10581098        bin = bout = NULL;
    10591099
    1060         load_case_tables();
     1100        smb_init_locale();
    10611101
    10621102        setup_logging("pdbedit", DEBUG_STDOUT);
    10631103
    1064         pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
     1104        pc = poptGetContext(NULL, argc, argv, long_options,
    10651105                            POPT_CONTEXT_KEEP_FIRST);
    10661106
     
    10781118                user_name = poptGetArg(pc);
    10791119
    1080         if (!lp_load(get_dyn_CONFIGFILE(),True,False,False,True)) {
     1120        if (!lp_load_global(get_dyn_CONFIGFILE())) {
    10811121                fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE());
    10821122                exit(1);
     
    11121152                        (hours_reset ? BIT_LOGONHOURS : 0) +
    11131153                        (kickoff_time ? BIT_KICKOFFTIME : 0) +
     1154                        (str_hex_pwd ? BIT_PWSETNTHASH : 0 ) +
    11141155                        (acct_desc ? BIT_DESCRIPTION : 0);
     1156                       
    11151157
    11161158        if (setparms & BIT_BACKEND) {
     
    11181160                 * This way we can use regular pdb functions for default
    11191161                 * operations that do not involve passdb migrations */
    1120                 lp_set_passdb_backend(backend);
     1162                lp_set_cmdline("passdb backend", backend);
    11211163        } else {
    11221164                backend = lp_passdb_backend();
     
    11431185                        int count;
    11441186                        int i;
    1145                         account_policy_names_list(&names, &count);
     1187                        account_policy_names_list(talloc_tos(), &names, &count);
    11461188                        fprintf(stderr, "No account policy by that name!\n");
    11471189                        if (count !=0) {
     
    11511193                                }
    11521194                        }
    1153                         SAFE_FREE(names);
     1195                        TALLOC_FREE(names);
    11541196                        exit(1);
    11551197                }
     
    11751217
    11761218        if (reset_account_policies) {
    1177                 if (!reinit_account_policies()) {
     1219                if (reinit_account_policies()) {
    11781220                        exit(1);
    11791221                }
     
    13091351                                                     user_sid, user_domain,
    13101352                                                     badpw_reset, hours_reset,
    1311                                                      kickoff_time);
     1353                                                     kickoff_time, str_hex_pwd);
    13121354                        }
    13131355                }
Note: See TracChangeset for help on using the changeset viewer.