From 858e63cab3b6a23692678d6eb03f9e48c3c08603 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 Apr 2000 14:04:06 +0000 Subject: split clientgen.c into several parts the next step is splitting out the auth code, to make adding lukes NTLMSSP support easier (This used to be commit 10c5470835b43116ed48b3137c3b9cc867a20989) --- source3/libsmb/clirap.c | 591 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 591 insertions(+) create mode 100644 source3/libsmb/clirap.c (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c new file mode 100644 index 0000000000..d918dcff55 --- /dev/null +++ b/source3/libsmb/clirap.c @@ -0,0 +1,591 @@ +/* + Unix SMB/Netbios implementation. + Version 3.0 + client RAP calls + Copyright (C) Andrew Tridgell 1994-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#define NO_SYSLOG + +#include "includes.h" + + +/**************************************************************************** +Call a remote api on an arbitrary pipe. takes param, data and setup buffers. +****************************************************************************/ +BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len, + uint16 *setup, uint32 setup_count, uint32 max_setup_count, + char *params, uint32 param_count, uint32 max_param_count, + char *data, uint32 data_count, uint32 max_data_count, + char **rparam, uint32 *rparam_count, + char **rdata, uint32 *rdata_count) +{ + if (pipe_name_len == 0) + pipe_name_len = strlen(pipe_name); + + cli_send_trans(cli, SMBtrans, + pipe_name, pipe_name_len, + 0,0, /* fid, flags */ + setup, setup_count, max_setup_count, + params, param_count, max_param_count, + data, data_count, max_data_count); + + return (cli_receive_trans(cli, SMBtrans, + rparam, (int *)rparam_count, + rdata, (int *)rdata_count)); +} + +/**************************************************************************** +call a remote api +****************************************************************************/ +BOOL cli_api(struct cli_state *cli, + char *param, int prcnt, int mprcnt, + char *data, int drcnt, int mdrcnt, + char **rparam, int *rprcnt, + char **rdata, int *rdrcnt) +{ + cli_send_trans(cli,SMBtrans, + PIPE_LANMAN,strlen(PIPE_LANMAN), /* Name, length */ + 0,0, /* fid, flags */ + NULL,0,0, /* Setup, length, max */ + param, prcnt, mprcnt, /* Params, length, max */ + data, drcnt, mdrcnt /* Data, length, max */ + ); + + return (cli_receive_trans(cli,SMBtrans, + rparam, rprcnt, + rdata, rdrcnt)); +} + + +/**************************************************************************** +perform a NetWkstaUserLogon +****************************************************************************/ +BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) +{ + char *rparam = NULL; + char *rdata = NULL; + char *p; + int rdrcnt,rprcnt; + pstring param; + + memset(param, 0, sizeof(param)); + + /* send a SMBtrans command with api NetWkstaUserLogon */ + p = param; + SSVAL(p,0,132); /* api number */ + p += 2; + pstrcpy(p,"OOWb54WrLh"); + p = skip_string(p,1); + pstrcpy(p,"WB21BWDWWDDDDDDDzzzD"); + p = skip_string(p,1); + SSVAL(p,0,1); + p += 2; + pstrcpy(p,user); + strupper(p); + p += 21; + p++; + p += 15; + p++; + pstrcpy(p, workstation); + strupper(p); + p += 16; + SSVAL(p, 0, CLI_BUFFER_SIZE); + p += 2; + SSVAL(p, 0, CLI_BUFFER_SIZE); + p += 2; + + if (cli_api(cli, + param, PTR_DIFF(p,param),1024, /* param, length, max */ + NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */ + &rparam, &rprcnt, /* return params, return size */ + &rdata, &rdrcnt /* return data, return size */ + )) { + cli->rap_error = SVAL(rparam,0); + p = rdata; + + if (cli->rap_error == 0) { + DEBUG(4,("NetWkstaUserLogon success\n")); + cli->privileges = SVAL(p, 24); + fstrcpy(cli->eff_name,p+2); + } else { + DEBUG(1,("NetwkstaUserLogon gave error %d\n", cli->rap_error)); + } + } + + if (rparam) + free(rparam); + if (rdata) + free(rdata); + return (cli->rap_error == 0); +} + +/**************************************************************************** +call a NetShareEnum - try and browse available connections on a host +****************************************************************************/ +int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)) +{ + char *rparam = NULL; + char *rdata = NULL; + char *p; + int rdrcnt,rprcnt; + pstring param; + int count = -1; + + /* now send a SMBtrans command with api RNetShareEnum */ + p = param; + SSVAL(p,0,0); /* api number */ + p += 2; + pstrcpy(p,"WrLeh"); + p = skip_string(p,1); + pstrcpy(p,"B13BWz"); + p = skip_string(p,1); + SSVAL(p,0,1); + /* + * Win2k needs a *smaller* buffer than 0xFFFF here - + * it returns "out of server memory" with 0xFFFF !!! JRA. + */ + SSVAL(p,2,0xFFE0); + p += 4; + + if (cli_api(cli, + param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */ + NULL, 0, 0xFFE0, /* data, length, maxlen - Win2k needs a small buffer here too ! */ + &rparam, &rprcnt, /* return params, length */ + &rdata, &rdrcnt)) /* return data, length */ + { + int res = SVAL(rparam,0); + int converter=SVAL(rparam,2); + int i; + + if (res == 0 || res == ERRmoredata) { + count=SVAL(rparam,4); + p = rdata; + + for (i=0;i rdrcnt) continue; + + stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; + + dos_to_unix(sname, True); + dos_to_unix(cmnt, True); + fn(sname, stype, cmnt); + } + } + } + + if (rparam) + free(rparam); + if (rdata) + free(rdata); + + return(count > 0); +} + + + +/**************************************************************************** +Send a SamOEMChangePassword command +****************************************************************************/ +BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, + const char *old_password) +{ + 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; + int param_len = 0; + char *rparam = NULL; + char *rdata = NULL; + int rprcnt, rdrcnt; + pstring dos_new_password; + + if (strlen(user) >= sizeof(fstring)-1) { + DEBUG(0,("cli_oem_change_password: user name %s is too long.\n", user)); + return False; + } + + SSVAL(p,0,214); /* SamOEMChangePassword command. */ + p += 2; + pstrcpy(p, "zsT"); + p = skip_string(p,1); + pstrcpy(p, "B516B16"); + p = skip_string(p,1); + pstrcpy(p,user); + p = skip_string(p,1); + SSVAL(p,0,532); + p += 2; + + param_len = PTR_DIFF(p,param); + + /* + * Get the Lanman hash of the old password, we + * use this as the key to make_oem_passwd_hash(). + */ + memset(upper_case_old_pw, '\0', sizeof(upper_case_old_pw)); + fstrcpy(upper_case_old_pw, old_password); + unix_to_dos(upper_case_old_pw,True); + strupper(upper_case_old_pw); + E_P16((uchar *)upper_case_old_pw, old_pw_hash); + + pstrcpy(dos_new_password, new_password); + unix_to_dos(dos_new_password, True); + + if (!make_oem_passwd_hash( data, dos_new_password, old_pw_hash, False)) + return False; + + /* + * Now place the old password hash in the data. + */ + memset(upper_case_new_pw, '\0', sizeof(upper_case_new_pw)); + fstrcpy(upper_case_new_pw, new_password); + unix_to_dos(upper_case_new_pw,True); + strupper(upper_case_new_pw); + + E_P16((uchar *)upper_case_new_pw, new_pw_hash); + + E_old_pw_hash( new_pw_hash, old_pw_hash, (uchar *)&data[516]); + + data_len = 532; + + if (cli_send_trans(cli,SMBtrans, + PIPE_LANMAN,strlen(PIPE_LANMAN), /* name, length */ + 0,0, /* fid, flags */ + NULL,0,0, /* setup, length, max */ + param,param_len,2, /* param, length, max */ + data,data_len,0 /* data, length, max */ + ) == False) { + DEBUG(0,("cli_oem_change_password: Failed to send password change for user %s\n", + user )); + return False; + } + + if (cli_receive_trans(cli,SMBtrans, + &rparam, &rprcnt, + &rdata, &rdrcnt)) { + if (rparam) + cli->rap_error = SVAL(rparam,0); + } + + if (rparam) + free(rparam); + if (rdata) + free(rdata); + + return (cli->rap_error == 0); +} + + +/**************************************************************************** +send a qpathinfo call +****************************************************************************/ +BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, + time_t *c_time, time_t *a_time, time_t *m_time, + size_t *size, uint16 *mode) +{ + int data_len = 0; + int param_len = 0; + uint16 setup = TRANSACT2_QPATHINFO; + pstring param; + char *rparam=NULL, *rdata=NULL; + int count=8; + BOOL ret; + time_t (*date_fn)(void *); + + param_len = strlen(fname) + 7; + + memset(param, 0, param_len); + SSVAL(param, 0, SMB_INFO_STANDARD); + pstrcpy(¶m[6], fname); + unix_to_dos(¶m[6],True); + + do { + ret = (cli_send_trans(cli, SMBtrans2, + NULL, 0, /* Name, length */ + -1, 0, /* fid, flags */ + &setup, 1, 0, /* setup, length, max */ + param, param_len, 10, /* param, length, max */ + NULL, data_len, cli->max_xmit /* data, length, max */ + ) && + cli_receive_trans(cli, SMBtrans2, + &rparam, ¶m_len, + &rdata, &data_len)); + if (!ret) { + /* we need to work around a Win95 bug - sometimes + it gives ERRSRV/ERRerror temprarily */ + uint8 eclass; + uint32 ecode; + cli_error(cli, &eclass, &ecode, NULL); + if (eclass != ERRSRV || ecode != ERRerror) break; + msleep(100); + } + } while (count-- && ret==False); + + if (!ret || !rdata || data_len < 22) { + return False; + } + + if (cli->win95) { + date_fn = make_unix_date; + } else { + date_fn = make_unix_date2; + } + + if (c_time) { + *c_time = date_fn(rdata+0); + } + if (a_time) { + *a_time = date_fn(rdata+4); + } + if (m_time) { + *m_time = date_fn(rdata+8); + } + if (size) { + *size = IVAL(rdata, 12); + } + if (mode) { + *mode = SVAL(rdata,l1_attrFile); + } + + if (rdata) free(rdata); + if (rparam) free(rparam); + return True; +} + +/**************************************************************************** +send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level +****************************************************************************/ +BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, + time_t *c_time, time_t *a_time, time_t *m_time, + time_t *w_time, size_t *size, uint16 *mode, + SMB_INO_T *ino) +{ + int data_len = 0; + int param_len = 0; + uint16 setup = TRANSACT2_QPATHINFO; + pstring param; + char *rparam=NULL, *rdata=NULL; + + param_len = strlen(fname) + 7; + + memset(param, 0, param_len); + SSVAL(param, 0, SMB_QUERY_FILE_ALL_INFO); + pstrcpy(¶m[6], fname); + unix_to_dos(¶m[6],True); + + if (!cli_send_trans(cli, SMBtrans2, + NULL, 0, /* name, length */ + -1, 0, /* fid, flags */ + &setup, 1, 0, /* setup, length, max */ + param, param_len, 10, /* 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 < 22) { + return False; + } + + if (c_time) { + *c_time = interpret_long_date(rdata+0) - cli->serverzone; + } + if (a_time) { + *a_time = interpret_long_date(rdata+8) - cli->serverzone; + } + if (m_time) { + *m_time = interpret_long_date(rdata+16) - cli->serverzone; + } + if (w_time) { + *w_time = interpret_long_date(rdata+24) - cli->serverzone; + } + if (mode) { + *mode = SVAL(rdata, 32); + } + if (size) { + *size = IVAL(rdata, 48); + } + if (ino) { + *ino = IVAL(rdata, 64); + } + + if (rdata) free(rdata); + if (rparam) free(rparam); + return True; +} + + +/**************************************************************************** +send a qfileinfo call +****************************************************************************/ +BOOL cli_qfileinfo(struct cli_state *cli, int fnum, + uint16 *mode, size_t *size, + time_t *c_time, time_t *a_time, time_t *m_time, + time_t *w_time, SMB_INO_T *ino) +{ + int data_len = 0; + int param_len = 0; + uint16 setup = TRANSACT2_QFILEINFO; + pstring param; + char *rparam=NULL, *rdata=NULL; + + /* if its a win95 server then fail this - win95 totally screws it + up */ + if (cli->win95) return False; + + param_len = 4; + + memset(param, 0, param_len); + SSVAL(param, 0, fnum); + SSVAL(param, 2, SMB_QUERY_FILE_ALL_INFO); + + if (!cli_send_trans(cli, SMBtrans2, + NULL, 0, /* name, length */ + -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 < 68) { + return False; + } + + if (c_time) { + *c_time = interpret_long_date(rdata+0) - cli->serverzone; + } + if (a_time) { + *a_time = interpret_long_date(rdata+8) - cli->serverzone; + } + if (m_time) { + *m_time = interpret_long_date(rdata+16) - cli->serverzone; + } + if (w_time) { + *w_time = interpret_long_date(rdata+24) - cli->serverzone; + } + if (mode) { + *mode = SVAL(rdata, 32); + } + if (size) { + *size = IVAL(rdata, 48); + } + if (ino) { + *ino = IVAL(rdata, 64); + } + + if (rdata) free(rdata); + if (rparam) free(rparam); + return True; +} + -- cgit From 05cb3464f972d336dcb82ca332bf9b2617646070 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Apr 2000 15:13:15 +0000 Subject: - added some error checking - removed the VTP hook in smbd (This used to be commit 09355fcd50e6c9c0c81e5f70ab9b7ff88aa897bf) --- source3/libsmb/clirap.c | 130 ++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 64 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index d918dcff55..5e7e9427f6 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -115,7 +115,7 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) &rparam, &rprcnt, /* return params, return size */ &rdata, &rdrcnt /* return data, return size */ )) { - cli->rap_error = SVAL(rparam,0); + cli->rap_error = rparam? SVAL(rparam,0) : -1; p = rdata; if (cli->rap_error == 0) { @@ -139,65 +139,66 @@ call a NetShareEnum - try and browse available connections on a host ****************************************************************************/ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)) { - char *rparam = NULL; - char *rdata = NULL; - char *p; - int rdrcnt,rprcnt; - pstring param; - int count = -1; - - /* now send a SMBtrans command with api RNetShareEnum */ - p = param; - SSVAL(p,0,0); /* api number */ - p += 2; - pstrcpy(p,"WrLeh"); - p = skip_string(p,1); - pstrcpy(p,"B13BWz"); - p = skip_string(p,1); - SSVAL(p,0,1); - /* - * Win2k needs a *smaller* buffer than 0xFFFF here - - * it returns "out of server memory" with 0xFFFF !!! JRA. - */ - SSVAL(p,2,0xFFE0); - p += 4; - - if (cli_api(cli, - param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */ - NULL, 0, 0xFFE0, /* data, length, maxlen - Win2k needs a small buffer here too ! */ - &rparam, &rprcnt, /* return params, length */ - &rdata, &rdrcnt)) /* return data, length */ - { - int res = SVAL(rparam,0); - int converter=SVAL(rparam,2); - int i; - - if (res == 0 || res == ERRmoredata) { - count=SVAL(rparam,4); - p = rdata; - - for (i=0;i 0); } -- cgit From 8582d426467e715a912ef06c13bdbbdeb9000739 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 7 Oct 2000 01:15:07 +0000 Subject: Ensure browse.dat is written and read in UNIX character set format. Jeremy. (This used to be commit 279d0ec656b03f9266e38b013f16b69e7571c0d5) --- source3/libsmb/clirap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 5e7e9427f6..085b1c35bb 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -237,6 +237,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p += 4; pstrcpy(p, workgroup); + unix_to_dos(p, True); p = skip_string(p,1); if (cli_api(cli, -- cgit From 92ebc81734a8a4165f88eeba9c05a05ea2917584 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Thu, 4 Jan 2001 11:35:55 +0000 Subject: I need a callback arg for cli_NetServerEnum and cli_RNetShareEnum, so I had to modifiy any routine that calls it to pass NULL and so forth. Should have no impact. It compiles OK. (This used to be commit 7f862e387f935a2125481338eee850afcb8d82ba) --- source3/libsmb/clirap.c | 52 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 085b1c35bb..cd261eac59 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -137,7 +137,7 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) /**************************************************************************** call a NetShareEnum - try and browse available connections on a host ****************************************************************************/ -int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *)) +int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state) { char *rparam = NULL; char *rdata = NULL; @@ -184,7 +184,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co char *cmnt = comment_offset?(rdata+comment_offset-converter):""; dos_to_unix(sname,True); dos_to_unix(cmnt,True); - fn(sname, type, cmnt); + fn(sname, type, cmnt, state); } } else { DEBUG(4,("NetShareEnum res=%d\n", res)); @@ -210,7 +210,8 @@ The callback function takes 3 arguments: the machine name, the server type and the comment. ****************************************************************************/ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *)) + void (*fn)(const char *, uint32, const char *, void *), + void *state) { char *rparam = NULL; char *rdata = NULL; @@ -219,16 +220,38 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, pstring param; int uLevel = 1; int count = -1; + + /* + * First, check that the stype is reasonable ... + */ + + if (stype&0x80000000 && stype&0x7FFFFFFF) { + + /* Set an error here ... */ + + return False; + + } /* send a SMBtrans command with api NetServerEnum */ p = param; SSVAL(p,0,0x68); /* api number */ p += 2; - pstrcpy(p,"WrLehDz"); + if (!(stype&0x80000000)) + pstrcpy(p,"WrLehDz"); + else + pstrcpy(p,"WrLehDO"); p = skip_string(p,1); - pstrcpy(p,"B16BBDz"); - + if (!(stype&0x80000000)) { + pstrcpy(p,"B16BBDz"); + uLevel = 1; + } + else { + pstrcpy(p,"B16"); + uLevel = 0; + } + p = skip_string(p,1); SSVAL(p,0,uLevel); SSVAL(p,2,CLI_BUFFER_SIZE); @@ -255,7 +278,9 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, count=SVAL(rparam,4); p = rdata; - for (i = 0;i < count;i++, p += 26) { + + if (!(stype&0x80000000)) { + for (i = 0;i < count;i++, p += 26) { char *sname = p; int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; char *cmnt = comment_offset?(rdata+comment_offset):""; @@ -265,7 +290,18 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, dos_to_unix(sname, True); dos_to_unix(cmnt, True); - fn(sname, stype, cmnt); + fn(sname, stype, cmnt, state); + } + } + else { + for (i = 0; i < count; i++, p+= 16) { + char *sname = p; + + dos_to_unix(sname, True); + + fn(sname, stype, NULL, state); + + } } } } -- cgit From c565c98723f1fab04d47ae6076d742c8ee2dcb49 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Feb 2001 10:11:40 +0000 Subject: pipe opening now works with unicode (This used to be commit ba3ce3404e1cd2e9da3ba1708f6fc8a12c085ef2) --- source3/libsmb/clirap.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index cd261eac59..cd0e5ab73f 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -27,18 +27,15 @@ /**************************************************************************** Call a remote api on an arbitrary pipe. takes param, data and setup buffers. ****************************************************************************/ -BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len, +BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, uint16 *setup, uint32 setup_count, uint32 max_setup_count, char *params, uint32 param_count, uint32 max_param_count, char *data, uint32 data_count, uint32 max_data_count, char **rparam, uint32 *rparam_count, char **rdata, uint32 *rdata_count) { - if (pipe_name_len == 0) - pipe_name_len = strlen(pipe_name); - cli_send_trans(cli, SMBtrans, - pipe_name, pipe_name_len, + pipe_name, 0,0, /* fid, flags */ setup, setup_count, max_setup_count, params, param_count, max_param_count, @@ -59,8 +56,8 @@ BOOL cli_api(struct cli_state *cli, char **rdata, int *rdrcnt) { cli_send_trans(cli,SMBtrans, - PIPE_LANMAN,strlen(PIPE_LANMAN), /* Name, length */ - 0,0, /* fid, flags */ + PIPE_LANMAN, /* Name */ + 0,0, /* fid, flags */ NULL,0,0, /* Setup, length, max */ param, prcnt, mprcnt, /* Params, length, max */ data, drcnt, mdrcnt /* Data, length, max */ @@ -385,7 +382,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char data_len = 532; if (cli_send_trans(cli,SMBtrans, - PIPE_LANMAN,strlen(PIPE_LANMAN), /* name, length */ + PIPE_LANMAN, /* name */ 0,0, /* fid, flags */ NULL,0,0, /* setup, length, max */ param,param_len,2, /* param, length, max */ @@ -437,7 +434,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, do { ret = (cli_send_trans(cli, SMBtrans2, - NULL, 0, /* Name, length */ + NULL, /* Name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 10, /* param, length, max */ @@ -510,7 +507,7 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, unix_to_dos(¶m[6],True); if (!cli_send_trans(cli, SMBtrans2, - NULL, 0, /* name, length */ + NULL, /* name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 10, /* param, length, max */ @@ -582,7 +579,7 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, SSVAL(param, 2, SMB_QUERY_FILE_ALL_INFO); if (!cli_send_trans(cli, SMBtrans2, - NULL, 0, /* name, length */ + NULL, /* name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 2, /* param, length, max */ -- cgit From 064898cf8ad604c3d0a7399964b122d4c53fe7df Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Feb 2001 13:16:01 +0000 Subject: converted a bunch more fns (This used to be commit f6b8d6730452522f77852af0917cb48424d4c8a9) --- source3/libsmb/clirap.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index cd0e5ab73f..d1ce4d712e 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -255,10 +255,9 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p += 4; SIVAL(p,0,stype); p += 4; - - pstrcpy(p, workgroup); - unix_to_dos(p, True); - p = skip_string(p,1); + + p += clistr_push(cli, p, workgroup, -1, + CLISTR_TERMINATE | CLISTR_CONVERT); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ @@ -275,29 +274,38 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, count=SVAL(rparam,4); p = rdata; - if (!(stype&0x80000000)) { for (i = 0;i < count;i++, p += 26) { - char *sname = p; - int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; - char *cmnt = comment_offset?(rdata+comment_offset):""; - if (comment_offset < 0 || comment_offset > rdrcnt) continue; - - stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; - - dos_to_unix(sname, True); - dos_to_unix(cmnt, True); - fn(sname, stype, cmnt, state); + fstring sname, cmnt; + int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; + char *cptr = comment_offset?(rdata+comment_offset):NULL; + if (comment_offset < 0 || comment_offset > rdrcnt) continue; + + stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; + clistr_pull(cli, sname, p, + sizeof(fstring), -1, + CLISTR_TERMINATE | + CLISTR_CONVERT); + fstrcpy(cmnt, ""); + if (cptr) { + clistr_pull(cli, cmnt, cptr, + sizeof(fstring), -1, + CLISTR_TERMINATE | + CLISTR_CONVERT); + } + fn(sname, stype, cmnt, state); } } else { for (i = 0; i < count; i++, p+= 16) { - char *sname = p; - - dos_to_unix(sname, True); + fstring sname; - fn(sname, stype, NULL, state); + clistr_pull(cli, sname, p, + sizeof(fstring), -1, + CLISTR_TERMINATE | + CLISTR_CONVERT); + fn(sname, stype, NULL, state); } } } -- cgit From 518f2fc391266c2f9b9cfc8b485a8e57ce359be8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 21 Feb 2001 02:52:41 +0000 Subject: reverted richards cli_NetServerEnum changes - they broke lots of things (This used to be commit 86adbb0caf26a8c2fc4d3748b965c0ce79360c1a) --- source3/libsmb/clirap.c | 68 +++++++++---------------------------------------- 1 file changed, 12 insertions(+), 56 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index d1ce4d712e..bf0940d1d6 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -218,36 +218,14 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, int uLevel = 1; int count = -1; - /* - * First, check that the stype is reasonable ... - */ - - if (stype&0x80000000 && stype&0x7FFFFFFF) { - - /* Set an error here ... */ - - return False; - - } - /* send a SMBtrans command with api NetServerEnum */ p = param; SSVAL(p,0,0x68); /* api number */ p += 2; - if (!(stype&0x80000000)) - pstrcpy(p,"WrLehDz"); - else - pstrcpy(p,"WrLehDO"); + pstrcpy(p,"WrLehDz"); p = skip_string(p,1); - if (!(stype&0x80000000)) { - pstrcpy(p,"B16BBDz"); - uLevel = 1; - } - else { - pstrcpy(p,"B16"); - uLevel = 0; - } + pstrcpy(p,"B16BBDz"); p = skip_string(p,1); SSVAL(p,0,uLevel); @@ -257,7 +235,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p += 4; p += clistr_push(cli, p, workgroup, -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + CLISTR_TERMINATE | CLISTR_CONVERT | CLISTR_ASCII); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ @@ -274,39 +252,17 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, count=SVAL(rparam,4); p = rdata; - if (!(stype&0x80000000)) { - for (i = 0;i < count;i++, p += 26) { - fstring sname, cmnt; - int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; - char *cptr = comment_offset?(rdata+comment_offset):NULL; - if (comment_offset < 0 || comment_offset > rdrcnt) continue; - - stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; - clistr_pull(cli, sname, p, - sizeof(fstring), -1, - CLISTR_TERMINATE | - CLISTR_CONVERT); - fstrcpy(cmnt, ""); - if (cptr) { - clistr_pull(cli, cmnt, cptr, - sizeof(fstring), -1, - CLISTR_TERMINATE | - CLISTR_CONVERT); - } - fn(sname, stype, cmnt, state); - } - } - else { - for (i = 0; i < count; i++, p+= 16) { - fstring sname; + for (i = 0;i < count;i++, p += 26) { + char *sname = p; + int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; + char *cmnt = comment_offset?(rdata+comment_offset):""; + if (comment_offset < 0 || comment_offset > rdrcnt) continue; - clistr_pull(cli, sname, p, - sizeof(fstring), -1, - CLISTR_TERMINATE | - CLISTR_CONVERT); + stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; - fn(sname, stype, NULL, state); - } + dos_to_unix(sname, True); + dos_to_unix(cmnt, True); + fn(sname, stype, cmnt, state); } } } -- cgit From d689f00026541dd2cb87c6949fdc2f8eb3ad919f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 21 Feb 2001 04:14:28 +0000 Subject: converted the last couple of functions in libsmb to be unicode the whole of libsmb should now do unicode where appropriate (This used to be commit ac7529d2b69826f8214d5632c31778cc87216653) --- source3/libsmb/clirap.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index bf0940d1d6..3c87464495 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -388,13 +388,15 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, int count=8; BOOL ret; time_t (*date_fn)(void *); + char *p; - param_len = strlen(fname) + 7; + p = param; + memset(p, 0, 6); + SSVAL(p, 0, SMB_INFO_STANDARD); + p += 6; + p += clistr_push(cli, p, fname, sizeof(pstring)-6, CLISTR_TERMINATE | CLISTR_CONVERT); - memset(param, 0, param_len); - SSVAL(param, 0, SMB_INFO_STANDARD); - pstrcpy(¶m[6], fname); - unix_to_dos(¶m[6],True); + param_len = PTR_DIFF(p, param); do { ret = (cli_send_trans(cli, SMBtrans2, @@ -462,13 +464,15 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, uint16 setup = TRANSACT2_QPATHINFO; pstring param; char *rparam=NULL, *rdata=NULL; + char *p; - param_len = strlen(fname) + 7; + p = param; + memset(p, 0, 6); + SSVAL(p, 0, SMB_QUERY_FILE_ALL_INFO); + p += 6; + p += clistr_push(cli, p, fname, sizeof(pstring)-6, CLISTR_TERMINATE | CLISTR_CONVERT); - memset(param, 0, param_len); - SSVAL(param, 0, SMB_QUERY_FILE_ALL_INFO); - pstrcpy(¶m[6], fname); - unix_to_dos(¶m[6],True); + param_len = PTR_DIFF(p, param); if (!cli_send_trans(cli, SMBtrans2, NULL, /* name */ -- cgit From 45c2ee3ff2d01fdd0a2db9fa90457cff4663c43d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Mar 2001 11:35:25 +0000 Subject: to use the same macros in the client and server rename the CLISTR_ macros to STR_ (This used to be commit 95c9e4e0ba8f37f565aaf136f41eb76489441ff7) --- source3/libsmb/clirap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 3c87464495..561d717e73 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -235,7 +235,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p += 4; p += clistr_push(cli, p, workgroup, -1, - CLISTR_TERMINATE | CLISTR_CONVERT | CLISTR_ASCII); + STR_TERMINATE | STR_CONVERT | STR_ASCII); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ @@ -394,7 +394,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, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE | STR_CONVERT); param_len = PTR_DIFF(p, param); @@ -470,7 +470,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, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE | STR_CONVERT); param_len = PTR_DIFF(p, param); -- cgit From 0c69d176532ea4ee2fa4c7809db37b00ecfbeeb6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 18 Jun 2001 23:31:22 +0000 Subject: New info level tester. Jeremy. (This used to be commit 9297ae69a7dde878bb4c696f90fbaceb46e18720) --- source3/libsmb/clirap.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 561d717e73..5d41af13f9 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -593,3 +593,46 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, return True; } +/**************************************************************************** +send a qfileinfo call +****************************************************************************/ +BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdata) +{ + int data_len = 0; + int param_len = 0; + uint16 setup = TRANSACT2_QFILEINFO; + pstring param; + char *rparam=NULL, *rdata=NULL; + + /* if its a win95 server then fail this - win95 totally screws it + up */ + if (cli->win95) return False; + + param_len = 4; + + memset(param, 0, param_len); + SSVAL(param, 0, fnum); + SSVAL(param, 2, level); + + 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; + } + + memcpy(outdata, rdata, data_len); + + if (rdata) free(rdata); + if (rparam) free(rparam); + return True; +} -- cgit From fda0f83d751a1ea6c731fd6a82484a724a1c6e32 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 21 Jun 2001 01:01:15 +0000 Subject: Following info from TAKAHASHI Motonobu , Samba Users Group Japan, ensure that we don't use dos_to_unix(xx,True), but always use dos_to_unix(xx,False) to prevent overwriting. Jeremy. (This used to be commit 244aec8ea623fec828add3ab09c5003bf32bd5c7) --- source3/libsmb/clirap.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 5d41af13f9..5050caf073 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -179,9 +179,12 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co int type = SVAL(p,14); int comment_offset = IVAL(p,16) & 0xFFFF; char *cmnt = comment_offset?(rdata+comment_offset-converter):""; - dos_to_unix(sname,True); - dos_to_unix(cmnt,True); - fn(sname, type, cmnt, state); + pstring s1, s2; + + pstrcpy(s1, dos_to_unix(sname, False)); + pstrcpy(s2, dos_to_unix(cmnt, False)); + + fn(s1, type, s2, state); } } else { DEBUG(4,("NetShareEnum res=%d\n", res)); @@ -256,13 +259,15 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, char *sname = p; int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; char *cmnt = comment_offset?(rdata+comment_offset):""; + pstring s1, s2; + if (comment_offset < 0 || comment_offset > rdrcnt) continue; stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; - dos_to_unix(sname, True); - dos_to_unix(cmnt, True); - fn(sname, stype, cmnt, state); + pstrcpy(s1, dos_to_unix(sname, False)); + pstrcpy(s2, dos_to_unix(cmnt, False)); + fn(s1, stype, s2, state); } } } -- cgit From 75e33b78036438b2a07eed3cc5a1e591103b7c9c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 3 Jul 2001 04:09:09 +0000 Subject: Fixed incorrect comment for cli_NetServerEnum() (This used to be commit 0a505e50a5059930de6583918f25ef84af53de0e) --- source3/libsmb/clirap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 5050caf073..253d192aba 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -203,11 +203,11 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co /**************************************************************************** -call a NetServerEnum for the specified workgroup and servertype mask. -This function then calls the specified callback function for each name returned. +call a NetServerEnum for the specified workgroup and servertype mask. This +function then calls the specified callback function for each name returned. -The callback function takes 3 arguments: the machine name, the server type and -the comment. +The callback function takes 4 arguments: the machine name, the server type, +the comment and a state pointer. ****************************************************************************/ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, void (*fn)(const char *, uint32, const char *, void *), -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/libsmb/clirap.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 253d192aba..c16fe2d08d 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -181,8 +181,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; - pstrcpy(s1, dos_to_unix(sname, False)); - pstrcpy(s2, dos_to_unix(cmnt, False)); + pull_ascii_pstring(s1, sname); + pull_ascii_pstring(s2, cmnt); fn(s1, type, s2, state); } @@ -237,8 +237,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SIVAL(p,0,stype); p += 4; - p += clistr_push(cli, p, workgroup, -1, - STR_TERMINATE | STR_CONVERT | STR_ASCII); + p += push_pstring(p, workgroup); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ @@ -265,8 +264,8 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; - pstrcpy(s1, dos_to_unix(sname, False)); - pstrcpy(s2, dos_to_unix(cmnt, False)); + pull_ascii_pstring(s1, sname); + pull_ascii_pstring(s2, cmnt); fn(s1, stype, s2, state); } } @@ -325,13 +324,10 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char * use this as the key to make_oem_passwd_hash(). */ memset(upper_case_old_pw, '\0', sizeof(upper_case_old_pw)); - fstrcpy(upper_case_old_pw, old_password); - unix_to_dos(upper_case_old_pw,True); - strupper(upper_case_old_pw); + clistr_push(cli, upper_case_old_pw, old_password, -1,STR_TERMINATE|STR_UPPER); E_P16((uchar *)upper_case_old_pw, old_pw_hash); - pstrcpy(dos_new_password, new_password); - unix_to_dos(dos_new_password, True); + clistr_push(cli, dos_new_password, new_password, -1, STR_TERMINATE); if (!make_oem_passwd_hash( data, dos_new_password, old_pw_hash, False)) return False; @@ -340,9 +336,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char * Now place the old password hash in the data. */ memset(upper_case_new_pw, '\0', sizeof(upper_case_new_pw)); - fstrcpy(upper_case_new_pw, new_password); - unix_to_dos(upper_case_new_pw,True); - strupper(upper_case_new_pw); + clistr_push(cli, upper_case_new_pw, new_password, -1, STR_TERMINATE|STR_UPPER); E_P16((uchar *)upper_case_new_pw, new_pw_hash); @@ -399,7 +393,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 | STR_CONVERT); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE); param_len = PTR_DIFF(p, param); @@ -475,7 +469,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 | STR_CONVERT); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE); param_len = PTR_DIFF(p, param); -- cgit From c4495240f63c2bae164d4ef29ab9af2d3d87aec1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Aug 2001 04:59:05 +0000 Subject: Changed the order of arguments in make_oem_passwd_hash(). All the other encryption functions have outputs as the last arguments. (This used to be commit fb60798a771a7a2358d78e5cef97487addf930e7) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index c16fe2d08d..c649aedfba 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -329,7 +329,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char clistr_push(cli, dos_new_password, new_password, -1, STR_TERMINATE); - if (!make_oem_passwd_hash( data, dos_new_password, old_pw_hash, False)) + if (!make_oem_passwd_hash(dos_new_password, old_pw_hash, False, data)) return False; /* -- cgit From 2ccfea3de7b2b7dc0be2438c3adb3f7be82a2dfc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Aug 2001 06:00:33 +0000 Subject: A rewrite of the error handling in the libsmb client code. I've separated out the error handling into a bunch of separate functions rather than all being handled in one big function. Fetch error codes from the last received packet: void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num); uint32 cli_nt_error(struct cli_state *); Convert errors to UNIX errno values: int cli_errno_from_dos(uint8 eclass, uint32 num); int cli_errno_from_nt(uint32 status); int cli_errno(struct cli_state *cli); Detect different kinds of errors: BOOL cli_is_dos_error(struct cli_state *cli); BOOL cli_is_nt_error(struct cli_state *cli); BOOL cli_is_error(struct cli_state *cli); This also means we now support CAP_STATUS32 as we can decode and understand NT errors instead of just DOS errors. Yay! Ported a whole bunch of files in libsmb to use this new API instead of the just the DOS error. (This used to be commit 6dbdb0d813f3c7ab20b38baa1223b0b479aadec9) --- source3/libsmb/clirap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index c649aedfba..bfbe478191 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -329,7 +329,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char clistr_push(cli, dos_new_password, new_password, -1, STR_TERMINATE); - if (!make_oem_passwd_hash(dos_new_password, old_pw_hash, False, data)) + if (!make_oem_passwd_hash( data, dos_new_password, old_pw_hash, False)) return False; /* @@ -408,12 +408,12 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, cli_receive_trans(cli, SMBtrans2, &rparam, ¶m_len, &rdata, &data_len)); - if (!ret) { + if (!ret && cli_is_dos_error(cli)) { /* we need to work around a Win95 bug - sometimes it gives ERRSRV/ERRerror temprarily */ uint8 eclass; uint32 ecode; - cli_error(cli, &eclass, &ecode, NULL); + cli_dos_error(cli, &eclass, &ecode); if (eclass != ERRSRV || ecode != ERRerror) break; msleep(100); } -- cgit From bcbd75f7add425ebee760ddbd2e80a1d4a51e619 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 17 Sep 2001 03:33:37 +0000 Subject: move to SAFE_FREE() (This used to be commit 48fc6a6cd52e01b287030fbbf0aa08a6814c5e11) --- source3/libsmb/clirap.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index bfbe478191..90f4d546d1 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -124,10 +124,8 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) } } - if (rparam) - free(rparam); - if (rdata) - free(rdata); + SAFE_FREE(rparam); + SAFE_FREE(rdata); return (cli->rap_error == 0); } @@ -193,10 +191,8 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co DEBUG(4,("NetShareEnum failed\n")); } - if (rparam) - free(rparam); - if (rdata) - free(rdata); + SAFE_FREE(rparam); + SAFE_FREE(rdata); return count; } @@ -271,10 +267,8 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, } } - if (rparam) - free(rparam); - if (rdata) - free(rdata); + SAFE_FREE(rparam); + SAFE_FREE(rdata); return(count > 0); } @@ -363,10 +357,8 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char cli->rap_error = SVAL(rparam,0); } - if (rparam) - free(rparam); - if (rdata) - free(rdata); + SAFE_FREE(rparam); + SAFE_FREE(rdata); return (cli->rap_error == 0); } @@ -445,8 +437,8 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, *mode = SVAL(rdata,l1_attrFile); } - if (rdata) free(rdata); - if (rparam) free(rparam); + SAFE_FREE(rdata); + SAFE_FREE(rparam); return True; } @@ -515,8 +507,8 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, *ino = IVAL(rdata, 64); } - if (rdata) free(rdata); - if (rparam) free(rparam); + SAFE_FREE(rdata); + SAFE_FREE(rparam); return True; } @@ -587,8 +579,8 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, *ino = IVAL(rdata, 64); } - if (rdata) free(rdata); - if (rparam) free(rparam); + SAFE_FREE(rdata); + SAFE_FREE(rparam); return True; } @@ -631,7 +623,7 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdat memcpy(outdata, rdata, data_len); - if (rdata) free(rdata); - if (rparam) free(rparam); + SAFE_FREE(rdata); + SAFE_FREE(rparam); return True; } -- cgit From e3249d0196a3bf0c159acf69bb5fb1d0c78d1290 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 Sep 2001 04:25:49 +0000 Subject: added cli_qpathinfo_alt_name() for fetching the 8.3 name of a file (This used to be commit b2eb7feb7f5bafe953fdeb92daaf9e4f08e44983) --- source3/libsmb/clirap.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 90f4d546d1..2136ba118b 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -627,3 +627,68 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdat SAFE_FREE(rparam); return True; } + + + +/**************************************************************************** +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; + int param_len = 0; + uint16 setup = TRANSACT2_QPATHINFO; + pstring param; + char *rparam=NULL, *rdata=NULL; + int count=8; + char *p; + BOOL ret; + int len; + + p = param; + 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); + + param_len = PTR_DIFF(p, param); + + do { + ret = (cli_send_trans(cli, SMBtrans2, + NULL, /* Name */ + -1, 0, /* fid, flags */ + &setup, 1, 0, /* setup, length, max */ + param, param_len, 10, /* param, length, max */ + NULL, data_len, cli->max_xmit /* data, length, max */ + ) && + cli_receive_trans(cli, SMBtrans2, + &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; + uint32 ecode; + cli_dos_error(cli, &eclass, &ecode); + if (eclass != ERRSRV || ecode != ERRerror) break; + msleep(100); + } + } while (count-- && ret==False); + + if (!ret || !rdata || data_len < 4) { + return NT_STATUS_UNSUCCESSFUL; + } + + len = IVAL(rdata, 0); + + if (len > data_len - 4) { + return NT_STATUS_INVALID_NETWORK_RESPONSE; + } + + clistr_pull(cli, alt_name, rdata+4, sizeof(fstring), len, 0); + + SAFE_FREE(rdata); + SAFE_FREE(rparam); + + return NT_STATUS_OK; +} -- cgit From a85390ae696998096b9323fd388fe0f1a9e1795c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 12 Dec 2001 19:40:22 +0000 Subject: Always use ASCII strings when changing passwords with RAP. Jeremy. (This used to be commit d3ac2265b1b83e2e030688ee8e0d43918ce4d203) --- source3/libsmb/clirap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 2136ba118b..4484b61381 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -318,10 +318,10 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char * use this as the key to make_oem_passwd_hash(). */ memset(upper_case_old_pw, '\0', sizeof(upper_case_old_pw)); - clistr_push(cli, upper_case_old_pw, old_password, -1,STR_TERMINATE|STR_UPPER); + clistr_push(cli, upper_case_old_pw, old_password, -1,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); + clistr_push(cli, dos_new_password, new_password, -1, STR_TERMINATE|STR_ASCII); if (!make_oem_passwd_hash( data, dos_new_password, old_pw_hash, False)) return False; @@ -330,7 +330,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char * Now place the old password hash in the data. */ memset(upper_case_new_pw, '\0', sizeof(upper_case_new_pw)); - clistr_push(cli, upper_case_new_pw, new_password, -1, STR_TERMINATE|STR_UPPER); + clistr_push(cli, upper_case_new_pw, new_password, -1, STR_TERMINATE|STR_UPPER|STR_ASCII); E_P16((uchar *)upper_case_new_pw, new_pw_hash); -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/libsmb/clirap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 4484b61381..42f1f652eb 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 3.0 + Unix SMB/CIFS implementation. client RAP calls Copyright (C) Andrew Tridgell 1994-1998 -- cgit From 5d2302899a78382dfbdf08ced2cca252cd1f4d63 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Feb 2002 01:30:02 +0000 Subject: fixed a bug in qpathinfo client code (This used to be commit 22f348a1f9501cc00d46d6c6064f71198558c0ee) --- source3/libsmb/clirap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 42f1f652eb..1cbadb4344 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -372,6 +372,7 @@ 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; @@ -397,9 +398,10 @@ 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, ¶m_len, - &rdata, &data_len)); - if (!ret && cli_is_dos_error(cli)) { + &rparam, &rparam_len, + &rdata, &rdata_len)); + if (!cli_is_dos_error(cli)) break; + if (!ret) { /* we need to work around a Win95 bug - sometimes it gives ERRSRV/ERRerror temprarily */ uint8 eclass; @@ -410,7 +412,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, } } while (count-- && ret==False); - if (!ret || !rdata || data_len < 22) { + if (!ret || !rdata || rdata_len < 22) { return False; } -- cgit From 0cbcf49f6cfb91a7251baa5339795436308578ea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Feb 2002 04:25:17 +0000 Subject: added cli_qfilename(), used in trans2 torture test (This used to be commit d37905f20397911e4f74e672ebdee28f1ddf3c2c) --- source3/libsmb/clirap.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 1cbadb4344..a2b6c8bb8b 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -514,6 +514,49 @@ 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 ****************************************************************************/ -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/libsmb/clirap.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index a2b6c8bb8b..2064e14954 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -117,7 +117,8 @@ 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); - fstrcpy(cli->eff_name,p+2); + /* The cli->eff_name field used to be set here + but it wasn't used anywhere else. */ } else { DEBUG(1,("NetwkstaUserLogon gave error %d\n", cli->rap_error)); } @@ -283,8 +284,6 @@ 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; @@ -316,9 +315,7 @@ 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(). */ - memset(upper_case_old_pw, '\0', sizeof(upper_case_old_pw)); - clistr_push(cli, upper_case_old_pw, old_password, -1,STR_TERMINATE|STR_UPPER|STR_ASCII); - E_P16((uchar *)upper_case_old_pw, old_pw_hash); + E_deshash(old_password, old_pw_hash); clistr_push(cli, dos_new_password, new_password, -1, STR_TERMINATE|STR_ASCII); @@ -328,10 +325,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char /* * Now place the old password hash in the data. */ - memset(upper_case_new_pw, '\0', sizeof(upper_case_new_pw)); - clistr_push(cli, upper_case_new_pw, new_password, -1, STR_TERMINATE|STR_UPPER|STR_ASCII); - - E_P16((uchar *)upper_case_new_pw, new_pw_hash); + E_deshash(new_password, new_pw_hash); E_old_pw_hash( new_pw_hash, old_pw_hash, (uchar *)&data[516]); -- cgit From 35ac9d287f000c27dc864789b341bebe7acb4c74 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 26 Oct 2002 02:20:59 +0000 Subject: Try to catch up on the code I've put into HEAD that should be in 3.0: - vorlan's hosts allow with DNS names patch - use x_fileno() in debug.c, not the struct directly. - check for server timeout on password change (was reporting success) - better error/status loggin in both the pam_winbind client and winbindd_pam server code. - (pdb_ldap) don't set the ldap version twice - we do it on every bind anyway. (This used to be commit 9fa1863d8e7788eda83911ca2610754486b33069) --- source3/libsmb/clirap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 2064e14954..b4924fd773 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -343,13 +343,17 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char return False; } - if (cli_receive_trans(cli,SMBtrans, + if (!cli_receive_trans(cli,SMBtrans, &rparam, &rprcnt, &rdata, &rdrcnt)) { - if (rparam) - cli->rap_error = SVAL(rparam,0); + DEBUG(0,("cli_oem_change_password: Failed to recieve reply to password change for user %s\n", + user )); + return False; } - + + if (rparam) + cli->rap_error = SVAL(rparam,0); + SAFE_FREE(rparam); SAFE_FREE(rdata); -- cgit From 634c54310c92c48dd4eceec602e230a021bdcfc5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 3 Jan 2003 08:28:12 +0000 Subject: Merge from HEAD - make Samba compile with -Wwrite-strings without additional warnings. (Adds a lot of const). Andrew Bartlett (This used to be commit 3a7458f9472432ef12c43008414925fd1ce8ea0c) --- source3/libsmb/clirap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index b4924fd773..792a3e7aa0 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -26,7 +26,7 @@ /**************************************************************************** Call a remote api on an arbitrary pipe. takes param, data and setup buffers. ****************************************************************************/ -BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, +BOOL cli_api_pipe(struct cli_state *cli, const char *pipe_name, uint16 *setup, uint32 setup_count, uint32 max_setup_count, char *params, uint32 param_count, uint32 max_param_count, char *data, uint32 data_count, uint32 max_data_count, @@ -176,7 +176,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co char *sname = p; int type = SVAL(p,14); int comment_offset = IVAL(p,16) & 0xFFFF; - char *cmnt = comment_offset?(rdata+comment_offset-converter):""; + const char *cmnt = comment_offset?(rdata+comment_offset-converter):""; pstring s1, s2; pull_ascii_pstring(s1, sname); @@ -253,7 +253,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, for (i = 0;i < count;i++, p += 26) { char *sname = p; int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; - char *cmnt = comment_offset?(rdata+comment_offset):""; + const char *cmnt = comment_offset?(rdata+comment_offset):""; pstring s1, s2; if (comment_offset < 0 || comment_offset > rdrcnt) continue; -- cgit From 42d9c734240574247cf3363a5d8ee67a17c668bc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 14 Jan 2003 03:02:18 +0000 Subject: merge alt_name patch from head (This used to be commit 20ebdee36d5351731698bdef6602fc73a45b1651) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 792a3e7aa0..f8f840abaa 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -727,7 +727,7 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin return NT_STATUS_INVALID_NETWORK_RESPONSE; } - clistr_pull(cli, alt_name, rdata+4, sizeof(fstring), len, 0); + clistr_pull(cli, alt_name, rdata+4, sizeof(fstring), len, STR_UNICODE); SAFE_FREE(rdata); SAFE_FREE(rparam); -- cgit From 8d563a985b1091b11554fb828700e57c18ac08fb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Mar 2003 16:54:57 +0000 Subject: strcpy_base from HEAD and trivial fix for smbclient -L Volker (This used to be commit 54c99ee1fbaf4541fb3fa10a9b764da1367af6d3) --- source3/libsmb/clirap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index f8f840abaa..b6fbb3880a 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -85,19 +85,19 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) p = param; SSVAL(p,0,132); /* api number */ p += 2; - pstrcpy(p,"OOWb54WrLh"); + pstrcpy_base(p,"OOWb54WrLh",param); p = skip_string(p,1); - pstrcpy(p,"WB21BWDWWDDDDDDDzzzD"); + pstrcpy_base(p,"WB21BWDWWDDDDDDDzzzD",param); p = skip_string(p,1); SSVAL(p,0,1); p += 2; - pstrcpy(p,user); + pstrcpy_base(p,user,param); strupper(p); p += 21; p++; p += 15; p++; - pstrcpy(p, workstation); + pstrcpy_base(p, workstation, param); strupper(p); p += 16; SSVAL(p, 0, CLI_BUFFER_SIZE); @@ -145,9 +145,9 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co p = param; SSVAL(p,0,0); /* api number */ p += 2; - pstrcpy(p,"WrLeh"); + pstrcpy_base(p,"WrLeh",param); p = skip_string(p,1); - pstrcpy(p,"B13BWz"); + pstrcpy_base(p,"B13BWz",param); p = skip_string(p,1); SSVAL(p,0,1); /* @@ -221,10 +221,10 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p = param; SSVAL(p,0,0x68); /* api number */ p += 2; - pstrcpy(p,"WrLehDz"); + pstrcpy_base(p,"WrLehDz",param); p = skip_string(p,1); - pstrcpy(p,"B16BBDz"); + pstrcpy_base(p,"B16BBDz",param); p = skip_string(p,1); SSVAL(p,0,uLevel); -- cgit From dbe2858b862232ede390fe0088f82d1e826612f9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Mar 2003 00:51:05 +0000 Subject: Change size parameters from signed to unsigned to fix up warnings. Jeremy. (This used to be commit 33b11d5eb53bdeb9d279d221fd5c01579253e1c7) --- source3/libsmb/clirap.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index b6fbb3880a..069ee374fa 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -41,8 +41,8 @@ BOOL cli_api_pipe(struct cli_state *cli, const char *pipe_name, data, data_count, max_data_count); return (cli_receive_trans(cli, SMBtrans, - rparam, (int *)rparam_count, - rdata, (int *)rdata_count)); + rparam, (unsigned int *)rparam_count, + rdata, (unsigned int *)rdata_count)); } /**************************************************************************** @@ -51,8 +51,8 @@ call a remote api BOOL cli_api(struct cli_state *cli, char *param, int prcnt, int mprcnt, char *data, int drcnt, int mdrcnt, - char **rparam, int *rprcnt, - char **rdata, int *rdrcnt) + char **rparam, unsigned int *rprcnt, + char **rdata, unsigned int *rdrcnt) { cli_send_trans(cli,SMBtrans, PIPE_LANMAN, /* Name */ @@ -286,8 +286,8 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char char *p = param; unsigned char old_pw_hash[16]; unsigned char new_pw_hash[16]; - int data_len; - int param_len = 0; + unsigned int data_len; + unsigned int param_len = 0; char *rparam = NULL; char *rdata = NULL; int rprcnt, rdrcnt; @@ -368,9 +368,9 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, time_t *c_time, time_t *a_time, time_t *m_time, size_t *size, uint16 *mode) { - int data_len = 0; - int param_len = 0; - int rparam_len, rdata_len; + unsigned int data_len = 0; + unsigned int param_len = 0; + unsigned int rparam_len, rdata_len; uint16 setup = TRANSACT2_QPATHINFO; pstring param; char *rparam=NULL, *rdata=NULL; @@ -449,8 +449,8 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, time_t *w_time, size_t *size, uint16 *mode, SMB_INO_T *ino) { - int data_len = 0; - int param_len = 0; + unsigned int data_len = 0; + unsigned int param_len = 0; uint16 setup = TRANSACT2_QPATHINFO; pstring param; char *rparam=NULL, *rdata=NULL; @@ -518,8 +518,8 @@ 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; + unsigned int data_len = 0; + unsigned int param_len = 0; uint16 setup = TRANSACT2_QFILEINFO; pstring param; char *rparam=NULL, *rdata=NULL; @@ -563,8 +563,8 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, time_t *c_time, time_t *a_time, time_t *m_time, time_t *w_time, SMB_INO_T *ino) { - int data_len = 0; - int param_len = 0; + unsigned int data_len = 0; + unsigned int param_len = 0; uint16 setup = TRANSACT2_QFILEINFO; pstring param; char *rparam=NULL, *rdata=NULL; @@ -631,8 +631,8 @@ send a qfileinfo call ****************************************************************************/ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdata) { - int data_len = 0; - int param_len = 0; + unsigned int data_len = 0; + unsigned int param_len = 0; uint16 setup = TRANSACT2_QFILEINFO; pstring param; char *rparam=NULL, *rdata=NULL; @@ -677,8 +677,8 @@ 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; - int param_len = 0; + unsigned int data_len = 0; + unsigned int param_len = 0; uint16 setup = TRANSACT2_QPATHINFO; pstring param; char *rparam=NULL, *rdata=NULL; -- cgit From cf9fcaa98ef7f11a660aad00a7628fd99dbaa950 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 17 Mar 2003 22:40:37 +0000 Subject: pstrcpy_base merges for client-side smbpasswd. Andrew Bartlett (This used to be commit 980f2eb7c2efa1a2c83098aebecf0e25a05724cb) --- source3/libsmb/clirap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 069ee374fa..224c37046c 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -221,10 +221,10 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p = param; SSVAL(p,0,0x68); /* api number */ p += 2; - pstrcpy_base(p,"WrLehDz",param); + pstrcpy_base(p,"WrLehDz", param); p = skip_string(p,1); - pstrcpy_base(p,"B16BBDz",param); + pstrcpy_base(p,"B16BBDz", param); p = skip_string(p,1); SSVAL(p,0,uLevel); @@ -233,7 +233,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SIVAL(p,0,stype); p += 4; - p += push_pstring(p, workgroup); + p += push_pstring_base(p, workgroup, param); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ @@ -281,7 +281,7 @@ Send a SamOEMChangePassword command BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, const char *old_password) { - char param[16+sizeof(fstring)]; + pstring param; char data[532]; char *p = param; unsigned char old_pw_hash[16]; @@ -300,11 +300,11 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char SSVAL(p,0,214); /* SamOEMChangePassword command. */ p += 2; - pstrcpy(p, "zsT"); + pstrcpy_base(p, "zsT", param); p = skip_string(p,1); - pstrcpy(p, "B516B16"); + pstrcpy_base(p, "B516B16", param); p = skip_string(p,1); - pstrcpy(p,user); + pstrcpy_base(p,user, param); p = skip_string(p,1); SSVAL(p,0,532); p += 2; @@ -317,7 +317,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char */ E_deshash(old_password, old_pw_hash); - clistr_push(cli, dos_new_password, new_password, -1, STR_TERMINATE|STR_ASCII); + clistr_push(cli, dos_new_password, new_password, sizeof(dos_new_password), STR_TERMINATE|STR_ASCII); if (!make_oem_passwd_hash( data, dos_new_password, old_pw_hash, False)) return False; @@ -685,7 +685,7 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin int count=8; char *p; BOOL ret; - int len; + unsigned int len; p = param; memset(p, 0, 6); -- cgit From ddf662d11886189151dca188a2eb4f6bd602caa0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2003 14:45:11 +0000 Subject: More merges from HEAD: - Stephan Kulow's changes (fixing warnings in libsmbclient) - VFS modules - Seperating libs (This used to be commit 6e9b7802335428c88ecf4e44a0e2395ac58e96b5) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 224c37046c..f05a65762b 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -233,7 +233,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SIVAL(p,0,stype); p += 4; - p += push_pstring_base(p, workgroup, param); + push_ascii(p, workgroup, sizeof(pstring)-PTR_DIFF(p,param)-1, STR_TERMINATE|STR_UPPER); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ -- cgit From 62f70d191077dd7bf41f7cdca00cb7b94607323c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 26 May 2003 19:47:53 +0000 Subject: Fix list of servers in 'smbclient -L' (debian bug #194553, patch by Heine Larsen) (This used to be commit e9df7d2820441c63c35e7b4fc5b3cc594053781c) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index f05a65762b..9d4411797d 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -233,7 +233,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SIVAL(p,0,stype); p += 4; - push_ascii(p, workgroup, sizeof(pstring)-PTR_DIFF(p,param)-1, STR_TERMINATE|STR_UPPER); + p += push_ascii(p, workgroup, sizeof(pstring)-PTR_DIFF(p,param)-1, STR_TERMINATE|STR_UPPER); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ -- cgit From ce72beb2b558d86fb49063c6b1fa00e07952ce56 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 3 Jul 2003 19:11:31 +0000 Subject: Removed strupper/strlower macros that automatically map to strupper_m/strlower_m. I really want people to think about when they're using multibyte strings. Jeremy. (This used to be commit ff222716a08af65d26ad842ce4c2841cc6540959) --- source3/libsmb/clirap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 9d4411797d..a307ac6ccf 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -92,13 +92,13 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) SSVAL(p,0,1); p += 2; pstrcpy_base(p,user,param); - strupper(p); + strupper_m(p); p += 21; p++; p += 15; p++; pstrcpy_base(p, workstation, param); - strupper(p); + strupper_m(p); p += 16; SSVAL(p, 0, CLI_BUFFER_SIZE); p += 2; -- cgit From 062f89bc2833bf49f873a7fd5c2624babd702db0 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Fri, 15 Aug 2003 01:42:30 +0000 Subject: get rid of some sompiler warnings on IRIX (This used to be commit a6a39c61e8228c8b3b7552ab3c61ec3a6a639143) --- source3/libsmb/clirap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index a307ac6ccf..79ad38fc8c 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -76,7 +76,7 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) char *rparam = NULL; char *rdata = NULL; char *p; - int rdrcnt,rprcnt; + unsigned int rdrcnt,rprcnt; pstring param; memset(param, 0, sizeof(param)); @@ -137,7 +137,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co char *rparam = NULL; char *rdata = NULL; char *p; - int rdrcnt,rprcnt; + unsigned int rdrcnt,rprcnt; pstring param; int count = -1; @@ -211,7 +211,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, { char *rparam = NULL; char *rdata = NULL; - int rdrcnt,rprcnt; + unsigned int rdrcnt,rprcnt; char *p; pstring param; int uLevel = 1; @@ -256,7 +256,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, const char *cmnt = comment_offset?(rdata+comment_offset):""; pstring s1, s2; - if (comment_offset < 0 || comment_offset > rdrcnt) continue; + if (comment_offset < 0 || comment_offset > (int)rdrcnt) continue; stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; @@ -290,7 +290,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char unsigned int param_len = 0; char *rparam = NULL; char *rdata = NULL; - int rprcnt, rdrcnt; + unsigned int rprcnt, rdrcnt; pstring dos_new_password; if (strlen(user) >= sizeof(fstring)-1) { -- cgit From 784b05c4895fa8d7f5215d4444bc74e91a918114 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 26 Jan 2004 08:45:02 +0000 Subject: This adds client-side support for the unicode/SAMR password change scheme. As well as avoiding DOS charset issues, this scheme returns useful error codes, that we can map back via the pam interface. This patch also cleans up the interfaces used for password buffers, to avoid duplication of code. Andrew Bartlett (This used to be commit 2a2b1f0c872d154fbcce71a250e23dfad085ba1e) --- source3/libsmb/clirap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 79ad38fc8c..36bc403e0b 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -291,7 +291,6 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char char *rparam = NULL; char *rdata = NULL; unsigned int rprcnt, rdrcnt; - pstring dos_new_password; if (strlen(user) >= sizeof(fstring)-1) { DEBUG(0,("cli_oem_change_password: user name %s is too long.\n", user)); @@ -317,10 +316,13 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char */ E_deshash(old_password, old_pw_hash); - clistr_push(cli, dos_new_password, new_password, sizeof(dos_new_password), STR_TERMINATE|STR_ASCII); - - if (!make_oem_passwd_hash( data, dos_new_password, old_pw_hash, False)) - return False; + encode_pw_buffer(data, new_password, STR_ASCII); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("make_oem_passwd_hash\n")); + dump_data(100, data, 516); +#endif + SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, 516); /* * Now place the old password hash in the data. -- cgit From 7d7849b18a625820b1fba05bd17a718c7f98837e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 20 Feb 2004 22:45:53 +0000 Subject: Make us bug-for-bug compatible with W2K3 - to get delete on close semantics on an initial open the desired_access field *must* contain DELETE_ACCESS, simply having it map from a GENERIC_ALL won't do. Fixes delete on close test. Jeremy. (This used to be commit 5c6f8b1053fd1f170fbb76640649653f8aa80f18) --- source3/libsmb/clirap.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 36bc403e0b..c4b08d21d8 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -631,7 +631,7 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, /**************************************************************************** send a qfileinfo call ****************************************************************************/ -BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdata) +BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutdata, uint32 *poutlen) { unsigned int data_len = 0; unsigned int param_len = 0; @@ -639,9 +639,13 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdat pstring param; char *rparam=NULL, *rdata=NULL; + *poutdata = NULL; + *poutlen = 0; + /* if its a win95 server then fail this - win95 totally screws it up */ - if (cli->win95) return False; + if (cli->win95) + return False; param_len = 4; @@ -665,7 +669,8 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char *outdat return False; } - memcpy(outdata, rdata, data_len); + memdup(poutdata, data_len); + *poutlen = data_len; SAFE_FREE(rdata); SAFE_FREE(rparam); -- cgit From ef8f8274492c142765a94cc453d3da640c9fef91 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 20 Feb 2004 23:19:39 +0000 Subject: Make SMB_FILE_ACCESS_INFORMATION call work correctly. Jeremy. (This used to be commit 0ea0ada6c609e1bb0fb4aace24e1beb7197495b5) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index c4b08d21d8..9c10e9d938 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -669,7 +669,7 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutd return False; } - memdup(poutdata, data_len); + *poutdata = memdup(rdata, data_len); *poutlen = data_len; SAFE_FREE(rdata); -- cgit From 24df38dbc6648261f86adcffd664ffc43f8f3346 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Mon, 23 Feb 2004 02:54:03 +0000 Subject: Janitor for tpot...bugzilla #1098, msleep already exists on aix (This used to be commit 4319df7fdc2d878c509381923cc1db4d731620ba) --- source3/libsmb/clirap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 9c10e9d938..f8204e05d6 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -408,7 +408,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, uint32 ecode; cli_dos_error(cli, &eclass, &ecode); if (eclass != ERRSRV || ecode != ERRerror) break; - msleep(100); + smb_msleep(100); } } while (count-- && ret==False); @@ -720,7 +720,7 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin uint32 ecode; cli_dos_error(cli, &eclass, &ecode); if (eclass != ERRSRV || ecode != ERRerror) break; - msleep(100); + smb_msleep(100); } } while (count-- && ret==False); -- cgit From 0689a2630d920d2cc4a27c2c6617693cff549271 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 26 Feb 2004 10:55:43 +0000 Subject: Apply some const Volker (This used to be commit 0b29d83d33153dc0e49406efa6735b6664d88ce7) --- source3/libsmb/clirap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index f8204e05d6..98066629d1 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -206,8 +206,9 @@ The callback function takes 4 arguments: the machine name, the server type, the comment and a state pointer. ****************************************************************************/ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *, void *), - void *state) + void (*fn)(const char *, uint32, const char *, + const void *), + const void *state) { char *rparam = NULL; char *rdata = NULL; -- cgit From e1190848a17fc54b479315b5f11238461bc3fa62 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 26 Feb 2004 14:34:44 +0000 Subject: That const was one too many (This used to be commit 005d92d57ea912b68dd107152d478fae2162511a) --- source3/libsmb/clirap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 98066629d1..f8204e05d6 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -206,9 +206,8 @@ The callback function takes 4 arguments: the machine name, the server type, the comment and a state pointer. ****************************************************************************/ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *, - const void *), - const void *state) + void (*fn)(const char *, uint32, const char *, void *), + void *state) { char *rparam = NULL; char *rdata = NULL; -- cgit From 6a110a5d2bdbdea201dc3165586e6dff5d09ce90 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Sat, 8 May 2004 20:15:52 +0000 Subject: r588: Some fixes from coolo ... I think that the ECONNREFUSED should probably be ENOENT. (This used to be commit faa8cc18df51c4406815b68caba5ed5b8d43ba18) --- source3/libsmb/clirap.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index f8204e05d6..8cc5d8bf90 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -217,6 +217,8 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, int uLevel = 1; int count = -1; + errno = 0; /* reset */ + /* send a SMBtrans command with api NetServerEnum */ p = param; SSVAL(p,0,0x68); /* api number */ @@ -269,7 +271,18 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SAFE_FREE(rparam); SAFE_FREE(rdata); - + + if (count < 0) { + errno = cli_errno(cli); + } else { + if (!count) { + /* this is a very special case, when the domain master for the + work group isn't part of the work group itself, there is something + wild going on */ + errno = ENOENT; + } + } + return(count > 0); } -- cgit From 01b87c63c90083dbb7a56d038f714bde1a49fb2a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 23 Feb 2005 17:29:28 +0000 Subject: r5518: Add initial msdfs support to smbclient. Currently I can only cd up and down the tree and get directory listings. Still have to figure out how to get a directory listing on a 2k dfs root. Also have to work out some issues with relative paths that cross dfs mount points. We're protected from the new code paths when connecting to a non-dfs root share ( the flag from the tcon&X is stored in the struct cli_state* ) (This used to be commit e57fd2c5f00de2b11a2b44374830e89a90bc0022) --- source3/libsmb/clirap.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 8cc5d8bf90..6ede1b2b53 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -1,7 +1,8 @@ /* Unix SMB/CIFS implementation. client RAP calls - Copyright (C) Andrew Tridgell 1994-1998 + Copyright (C) Andrew Tridgell 1994-1998 + Copyright (C) Gerald (Jerry) Carter 2004 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -641,9 +642,65 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, return True; } + +/**************************************************************************** +send a qpathinfo BASIC_INFO call +****************************************************************************/ +BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, + SMB_STRUCT_STAT *sbuf, uint32 *attributes ) +{ + unsigned int param_len = 0; + unsigned int data_len = 0; + uint16 setup = TRANSACT2_QPATHINFO; + char param[sizeof(pstring)+6]; + char *rparam=NULL, *rdata=NULL; + char *p; + + p = param; + memset(p, 0, 6); + SSVAL(p, 0, SMB_QUERY_FILE_BASIC_INFO); + p += 6; + p += clistr_push(cli, p, name, sizeof(pstring)-6, STR_TERMINATE); + param_len = PTR_DIFF(p, param); + + 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, 0, cli->max_xmit /* data, length, max */ + )) { + return False; + } + + if (!cli_receive_trans(cli, SMBtrans2, + &rparam, ¶m_len, + &rdata, &data_len)) { + return False; + } + + if (data_len < 36) { + SAFE_FREE(rdata); + SAFE_FREE(rparam); + return False; + } + + sbuf->st_atime = interpret_long_date( rdata+8 ); + sbuf->st_mtime = interpret_long_date( rdata+16 ); + sbuf->st_ctime = interpret_long_date( rdata+24 ); + + *attributes = IVAL( rdata, 32 ); + + SAFE_FREE(rparam); + SAFE_FREE(rdata); + + return True; +} + /**************************************************************************** send a qfileinfo call ****************************************************************************/ + BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutdata, uint32 *poutlen) { unsigned int data_len = 0; -- cgit From 584c412e0a87bb73d41e260f93b9915286888ba2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Feb 2005 19:10:28 +0000 Subject: r5542: fix a few more msdfs bugs in smbclient against both smbd and 2k dfs root shares. (This used to be commit 5d2624c453b0bc961302edd9f2421a7c3d504d1f) --- source3/libsmb/clirap.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 6ede1b2b53..8e6742d438 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -655,12 +655,27 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, char param[sizeof(pstring)+6]; char *rparam=NULL, *rdata=NULL; char *p; + pstring path; + int len; + + /* send full paths to dfs root shares */ + + if ( cli->dfsroot ) + pstr_sprintf(path, "\\%s\\%s\\%s", cli->desthost, cli->share, name ); + else + pstrcpy( path, name ); + + /* cleanup */ + + len = strlen( path ); + if ( path[len] == '\\' ) + path[len] = '\0'; p = param; memset(p, 0, 6); SSVAL(p, 0, SMB_QUERY_FILE_BASIC_INFO); p += 6; - p += clistr_push(cli, p, name, sizeof(pstring)-6, STR_TERMINATE); + p += clistr_push(cli, p, path, sizeof(pstring)-6, STR_TERMINATE); param_len = PTR_DIFF(p, param); if (!cli_send_trans(cli, SMBtrans2, -- cgit From b3e57cb3ffb6eeb3edb1a7b02be35f70e1e7dfcf Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Mar 2005 21:17:01 +0000 Subject: r5968: derrell's large file fix for libsmbclient (BUG 2505) (This used to be commit 85be4c5df398faa6c5bfacd1f9d2f12c39d411e1) --- source3/libsmb/clirap.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 8e6742d438..1f6a99d4be 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -382,7 +382,7 @@ send a qpathinfo call ****************************************************************************/ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, time_t *c_time, time_t *a_time, time_t *m_time, - size_t *size, uint16 *mode) + SMB_OFF_T *size, uint16 *mode) { unsigned int data_len = 0; unsigned int param_len = 0; @@ -462,7 +462,7 @@ send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level ****************************************************************************/ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, time_t *c_time, time_t *a_time, time_t *m_time, - time_t *w_time, size_t *size, uint16 *mode, + time_t *w_time, SMB_OFF_T *size, uint16 *mode, SMB_INO_T *ino) { unsigned int data_len = 0; @@ -516,7 +516,7 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, *mode = SVAL(rdata, 32); } if (size) { - *size = IVAL(rdata, 48); + *size = IVAL2_TO_SMB_BIG_UINT(rdata,48); } if (ino) { *ino = IVAL(rdata, 64); @@ -546,11 +546,11 @@ BOOL cli_qfilename(struct cli_state *cli, int 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 */ + 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; } @@ -575,7 +575,7 @@ BOOL cli_qfilename(struct cli_state *cli, int fnum, send a qfileinfo call ****************************************************************************/ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, - uint16 *mode, size_t *size, + uint16 *mode, SMB_OFF_T *size, time_t *c_time, time_t *a_time, time_t *m_time, time_t *w_time, SMB_INO_T *ino) { @@ -596,11 +596,11 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, SSVAL(param, 2, SMB_QUERY_FILE_ALL_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 */ + 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; } @@ -631,7 +631,7 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, *mode = SVAL(rdata, 32); } if (size) { - *size = IVAL(rdata, 48); + *size = IVAL2_TO_SMB_BIG_UINT(rdata,48); } if (ino) { *ino = IVAL(rdata, 64); -- cgit From 1635d50a20fb03b402465731494826471efc8f88 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 30 Mar 2005 02:35:31 +0000 Subject: r6125: smbc_stat() returned incorrect timestamps IFF it used cli_qpathinfo2() to retrieve the timestamps (Win2k) and not if it used cli-getatr() to retrieve the timestamps (Win98). Timestamps are supposed to be in GMT, and should not have serverzone deducted from them in cli_qpathinfo2(). (This used to be commit 443d8df94c2937b7d458b7228bdc1d433581558a) --- source3/libsmb/clirap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 1f6a99d4be..06b683b038 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -501,16 +501,16 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, } if (c_time) { - *c_time = interpret_long_date(rdata+0) - cli->serverzone; + *c_time = interpret_long_date(rdata+0); } if (a_time) { - *a_time = interpret_long_date(rdata+8) - cli->serverzone; + *a_time = interpret_long_date(rdata+8); } if (m_time) { - *m_time = interpret_long_date(rdata+16) - cli->serverzone; + *m_time = interpret_long_date(rdata+16); } if (w_time) { - *w_time = interpret_long_date(rdata+24) - cli->serverzone; + *w_time = interpret_long_date(rdata+24); } if (mode) { *mode = SVAL(rdata, 32); -- cgit From f3ad9323c62860107ad222a0014d6e661aee42f3 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 1 Jun 2005 20:17:16 +0000 Subject: r7172: This is the proper fix for setting file times from libsmbclient. We now try setpathinfo, and if that doesn't work (e.g. on win98), revert to the previous slower method. (This used to be commit 6c05812bd90b0db69d974ee2758721dc2974a507) --- source3/libsmb/clirap.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 06b683b038..4766811c8e 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -457,6 +457,101 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, return True; } + +/**************************************************************************** +send a setpathinfo call +****************************************************************************/ +BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, + time_t c_time, time_t a_time, time_t m_time, uint16 mode) +{ + unsigned int data_len = 0; + unsigned int param_len = 0; + unsigned int rparam_len, rdata_len; + uint16 setup = TRANSACT2_SETPATHINFO; + pstring param; + pstring data; + char *rparam=NULL, *rdata=NULL; + int count=8; + BOOL ret; + void (*date_fn)(char *buf,int offset,time_t unixdate); + char *p; + + memset(param, 0, sizeof(param)); + memset(data, 0, sizeof(data)); + + p = param; + + /* Add the information level */ + SSVAL(p, 0, SMB_INFO_STANDARD); + + /* Skip reserved */ + p += 6; + + /* Add the file name */ + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE); + + param_len = PTR_DIFF(p, param); + + p = data; + + if (cli->win95) { + date_fn = put_dos_date; + } else { + date_fn = put_dos_date2; + } + + /* Add the create, last access, and modification times */ + (*date_fn)(p, 0, c_time); + (*date_fn)(p, 4, a_time); + (*date_fn)(p, 8, m_time); + p += 12; + + /* Skip DataSize and AllocationSize */ + p += 8; + + /* Add attributes */ + SSVAL(p, 0, mode); + p += 2; + + /* Add EA size (none) */ + SIVAL(p, 0, 0); + p += 4; + + data_len = PTR_DIFF(p, data); + + do { + ret = (cli_send_trans(cli, SMBtrans2, + NULL, /* Name */ + -1, 0, /* fid, flags */ + &setup, 1, 0, /* setup, length, max */ + param, param_len, 10, /* param, length, max */ + data, 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) { + /* we need to work around a Win95 bug - sometimes + it gives ERRSRV/ERRerror temprarily */ + uint8 eclass; + uint32 ecode; + cli_dos_error(cli, &eclass, &ecode); + if (eclass != ERRSRV || ecode != ERRerror) break; + smb_msleep(100); + } + } while (count-- && ret==False); + + if (!ret) { + return False; + } + + SAFE_FREE(rdata); + SAFE_FREE(rparam); + return True; +} + + /**************************************************************************** send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level ****************************************************************************/ -- cgit From ab398643a4e44211696ef5ce72b62ab7ecee7bc9 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 19 Jul 2005 02:37:04 +0000 Subject: r8572: Remove crufty #define NO_SYSLOG as it's not used at all anymore. (This used to be commit 985dbb47d925e79c1195ca219f7ab5d6648b22b8) --- source3/libsmb/clirap.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 4766811c8e..b53e19ef98 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -19,8 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define NO_SYSLOG - #include "includes.h" -- cgit From 8d7c88667190fe286971ac4fffb64ee5bd9eeeb0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Oct 2005 03:24:00 +0000 Subject: r11137: Compile with only 2 warnings (I'm still working on that code) on a gcc4 x86_64 box. Jeremy. (This used to be commit d720867a788c735e56d53d63265255830ec21208) --- source3/libsmb/clirap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index b53e19ef98..34f73cfafe 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -294,7 +294,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char const char *old_password) { pstring param; - char data[532]; + unsigned char data[532]; char *p = param; unsigned char old_pw_hash[16]; unsigned char new_pw_hash[16]; @@ -332,7 +332,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char #ifdef DEBUG_PASSWORD DEBUG(100,("make_oem_passwd_hash\n")); - dump_data(100, data, 516); + dump_data(100, (char *)data, 516); #endif SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, 516); @@ -350,7 +350,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char 0,0, /* fid, flags */ NULL,0,0, /* setup, length, max */ param,param_len,2, /* param, length, max */ - data,data_len,0 /* data, length, max */ + (char *)data,data_len,0 /* data, length, max */ ) == False) { DEBUG(0,("cli_oem_change_password: Failed to send password change for user %s\n", user )); -- cgit From 6d5757395a0e54245543794d0d6d6d6a32cd857a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 5 Nov 2005 04:21:55 +0000 Subject: r11511: A classic "friday night check-in" :-). This moves much of the Samba4 timezone handling code back into Samba3. Gets rid of "kludge-gmt" and removes the effectiveness of the parameter "time offset" (I can add this back in very easily if needed) - it's no longer being looked at. I'm hoping this will fix the problems people have been having with DST transitions. I'll start comprehensive testing tomorrow, but for now all modifications are done. Splits time get/set functions into srv_XXX and cli_XXX as they need to look at different timezone offsets. Get rid of much of the "efficiency" cruft that was added to Samba back in the day when the C library timezone handling functions were slow. Jeremy. (This used to be commit 414303bc0272f207046b471a0364fa296b67c1f8) --- source3/libsmb/clirap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 34f73cfafe..172dea4090 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -390,7 +390,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, char *rparam=NULL, *rdata=NULL; int count=8; BOOL ret; - time_t (*date_fn)(void *); + time_t (*date_fn)(struct cli_state *, void *); char *p; p = param; @@ -429,19 +429,19 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, } if (cli->win95) { - date_fn = make_unix_date; + date_fn = cli_make_unix_date; } else { - date_fn = make_unix_date2; + date_fn = cli_make_unix_date2; } if (c_time) { - *c_time = date_fn(rdata+0); + *c_time = date_fn(cli, rdata+0); } if (a_time) { - *a_time = date_fn(rdata+4); + *a_time = date_fn(cli, rdata+4); } if (m_time) { - *m_time = date_fn(rdata+8); + *m_time = date_fn(cli, rdata+8); } if (size) { *size = IVAL(rdata, 12); @@ -471,7 +471,7 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, char *rparam=NULL, *rdata=NULL; int count=8; BOOL ret; - void (*date_fn)(char *buf,int offset,time_t unixdate); + void (*date_fn)(struct cli_state *, char *buf,int offset,time_t unixdate); char *p; memset(param, 0, sizeof(param)); @@ -493,15 +493,15 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, p = data; if (cli->win95) { - date_fn = put_dos_date; + date_fn = cli_put_dos_date; } else { - date_fn = put_dos_date2; + date_fn = cli_put_dos_date2; } /* Add the create, last access, and modification times */ - (*date_fn)(p, 0, c_time); - (*date_fn)(p, 4, a_time); - (*date_fn)(p, 8, m_time); + (*date_fn)(cli, p, 0, c_time); + (*date_fn)(cli, p, 4, a_time); + (*date_fn)(cli, p, 8, m_time); p += 12; /* Skip DataSize and AllocationSize */ -- cgit From 56b20b83971f94b0692f7e6685b352a76f14ef38 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 25 Dec 2005 02:00:21 +0000 Subject: r12466: r12028@cabra: derrell | 2005-12-24 20:25:38 -0500 parse dates correctly. w_time and m_time were reversed. (This used to be commit 481abfbab40209e087c82eadc15c3697eae0ae5b) --- source3/libsmb/clirap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 172dea4090..6716971fe2 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -592,18 +592,18 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, if (!rdata || data_len < 22) { return False; } - + if (c_time) { *c_time = interpret_long_date(rdata+0); } if (a_time) { *a_time = interpret_long_date(rdata+8); } - if (m_time) { - *m_time = interpret_long_date(rdata+16); - } if (w_time) { - *w_time = interpret_long_date(rdata+24); + *w_time = interpret_long_date(rdata+16); + } + if (m_time) { + *m_time = interpret_long_date(rdata+24); } if (mode) { *mode = SVAL(rdata, 32); -- cgit From 7ed3868780f72e00687cbd056109ef85ea2ea092 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sun, 29 Jan 2006 04:57:42 +0000 Subject: r13216: r12422@cabra: derrell | 2006-01-28 23:57:35 -0500 Fix cli_setpathinfo() to actually do what it's supposed to. Also, get rid of some apparently drug-induced code to deal with create time which isn't being manipulated anyway. (This used to be commit aa25dc1248b15e8e1b39cf8a98496e5aba475c4a) --- source3/libsmb/clirap.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 6716971fe2..58fa9c8dff 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -471,7 +471,6 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, char *rparam=NULL, *rdata=NULL; int count=8; BOOL ret; - void (*date_fn)(struct cli_state *, char *buf,int offset,time_t unixdate); char *p; memset(param, 0, sizeof(param)); @@ -480,7 +479,7 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, p = param; /* Add the information level */ - SSVAL(p, 0, SMB_INFO_STANDARD); + SSVAL(p, 0, SMB_FILE_BASIC_INFORMATION); /* Skip reserved */ p += 6; @@ -492,26 +491,27 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, p = data; - if (cli->win95) { - date_fn = cli_put_dos_date; - } else { - date_fn = cli_put_dos_date2; - } - - /* Add the create, last access, and modification times */ - (*date_fn)(cli, p, 0, c_time); - (*date_fn)(cli, p, 4, a_time); - (*date_fn)(cli, p, 8, m_time); - p += 12; + /* + * Add the create, last access, modification, and status change times + */ + + /* Don't set create time, at offset 0 */ + p += 8; - /* Skip DataSize and AllocationSize */ + put_long_date(p, a_time); + p += 8; + + put_long_date(p, m_time); + p += 8; + + put_long_date(p, c_time); p += 8; /* Add attributes */ - SSVAL(p, 0, mode); - p += 2; + SIVAL(p, 0, mode); + p += 4; - /* Add EA size (none) */ + /* Add padding */ SIVAL(p, 0, 0); p += 4; -- cgit From d1014c1cdfce116741ddd6eccd65b69530ce0b84 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 00:50:14 +0000 Subject: r16582: Fix Klocwork #1997 and all generic class of problems where we don't correctly check the return from memdup. Jeremy. (This used to be commit ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca) --- source3/libsmb/clirap.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 58fa9c8dff..26f22f2131 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -848,6 +848,12 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutd } *poutdata = memdup(rdata, data_len); + if (!*poutdata) { + SAFE_FREE(rdata); + SAFE_FREE(rparam); + return False; + } + *poutlen = data_len; SAFE_FREE(rdata); -- cgit From 02eea79624c85fb5ce6c3ffefe2d27e40c5ff97f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 31 Jul 2006 03:53:39 +0000 Subject: r17333: Some C++ warnings (This used to be commit be9aaffdaccae06c8c035eaf31862e34b7cfbe38) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 26f22f2131..a33baed536 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -847,7 +847,7 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutd return False; } - *poutdata = memdup(rdata, data_len); + *poutdata = (char *)memdup(rdata, data_len); if (!*poutdata) { SAFE_FREE(rdata); SAFE_FREE(rparam); -- cgit From aee6b5942a3418b9d9a9a73fa33c21d5e4e18df8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Aug 2006 22:33:50 +0000 Subject: r17761: Handle times consistently across all client utils. Fixes bugs reported in libsmbclient. Jeremy. (This used to be commit 42a417fb75313b093948602c3be8e2f386048b5f) --- source3/libsmb/clirap.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index a33baed536..1227b26b2f 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -553,9 +553,10 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, /**************************************************************************** send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level ****************************************************************************/ + BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, - time_t *c_time, time_t *a_time, time_t *m_time, - time_t *w_time, SMB_OFF_T *size, uint16 *mode, + time_t *create_time, time_t *access_time, time_t *write_time, + time_t *change_time, SMB_OFF_T *size, uint16 *mode, SMB_INO_T *ino) { unsigned int data_len = 0; @@ -593,17 +594,17 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, return False; } - if (c_time) { - *c_time = interpret_long_date(rdata+0); + if (create_time) { + *create_time = interpret_long_date(rdata+0); } - if (a_time) { - *a_time = interpret_long_date(rdata+8); + if (access_time) { + *access_time = interpret_long_date(rdata+8); } - if (w_time) { - *w_time = interpret_long_date(rdata+16); + if (write_time) { + *write_time = interpret_long_date(rdata+16); } - if (m_time) { - *m_time = interpret_long_date(rdata+24); + if (change_time) { + *change_time = interpret_long_date(rdata+24); } if (mode) { *mode = SVAL(rdata, 32); @@ -669,8 +670,8 @@ send a qfileinfo call ****************************************************************************/ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, uint16 *mode, SMB_OFF_T *size, - time_t *c_time, time_t *a_time, time_t *m_time, - time_t *w_time, SMB_INO_T *ino) + time_t *create_time, time_t *access_time, time_t *write_time, + time_t *change_time, SMB_INO_T *ino) { unsigned int data_len = 0; unsigned int param_len = 0; @@ -708,17 +709,17 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, return False; } - if (c_time) { - *c_time = interpret_long_date(rdata+0) - cli->serverzone; + if (create_time) { + *create_time = interpret_long_date(rdata+0); } - if (a_time) { - *a_time = interpret_long_date(rdata+8) - cli->serverzone; + if (access_time) { + *access_time = interpret_long_date(rdata+8); } - if (m_time) { - *m_time = interpret_long_date(rdata+16) - cli->serverzone; + if (write_time) { + *write_time = interpret_long_date(rdata+16); } - if (w_time) { - *w_time = interpret_long_date(rdata+24) - cli->serverzone; + if (change_time) { + *change_time = interpret_long_date(rdata+24); } if (mode) { *mode = SVAL(rdata, 32); @@ -793,9 +794,9 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, return False; } - sbuf->st_atime = interpret_long_date( rdata+8 ); - sbuf->st_mtime = interpret_long_date( rdata+16 ); - sbuf->st_ctime = interpret_long_date( rdata+24 ); + sbuf->st_atime = interpret_long_date( rdata+8 ); /* Access time. */ + sbuf->st_mtime = interpret_long_date( rdata+16 ); /* Write time. */ + sbuf->st_ctime = interpret_long_date( rdata+24 ); /* Change time. */ *attributes = IVAL( rdata, 32 ); -- cgit From a64925ddff467a47f7adfac4b1b977ddc0c7f4ef Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 24 Aug 2006 16:44:00 +0000 Subject: r17800: Start using struct timespec internally for file times on the wire. This allows us to go to nsec resolution for systems that support it. It should also now be easy to add a correct "create time" (birth time) for systems that support it (*BSD). I'll be watching the build farm closely after this one for breakage :-). Jeremy. (This used to be commit 425280a1d23f97ef0b0be77462386d619f47b21d) --- source3/libsmb/clirap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 1227b26b2f..677c8f1fc3 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -555,8 +555,8 @@ send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level ****************************************************************************/ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, - time_t *create_time, time_t *access_time, time_t *write_time, - time_t *change_time, SMB_OFF_T *size, uint16 *mode, + struct timespec *create_time, struct timespec *access_time, struct timespec *write_time, + struct timespec *change_time, SMB_OFF_T *size, uint16 *mode, SMB_INO_T *ino) { unsigned int data_len = 0; @@ -670,8 +670,8 @@ send a qfileinfo call ****************************************************************************/ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, uint16 *mode, SMB_OFF_T *size, - time_t *create_time, time_t *access_time, time_t *write_time, - time_t *change_time, SMB_INO_T *ino) + struct timespec *create_time, struct timespec *access_time, struct timespec *write_time, + struct timespec *change_time, SMB_INO_T *ino) { unsigned int data_len = 0; unsigned int param_len = 0; @@ -794,9 +794,9 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, return False; } - sbuf->st_atime = interpret_long_date( rdata+8 ); /* Access time. */ - sbuf->st_mtime = interpret_long_date( rdata+16 ); /* Write time. */ - sbuf->st_ctime = interpret_long_date( rdata+24 ); /* Change time. */ + set_atimespec(sbuf, interpret_long_date( rdata+8 )); /* Access time. */ + set_mtimespec(sbuf, interpret_long_date( rdata+16 )); /* Write time. */ + set_ctimespec(sbuf, interpret_long_date( rdata+24 )); /* Change time. */ *attributes = IVAL( rdata, 32 ); -- cgit From 5e44fc4cd47108245c567b9e676a5d8c09787d96 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 2 Sep 2006 21:47:56 +0000 Subject: r18009: Fixes bug 4026. This completes the work Jeremy began last week, disambiguating the meaning of c_time. (In POSIX terminology, c_time means "status Change time", not "create time".) All uses of c_time, a_time and m_time have now been replaced with change_time, access_time, and write_time, and when creation time is intended, create_time is used. Additionally, the capability of setting and retrieving the create time have been added to the smbc_setxattr() and smbc_getxattr() functions. An example of setting all four times can be seen with the program examples/libsmbclient/testacl with the following command line similar to: testacl -f -S "system.*:CREATE_TIME:1000000000,ACCESS_TIME:1000000060,WRITE_TIME:1000000120,CHANGE_TIME:1000000180" 'smb://server/share/testfile.txt' The -f option turns on the new mode which uses full time names in the attribute specification (e.g. ACCESS_TIME vs A_TIME). (This used to be commit 8e119b64f1d92026dda855d904be09912a40601c) --- source3/libsmb/clirap.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 677c8f1fc3..caa23b59d9 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -379,7 +379,9 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char send a qpathinfo call ****************************************************************************/ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, - time_t *c_time, time_t *a_time, time_t *m_time, + time_t *change_time, + time_t *access_time, + time_t *write_time, SMB_OFF_T *size, uint16 *mode) { unsigned int data_len = 0; @@ -434,14 +436,14 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, date_fn = cli_make_unix_date2; } - if (c_time) { - *c_time = date_fn(cli, rdata+0); + if (change_time) { + *change_time = date_fn(cli, rdata+0); } - if (a_time) { - *a_time = date_fn(cli, rdata+4); + if (access_time) { + *access_time = date_fn(cli, rdata+4); } - if (m_time) { - *m_time = date_fn(cli, rdata+8); + if (write_time) { + *write_time = date_fn(cli, rdata+8); } if (size) { *size = IVAL(rdata, 12); @@ -460,7 +462,11 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, send a setpathinfo call ****************************************************************************/ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, - time_t c_time, time_t a_time, time_t m_time, uint16 mode) + time_t create_time, + time_t access_time, + time_t write_time, + time_t change_time, + uint16 mode) { unsigned int data_len = 0; unsigned int param_len = 0; @@ -495,16 +501,16 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, * Add the create, last access, modification, and status change times */ - /* Don't set create time, at offset 0 */ + put_long_date(p, create_time); p += 8; - put_long_date(p, a_time); + put_long_date(p, access_time); p += 8; - put_long_date(p, m_time); + put_long_date(p, write_time); p += 8; - put_long_date(p, c_time); + put_long_date(p, change_time); p += 8; /* Add attributes */ @@ -555,8 +561,11 @@ send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level ****************************************************************************/ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, - struct timespec *create_time, struct timespec *access_time, struct timespec *write_time, - struct timespec *change_time, SMB_OFF_T *size, uint16 *mode, + struct timespec *create_time, + struct timespec *access_time, + struct timespec *write_time, + struct timespec *change_time, + SMB_OFF_T *size, uint16 *mode, SMB_INO_T *ino) { unsigned int data_len = 0; @@ -670,8 +679,11 @@ send a qfileinfo call ****************************************************************************/ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, uint16 *mode, SMB_OFF_T *size, - struct timespec *create_time, struct timespec *access_time, struct timespec *write_time, - struct timespec *change_time, SMB_INO_T *ino) + struct timespec *create_time, + struct timespec *access_time, + struct timespec *write_time, + struct timespec *change_time, + SMB_INO_T *ino) { unsigned int data_len = 0; unsigned int param_len = 0; -- cgit From 2db5ed7fa5b07ce28daf44d56bf07c131af90d02 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 11 Oct 2006 00:33:48 +0000 Subject: r19231: I encountered a WinXP/Home system which, acting as the master browser for its workgroup, decided periodically to stop sending recognized responses to a NetServerEnum2 request for the workgroup. Instead of returning the list of servers (only itself; nothing else in the workgroup), it returns a status code of 8 which is unsupported by samba3, samba4, and ethereal. The code for this request assumed that if an unexpected status code was received, the connection had a problem, i.e. that cli_errno() would show a problem. That turns out not to be the case. This patch changes the behavior so tha any time a response is received and cli_errno() == 0, we continue processing the reply and base our response on the returned count (zero). The pre-existing code then converts this count=0 into an ENOENT errno which can be properly handled by the application (whereas an error return with errno=0 can't be). This packet dump has only 2 frames. Sorry about the text version but it's most easily attached to this log message. I also have it saved as .pcap if anyone wants it. Derrell No. Time Source Destination Protocol Info 1 14:31:59.802668 192.168.1.106 192.168.1.100 LANMAN NetServerEnum2 Request, Server, SQL Server, Domain Controller, Backup Controller, Time Source, Apple Server, Novell Server, Domain Member Server, Print Queue Server, Dialin Server, Xenix Server, NT Workstation, Windows for Workgroups, Unknown server type:14, NT Server Frame 1 (196 bytes on wire, 196 bytes captured) Arrival Time: Oct 10, 2006 14:31:59.802668000 Time delta from previous packet: 0.000000000 seconds Time since reference or first frame: 0.000000000 seconds Frame Number: 1 Packet Length: 196 bytes Capture Length: 196 bytes Protocols in frame: eth:ip:tcp:nbss:smb Ethernet II, Src: IntelCor_4a:47:bb (00:13:20:4a:47:bb), Dst: Micro-St_74:16:e7 (00:0c:76:74:16:e7) Destination: Micro-St_74:16:e7 (00:0c:76:74:16:e7) Source: IntelCor_4a:47:bb (00:13:20:4a:47:bb) Type: IP (0x0800) Internet Protocol, Src: 192.168.1.106 (192.168.1.106), Dst: 192.168.1.100 (192.168.1.100) Version: 4 Header length: 20 bytes Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00) 0000 00.. = Differentiated Services Codepoint: Default (0x00) .... ..0. = ECN-Capable Transport (ECT): 0 .... ...0 = ECN-CE: 0 Total Length: 182 Identification: 0xb838 (47160) Flags: 0x04 (Don't Fragment) 0... = Reserved bit: Not set .1.. = Don't fragment: Set ..0. = More fragments: Not set Fragment offset: 0 Time to live: 64 Protocol: TCP (0x06) Header checksum: 0xfdea [correct] Good: True Bad : False Source: 192.168.1.106 (192.168.1.106) Destination: 192.168.1.100 (192.168.1.100) Transmission Control Protocol, Src Port: 44932 (44932), Dst Port: netbios-ssn (139), Seq: 851982066, Ack: 1274726157, Len: 130 Source port: 44932 (44932) Destination port: netbios-ssn (139) Sequence number: 851982066 Next sequence number: 851982196 Acknowledgement number: 1274726157 Header length: 32 bytes Flags: 0x0018 (PSH, ACK) 0... .... = Congestion Window Reduced (CWR): Not set .0.. .... = ECN-Echo: Not set ..0. .... = Urgent: Not set ...1 .... = Acknowledgment: Set .... 1... = Push: Set .... .0.. = Reset: Not set .... ..0. = Syn: Not set .... ...0 = Fin: Not set Window size: 6432 Checksum: 0xb4e0 [correct] Options: (12 bytes) NOP NOP Time stamp: tsval 1184074739, tsecr 11576161 NetBIOS Session Service Message Type: Session message Flags: 0x00 .... ...0 = Add 0 to length Length: 126 SMB (Server Message Block Protocol) SMB Header Server Component: SMB Response in: 2 SMB Command: Trans (0x25) NT Status: STATUS_SUCCESS (0x00000000) Flags: 0x08 0... .... = Request/Response: Message is a request to the server .0.. .... = Notify: Notify client only on open ..0. .... = Oplocks: OpLock not requested/granted ...0 .... = Canonicalized Pathnames: Pathnames are not canonicalized .... 1... = Case Sensitivity: Path names are caseless .... ..0. = Receive Buffer Posted: Receive buffer has not been posted .... ...0 = Lock and Read: Lock&Read, Write&Unlock are not supported Flags2: 0xc801 1... .... .... .... = Unicode Strings: Strings are Unicode .1.. .... .... .... = Error Code Type: Error codes are NT error codes ..0. .... .... .... = Execute-only Reads: Don't permit reads if execute-only ...0 .... .... .... = Dfs: Don't resolve pathnames with Dfs .... 1... .... .... = Extended Security Negotiation: Extended security negotiation is supported .... .... .0.. .... = Long Names Used: Path names in request are not long file names .... .... .... .0.. = Security Signatures: Security signatures are not supported .... .... .... ..0. = Extended Attributes: Extended attributes are not supported .... .... .... ...1 = Long Names Allowed: Long file names are allowed in the response Process ID High: 0 Signature: 0000000000000000 Reserved: 0000 Tree ID: 2048 Process ID: 12967 User ID: 2048 Multiplex ID: 6 Trans Request (0x25) Word Count (WCT): 14 Total Parameter Count: 36 Total Data Count: 0 Max Parameter Count: 8 Max Data Count: 65535 Max Setup Count: 0 Reserved: 00 Flags: 0x0000 .... .... .... ..0. = One Way Transaction: Two way transaction .... .... .... ...0 = Disconnect TID: Do NOT disconnect TID Timeout: Return immediately (0) Reserved: 0000 Parameter Count: 36 Parameter Offset: 90 Data Count: 0 Data Offset: 126 Setup Count: 0 Reserved: 00 Byte Count (BCC): 63 Transaction Name: \PIPE\LANMAN SMB Pipe Protocol Microsoft Windows Lanman Remote API Protocol Function Code: NetServerEnum2 (104) Parameter Descriptor: WrLehDz Return Descriptor: B16BBDz Detail Level: 1 Receive Buffer Length: 65535 Server Type: 0x0000fffe .... .... .... .... .... .... .... ...0 = Workstation: This is NOT a Workstation .... .... .... .... .... .... .... ..1. = Server: This is a Server .... .... .... .... .... .... .... .1.. = SQL: This is an SQL server .... .... .... .... .... .... .... 1... = Domain Controller: This is a Domain Controller .... .... .... .... .... .... ...1 .... = Backup Controller: This is a Backup Controller .... .... .... .... .... .... ..1. .... = Time Source: This is a Time Source .... .... .... .... .... .... .1.. .... = Apple: This is an Apple host .... .... .... .... .... .... 1... .... = Novell: This is a Novell server .... .... .... .... .... ...1 .... .... = Member: This is a Domain Member server .... .... .... .... .... ..1. .... .... = Print: This is a Print Queue server .... .... .... .... .... .1.. .... .... = Dialin: This is a Dialin server .... .... .... .... .... 1... .... .... = Xenix: This is a Xenix server .... .... .... .... ...1 .... .... .... = NT Workstation: This is an NT Workstation .... .... .... .... ..1. .... .... .... = WfW: This is a WfW host .... .... .... .... 1... .... .... .... = NT Server: This is an NT Server .... .... .... ...0 .... .... .... .... = Potential Browser: This is NOT a Potential Browser .... .... .... ..0. .... .... .... .... = Backup Browser: This is NOT a Backup Browser .... .... .... .0.. .... .... .... .... = Master Browser: This is NOT a Master Browser .... .... .... 0... .... .... .... .... = Domain Master Browser: This is NOT a Domain Master Browser .... .... ...0 .... .... .... .... .... = OSF: This is NOT an OSF host .... .... ..0. .... .... .... .... .... = VMS: This is NOT a VMS host .... .... .0.. .... .... .... .... .... = Windows 95+: This is NOT a Windows 95 or above host .0.. .... .... .... .... .... .... .... = Local: This is NOT a local list only request 0... .... .... .... .... .... .... .... = Domain Enum: This is NOT a Domain Enum request Enumeration Domain: WORKGROUP No. Time Source Destination Protocol Info 2 14:31:59.803918 192.168.1.100 192.168.1.106 LANMAN NetServerEnum2 Response Frame 2 (134 bytes on wire, 134 bytes captured) Arrival Time: Oct 10, 2006 14:31:59.803918000 Time delta from previous packet: 0.001250000 seconds Time since reference or first frame: 0.001250000 seconds Frame Number: 2 Packet Length: 134 bytes Capture Length: 134 bytes Protocols in frame: eth:ip:tcp:nbss:smb Ethernet II, Src: Micro-St_74:16:e7 (00:0c:76:74:16:e7), Dst: IntelCor_4a:47:bb (00:13:20:4a:47:bb) Destination: IntelCor_4a:47:bb (00:13:20:4a:47:bb) Source: Micro-St_74:16:e7 (00:0c:76:74:16:e7) Type: IP (0x0800) Internet Protocol, Src: 192.168.1.100 (192.168.1.100), Dst: 192.168.1.106 (192.168.1.106) Version: 4 Header length: 20 bytes Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00) 0000 00.. = Differentiated Services Codepoint: Default (0x00) .... ..0. = ECN-Capable Transport (ECT): 0 .... ...0 = ECN-CE: 0 Total Length: 120 Identification: 0xea10 (59920) Flags: 0x04 (Don't Fragment) 0... = Reserved bit: Not set .1.. = Don't fragment: Set ..0. = More fragments: Not set Fragment offset: 0 Time to live: 128 Protocol: TCP (0x06) Header checksum: 0x8c50 [correct] Good: True Bad : False Source: 192.168.1.100 (192.168.1.100) Destination: 192.168.1.106 (192.168.1.106) Transmission Control Protocol, Src Port: netbios-ssn (139), Dst Port: 44932 (44932), Seq: 1274726157, Ack: 851982196, Len: 68 Source port: netbios-ssn (139) Destination port: 44932 (44932) Sequence number: 1274726157 Next sequence number: 1274726225 Acknowledgement number: 851982196 Header length: 32 bytes Flags: 0x0018 (PSH, ACK) 0... .... = Congestion Window Reduced (CWR): Not set .0.. .... = ECN-Echo: Not set ..0. .... = Urgent: Not set ...1 .... = Acknowledgment: Set .... 1... = Push: Set .... .0.. = Reset: Not set .... ..0. = Syn: Not set .... ...0 = Fin: Not set Window size: 64606 Checksum: 0x1e0d [correct] Options: (12 bytes) NOP NOP Time stamp: tsval 11576161, tsecr 1184074739 NetBIOS Session Service Message Type: Session message Flags: 0x00 .... ...0 = Add 0 to length Length: 64 SMB (Server Message Block Protocol) SMB Header Server Component: SMB Response to: 1 Time from request: 0.001250000 seconds SMB Command: Trans (0x25) NT Status: STATUS_SUCCESS (0x00000000) Flags: 0x88 1... .... = Request/Response: Message is a response to the client/redirector .0.. .... = Notify: Notify client only on open ..0. .... = Oplocks: OpLock not requested/granted ...0 .... = Canonicalized Pathnames: Pathnames are not canonicalized .... 1... = Case Sensitivity: Path names are caseless .... ..0. = Receive Buffer Posted: Receive buffer has not been posted .... ...0 = Lock and Read: Lock&Read, Write&Unlock are not supported Flags2: 0xc801 1... .... .... .... = Unicode Strings: Strings are Unicode .1.. .... .... .... = Error Code Type: Error codes are NT error codes ..0. .... .... .... = Execute-only Reads: Don't permit reads if execute-only ...0 .... .... .... = Dfs: Don't resolve pathnames with Dfs .... 1... .... .... = Extended Security Negotiation: Extended security negotiation is supported .... .... .0.. .... = Long Names Used: Path names in request are not long file names .... .... .... .0.. = Security Signatures: Security signatures are not supported .... .... .... ..0. = Extended Attributes: Extended attributes are not supported .... .... .... ...1 = Long Names Allowed: Long file names are allowed in the response Process ID High: 0 Signature: 0000000000000000 Reserved: 0000 Tree ID: 2048 Process ID: 12967 User ID: 2048 Multiplex ID: 6 Trans Response (0x25) Word Count (WCT): 10 Total Parameter Count: 8 Total Data Count: 0 Reserved: 0000 Parameter Count: 8 Parameter Offset: 56 Parameter Displacement: 0 Data Count: 0 Data Offset: 64 Data Displacement: 0 Setup Count: 0 Reserved: 00 Byte Count (BCC): 9 Padding: 00 SMB Pipe Protocol Microsoft Windows Lanman Remote API Protocol Function Code: NetServerEnum2 (104) Status: Unknown (8) Convert: 0 Entry Count: 0 Available Entries: 0 (This used to be commit 88fa5ac7347cbae92abe17da8d3af00e85110c43) --- source3/libsmb/clirap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index caa23b59d9..61cdd79f36 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -244,7 +244,8 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, )) { int res = rparam? SVAL(rparam,0) : -1; - if (res == 0 || res == ERRmoredata) { + if (res == 0 || res == ERRmoredata || + (res != -1 && cli_errno(cli) == 0)) { int i; int converter=SVAL(rparam,2); -- cgit From 540911001d1bf25d9534b72b90a32fc7e5efc4b0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 8 Mar 2007 23:54:57 +0000 Subject: r21768: Fix the client dfs code such that smbclient can process deep dfs links (ie. links that go to non root parts of a share). Make the directory handling conanonical in POSIX and Windows pathname processing. dfs should not be fully working in client tools. Please bug me if not. Jeremy. (This used to be commit 1c9e10569cd97ee41de39f9f012bea4e4c932b5d) --- source3/libsmb/clirap.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 61cdd79f36..ba4305dd0a 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -749,10 +749,10 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, return True; } - /**************************************************************************** -send a qpathinfo BASIC_INFO call + Send a qpathinfo BASIC_INFO call. ****************************************************************************/ + BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbuf, uint32 *attributes ) { @@ -765,18 +765,12 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, pstring path; int len; - /* send full paths to dfs root shares */ - - if ( cli->dfsroot ) - pstr_sprintf(path, "\\%s\\%s\\%s", cli->desthost, cli->share, name ); - else - pstrcpy( path, name ); - + pstrcpy( path, name ); /* cleanup */ len = strlen( path ); - if ( path[len] == '\\' ) - path[len] = '\0'; + if ( path[len-1] == '\\' || path[len-1] == '/') + path[len-1] = '\0'; p = param; memset(p, 0, 6); -- cgit From c2fd7de44e7ba8a7d93110a6f579878697ceaa8d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 17 Mar 2007 00:15:18 +0000 Subject: r21864: Reformatting. Jeremy. (This used to be commit f18e87ba6b6a3f4c16777cb5b6bf93a656800247) --- source3/libsmb/clirap.c | 184 ++++++++++++++++++++++++------------------------ 1 file changed, 92 insertions(+), 92 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index ba4305dd0a..05dc36e91c 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -21,10 +21,10 @@ #include "includes.h" - /**************************************************************************** -Call a remote api on an arbitrary pipe. takes param, data and setup buffers. + Call a remote api on an arbitrary pipe. takes param, data and setup buffers. ****************************************************************************/ + BOOL cli_api_pipe(struct cli_state *cli, const char *pipe_name, uint16 *setup, uint32 setup_count, uint32 max_setup_count, char *params, uint32 param_count, uint32 max_param_count, @@ -32,28 +32,29 @@ BOOL cli_api_pipe(struct cli_state *cli, const char *pipe_name, char **rparam, uint32 *rparam_count, char **rdata, uint32 *rdata_count) { - cli_send_trans(cli, SMBtrans, + cli_send_trans(cli, SMBtrans, pipe_name, 0,0, /* fid, flags */ setup, setup_count, max_setup_count, params, param_count, max_param_count, data, data_count, max_data_count); - return (cli_receive_trans(cli, SMBtrans, + return (cli_receive_trans(cli, SMBtrans, rparam, (unsigned int *)rparam_count, rdata, (unsigned int *)rdata_count)); } /**************************************************************************** -call a remote api + Call a remote api ****************************************************************************/ + BOOL cli_api(struct cli_state *cli, char *param, int prcnt, int mprcnt, char *data, int drcnt, int mdrcnt, char **rparam, unsigned int *rprcnt, char **rdata, unsigned int *rdrcnt) { - cli_send_trans(cli,SMBtrans, + cli_send_trans(cli,SMBtrans, PIPE_LANMAN, /* Name */ 0,0, /* fid, flags */ NULL,0,0, /* Setup, length, max */ @@ -61,15 +62,15 @@ BOOL cli_api(struct cli_state *cli, data, drcnt, mdrcnt /* Data, length, max */ ); - return (cli_receive_trans(cli,SMBtrans, + return (cli_receive_trans(cli,SMBtrans, rparam, rprcnt, rdata, rdrcnt)); } - /**************************************************************************** -perform a NetWkstaUserLogon + Perform a NetWkstaUserLogon. ****************************************************************************/ + BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) { char *rparam = NULL; @@ -129,8 +130,9 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) } /**************************************************************************** -call a NetShareEnum - try and browse available connections on a host + Call a NetShareEnum - try and browse available connections on a host. ****************************************************************************/ + int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state) { char *rparam = NULL; @@ -196,14 +198,14 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co return count; } - /**************************************************************************** -call a NetServerEnum for the specified workgroup and servertype mask. This -function then calls the specified callback function for each name returned. + Call a NetServerEnum for the specified workgroup and servertype mask. This + function then calls the specified callback function for each name returned. -The callback function takes 4 arguments: the machine name, the server type, -the comment and a state pointer. + The callback function takes 4 arguments: the machine name, the server type, + the comment and a state pointer. ****************************************************************************/ + BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, void (*fn)(const char *, uint32, const char *, void *), void *state) @@ -286,99 +288,99 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, return(count > 0); } - - /**************************************************************************** -Send a SamOEMChangePassword command + Send a SamOEMChangePassword command. ****************************************************************************/ + BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, const char *old_password) { - pstring param; - unsigned char data[532]; - char *p = param; - unsigned char old_pw_hash[16]; - unsigned char new_pw_hash[16]; - unsigned int data_len; - unsigned int param_len = 0; - char *rparam = NULL; - char *rdata = NULL; - unsigned int rprcnt, rdrcnt; - - if (strlen(user) >= sizeof(fstring)-1) { - DEBUG(0,("cli_oem_change_password: user name %s is too long.\n", user)); - return False; - } - - SSVAL(p,0,214); /* SamOEMChangePassword command. */ - p += 2; - pstrcpy_base(p, "zsT", param); - p = skip_string(p,1); - pstrcpy_base(p, "B516B16", param); - p = skip_string(p,1); - pstrcpy_base(p,user, param); - p = skip_string(p,1); - SSVAL(p,0,532); - p += 2; - - param_len = PTR_DIFF(p,param); - - /* - * 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); - - encode_pw_buffer(data, new_password, STR_ASCII); + pstring param; + unsigned char data[532]; + char *p = param; + unsigned char old_pw_hash[16]; + unsigned char new_pw_hash[16]; + unsigned int data_len; + unsigned int param_len = 0; + char *rparam = NULL; + char *rdata = NULL; + unsigned int rprcnt, rdrcnt; + + if (strlen(user) >= sizeof(fstring)-1) { + DEBUG(0,("cli_oem_change_password: user name %s is too long.\n", user)); + return False; + } + + SSVAL(p,0,214); /* SamOEMChangePassword command. */ + p += 2; + pstrcpy_base(p, "zsT", param); + p = skip_string(p,1); + pstrcpy_base(p, "B516B16", param); + p = skip_string(p,1); + pstrcpy_base(p,user, param); + p = skip_string(p,1); + SSVAL(p,0,532); + p += 2; + + param_len = PTR_DIFF(p,param); + + /* + * 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); + + encode_pw_buffer(data, new_password, STR_ASCII); #ifdef DEBUG_PASSWORD - DEBUG(100,("make_oem_passwd_hash\n")); - dump_data(100, (char *)data, 516); + DEBUG(100,("make_oem_passwd_hash\n")); + dump_data(100, (char *)data, 516); #endif - SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, 516); + SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, 516); - /* - * Now place the old password hash in the data. - */ - E_deshash(new_password, new_pw_hash); + /* + * Now place the old password hash in the data. + */ + E_deshash(new_password, new_pw_hash); - E_old_pw_hash( new_pw_hash, old_pw_hash, (uchar *)&data[516]); + E_old_pw_hash( new_pw_hash, old_pw_hash, (uchar *)&data[516]); - data_len = 532; + data_len = 532; - if (cli_send_trans(cli,SMBtrans, + if (cli_send_trans(cli,SMBtrans, PIPE_LANMAN, /* name */ 0,0, /* fid, flags */ NULL,0,0, /* setup, length, max */ param,param_len,2, /* param, length, max */ (char *)data,data_len,0 /* data, length, max */ ) == False) { - DEBUG(0,("cli_oem_change_password: Failed to send password change for user %s\n", - user )); - return False; - } + DEBUG(0,("cli_oem_change_password: Failed to send password change for user %s\n", + user )); + return False; + } - if (!cli_receive_trans(cli,SMBtrans, + if (!cli_receive_trans(cli,SMBtrans, &rparam, &rprcnt, &rdata, &rdrcnt)) { - DEBUG(0,("cli_oem_change_password: Failed to recieve reply to password change for user %s\n", - user )); - return False; - } + DEBUG(0,("cli_oem_change_password: Failed to recieve reply to password change for user %s\n", + user )); + return False; + } - if (rparam) - cli->rap_error = SVAL(rparam,0); + if (rparam) { + cli->rap_error = SVAL(rparam,0); + } - SAFE_FREE(rparam); - SAFE_FREE(rdata); + SAFE_FREE(rparam); + SAFE_FREE(rdata); - return (cli->rap_error == 0); + return (cli->rap_error == 0); } - /**************************************************************************** -send a qpathinfo call + Send a qpathinfo call. ****************************************************************************/ + BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, time_t *change_time, time_t *access_time, @@ -458,10 +460,10 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, return True; } - /**************************************************************************** -send a setpathinfo call + Send a setpathinfo call. ****************************************************************************/ + BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, time_t create_time, time_t access_time, @@ -556,9 +558,8 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, return True; } - /**************************************************************************** -send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level + Send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level. ****************************************************************************/ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, @@ -631,10 +632,10 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, return True; } - /**************************************************************************** -send a qfileinfo QUERY_FILE_NAME_INFO call + Send a qfileinfo QUERY_FILE_NAME_INFO call. ****************************************************************************/ + BOOL cli_qfilename(struct cli_state *cli, int fnum, pstring name) { @@ -674,10 +675,10 @@ BOOL cli_qfilename(struct cli_state *cli, int fnum, return True; } - /**************************************************************************** -send a qfileinfo call + Send a qfileinfo call. ****************************************************************************/ + BOOL cli_qfileinfo(struct cli_state *cli, int fnum, uint16 *mode, SMB_OFF_T *size, struct timespec *create_time, @@ -814,7 +815,7 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, } /**************************************************************************** -send a qfileinfo call + Send a qfileinfo call. ****************************************************************************/ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutdata, uint32 *poutlen) @@ -869,11 +870,10 @@ BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutd 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) { unsigned int data_len = 0; -- cgit From 56ba44766854ed7cda265bdaf85913f2a1008282 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Mar 2007 13:34:59 +0000 Subject: r22001: change prototype of dump_data(), so that it takes unsigned char * now, which matches what samba4 has. also fix all the callers to prevent compiler warnings metze (This used to be commit fa322f0cc9c26a9537ba3f0a7d4e4a25941317e7) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 05dc36e91c..4be03e16f0 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -334,7 +334,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char #ifdef DEBUG_PASSWORD DEBUG(100,("make_oem_passwd_hash\n")); - dump_data(100, (char *)data, 516); + dump_data(100, data, 516); #endif SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, 516); -- cgit From 261c004d7bf85de945a1a3956c1d8f15075bc224 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 30 Mar 2007 22:25:08 +0000 Subject: r22014: Make us pass RANDOMIPC test again :-(. This is an ugly check-in, but I've no option. Jeremy. (This used to be commit c3a565081d70b209a4f9e6e8f1859bf7194a5f74) --- source3/libsmb/clirap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 4be03e16f0..3fc95e8429 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -86,9 +86,9 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) SSVAL(p,0,132); /* api number */ p += 2; pstrcpy_base(p,"OOWb54WrLh",param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); pstrcpy_base(p,"WB21BWDWWDDDDDDDzzzD",param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); SSVAL(p,0,1); p += 2; pstrcpy_base(p,user,param); @@ -147,9 +147,9 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co SSVAL(p,0,0); /* api number */ p += 2; pstrcpy_base(p,"WrLeh",param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); pstrcpy_base(p,"B13BWz",param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); SSVAL(p,0,1); /* * Win2k needs a *smaller* buffer than 0xFFFF here - @@ -225,11 +225,11 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SSVAL(p,0,0x68); /* api number */ p += 2; pstrcpy_base(p,"WrLehDz", param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); pstrcpy_base(p,"B16BBDz", param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); SSVAL(p,0,uLevel); SSVAL(p,2,CLI_BUFFER_SIZE); p += 4; @@ -314,11 +314,11 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char SSVAL(p,0,214); /* SamOEMChangePassword command. */ p += 2; pstrcpy_base(p, "zsT", param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); pstrcpy_base(p, "B516B16", param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); pstrcpy_base(p,user, param); - p = skip_string(p,1); + p = skip_string(param,sizeof(param),p,1); SSVAL(p,0,532); p += 2; -- cgit From 0a2cc569a1803f459f7db77d03e6e90ae30aa35d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 2 Apr 2007 20:10:21 +0000 Subject: r22045: As Volker noticed, skip_string's last argument is redundent. Remove it. Jeremy. (This used to be commit 140881cfbb59ce4a699b5900efe02bf315be7bd5) --- source3/libsmb/clirap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 3fc95e8429..5891120323 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -86,9 +86,9 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) SSVAL(p,0,132); /* api number */ p += 2; pstrcpy_base(p,"OOWb54WrLh",param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); pstrcpy_base(p,"WB21BWDWWDDDDDDDzzzD",param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); SSVAL(p,0,1); p += 2; pstrcpy_base(p,user,param); @@ -147,9 +147,9 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co SSVAL(p,0,0); /* api number */ p += 2; pstrcpy_base(p,"WrLeh",param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); pstrcpy_base(p,"B13BWz",param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); SSVAL(p,0,1); /* * Win2k needs a *smaller* buffer than 0xFFFF here - @@ -225,11 +225,11 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SSVAL(p,0,0x68); /* api number */ p += 2; pstrcpy_base(p,"WrLehDz", param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); pstrcpy_base(p,"B16BBDz", param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); SSVAL(p,0,uLevel); SSVAL(p,2,CLI_BUFFER_SIZE); p += 4; @@ -314,11 +314,11 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char SSVAL(p,0,214); /* SamOEMChangePassword command. */ p += 2; pstrcpy_base(p, "zsT", param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); pstrcpy_base(p, "B516B16", param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); pstrcpy_base(p,user, param); - p = skip_string(param,sizeof(param),p,1); + p = skip_string(param,sizeof(param),p); SSVAL(p,0,532); p += 2; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 5891120323..85d668e942 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/libsmb/clirap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 85d668e942..801b6f61ec 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/libsmb/clirap.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 801b6f61ec..9d106d0394 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -24,7 +24,7 @@ Call a remote api on an arbitrary pipe. takes param, data and setup buffers. ****************************************************************************/ -BOOL cli_api_pipe(struct cli_state *cli, const char *pipe_name, +bool cli_api_pipe(struct cli_state *cli, const char *pipe_name, uint16 *setup, uint32 setup_count, uint32 max_setup_count, char *params, uint32 param_count, uint32 max_param_count, char *data, uint32 data_count, uint32 max_data_count, @@ -47,7 +47,7 @@ BOOL cli_api_pipe(struct cli_state *cli, const char *pipe_name, Call a remote api ****************************************************************************/ -BOOL cli_api(struct cli_state *cli, +bool cli_api(struct cli_state *cli, char *param, int prcnt, int mprcnt, char *data, int drcnt, int mdrcnt, char **rparam, unsigned int *rprcnt, @@ -70,7 +70,7 @@ BOOL cli_api(struct cli_state *cli, Perform a NetWkstaUserLogon. ****************************************************************************/ -BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) +bool cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) { char *rparam = NULL; char *rdata = NULL; @@ -205,7 +205,7 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co the comment and a state pointer. ****************************************************************************/ -BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, +bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, void (*fn)(const char *, uint32, const char *, void *), void *state) { @@ -291,7 +291,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, Send a SamOEMChangePassword command. ****************************************************************************/ -BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, +bool cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, const char *old_password) { pstring param; @@ -380,7 +380,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char Send a qpathinfo call. ****************************************************************************/ -BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, +bool cli_qpathinfo(struct cli_state *cli, const char *fname, time_t *change_time, time_t *access_time, time_t *write_time, @@ -393,7 +393,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, pstring param; char *rparam=NULL, *rdata=NULL; int count=8; - BOOL ret; + bool ret; time_t (*date_fn)(struct cli_state *, void *); char *p; @@ -463,7 +463,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, Send a setpathinfo call. ****************************************************************************/ -BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, +bool cli_setpathinfo(struct cli_state *cli, const char *fname, time_t create_time, time_t access_time, time_t write_time, @@ -478,7 +478,7 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, pstring data; char *rparam=NULL, *rdata=NULL; int count=8; - BOOL ret; + bool ret; char *p; memset(param, 0, sizeof(param)); @@ -561,7 +561,7 @@ BOOL cli_setpathinfo(struct cli_state *cli, const char *fname, Send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level. ****************************************************************************/ -BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, +bool cli_qpathinfo2(struct cli_state *cli, const char *fname, struct timespec *create_time, struct timespec *access_time, struct timespec *write_time, @@ -635,7 +635,7 @@ 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, +bool cli_qfilename(struct cli_state *cli, int fnum, pstring name) { unsigned int data_len = 0; @@ -678,7 +678,7 @@ BOOL cli_qfilename(struct cli_state *cli, int fnum, Send a qfileinfo call. ****************************************************************************/ -BOOL cli_qfileinfo(struct cli_state *cli, int fnum, +bool cli_qfileinfo(struct cli_state *cli, int fnum, uint16 *mode, SMB_OFF_T *size, struct timespec *create_time, struct timespec *access_time, @@ -753,7 +753,7 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum, Send a qpathinfo BASIC_INFO call. ****************************************************************************/ -BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, +bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbuf, uint32 *attributes ) { unsigned int param_len = 0; @@ -817,7 +817,7 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name, Send a qfileinfo call. ****************************************************************************/ -BOOL cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutdata, uint32 *poutlen) +bool cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutdata, uint32 *poutlen) { unsigned int data_len = 0; unsigned int param_len = 0; @@ -882,7 +882,7 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin char *rparam=NULL, *rdata=NULL; int count=8; char *p; - BOOL ret; + bool ret; unsigned int len; p = param; -- cgit From cae4c742a896c6adb02b3e7a3c091d02aebb7339 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 19 Nov 2007 17:43:28 -0800 Subject: Always check return from push_ascii. Jeremy. (This used to be commit 9c3d10521e691169cfbb8b728f123911c3c970ae) --- source3/libsmb/clirap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 9d106d0394..848a8d5482 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -216,6 +216,7 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, pstring param; int uLevel = 1; int count = -1; + size_t len; errno = 0; /* reset */ @@ -235,7 +236,11 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SIVAL(p,0,stype); p += 4; - p += push_ascii(p, workgroup, sizeof(pstring)-PTR_DIFF(p,param)-1, STR_TERMINATE|STR_UPPER); + len = push_ascii(p, workgroup, sizeof(pstring)-PTR_DIFF(p,param)-1, STR_TERMINATE|STR_UPPER); + if (len == (size_t)-1) { + return false; + } + p += len; if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ -- cgit From d2cf97aeba14a4d336fb57b01f19bd5a08dcb003 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Nov 2007 13:24:54 -0800 Subject: Remove the explicit TALLOC_CTX * from cli_struct. Make us very explicit about how long a talloc ctx should last. Jeremy. (This used to be commit ba9e2be2b5a59684e854609f9d82ea1633448c62) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 848a8d5482..c877dfa2ab 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -399,7 +399,7 @@ bool cli_qpathinfo(struct cli_state *cli, const char *fname, char *rparam=NULL, *rdata=NULL; int count=8; bool ret; - time_t (*date_fn)(struct cli_state *, void *); + time_t (*date_fn)(struct cli_state *, const void *); char *p; p = param; -- cgit From 4e266bd60fe7c43ba6255314bf2fb56d21e38e93 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 30 Nov 2007 16:13:35 -0800 Subject: Remove pstring from clirap.c. Jeremy. (This used to be commit 6e27663cb44a79f729fa4366e000c43383f6d1b7) --- source3/libsmb/clirap.c | 305 +++++++++++++++++++++++++++++------------------- 1 file changed, 187 insertions(+), 118 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index c877dfa2ab..d8d8f2608c 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -1,19 +1,19 @@ -/* +/* Unix SMB/CIFS implementation. client RAP calls Copyright (C) Andrew Tridgell 1994-1998 Copyright (C) Gerald (Jerry) Carter 2004 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -24,21 +24,21 @@ Call a remote api on an arbitrary pipe. takes param, data and setup buffers. ****************************************************************************/ -bool cli_api_pipe(struct cli_state *cli, const char *pipe_name, +bool cli_api_pipe(struct cli_state *cli, const char *pipe_name, uint16 *setup, uint32 setup_count, uint32 max_setup_count, char *params, uint32 param_count, uint32 max_param_count, char *data, uint32 data_count, uint32 max_data_count, char **rparam, uint32 *rparam_count, char **rdata, uint32 *rdata_count) { - cli_send_trans(cli, SMBtrans, - pipe_name, + cli_send_trans(cli, SMBtrans, + pipe_name, 0,0, /* fid, flags */ setup, setup_count, max_setup_count, params, param_count, max_param_count, data, data_count, max_data_count); - return (cli_receive_trans(cli, SMBtrans, + return (cli_receive_trans(cli, SMBtrans, rparam, (unsigned int *)rparam_count, rdata, (unsigned int *)rdata_count)); } @@ -58,7 +58,7 @@ bool cli_api(struct cli_state *cli, 0,0, /* fid, flags */ NULL,0,0, /* Setup, length, max */ param, prcnt, mprcnt, /* Params, length, max */ - data, drcnt, mdrcnt /* Data, length, max */ + data, drcnt, mdrcnt /* Data, length, max */ ); return (cli_receive_trans(cli,SMBtrans, @@ -76,35 +76,35 @@ bool cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) char *rdata = NULL; char *p; unsigned int rdrcnt,rprcnt; - pstring param; + char param[1024]; memset(param, 0, sizeof(param)); - + /* send a SMBtrans command with api NetWkstaUserLogon */ p = param; SSVAL(p,0,132); /* api number */ p += 2; - pstrcpy_base(p,"OOWb54WrLh",param); + strlcpy(p,"OOWb54WrLh",sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); - pstrcpy_base(p,"WB21BWDWWDDDDDDDzzzD",param); + strlcpy(p,"WB21BWDWWDDDDDDDzzzD",sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); SSVAL(p,0,1); p += 2; - pstrcpy_base(p,user,param); + strlcpy(p,user,sizeof(param)-PTR_DIFF(p,param)); strupper_m(p); p += 21; p++; p += 15; - p++; - pstrcpy_base(p, workstation, param); + p++; + strlcpy(p, workstation,sizeof(param)-PTR_DIFF(p,param)); strupper_m(p); p += 16; SSVAL(p, 0, CLI_BUFFER_SIZE); p += 2; SSVAL(p, 0, CLI_BUFFER_SIZE); p += 2; - - if (cli_api(cli, + + if (cli_api(cli, param, PTR_DIFF(p,param),1024, /* param, length, max */ NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */ &rparam, &rprcnt, /* return params, return size */ @@ -112,7 +112,7 @@ bool cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) )) { cli->rap_error = rparam? SVAL(rparam,0) : -1; p = rdata; - + if (cli->rap_error == 0) { DEBUG(4,("NetWkstaUserLogon success\n")); cli->privileges = SVAL(p, 24); @@ -122,7 +122,7 @@ bool cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation) DEBUG(1,("NetwkstaUserLogon gave error %d\n", cli->rap_error)); } } - + SAFE_FREE(rparam); SAFE_FREE(rdata); return (cli->rap_error == 0); @@ -138,16 +138,16 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co char *rdata = NULL; char *p; unsigned int rdrcnt,rprcnt; - pstring param; + char param[1024]; int count = -1; /* now send a SMBtrans command with api RNetShareEnum */ p = param; SSVAL(p,0,0); /* api number */ p += 2; - pstrcpy_base(p,"WrLeh",param); + strlcpy(p,"WrLeh",sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); - pstrcpy_base(p,"B13BWz",param); + strlcpy(p,"B13BWz",sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); SSVAL(p,0,1); /* @@ -156,44 +156,77 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co */ SSVAL(p,2,0xFFE0); p += 4; - - if (cli_api(cli, + + if (cli_api(cli, param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */ NULL, 0, 0xFFE0, /* data, length, maxlen - Win2k needs a small buffer here too ! */ &rparam, &rprcnt, /* return params, length */ &rdata, &rdrcnt)) /* return data, length */ { int res = rparam? SVAL(rparam,0) : -1; - + if (res == 0 || res == ERRmoredata) { int converter=SVAL(rparam,2); int i; - + char *rdata_end = rdata + rdrcnt; + count=SVAL(rparam,4); p = rdata; - - for (i=0;i rdata_end) { + TALLOC_FREE(frame); + break; + } + + sname = p; + type = SVAL(p,14); + comment_offset = IVAL(p,16) & 0xFFFF; + if (comment_offset < 0 || comment_offset > (int)rdrcnt) { + TALLOC_FREE(frame); + break; + } + cmnt = comment_offset?(rdata+comment_offset-converter):""; + + /* Work out the comment length. */ + for (p1 = cmnt, len = 0; *p1 && + p1 < rdata_end; len++) + p1++; + if (!*p1) { + len++; + } + pull_string_talloc(frame,rdata,0, + &s1,sname,14,STR_ASCII); + pull_string_talloc(frame,rdata,0, + &s2,cmnt,len,STR_ASCII); + if (!s1 || !s2) { + TALLOC_FREE(frame); + continue; + } fn(s1, type, s2, state); + + TALLOC_FREE(frame); } } else { DEBUG(4,("NetShareEnum res=%d\n", res)); - } + } } else { DEBUG(4,("NetShareEnum failed\n")); } - + SAFE_FREE(rparam); SAFE_FREE(rdata); - + return count; } @@ -213,7 +246,7 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, char *rdata = NULL; unsigned int rdrcnt,rprcnt; char *p; - pstring param; + char param[1024]; int uLevel = 1; int count = -1; size_t len; @@ -224,10 +257,10 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p = param; SSVAL(p,0,0x68); /* api number */ p += 2; - pstrcpy_base(p,"WrLehDz", param); + strlcpy(p,"WrLehDz", sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); - - pstrcpy_base(p,"B16BBDz", param); + + strlcpy(p,"B16BBDz", sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); SSVAL(p,0,uLevel); @@ -236,20 +269,22 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, SIVAL(p,0,stype); p += 4; - len = push_ascii(p, workgroup, sizeof(pstring)-PTR_DIFF(p,param)-1, STR_TERMINATE|STR_UPPER); + len = push_ascii(p, workgroup, sizeof(param)-PTR_DIFF(p,param)-1, + STR_TERMINATE|STR_UPPER); if (len == (size_t)-1) { return false; } p += len; - - if (cli_api(cli, + + if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */ &rparam, &rprcnt, /* return params, return size */ &rdata, &rdrcnt /* return data, return size */ )) { int res = rparam? SVAL(rparam,0) : -1; - + char *rdata_end = rdata + rdrcnt; + if (res == 0 || res == ERRmoredata || (res != -1 && cli_errno(cli) == 0)) { int i; @@ -257,24 +292,55 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, count=SVAL(rparam,4); p = rdata; - + for (i = 0;i < count;i++, p += 26) { - char *sname = p; - int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; - const char *cmnt = comment_offset?(rdata+comment_offset):""; - pstring s1, s2; + char *sname; + int comment_offset; + const char *cmnt; + const char *p1; + char *s1, *s2; + TALLOC_CTX *frame = talloc_stackframe(); + + if (p + 26 > rdata_end) { + TALLOC_FREE(frame); + break; + } + + sname = p; + comment_offset = (IVAL(p,22) & 0xFFFF)-converter; + cmnt = comment_offset?(rdata+comment_offset):""; - if (comment_offset < 0 || comment_offset > (int)rdrcnt) continue; + if (comment_offset < 0 || comment_offset > (int)rdrcnt) { + TALLOC_FREE(frame); + continue; + } + + /* Work out the comment length. */ + for (p1 = cmnt, len = 0; *p1 && + p1 < rdata_end; len++) + p1++; + if (!*p1) { + len++; + } stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; - pull_ascii_pstring(s1, sname); - pull_ascii_pstring(s2, cmnt); + pull_string_talloc(frame,rdata,0, + &s1,sname,16,STR_ASCII); + pull_string_talloc(frame,rdata,0, + &s2,cmnt,len,STR_ASCII); + + if (!s1 || !s2) { + TALLOC_FREE(frame); + continue; + } + fn(s1, stype, s2, state); + TALLOC_FREE(frame); } } } - + SAFE_FREE(rparam); SAFE_FREE(rdata); @@ -282,13 +348,13 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, errno = cli_errno(cli); } else { if (!count) { - /* this is a very special case, when the domain master for the + /* this is a very special case, when the domain master for the work group isn't part of the work group itself, there is something wild going on */ errno = ENOENT; } } - + return(count > 0); } @@ -299,7 +365,7 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, bool cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, const char *old_password) { - pstring param; + char param[1024]; unsigned char data[532]; char *p = param; unsigned char old_pw_hash[16]; @@ -317,11 +383,11 @@ bool cli_oem_change_password(struct cli_state *cli, const char *user, const char SSVAL(p,0,214); /* SamOEMChangePassword command. */ p += 2; - pstrcpy_base(p, "zsT", param); + strlcpy(p, "zsT", sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); - pstrcpy_base(p, "B516B16", param); + strlcpy(p, "B516B16", sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); - pstrcpy_base(p,user, param); + strlcpy(p,user, sizeof(param)-PTR_DIFF(p,param)); p = skip_string(param,sizeof(param),p); SSVAL(p,0,532); p += 2; @@ -335,14 +401,14 @@ bool cli_oem_change_password(struct cli_state *cli, const char *user, const char E_deshash(old_password, old_pw_hash); encode_pw_buffer(data, new_password, STR_ASCII); - + #ifdef DEBUG_PASSWORD DEBUG(100,("make_oem_passwd_hash\n")); dump_data(100, data, 516); #endif SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, 516); - /* + /* * Now place the old password hash in the data. */ E_deshash(new_password, new_pw_hash); @@ -350,7 +416,7 @@ bool cli_oem_change_password(struct cli_state *cli, const char *user, const char E_old_pw_hash( new_pw_hash, old_pw_hash, (uchar *)&data[516]); data_len = 532; - + if (cli_send_trans(cli,SMBtrans, PIPE_LANMAN, /* name */ 0,0, /* fid, flags */ @@ -370,11 +436,11 @@ bool cli_oem_change_password(struct cli_state *cli, const char *user, const char user )); return False; } - + if (rparam) { cli->rap_error = SVAL(rparam,0); } - + SAFE_FREE(rparam); SAFE_FREE(rdata); @@ -385,17 +451,17 @@ bool cli_oem_change_password(struct cli_state *cli, const char *user, const char Send a qpathinfo call. ****************************************************************************/ -bool cli_qpathinfo(struct cli_state *cli, const char *fname, +bool cli_qpathinfo(struct cli_state *cli, const char *fname, time_t *change_time, time_t *access_time, - time_t *write_time, + time_t *write_time, SMB_OFF_T *size, uint16 *mode) { unsigned int data_len = 0; unsigned int param_len = 0; unsigned int rparam_len, rdata_len; uint16 setup = TRANSACT2_QPATHINFO; - pstring param; + char param[1024]; char *rparam=NULL, *rdata=NULL; int count=8; bool ret; @@ -406,19 +472,19 @@ 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(param)-6, STR_TERMINATE); param_len = PTR_DIFF(p, param); do { - ret = (cli_send_trans(cli, SMBtrans2, + ret = (cli_send_trans(cli, SMBtrans2, NULL, /* Name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 10, /* param, length, max */ NULL, data_len, cli->max_xmit /* data, length, max */ ) && - cli_receive_trans(cli, SMBtrans2, + cli_receive_trans(cli, SMBtrans2, &rparam, &rparam_len, &rdata, &rdata_len)); if (!cli_is_dos_error(cli)) break; @@ -468,7 +534,7 @@ bool cli_qpathinfo(struct cli_state *cli, const char *fname, Send a setpathinfo call. ****************************************************************************/ -bool cli_setpathinfo(struct cli_state *cli, const char *fname, +bool cli_setpathinfo(struct cli_state *cli, const char *fname, time_t create_time, time_t access_time, time_t write_time, @@ -479,8 +545,8 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, unsigned int param_len = 0; unsigned int rparam_len, rdata_len; uint16 setup = TRANSACT2_SETPATHINFO; - pstring param; - pstring data; + char param[1024]; + char data[1024]; char *rparam=NULL, *rdata=NULL; int count=8; bool ret; @@ -498,7 +564,7 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, p += 6; /* Add the file name */ - p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE); + p += clistr_push(cli, p, fname, sizeof(param)-6, STR_TERMINATE); param_len = PTR_DIFF(p, param); @@ -507,16 +573,15 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, /* * Add the create, last access, modification, and status change times */ - put_long_date(p, create_time); p += 8; put_long_date(p, access_time); p += 8; - + put_long_date(p, write_time); p += 8; - + put_long_date(p, change_time); p += 8; @@ -531,14 +596,14 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, data_len = PTR_DIFF(p, data); do { - ret = (cli_send_trans(cli, SMBtrans2, + ret = (cli_send_trans(cli, SMBtrans2, NULL, /* Name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 10, /* param, length, max */ data, data_len, cli->max_xmit /* data, length, max */ ) && - cli_receive_trans(cli, SMBtrans2, + cli_receive_trans(cli, SMBtrans2, &rparam, &rparam_len, &rdata, &rdata_len)); if (!cli_is_dos_error(cli)) break; @@ -566,10 +631,10 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, Send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level. ****************************************************************************/ -bool cli_qpathinfo2(struct cli_state *cli, const char *fname, +bool cli_qpathinfo2(struct cli_state *cli, const char *fname, struct timespec *create_time, struct timespec *access_time, - struct timespec *write_time, + struct timespec *write_time, struct timespec *change_time, SMB_OFF_T *size, uint16 *mode, SMB_INO_T *ino) @@ -577,7 +642,7 @@ bool cli_qpathinfo2(struct cli_state *cli, const char *fname, unsigned int data_len = 0; unsigned int param_len = 0; uint16 setup = TRANSACT2_QPATHINFO; - pstring param; + char param[1024]; char *rparam=NULL, *rdata=NULL; char *p; @@ -585,11 +650,11 @@ 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(param)-6, STR_TERMINATE); param_len = PTR_DIFF(p, param); - if (!cli_send_trans(cli, SMBtrans2, + if (!cli_send_trans(cli, SMBtrans2, NULL, /* name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ @@ -608,7 +673,7 @@ bool cli_qpathinfo2(struct cli_state *cli, const char *fname, if (!rdata || data_len < 22) { return False; } - + if (create_time) { *create_time = interpret_long_date(rdata+0); } @@ -640,21 +705,19 @@ 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) +bool cli_qfilename(struct cli_state *cli, int fnum, char *name, size_t namelen) { unsigned int data_len = 0; unsigned int param_len = 0; uint16 setup = TRANSACT2_QFILEINFO; - pstring param; + char param[4]; 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, + if (!cli_send_trans(cli, SMBtrans2, NULL, /* name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ @@ -674,7 +737,7 @@ bool cli_qfilename(struct cli_state *cli, int fnum, return False; } - clistr_pull(cli, name, rdata+4, sizeof(pstring), IVAL(rdata, 0), STR_UNICODE); + clistr_pull(cli, name, rdata+4, namelen, IVAL(rdata, 0), STR_UNICODE); return True; } @@ -683,18 +746,18 @@ bool cli_qfilename(struct cli_state *cli, int fnum, Send a qfileinfo call. ****************************************************************************/ -bool cli_qfileinfo(struct cli_state *cli, int fnum, +bool cli_qfileinfo(struct cli_state *cli, int fnum, uint16 *mode, SMB_OFF_T *size, struct timespec *create_time, struct timespec *access_time, - struct timespec *write_time, + struct timespec *write_time, struct timespec *change_time, SMB_INO_T *ino) { unsigned int data_len = 0; unsigned int param_len = 0; uint16 setup = TRANSACT2_QFILEINFO; - pstring param; + char param[4]; char *rparam=NULL, *rdata=NULL; /* if its a win95 server then fail this - win95 totally screws it @@ -703,11 +766,10 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum, param_len = 4; - memset(param, 0, param_len); SSVAL(param, 0, fnum); SSVAL(param, 2, SMB_QUERY_FILE_ALL_INFO); - if (!cli_send_trans(cli, SMBtrans2, + if (!cli_send_trans(cli, SMBtrans2, NULL, /* name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ @@ -758,32 +820,40 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum, Send a qpathinfo BASIC_INFO call. ****************************************************************************/ -bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, +bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbuf, uint32 *attributes ) { unsigned int param_len = 0; unsigned int data_len = 0; uint16 setup = TRANSACT2_QPATHINFO; - char param[sizeof(pstring)+6]; + char param[1024+6]; char *rparam=NULL, *rdata=NULL; char *p; - pstring path; + char *path; int len; - - pstrcpy( path, name ); + TALLOC_CTX *frame = talloc_stackframe(); + + path = talloc_strdup(frame, name); + if (!path) { + TALLOC_FREE(frame); + return false; + } /* cleanup */ - - len = strlen( path ); - if ( path[len-1] == '\\' || path[len-1] == '/') + + len = strlen(path); + if ( path[len-1] == '\\' || path[len-1] == '/') { path[len-1] = '\0'; + } p = param; memset(p, 0, 6); SSVAL(p, 0, SMB_QUERY_FILE_BASIC_INFO); p += 6; - p += clistr_push(cli, p, path, sizeof(pstring)-6, STR_TERMINATE); + p += clistr_push(cli, p, path, sizeof(param)-6, STR_TERMINATE); param_len = PTR_DIFF(p, param); + TALLOC_FREE(frame); + if (!cli_send_trans(cli, SMBtrans2, NULL, /* name */ -1, 0, /* fid, flags */ @@ -809,12 +879,12 @@ bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, set_atimespec(sbuf, interpret_long_date( rdata+8 )); /* Access time. */ set_mtimespec(sbuf, interpret_long_date( rdata+16 )); /* Write time. */ set_ctimespec(sbuf, interpret_long_date( rdata+24 )); /* Change time. */ - + *attributes = IVAL( rdata, 32 ); - + SAFE_FREE(rparam); SAFE_FREE(rdata); - + return True; } @@ -827,7 +897,7 @@ bool cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutd unsigned int data_len = 0; unsigned int param_len = 0; uint16 setup = TRANSACT2_QFILEINFO; - pstring param; + char param[4]; char *rparam=NULL, *rdata=NULL; *poutdata = NULL; @@ -840,11 +910,10 @@ bool cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutd param_len = 4; - memset(param, 0, param_len); SSVAL(param, 0, fnum); SSVAL(param, 2, level); - if (!cli_send_trans(cli, SMBtrans2, + if (!cli_send_trans(cli, SMBtrans2, NULL, /* name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ @@ -883,7 +952,7 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin unsigned int data_len = 0; unsigned int param_len = 0; uint16 setup = TRANSACT2_QPATHINFO; - pstring param; + char param[1024+6]; char *rparam=NULL, *rdata=NULL; int count=8; char *p; @@ -894,19 +963,19 @@ 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(param)-6, STR_TERMINATE); param_len = PTR_DIFF(p, param); do { - ret = (cli_send_trans(cli, SMBtrans2, + ret = (cli_send_trans(cli, SMBtrans2, NULL, /* Name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ param, param_len, 10, /* param, length, max */ NULL, data_len, cli->max_xmit /* data, length, max */ ) && - cli_receive_trans(cli, SMBtrans2, + cli_receive_trans(cli, SMBtrans2, &rparam, ¶m_len, &rdata, &data_len)); if (!ret && cli_is_dos_error(cli)) { -- cgit From 1938e861d0081fd5a28b8b345df70f22b3d841a5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 5 Dec 2007 13:31:24 -0800 Subject: Remove arbitrary 1k limit on pathnames. Malloc them. Jeremy. (This used to be commit 71770b4c1d021d829deeb53a6ea3b747fce55c84) --- source3/libsmb/clirap.c | 97 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 31 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index d8d8f2608c..c10900cf43 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -451,29 +451,35 @@ bool cli_oem_change_password(struct cli_state *cli, const char *user, const char Send a qpathinfo call. ****************************************************************************/ -bool cli_qpathinfo(struct cli_state *cli, const char *fname, - time_t *change_time, - time_t *access_time, - time_t *write_time, - SMB_OFF_T *size, uint16 *mode) +bool cli_qpathinfo(struct cli_state *cli, + const char *fname, + time_t *change_time, + time_t *access_time, + time_t *write_time, + SMB_OFF_T *size, + uint16 *mode) { unsigned int data_len = 0; unsigned int param_len = 0; unsigned int rparam_len, rdata_len; uint16 setup = TRANSACT2_QPATHINFO; - char param[1024]; + char *param; char *rparam=NULL, *rdata=NULL; int count=8; bool ret; time_t (*date_fn)(struct cli_state *, const void *); char *p; + size_t nlen = 2*(strlen(fname)+1); + param = SMB_MALLOC(6+nlen+2); + if (!param) { + return false; + } p = param; - memset(p, 0, 6); + memset(p, '\0', 6); SSVAL(p, 0, SMB_INFO_STANDARD); p += 6; - p += clistr_push(cli, p, fname, sizeof(param)-6, STR_TERMINATE); - + p += clistr_push(cli, p, fname, nlen, STR_TERMINATE); param_len = PTR_DIFF(p, param); do { @@ -499,6 +505,7 @@ bool cli_qpathinfo(struct cli_state *cli, const char *fname, } } while (count-- && ret==False); + SAFE_FREE(param); if (!ret || !rdata || rdata_len < 22) { return False; } @@ -545,14 +552,19 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, unsigned int param_len = 0; unsigned int rparam_len, rdata_len; uint16 setup = TRANSACT2_SETPATHINFO; - char param[1024]; - char data[1024]; + char *param; + char data[40]; char *rparam=NULL, *rdata=NULL; int count=8; bool ret; char *p; + size_t nlen = 2*(strlen(fname)+1); - memset(param, 0, sizeof(param)); + param = SMB_MALLOC(6+nlen+2); + if (!param) { + return false; + } + memset(param, '\0', 6); memset(data, 0, sizeof(data)); p = param; @@ -564,7 +576,7 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, p += 6; /* Add the file name */ - p += clistr_push(cli, p, fname, sizeof(param)-6, STR_TERMINATE); + p += clistr_push(cli, p, fname, nlen, STR_TERMINATE); param_len = PTR_DIFF(p, param); @@ -618,6 +630,7 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, } } while (count-- && ret==False); + SAFE_FREE(param); if (!ret) { return False; } @@ -642,15 +655,20 @@ bool cli_qpathinfo2(struct cli_state *cli, const char *fname, unsigned int data_len = 0; unsigned int param_len = 0; uint16 setup = TRANSACT2_QPATHINFO; - char param[1024]; + char *param; char *rparam=NULL, *rdata=NULL; char *p; + size_t nlen = 2*(strlen(fname)+1); + param = SMB_MALLOC(6+nlen+2); + if (!param) { + return false; + } p = param; - memset(p, 0, 6); + memset(param, '\0', 6); SSVAL(p, 0, SMB_QUERY_FILE_ALL_INFO); p += 6; - p += clistr_push(cli, p, fname, sizeof(param)-6, STR_TERMINATE); + p += clistr_push(cli, p, fname, nlen, STR_TERMINATE); param_len = PTR_DIFF(p, param); @@ -661,9 +679,11 @@ bool cli_qpathinfo2(struct cli_state *cli, const char *fname, param, param_len, 10, /* param, length, max */ NULL, data_len, cli->max_xmit /* data, length, max */ )) { + SAFE_FREE(param); return False; } + SAFE_FREE(param); if (!cli_receive_trans(cli, SMBtrans2, &rparam, ¶m_len, &rdata, &data_len)) { @@ -826,11 +846,12 @@ bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, unsigned int param_len = 0; unsigned int data_len = 0; uint16 setup = TRANSACT2_QPATHINFO; - char param[1024+6]; + char *param; char *rparam=NULL, *rdata=NULL; char *p; char *path; int len; + size_t nlen; TALLOC_CTX *frame = talloc_stackframe(); path = talloc_strdup(frame, name); @@ -844,26 +865,34 @@ bool cli_qpathinfo_basic( struct cli_state *cli, const char *name, if ( path[len-1] == '\\' || path[len-1] == '/') { path[len-1] = '\0'; } + nlen = 2*(strlen(path)+1); + param = TALLOC_ARRAY(frame,char,6+nlen+2); + if (!param) { + return false; + } p = param; - memset(p, 0, 6); + memset(param, '\0', 6); + SSVAL(p, 0, SMB_QUERY_FILE_BASIC_INFO); p += 6; - p += clistr_push(cli, p, path, sizeof(param)-6, STR_TERMINATE); + p += clistr_push(cli, p, path, nlen, STR_TERMINATE); param_len = PTR_DIFF(p, param); - TALLOC_FREE(frame); 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, 0, cli->max_xmit /* data, length, max */ - )) { - return False; + NULL, /* name */ + -1, 0, /* fid, flags */ + &setup, 1, 0, /* setup, length, max */ + param, param_len, 2, /* param, length, max */ + NULL, 0, cli->max_xmit /* data, length, max */ + )) { + TALLOC_FREE(frame); + return False; } + TALLOC_FREE(frame); + if (!cli_receive_trans(cli, SMBtrans2, &rparam, ¶m_len, &rdata, &data_len)) { @@ -952,19 +981,23 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin unsigned int data_len = 0; unsigned int param_len = 0; uint16 setup = TRANSACT2_QPATHINFO; - char param[1024+6]; + char *param; char *rparam=NULL, *rdata=NULL; int count=8; char *p; bool ret; unsigned int len; + size_t nlen = 2*(strlen(fname)+1); + param = SMB_MALLOC(6+nlen+2); + if (!param) { + return NT_STATUS_NO_MEMORY; + } p = param; - memset(p, 0, 6); + memset(param, '\0', 6); SSVAL(p, 0, SMB_QUERY_FILE_ALT_NAME_INFO); p += 6; - p += clistr_push(cli, p, fname, sizeof(param)-6, STR_TERMINATE); - + p += clistr_push(cli, p, fname, nlen, STR_TERMINATE); param_len = PTR_DIFF(p, param); do { @@ -989,6 +1022,8 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin } } while (count-- && ret==False); + SAFE_FREE(param); + if (!ret || !rdata || data_len < 4) { return NT_STATUS_UNSUCCESSFUL; } -- cgit From 1e26ecf6660ef692ee6dbce14171da49a3833132 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 8 Dec 2007 11:21:08 +0100 Subject: Fix C++ warnings (This used to be commit 01a5c3ea4bf18d99ca1c35e8c38367046e4c867b) --- source3/libsmb/clirap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index c10900cf43..410b7cb138 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -471,7 +471,7 @@ bool cli_qpathinfo(struct cli_state *cli, char *p; size_t nlen = 2*(strlen(fname)+1); - param = SMB_MALLOC(6+nlen+2); + param = SMB_MALLOC_ARRAY(char, 6+nlen+2); if (!param) { return false; } @@ -560,7 +560,7 @@ bool cli_setpathinfo(struct cli_state *cli, const char *fname, char *p; size_t nlen = 2*(strlen(fname)+1); - param = SMB_MALLOC(6+nlen+2); + param = SMB_MALLOC_ARRAY(char, 6+nlen+2); if (!param) { return false; } @@ -660,7 +660,7 @@ bool cli_qpathinfo2(struct cli_state *cli, const char *fname, char *p; size_t nlen = 2*(strlen(fname)+1); - param = SMB_MALLOC(6+nlen+2); + param = SMB_MALLOC_ARRAY(char, 6+nlen+2); if (!param) { return false; } @@ -989,7 +989,7 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin unsigned int len; size_t nlen = 2*(strlen(fname)+1); - param = SMB_MALLOC(6+nlen+2); + param = SMB_MALLOC_ARRAY(char, 6+nlen+2); if (!param) { return NT_STATUS_NO_MEMORY; } -- cgit From f78ce189c29c873b45ada282edce050fb0186c39 Mon Sep 17 00:00:00 2001 From: James Peach Date: Sun, 9 Dec 2007 14:18:54 -0800 Subject: Support fetching very long server lists with RAP_NetServerEnum3. Use the RAP_NetServerEnum3 server list continuation API for retrieving server lists that are too long to fit in a single reply. Patch from George Colley . (This used to be commit 40c26d55736ae08934e18c27168fff10dd15442f) --- source3/libsmb/clirap.c | 167 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 125 insertions(+), 42 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 410b7cb138..54504f608d 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -3,6 +3,7 @@ client RAP calls Copyright (C) Andrew Tridgell 1994-1998 Copyright (C) Gerald (Jerry) Carter 2004 + Copyright (C) James Peach 2007 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -244,57 +245,118 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, { char *rparam = NULL; char *rdata = NULL; + char *rdata_end = NULL; unsigned int rdrcnt,rprcnt; char *p; char param[1024]; int uLevel = 1; - int count = -1; size_t len; + uint32 func = RAP_NetServerEnum2; + char *last_entry = NULL; + int total_cnt = 0; + int return_cnt = 0; + int res; errno = 0; /* reset */ - /* send a SMBtrans command with api NetServerEnum */ - p = param; - SSVAL(p,0,0x68); /* api number */ - p += 2; - strlcpy(p,"WrLehDz", sizeof(param)-PTR_DIFF(p,param)); - p = skip_string(param,sizeof(param),p); + /* + * This may take more than one transaction, so we should loop until + * we no longer get a more data to process or we have all of the + * items. + */ + do { + /* send a SMBtrans command with api NetServerEnum */ + p = param; + SIVAL(p,0,func); /* api number */ + p += 2; + /* Next time through we need to use the continue api */ + func = RAP_NetServerEnum3; + + if (last_entry) { + strlcpy(p,"WrLehDOz", sizeof(param)-PTR_DIFF(p,param)); + } else { + strlcpy(p,"WrLehDz", sizeof(param)-PTR_DIFF(p,param)); + } - strlcpy(p,"B16BBDz", sizeof(param)-PTR_DIFF(p,param)); + p = skip_string(param, sizeof(param), p); + strlcpy(p,"B16BBDz", sizeof(param)-PTR_DIFF(p,param)); + + p = skip_string(param, sizeof(param), p); + SSVAL(p,0,uLevel); + SSVAL(p,2,CLI_BUFFER_SIZE); + p += 4; + SIVAL(p,0,stype); + p += 4; + + /* If we have more data, tell the server where + * to continue from. + */ + len = push_ascii(p, + last_entry ? last_entry : workgroup, + sizeof(param) - PTR_DIFF(p,param) - 1, + STR_TERMINATE|STR_UPPER); + + if (len == (size_t)-1) { + return false; + } + p += len; - p = skip_string(param,sizeof(param),p); - SSVAL(p,0,uLevel); - SSVAL(p,2,CLI_BUFFER_SIZE); - p += 4; - SIVAL(p,0,stype); - p += 4; + if (!cli_api(cli, + param, PTR_DIFF(p,param), 8, /* params, length, max */ + NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */ + &rparam, &rprcnt, /* return params, return size */ + &rdata, &rdrcnt)) { /* return data, return size */ - len = push_ascii(p, workgroup, sizeof(param)-PTR_DIFF(p,param)-1, - STR_TERMINATE|STR_UPPER); - if (len == (size_t)-1) { - return false; - } - p += len; + /* break out of the loop on error */ + res = -1; + break; + } - if (cli_api(cli, - param, PTR_DIFF(p,param), 8, /* params, length, max */ - NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */ - &rparam, &rprcnt, /* return params, return size */ - &rdata, &rdrcnt /* return data, return size */ - )) { - int res = rparam? SVAL(rparam,0) : -1; - char *rdata_end = rdata + rdrcnt; + rdata_end = rdata + rdrcnt; + res = rparam ? SVAL(rparam,0) : -1; if (res == 0 || res == ERRmoredata || (res != -1 && cli_errno(cli) == 0)) { - int i; + char *sname = NULL; + int i, count; int converter=SVAL(rparam,2); - count=SVAL(rparam,4); + /* Get the number of items returned in this buffer */ + count = SVAL(rparam, 4); + + /* The next field contains the number of items left, + * including those returned in this buffer. So the + * first time through this should contain all of the + * entries. + */ + if (total_cnt == 0) { + total_cnt = SVAL(rparam, 6); + } + + /* Keep track of how many we have read */ + return_cnt += count; p = rdata; - for (i = 0;i < count;i++, p += 26) { - char *sname; + /* The last name in the previous NetServerEnum reply is + * sent back to server in the NetServerEnum3 request + * (last_entry). The next reply should repeat this entry + * as the first element. We have no proof that this is + * always true, but from traces that seems to be the + * behavior from Window Servers. So first lets do a lot + * of checking, just being paranoid. If the string + * matches then we already saw this entry so skip it. + * + * NOTE: sv1_name field must be null terminated and has + * a max size of 16 (NetBIOS Name). + */ + if (last_entry && count && p && + (strncmp(last_entry, p, 16) == 0)) { + count -= 1; /* Skip this entry */ + return_cnt = -1; /* Not part of total, so don't count. */ + p = rdata + 26; /* Skip the whole record */ + } + + for (i = 0; i < count; i++, p += 26) { int comment_offset; const char *cmnt; const char *p1; @@ -338,24 +400,45 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, fn(s1, stype, s2, state); TALLOC_FREE(frame); } + + /* We are done with the old last entry, so now we can free it */ + if (last_entry) { + SAFE_FREE(last_entry); /* This will set it to null */ + } + + /* We always make a copy of the last entry if we have one */ + if (sname) { + last_entry = smb_xstrdup(sname); + } + + /* If we have more data, but no last entry then error out */ + if (!last_entry && (res == ERRmoredata)) { + errno = EINVAL; + res = 0; + } + } - } + + SAFE_FREE(rparam); + SAFE_FREE(rdata); + } while ((res == ERRmoredata) && (total_cnt > return_cnt)); SAFE_FREE(rparam); SAFE_FREE(rdata); + SAFE_FREE(last_entry); - if (count < 0) { - errno = cli_errno(cli); + if (res == -1) { + errno = cli_errno(cli); } else { - if (!count) { - /* this is a very special case, when the domain master for the - work group isn't part of the work group itself, there is something - wild going on */ - errno = ENOENT; + if (!return_cnt) { + /* this is a very special case, when the domain master for the + work group isn't part of the work group itself, there is something + wild going on */ + errno = ENOENT; + } } - } - return(count > 0); + return(return_cnt > 0); } /**************************************************************************** -- cgit From c0c299cb267f6c559a0a407fde536aa32efc29f6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 9 Jan 2008 22:25:52 +0100 Subject: Fix a memleak found by the IBM checker. Michael (This used to be commit b4a37a66bbd8f5346de743d4ab427d6671e29075) --- source3/libsmb/clirap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 54504f608d..aab77a3d54 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -297,6 +297,7 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, STR_TERMINATE|STR_UPPER); if (len == (size_t)-1) { + SAFE_FREE(last_entry); return false; } p += len; -- cgit From 3d3d6e7020749c63455e16ba110bc46862d3c146 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 18 Jan 2008 11:08:17 +0100 Subject: Add the "allinfo" command to smbclient Modeled after the Samba4 allinfo command (This used to be commit 3fa0cf3fe5f819f6e76df6f7cef3bb4e1c307a52) --- source3/libsmb/clirap.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index aab77a3d54..4c5e338606 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -805,6 +805,137 @@ bool cli_qpathinfo2(struct cli_state *cli, const char *fname, return True; } +/**************************************************************************** + Get the stream info +****************************************************************************/ + +bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname, + TALLOC_CTX *mem_ctx, + unsigned int *pnum_streams, + struct stream_struct **pstreams) +{ + unsigned int data_len = 0; + unsigned int param_len = 0; + uint16 setup = TRANSACT2_QPATHINFO; + char *param; + char *rparam=NULL, *rdata=NULL; + char *p; + unsigned int num_streams; + struct stream_struct *streams; + unsigned int ofs; + size_t namelen = 2*(strlen(fname)+1); + + param = SMB_MALLOC_ARRAY(char, 6+namelen+2); + if (param == NULL) { + return false; + } + p = param; + memset(p, 0, 6); + SSVAL(p, 0, SMB_FILE_STREAM_INFORMATION); + p += 6; + p += clistr_push(cli, p, fname, namelen, STR_TERMINATE); + + param_len = PTR_DIFF(p, param); + + if (!cli_send_trans(cli, SMBtrans2, + NULL, /* name */ + -1, 0, /* fid, flags */ + &setup, 1, 0, /* setup, len, max */ + param, param_len, 10, /* param, len, max */ + NULL, data_len, cli->max_xmit /* data, len, max */ + )) { + return false; + } + + if (!cli_receive_trans(cli, SMBtrans2, + &rparam, ¶m_len, + &rdata, &data_len)) { + return false; + } + + if (!rdata) { + SAFE_FREE(rparam); + return false; + } + + num_streams = 0; + streams = NULL; + ofs = 0; + + while ((data_len > ofs) && (data_len - ofs >= 24)) { + uint32_t nlen, len; + ssize_t size; + void *vstr; + struct stream_struct *tmp; + uint8_t *tmp_buf; + + tmp = TALLOC_REALLOC_ARRAY(mem_ctx, streams, + struct stream_struct, + num_streams+1); + + if (tmp == NULL) { + goto fail; + } + streams = tmp; + + nlen = IVAL(rdata, ofs + 0x04); + + streams[num_streams].size = IVAL_TO_SMB_OFF_T( + rdata, ofs + 0x08); + streams[num_streams].alloc_size = IVAL_TO_SMB_OFF_T( + rdata, ofs + 0x10); + + if (nlen > data_len - (ofs + 24)) { + goto fail; + } + + /* + * We need to null-terminate src, how do I do this with + * convert_string_talloc?? + */ + + tmp_buf = TALLOC_ARRAY(streams, uint8_t, nlen+2); + if (tmp_buf == NULL) { + goto fail; + } + + memcpy(tmp_buf, rdata+ofs+24, nlen); + tmp_buf[nlen] = 0; + tmp_buf[nlen+1] = 0; + + size = convert_string_talloc(streams, CH_UTF16, CH_UNIX, + tmp_buf, nlen+2, &vstr, + false); + TALLOC_FREE(tmp_buf); + + if (size == -1) { + goto fail; + } + streams[num_streams].name = (char *)vstr; + num_streams++; + + len = IVAL(rdata, ofs); + if (len > data_len - ofs) { + goto fail; + } + if (len == 0) break; + ofs += len; + } + + SAFE_FREE(rdata); + SAFE_FREE(rparam); + + *pnum_streams = num_streams; + *pstreams = streams; + return true; + + fail: + TALLOC_FREE(streams); + SAFE_FREE(rdata); + SAFE_FREE(rparam); + return false; +} + /**************************************************************************** Send a qfileinfo QUERY_FILE_NAME_INFO call. ****************************************************************************/ -- cgit From c0e92cd4b8eae573848dc1587eecd2946715d754 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Feb 2008 10:07:05 -0800 Subject: Fix bug reported on IRC enumerating shares with OS/2. Report and fix from kukks (thanks once again !). Jeremy. (This used to be commit 3ca58b792fb10ff2a4c25283c587f8270ed82d74) --- source3/libsmb/clirap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 4c5e338606..8c167e1257 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -191,12 +191,13 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co sname = p; type = SVAL(p,14); - comment_offset = IVAL(p,16) & 0xFFFF; - if (comment_offset < 0 || comment_offset > (int)rdrcnt) { + comment_offset = (IVAL(p,16) & 0xFFFF) - converter; + if (comment_offset < 0 || + comment_offset > (int)rdrcnt) { TALLOC_FREE(frame); break; } - cmnt = comment_offset?(rdata+comment_offset-converter):""; + cmnt = comment_offset?(rdata+comment_offset):""; /* Work out the comment length. */ for (p1 = cmnt, len = 0; *p1 && -- cgit From fb37f156009611af0dd454a0fb0829a09cd638ac Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Tue, 29 Apr 2008 14:36:24 -0700 Subject: Cleanup size_t return values in callers of convert_string_allocate This patch is the second iteration of an inside-out conversion to cleanup functions in charcnv.c returning size_t == -1 to indicate failure. (This used to be commit 6b189dabc562d86dcaa685419d0cb6ea276f100d) --- source3/libsmb/clirap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 8c167e1257..cf4f4987cf 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -904,14 +904,14 @@ bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname, tmp_buf[nlen] = 0; tmp_buf[nlen+1] = 0; - size = convert_string_talloc(streams, CH_UTF16, CH_UNIX, - tmp_buf, nlen+2, &vstr, - false); - TALLOC_FREE(tmp_buf); - - if (size == -1) { + if (!convert_string_talloc(streams, CH_UTF16, CH_UNIX, tmp_buf, + nlen+2, &vstr, &size, false)) + { + TALLOC_FREE(tmp_buf); goto fail; } + + TALLOC_FREE(tmp_buf); streams[num_streams].name = (char *)vstr; num_streams++; -- cgit From e2d8b0a7923f52cf2be1c3a14f6390aea9c06fe7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 20 May 2008 23:06:38 +0200 Subject: Fix some signed/unsigned warnings (This used to be commit dbb4d8107a61051d8bcf6c4c69ee976efc50b961) --- source3/libsmb/clirap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index cf4f4987cf..61e2fb7f1a 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -865,7 +865,7 @@ bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname, while ((data_len > ofs) && (data_len - ofs >= 24)) { uint32_t nlen, len; - ssize_t size; + size_t size; void *vstr; struct stream_struct *tmp; uint8_t *tmp_buf; -- cgit From 7fafa9756a273e200fa251c1dea25e884729628c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 8 Sep 2008 22:39:16 +0200 Subject: Fix a memleak in cli_qfilename (only used in smbtorture) (This used to be commit 7e0cca19fec078c0b46807492a7a035f4fab612b) --- source3/libsmb/clirap.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 61e2fb7f1a..3b4db2e26d 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -970,11 +970,16 @@ bool cli_qfilename(struct cli_state *cli, int fnum, char *name, size_t namelen) } if (!rdata || data_len < 4) { + SAFE_FREE(rparam); + SAFE_FREE(rdata); return False; } clistr_pull(cli, name, rdata+4, namelen, IVAL(rdata, 0), STR_UNICODE); + SAFE_FREE(rparam); + SAFE_FREE(rdata); + return True; } -- cgit From bb2a7183b91706db80d096504c9d4668c477d36c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 9 Sep 2008 15:03:34 +0200 Subject: Convert cli_qfileinfo to the async trans call (This used to be commit ddc5e77b619db7c2369b3bf72b60360051797087) --- source3/libsmb/clirap.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 3b4db2e26d..631bc3f36b 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -998,8 +998,9 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum, unsigned int data_len = 0; unsigned int param_len = 0; uint16 setup = TRANSACT2_QFILEINFO; - char param[4]; - char *rparam=NULL, *rdata=NULL; + uint8_t param[4]; + uint8_t *rparam=NULL, *rdata=NULL; + NTSTATUS status; /* if its a win95 server then fail this - win95 totally screws it up */ @@ -1010,20 +1011,17 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum, SSVAL(param, 0, fnum); SSVAL(param, 2, SMB_QUERY_FILE_ALL_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; - } + status = cli_trans(talloc_tos(), cli, SMBtrans2, + NULL, -1, 0, 0, /* name, fid, function, flags */ + &setup, 1, 0, /* setup, length, max */ + param, param_len, 2, /* param, length, max */ + NULL, 0, MIN(cli->max_xmit, 0xffff), /* data, length, max */ + NULL, NULL, /* rsetup, length */ + &rparam, ¶m_len, /* rparam, length */ + &rdata, &data_len); - if (!cli_receive_trans(cli, SMBtrans2, - &rparam, ¶m_len, - &rdata, &data_len)) { - return False; + if (!NT_STATUS_IS_OK(status)) { + return false; } if (!rdata || data_len < 68) { @@ -1031,16 +1029,16 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum, } if (create_time) { - *create_time = interpret_long_date(rdata+0); + *create_time = interpret_long_date((char *)rdata+0); } if (access_time) { - *access_time = interpret_long_date(rdata+8); + *access_time = interpret_long_date((char *)rdata+8); } if (write_time) { - *write_time = interpret_long_date(rdata+16); + *write_time = interpret_long_date((char *)rdata+16); } if (change_time) { - *change_time = interpret_long_date(rdata+24); + *change_time = interpret_long_date((char *)rdata+24); } if (mode) { *mode = SVAL(rdata, 32); @@ -1052,8 +1050,8 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum, *ino = IVAL(rdata, 64); } - SAFE_FREE(rdata); - SAFE_FREE(rparam); + TALLOC_FREE(rdata); + TALLOC_FREE(rparam); return True; } -- cgit From a1d0f59f4604c4d324c1b082fba43ffa11ea8f97 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 9 Sep 2008 22:13:39 +0200 Subject: Fix make test on sparc and possibly also on AIX (This used to be commit 5721205bff539ed5f8592a86168679ec5a9c368e) --- source3/libsmb/clirap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/libsmb/clirap.c') diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 631bc3f36b..eee8636fdd 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -997,7 +997,7 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum, { unsigned int data_len = 0; unsigned int param_len = 0; - uint16 setup = TRANSACT2_QFILEINFO; + uint16 setup; uint8_t param[4]; uint8_t *rparam=NULL, *rdata=NULL; NTSTATUS status; @@ -1011,6 +1011,8 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum, SSVAL(param, 0, fnum); SSVAL(param, 2, SMB_QUERY_FILE_ALL_INFO); + SSVAL(&setup, 0, TRANSACT2_QFILEINFO); + status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, -1, 0, 0, /* name, fid, function, flags */ &setup, 1, 0, /* setup, length, max */ -- cgit