diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/passdb/nispass.c | 51 | ||||
-rw-r--r-- | source3/passdb/passdb.c | 72 | ||||
-rw-r--r-- | source3/passdb/smbpass.c | 4 | ||||
-rw-r--r-- | source3/rpc_parse/parse_net.c | 2 | ||||
-rw-r--r-- | source3/rpc_parse/parse_reg.c | 4 | ||||
-rw-r--r-- | source3/rpc_server/srv_netlog.c | 4 | ||||
-rw-r--r-- | source3/rpc_server/srv_reg.c | 2 |
8 files changed, 89 insertions, 53 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 005911d1f6..9af21c5637 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1596,7 +1596,8 @@ time_t pdb_get_last_set_time(char *p); void pdb_set_last_set_time(char *p, int max_len, time_t t); char *pdb_encode_acct_ctrl(uint16 acct_ctrl); uint16 pdb_decode_acct_ctrl(char *p); -int pdb_gethexpwd(char *p, char *pwd); +BOOL pdb_gethexpwd(char *p, char *pwd); +void pdb_sethexpwd(char *p, char *pwd, uint16 acct_ctrl); BOOL pdb_name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid); BOOL pdb_generate_machine_sid(void); uid_t pdb_user_rid_to_uid(uint32 u_rid); diff --git a/source3/passdb/nispass.c b/source3/passdb/nispass.c index 62172f0e72..a61d38c1ec 100644 --- a/source3/passdb/nispass.c +++ b/source3/passdb/nispass.c @@ -234,6 +234,9 @@ static BOOL add_nisp21pwd_entry(struct sam_passwd *newpwd) fstring group_rid; fstring acb; + fstring smb_passwd; + fstring smb_nt_passwd; + fstring logon_t; fstring logoff_t; fstring kick_t; @@ -307,6 +310,9 @@ static BOOL add_nisp21pwd_entry(struct sam_passwd *newpwd) new_obj.zo_data.objdata_u.en_data.en_cols.en_cols_len = NIS_RES_OBJECT(tblresult)->zo_data.objdata_u.ta_data.ta_maxcol; new_obj.zo_data.objdata_u.en_data.en_cols.en_cols_val = calloc(new_obj.zo_data.objdata_u.en_data.en_cols.en_cols_len, sizeof(entry_col)); + pdb_sethexpwd(smb_passwd , newpwd->smb_passwd , newpwd->acct_ctrl); + pdb_sethexpwd(smb_nt_passwd, newpwd->smb_nt_passwd, newpwd->acct_ctrl); + #if 0 pdb_set_logon_time (logon_t , sizeof(logon_t ), newpwd->logon_time ); pdb_set_logoff_time (logoff_t , sizeof(logoff_t ), newpwd->logoff_time ); @@ -325,29 +331,28 @@ static BOOL add_nisp21pwd_entry(struct sam_passwd *newpwd) safe_strcpy(acb, pdb_encode_acct_ctrl(newpwd->acct_ctrl), sizeof(acb)); - set_single_attribute(&new_obj, NPF_NAME , newpwd->smb_name , strlen(newpwd->smb_name) , 0); - set_single_attribute(&new_obj, NPF_UID , uid , strlen(uid) , 0); - set_single_attribute(&new_obj, NPF_USER_RID , user_rid , strlen(user_rid) , 0); - set_single_attribute(&new_obj, NPF_SMB_GRPID , smb_grpid , strlen(smb_grpid) , 0); - set_single_attribute(&new_obj, NPF_GROUP_RID , group_rid , strlen(group_rid) , 0); - set_single_attribute(&new_obj, NPF_ACB , acb , strlen(acb) , 0); - set_single_attribute(&new_obj, NPF_LMPWD , newpwd->smb_passwd , newpwd->smb_passwd != NULL ? 16 : 0 , EN_CRYPT); - set_single_attribute(&new_obj, NPF_NTPWD , newpwd->smb_nt_passwd, newpwd->smb_nt_passwd != NULL ? 16 : 0, EN_CRYPT); - set_single_attribute(&new_obj, NPF_LOGON_T , logon_t , strlen(logon_t) , 0); - set_single_attribute(&new_obj, NPF_LOGOFF_T , logoff_t , strlen(logoff_t) , 0); - set_single_attribute(&new_obj, NPF_KICK_T , kick_t , strlen(kick_t) , 0); - set_single_attribute(&new_obj, NPF_PWDLSET_T , pwdlset_t , strlen(pwdlset_t) , 0); - set_single_attribute(&new_obj, NPF_PWDLCHG_T , pwdlchg_t , strlen(pwdlchg_t) , 0); - set_single_attribute(&new_obj, NPF_PWDMCHG_T , pwdmchg_t , strlen(pwdmchg_t) , 0); - set_single_attribute(&new_obj, NPF_FULL_NAME , newpwd->full_name , strlen(newpwd->full_name) , 0); - set_single_attribute(&new_obj, NPF_HOME_DIR , newpwd->home_dir , strlen(newpwd->home_dir) , 0); - set_single_attribute(&new_obj, NPF_DIR_DRIVE , newpwd->dir_drive , strlen(newpwd->dir_drive) , 0); - set_single_attribute(&new_obj, NPF_LOGON_SCRIPT , newpwd->logon_script , strlen(newpwd->logon_script) , 0); - set_single_attribute(&new_obj, NPF_PROFILE_PATH , newpwd->profile_path , strlen(newpwd->profile_path) , 0); - set_single_attribute(&new_obj, NPF_ACCT_DESC , newpwd->acct_desc , strlen(newpwd->acct_desc) , 0); - set_single_attribute(&new_obj, NPF_WORKSTATIONS , newpwd->workstations , strlen(newpwd->workstations) , 0); - set_single_attribute(&new_obj, NPF_HOURS , newpwd->hours , newpwd->hours_len , 0); - + set_single_attribute(&new_obj, NPF_NAME , newpwd->smb_name , strlen(newpwd->smb_name) , 0); + set_single_attribute(&new_obj, NPF_UID , uid , strlen(uid) , 0); + set_single_attribute(&new_obj, NPF_USER_RID , user_rid , strlen(user_rid) , 0); + set_single_attribute(&new_obj, NPF_SMB_GRPID , smb_grpid , strlen(smb_grpid) , 0); + set_single_attribute(&new_obj, NPF_GROUP_RID , group_rid , strlen(group_rid) , 0); + set_single_attribute(&new_obj, NPF_ACB , acb , strlen(acb) , 0); + set_single_attribute(&new_obj, NPF_LMPWD , smb_passwd , strlen(smb_passwd) , EN_CRYPT); + set_single_attribute(&new_obj, NPF_NTPWD , smb_nt_passwd , strlen(smb_nt_passwd) , EN_CRYPT); + set_single_attribute(&new_obj, NPF_LOGON_T , logon_t , strlen(logon_t) , 0); + set_single_attribute(&new_obj, NPF_LOGOFF_T , logoff_t , strlen(logoff_t) , 0); + set_single_attribute(&new_obj, NPF_KICK_T , kick_t , strlen(kick_t) , 0); + set_single_attribute(&new_obj, NPF_PWDLSET_T , pwdlset_t , strlen(pwdlset_t) , 0); + set_single_attribute(&new_obj, NPF_PWDLCHG_T , pwdlchg_t , strlen(pwdlchg_t) , 0); + set_single_attribute(&new_obj, NPF_PWDMCHG_T , pwdmchg_t , strlen(pwdmchg_t) , 0); + set_single_attribute(&new_obj, NPF_FULL_NAME , newpwd->full_name , strlen(newpwd->full_name) , 0); + set_single_attribute(&new_obj, NPF_HOME_DIR , newpwd->home_dir , strlen(newpwd->home_dir) , 0); + set_single_attribute(&new_obj, NPF_DIR_DRIVE , newpwd->dir_drive , strlen(newpwd->dir_drive) , 0); + set_single_attribute(&new_obj, NPF_LOGON_SCRIPT , newpwd->logon_script , strlen(newpwd->logon_script) , 0); + set_single_attribute(&new_obj, NPF_PROFILE_PATH , newpwd->profile_path , strlen(newpwd->profile_path) , 0); + set_single_attribute(&new_obj, NPF_ACCT_DESC , newpwd->acct_desc , strlen(newpwd->acct_desc) , 0); + set_single_attribute(&new_obj, NPF_WORKSTATIONS , newpwd->workstations , strlen(newpwd->workstations) , 0); + set_single_attribute(&new_obj, NPF_HOURS , newpwd->hours , newpwd->hours_len , 0); obj = &new_obj; diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index 4a86e095da..b07829cb8b 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -736,31 +736,61 @@ uint16 pdb_decode_acct_ctrl(char *p) } /************************************************************* - Routine to get the next 32 hex characters and turn them + Routine to get the 32 hex characters and turn them into a 16 byte array. **************************************************************/ +BOOL pdb_gethexpwd(char *p, char *pwd) +{ + int i; + unsigned char lonybble, hinybble; + char *hexchars = "0123456789ABCDEF"; + char *p1, *p2; + + for (i = 0; i < 32; i += 2) + { + hinybble = toupper(p[i]); + lonybble = toupper(p[i + 1]); + + p1 = strchr(hexchars, hinybble); + p2 = strchr(hexchars, lonybble); + + if (!p1 || !p2) + { + return (False); + } -int pdb_gethexpwd(char *p, char *pwd) + hinybble = PTR_DIFF(p1, hexchars); + lonybble = PTR_DIFF(p2, hexchars); + + pwd[i / 2] = (hinybble << 4) | lonybble; + } + return (True); +} + +/************************************************************* + Routine to set 32 hex password characters from a 16 byte array. +**************************************************************/ +void pdb_sethexpwd(char *p, char *pwd, uint16 acct_ctrl) { - int i; - unsigned char lonybble, hinybble; - char *hexchars = "0123456789ABCDEF"; - char *p1, *p2; - - for (i = 0; i < 32; i += 2) { - hinybble = toupper(p[i]); - lonybble = toupper(p[i + 1]); - - p1 = strchr(hexchars, hinybble); - p2 = strchr(hexchars, lonybble); - if (!p1 || !p2) - return (False); - hinybble = PTR_DIFF(p1, hexchars); - lonybble = PTR_DIFF(p2, hexchars); - - pwd[i / 2] = (hinybble << 4) | lonybble; - } - return (True); + if (pwd != NULL) + { + int i; + for (i = 0; i < 16; i++) + { + slprintf(&p[i*2], 33, "%02X", pwd[i]); + } + } + else + { + if (IS_BITS_SET_ALL(acct_ctrl, ACB_PWNOTREQ)) + { + safe_strcpy(p, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX", 33); + } + else + { + safe_strcpy(p, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 33); + } + } } /******************************************************************* diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index 4d446c65c2..a9efcf2a52 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -253,7 +253,7 @@ static struct smb_passwd *getsmbfilepwent(void *vp) if (*p == '[') { - pw_buf.acct_ctrl = pdb_decode_acct_ctrl(p); + pw_buf.acct_ctrl = pdb_decode_acct_ctrl((char*)p); /* Must have some account type set. */ if(pw_buf.acct_ctrl == 0) @@ -952,5 +952,5 @@ struct passdb_ops *file_initialize_password_db(void) } #else - void dummy_function(void) { } /* stop some compilers complaining */ + static void dummy_function(void) { } /* stop some compilers complaining */ #endif /* USE_SMBPASS_DB */ diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index fd9f7255de..9b12668184 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -736,7 +736,7 @@ void make_id_info2(NET_ID_INFO_2 *id, char *domain_name, lm_chal_resp = lm_owf; } - memcpy(&(id->lm_chal), lm_challenge, sizeof(id->lm_chal)); + memcpy(id->lm_chal, lm_challenge, sizeof(id->lm_chal)); make_str_hdr(&(id->hdr_nt_chal_resp), 24, 24, nt_chal_resp != NULL ? 1 : 0); make_str_hdr(&(id->hdr_lm_chal_resp), 24, 24, lm_chal_resp != NULL ? 1 : 0); diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c index d278b75f5d..dec5110b41 100644 --- a/source3/rpc_parse/parse_reg.c +++ b/source3/rpc_parse/parse_reg.c @@ -142,12 +142,12 @@ void make_reg_q_info(REG_Q_INFO *r_q, memcpy(&(r_q->time), prod_time, sizeof(r_q->time)); r_q->major_version1 = major_version; r_q->minor_version1 = minor_version; - bzero(&(r_q->pad1), sizeof(r_q->pad1)); + bzero(r_q->pad1, sizeof(r_q->pad1)); r_q->ptr2 = 1; r_q->major_version2 = major_version; r_q->minor_version2 = minor_version; - bzero(&(r_q->pad2), sizeof(r_q->pad2)); + bzero(r_q->pad2, sizeof(r_q->pad2)); r_q->ptr3 = 1; r_q->unknown = unknown; diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index c81a8244d9..821945b757 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -344,8 +344,8 @@ static void api_net_auth_2( int uid, cred_create(vuser->dc.sess_key, &(vuser->dc.srv_cred.challenge), srv_time, &srv_cred); /* copy the received client credentials for use next time */ - memcpy(vuser->dc.clnt_cred.challenge.data, &(q_a.clnt_chal.data), sizeof(q_a.clnt_chal.data)); - memcpy(vuser->dc.srv_cred.challenge.data, &(q_a.clnt_chal.data), sizeof(q_a.clnt_chal.data)); + memcpy(vuser->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + memcpy(vuser->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); } else { diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index fa856f6983..3f9cdc20f4 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -38,7 +38,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, REG_R_CLOSE r_u; /* set up the REG unknown_1 response */ - bzero(&(r_u.pol.data), POL_HND_SIZE); + bzero(r_u.pol.data, POL_HND_SIZE); /* close the policy handle */ if (close_lsa_policy_hnd(&(q_r->pol))) |