diff options
Diffstat (limited to 'source/libsmb/clirap.c')
-rw-r--r-- | source/libsmb/clirap.c | 96 |
1 files changed, 29 insertions, 67 deletions
diff --git a/source/libsmb/clirap.c b/source/libsmb/clirap.c index 2064e149543..e0e5bc0c1f8 100644 --- a/source/libsmb/clirap.c +++ b/source/libsmb/clirap.c @@ -1,5 +1,6 @@ /* - Unix SMB/CIFS implementation. + Unix SMB/Netbios implementation. + Version 3.0 client RAP calls Copyright (C) Andrew Tridgell 1994-1998 @@ -117,8 +118,7 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) if (cli->rap_error == 0) { DEBUG(4,("NetWkstaUserLogon success\n")); cli->privileges = SVAL(p, 24); - /* The cli->eff_name field used to be set here - but it wasn't used anywhere else. */ + fstrcpy(cli->eff_name,p+2); } else { DEBUG(1,("NetwkstaUserLogon gave error %d\n", cli->rap_error)); } @@ -179,8 +179,8 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co char *cmnt = comment_offset?(rdata+comment_offset-converter):""; pstring s1, s2; - pull_ascii_pstring(s1, sname); - pull_ascii_pstring(s2, cmnt); + pstrcpy(s1, dos_to_unix_static(sname)); + pstrcpy(s2, dos_to_unix_static(cmnt)); fn(s1, type, s2, state); } @@ -233,8 +233,9 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SIVAL(p,0,stype); p += 4; - p += push_pstring(p, workgroup); - + p += clistr_push(cli, p, workgroup, -1, + STR_TERMINATE | STR_CONVERT | STR_ASCII); + if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */ @@ -260,8 +261,8 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; - pull_ascii_pstring(s1, sname); - pull_ascii_pstring(s2, cmnt); + pstrcpy(s1, dos_to_unix_static(sname)); + pstrcpy(s2, dos_to_unix_static(cmnt)); fn(s1, stype, s2, state); } } @@ -284,6 +285,8 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char char param[16+sizeof(fstring)]; char data[532]; char *p = param; + fstring upper_case_old_pw; + fstring upper_case_new_pw; unsigned char old_pw_hash[16]; unsigned char new_pw_hash[16]; int data_len; @@ -315,9 +318,11 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char * Get the Lanman hash of the old password, we * use this as the key to make_oem_passwd_hash(). */ - E_deshash(old_password, old_pw_hash); + memset(upper_case_old_pw, '\0', sizeof(upper_case_old_pw)); + clistr_push(cli, upper_case_old_pw, old_password, -1,STR_CONVERT|STR_TERMINATE|STR_UPPER|STR_ASCII); + E_P16((uchar *)upper_case_old_pw, old_pw_hash); - clistr_push(cli, dos_new_password, new_password, -1, STR_TERMINATE|STR_ASCII); + clistr_push(cli, dos_new_password, new_password, -1, STR_CONVERT|STR_TERMINATE|STR_ASCII); if (!make_oem_passwd_hash( data, dos_new_password, old_pw_hash, False)) return False; @@ -325,7 +330,10 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char /* * Now place the old password hash in the data. */ - E_deshash(new_password, new_pw_hash); + memset(upper_case_new_pw, '\0', sizeof(upper_case_new_pw)); + clistr_push(cli, upper_case_new_pw, new_password, -1, STR_CONVERT|STR_TERMINATE|STR_UPPER|STR_ASCII); + + E_P16((uchar *)upper_case_new_pw, new_pw_hash); E_old_pw_hash( new_pw_hash, old_pw_hash, (uchar *)&data[516]); @@ -366,7 +374,6 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, { int data_len = 0; int param_len = 0; - int rparam_len, rdata_len; uint16 setup = TRANSACT2_QPATHINFO; pstring param; char *rparam=NULL, *rdata=NULL; @@ -379,7 +386,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, memset(p, 0, 6); SSVAL(p, 0, SMB_INFO_STANDARD); p += 6; - p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE|STR_CONVERT ); param_len = PTR_DIFF(p, param); @@ -392,10 +399,9 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, NULL, data_len, cli->max_xmit /* data, length, max */ ) && cli_receive_trans(cli, SMBtrans2, - &rparam, &rparam_len, - &rdata, &rdata_len)); - if (!cli_is_dos_error(cli)) break; - if (!ret) { + &rparam, ¶m_len, + &rdata, &data_len)); + if (!ret && cli_is_dos_error(cli)) { /* we need to work around a Win95 bug - sometimes it gives ERRSRV/ERRerror temprarily */ uint8 eclass; @@ -406,7 +412,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, } } while (count-- && ret==False); - if (!ret || !rdata || rdata_len < 22) { + if (!ret || !rdata || data_len < 22) { return False; } @@ -456,7 +462,7 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, memset(p, 0, 6); SSVAL(p, 0, SMB_QUERY_FILE_ALL_INFO); p += 6; - p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE|STR_CONVERT ); param_len = PTR_DIFF(p, param); @@ -509,49 +515,6 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, /**************************************************************************** -send a qfileinfo QUERY_FILE_NAME_INFO call -****************************************************************************/ -BOOL cli_qfilename(struct cli_state *cli, int fnum, - pstring name) -{ - int data_len = 0; - int param_len = 0; - uint16 setup = TRANSACT2_QFILEINFO; - pstring param; - char *rparam=NULL, *rdata=NULL; - - param_len = 4; - memset(param, 0, param_len); - SSVAL(param, 0, fnum); - SSVAL(param, 2, SMB_QUERY_FILE_NAME_INFO); - - if (!cli_send_trans(cli, SMBtrans2, - NULL, /* name */ - -1, 0, /* fid, flags */ - &setup, 1, 0, /* setup, length, max */ - param, param_len, 2, /* param, length, max */ - NULL, data_len, cli->max_xmit /* data, length, max */ - )) { - return False; - } - - if (!cli_receive_trans(cli, SMBtrans2, - &rparam, ¶m_len, - &rdata, &data_len)) { - return False; - } - - if (!rdata || data_len < 4) { - return False; - } - - clistr_pull(cli, name, rdata+4, sizeof(pstring), IVAL(rdata, 0), STR_UNICODE); - - return True; -} - - -/**************************************************************************** send a qfileinfo call ****************************************************************************/ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, @@ -666,11 +629,10 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdat return True; } - - /**************************************************************************** -send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call + Send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call. ****************************************************************************/ + NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstring alt_name) { int data_len = 0; @@ -687,7 +649,7 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin memset(p, 0, 6); SSVAL(p, 0, SMB_QUERY_FILE_ALT_NAME_INFO); p += 6; - p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE|STR_CONVERT); param_len = PTR_DIFF(p, param); |