summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-04-17 22:44:01 +0000
committerJeremy Allison <jra@samba.org>1998-04-17 22:44:01 +0000
commitf9a96f060bdc8d045748b5f7e31d177e43e8810a (patch)
treea8d75fc796573d7b841896116073a43d0e8ab958 /source3
parent373d7c62577c13e1a85043844953a8d779858432 (diff)
downloadsamba-f9a96f060bdc8d045748b5f7e31d177e43e8810a.tar.gz
samba-f9a96f060bdc8d045748b5f7e31d177e43e8810a.tar.bz2
samba-f9a96f060bdc8d045748b5f7e31d177e43e8810a.zip
clientgen.c: Changes 'cli_xxx_' calls to use the following
regularized parameter syntax: setup, setup_count, max_setup_count, params, params_count, max_params_count, data, data_count, max_data_count, (and if a reply is needed) *reply_params, *reply_data_len *reply_data, *reply_data_len This allows the pointers and the lengths that relate to these pointers to be next to each other in the parameter list. This makes seeing what you are passing to these functions much easier to see. Getting ready for adding the lib/rpc/client functions needed to do security=domain. torture.c: Fixed it so it uses / rather than \\ internally for the //machine/share syntax. Jeremy. (This used to be commit 38350ea8b949d0908497490898ff04df7591ccac)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/libsmb/clientgen.c152
-rw-r--r--source3/utils/torture.c14
3 files changed, 114 insertions, 58 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index b1a5edab62..3afc150649 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -51,6 +51,12 @@ void cmd_help(char *dum_in, char *dum_out);
/*The following definitions come from clientgen.c */
+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);
BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation);
BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
void (*fn)(char *, uint32, char *));
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 4bca10cb3a..bffce26294 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -47,10 +47,12 @@ static void cli_setup_packet(struct cli_state *cli)
/****************************************************************************
send a SMB trans or trans2 request
****************************************************************************/
-static BOOL cli_send_trans(struct cli_state *cli,
- int trans, char *name, int fid, int flags,
- char *data,char *param,uint16 *setup, int ldata,int lparam,
- int lsetup,int mdata,int mparam,int msetup)
+static BOOL cli_send_trans(struct cli_state *cli, int trans,
+ char *name, int pipe_name_len,
+ int fid, int flags,
+ uint16 *setup, int lsetup, int msetup,
+ char *param, int lparam, int mparam,
+ char *data, int ldata, int mdata)
{
int i;
int this_ldata,this_lparam;
@@ -67,7 +69,7 @@ static BOOL cli_send_trans(struct cli_state *cli,
SSVAL(cli->outbuf,smb_tid, cli->cnum);
cli_setup_packet(cli);
- outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? strlen(name)+1 : 3);
+ outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? pipe_name_len+1 : 3);
outdata = outparam+this_lparam;
/* primary request */
@@ -87,7 +89,7 @@ static BOOL cli_send_trans(struct cli_state *cli,
SSVAL(cli->outbuf,smb_setup+i*2,setup[i]);
p = smb_buf(cli->outbuf);
if (trans==SMBtrans) {
- strcpy(p,name); /* name[] */
+ memcpy(p,name, pipe_name_len + 1); /* name[] */
} else {
*p++ = 0; /* put in a null smb_name */
*p++ = 'D'; *p++ = ' '; /* observed in OS/2 */
@@ -155,9 +157,9 @@ static BOOL cli_send_trans(struct cli_state *cli,
/****************************************************************************
receive a SMB trans or trans2 response allocating the necessary memory
****************************************************************************/
-static BOOL cli_receive_trans(struct cli_state *cli,
- int trans,int *data_len,
- int *param_len, char **data,char **param)
+static BOOL cli_receive_trans(struct cli_state *cli,int trans,
+ char **param, int *param_len,
+ char **data, int *data_len)
{
int total_data=0;
int total_param=0;
@@ -235,23 +237,51 @@ static BOOL cli_receive_trans(struct cli_state *cli,
return(True);
}
+/****************************************************************************
+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, rparam_count,
+ rdata, rdata_count));
+}
/****************************************************************************
call a remote api
****************************************************************************/
static BOOL cli_api(struct cli_state *cli,
- int prcnt,int drcnt,int mprcnt,int mdrcnt,int *rprcnt,
- int *rdrcnt, char *param,char *data,
- char **rparam, char **rdata)
+ 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,0,0,
- data,param,NULL,
- drcnt,prcnt,0,
- mdrcnt,mprcnt,0);
+ 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,
- rdrcnt,rprcnt,
- rdata,rparam));
+ rparam, rprcnt,
+ rdata, rdrcnt));
}
@@ -291,11 +321,12 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation)
cli->error = -1;
- if (cli_api(cli, PTR_DIFF(p,param),0,
- 1024,BUFFER_SIZE,
- &rprcnt,&rdrcnt,
- param,NULL,
- &rparam,&rdata)) {
+ if (cli_api(cli,
+ param, PTR_DIFF(p,param),1024, /* param, length, max */
+ NULL, 0, BUFFER_SIZE, /* data, length, max */
+ &rparam, &rprcnt, /* return params, return size */
+ &rdata, &rdrcnt /* return data, return size */
+ )) {
cli->error = SVAL(rparam,0);
p = rdata;
@@ -352,13 +383,11 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
p = skip_string(p,1);
if (cli_api(cli,
- PTR_DIFF(p,param), /* param count */
- 0, /*data count */
- 8, /* mprcount */
- BUFFER_SIZE, /* mdrcount */
- &rprcnt,&rdrcnt,
- param, NULL,
- &rparam,&rdata)) {
+ param, PTR_DIFF(p,param), 8, /* params, length, max */
+ NULL, 0, BUFFER_SIZE, /* data, length, max */
+ &rparam, &rprcnt, /* return params, return size */
+ &rdata, &rdrcnt /* return data, return size */
+ )) {
int res = SVAL(rparam,0);
int converter=SVAL(rparam,2);
int i;
@@ -1068,15 +1097,19 @@ BOOL cli_qpathinfo(struct cli_state *cli, char *fname,
SSVAL(param, 0, SMB_INFO_STANDARD);
pstrcpy(&param[6], fname);
- if (!cli_send_trans(cli, SMBtrans2, NULL, -1, 0,
- NULL, param, &setup,
- data_len, param_len, 1,
- cli->max_xmit, 10, 0)) {
+ 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, &data_len, &param_len,
- &rdata, &rparam)) {
+ if (!cli_receive_trans(cli, SMBtrans2,
+ &rparam, &param_len,
+ &rdata, &data_len)) {
return False;
}
@@ -1121,15 +1154,19 @@ BOOL cli_qpathinfo2(struct cli_state *cli, char *fname,
SSVAL(param, 0, SMB_QUERY_FILE_ALL_INFO);
pstrcpy(&param[6], fname);
- if (!cli_send_trans(cli, SMBtrans2, NULL, -1, 0,
- NULL, param, &setup,
- data_len, param_len, 1,
- cli->max_xmit, 10, 0)) {
+ 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, &data_len, &param_len,
- &rdata, &rparam)) {
+ if (!cli_receive_trans(cli, SMBtrans2,
+ &rparam, &param_len,
+ &rdata, &data_len)) {
return False;
}
@@ -1177,15 +1214,19 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
SSVAL(param, 0, fnum);
SSVAL(param, 2, SMB_INFO_STANDARD);
- if (!cli_send_trans(cli, SMBtrans2, NULL, -1, 0,
- NULL, param, &setup,
- data_len, param_len, 1,
- cli->max_xmit, 2, 0)) {
+ 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, &data_len, &param_len,
- &rdata, &rparam)) {
+ if (!cli_receive_trans(cli, SMBtrans2,
+ &rparam, &param_len,
+ &rdata, &data_len)) {
return False;
}
@@ -1288,16 +1329,21 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
data_len = 532;
- if(cli_send_trans(cli,SMBtrans,PIPE_LANMAN,0,0,
- data,param,NULL,
- data_len , param_len,0,
- 0,2,0) == False) {
+ 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, &rdrcnt, &rprcnt, &rdata, &rparam)) {
+ if(cli_receive_trans(cli,SMBtrans,
+ &rparam, &rprcnt,
+ &rdata, &rdrcnt)) {
if(rparam)
cli->error = SVAL(rparam,0);
}
diff --git a/source3/utils/torture.c b/source3/utils/torture.c
index c7fded6b3f..ede801afe9 100644
--- a/source3/utils/torture.c
+++ b/source3/utils/torture.c
@@ -32,12 +32,12 @@ static char *sockops="";
static struct timeval tp1,tp2;
-static void start_timer()
+static void start_timer(void)
{
gettimeofday(&tp1,NULL);
}
-static double end_timer()
+static double end_timer(void)
{
gettimeofday(&tp2,NULL);
return((tp2.tv_sec - tp1.tv_sec) +
@@ -191,7 +191,7 @@ static BOOL rw_torture(struct cli_state *c, int numops)
static void usage(void)
{
- printf("Usage: smbtorture \\\\server\\share <options>\n");
+ printf("Usage: smbtorture //server/share <options>\n");
printf("\t-U user%%pass\n");
printf("\t-N numprocs\n");
@@ -841,12 +841,16 @@ static void create_procs(int nprocs, int numops)
usage();
}
- if (strncmp(argv[1], "\\\\", 2)) {
+ for(p = argv[1]; *p; p++)
+ if(*p == '\\')
+ *p = '/';
+
+ if (strncmp(argv[1], "//", 2)) {
usage();
}
fstrcpy(host, &argv[1][2]);
- p = strchr(&host[2],'\\');
+ p = strchr(&host[2],'/');
if (!p) {
usage();
}