diff options
Diffstat (limited to 'source4/torture/basic')
-rw-r--r-- | source4/torture/basic/base.c | 2 | ||||
-rw-r--r-- | source4/torture/basic/charset.c | 3 | ||||
-rw-r--r-- | source4/torture/basic/misc.c | 2 | ||||
-rw-r--r-- | source4/torture/basic/scanner.c | 222 | ||||
-rw-r--r-- | source4/torture/basic/utable.c | 5 |
5 files changed, 152 insertions, 82 deletions
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c index 24c0d292ac..cba57ac413 100644 --- a/source4/torture/basic/base.c +++ b/source4/torture/basic/base.c @@ -51,7 +51,7 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx) goto failed; } - if (!smbcli_socket_connect(cli, host, lp_name_resolve_order(tctx->lp_ctx), lp_max_xmit(tctx->lp_ctx), lp_maxmux(tctx->lp_ctx))) { + if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), lp_max_xmit(tctx->lp_ctx), lp_maxmux(tctx->lp_ctx))) { torture_comment(tctx, "Failed to connect with %s\n", host); goto failed; } diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c index 6b993aad8c..a5d534b92b 100644 --- a/source4/torture/basic/charset.c +++ b/source4/torture/basic/charset.c @@ -24,6 +24,7 @@ #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" #include "torture/util.h" +#include "param/param.h" #define BASEDIR "\\chartest\\" @@ -55,7 +56,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx, } SSVAL(ucs_name, i*2, 0); - i = convert_string_talloc(ucs_name, global_smb_iconv_convenience, CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname); + i = convert_string_talloc(ucs_name, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname); if (i == -1) { torture_comment(tctx, "Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n"); talloc_free(ucs_name); diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index e9a41e8299..0832556b53 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -815,7 +815,7 @@ static struct composite_context *torture_connect_async( torture_comment(tctx, "Open Connection to %s/%s\n",host,share); smb->in.dest_host=talloc_strdup(mem_ctx,host); smb->in.service=talloc_strdup(mem_ctx,share); - smb->in.port=0; + smb->in.dest_ports=lp_smb_ports(tctx->lp_ctx); smb->in.called_name = strupper_talloc(mem_ctx, host); smb->in.service_type=NULL; smb->in.credentials=cmdline_credentials; diff --git a/source4/torture/basic/scanner.c b/source4/torture/basic/scanner.c index 884be8490d..68fccc5010 100644 --- a/source4/torture/basic/scanner.c +++ b/source4/torture/basic/scanner.c @@ -23,11 +23,12 @@ #include "torture/util.h" #include "libcli/raw/libcliraw.h" #include "system/filesys.h" -#include "pstring.h" +#include "param/param.h" #define VERBOSE 0 #define OP_MIN 0 #define OP_MAX 100 +#define PARAM_SIZE 1024 /**************************************************************************** look for a partial hit @@ -81,12 +82,12 @@ static NTSTATUS try_trans2(struct smbcli_state *cli, *rdata_len = t2.out.data.length; talloc_free(mem_ctx); - + return status; } -static NTSTATUS try_trans2_len(struct smbcli_state *cli, +static NTSTATUS try_trans2_len(struct smbcli_state *cli, const char *format, int op, int level, uint8_t *param, uint8_t *data, @@ -96,14 +97,14 @@ static NTSTATUS try_trans2_len(struct smbcli_state *cli, NTSTATUS ret=NT_STATUS_OK; ret = try_trans2(cli, op, param, data, param_len, - sizeof(pstring), rparam_len, rdata_len); -#if VERBOSE + PARAM_SIZE, rparam_len, rdata_len); +#if VERBOSE printf("op=%d level=%d ret=%s\n", op, level, nt_errstr(ret)); #endif if (!NT_STATUS_IS_OK(ret)) return ret; *data_len = 0; - while (*data_len < sizeof(pstring)) { + while (*data_len < PARAM_SIZE) { ret = try_trans2(cli, op, param, data, param_len, *data_len, rparam_len, rdata_len); if (NT_STATUS_IS_OK(ret)) break; @@ -124,124 +125,162 @@ check whether a trans2 opnum exists at all ****************************************************************************/ static bool trans2_op_exists(struct smbcli_state *cli, int op) { - int data_len = 0; - int param_len = 0; + int data_len = PARAM_SIZE; + int param_len = PARAM_SIZE; int rparam_len, rdata_len; - uint8_t param[1024], data[1024]; + uint8_t *param, *data; NTSTATUS status1, status2; + TALLOC_CTX *mem_ctx; - memset(data, 0, sizeof(data)); - data_len = 4; + mem_ctx = talloc_init("trans2_op_exists"); /* try with a info level only */ - param_len = sizeof(param); - data_len = sizeof(data); - memset(param, 0xFF, sizeof(param)); - memset(data, 0xFF, sizeof(data)); - - status1 = try_trans2(cli, 0xFFFF, param, data, param_len, data_len, + param = talloc_array(mem_ctx, uint8_t, param_len); + data = talloc_array(mem_ctx, uint8_t, data_len); + + memset(param, 0xFF, param_len); + memset(data, 0xFF, data_len); + + status1 = try_trans2(cli, 0xFFFF, param, data, param_len, data_len, &rparam_len, &rdata_len); - status2 = try_trans2(cli, op, param, data, param_len, data_len, + status2 = try_trans2(cli, op, param, data, param_len, data_len, &rparam_len, &rdata_len); - if (NT_STATUS_EQUAL(status1, status2)) return false; + if (NT_STATUS_EQUAL(status1, status2)) { + talloc_free(mem_ctx); + return false; + } printf("Found op %d (status=%s)\n", op, nt_errstr(status2)); + talloc_free(mem_ctx); return true; } /**************************************************************************** check for existance of a trans2 call ****************************************************************************/ -static bool scan_trans2(struct smbcli_state *cli, int op, int level, +static bool scan_trans2(struct smbcli_state *cli, int op, int level, int fnum, int dnum, int qfnum, const char *fname) { int data_len = 0; int param_len = 0; int rparam_len, rdata_len; - uint8_t param[1024], data[1024]; + uint8_t *param, *data; NTSTATUS status; + TALLOC_CTX *mem_ctx; + + mem_ctx = talloc_init("scan_trans2"); + + data = talloc_array(mem_ctx, uint8_t, PARAM_SIZE); + param = talloc_array(mem_ctx, uint8_t, PARAM_SIZE); - memset(data, 0, sizeof(data)); + memset(data, 0, PARAM_SIZE); data_len = 4; /* try with a info level only */ param_len = 2; SSVAL(param, 0, level); - status = try_trans2_len(cli, "void", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; + status = try_trans2_len(cli, "void", op, level, param, data, param_len, + &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a file descriptor */ param_len = 6; SSVAL(param, 0, fnum); SSVAL(param, 2, level); SSVAL(param, 4, 0); - status = try_trans2_len(cli, "fnum", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; + status = try_trans2_len(cli, "fnum", op, level, param, data, param_len, + &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a quota file descriptor */ param_len = 6; SSVAL(param, 0, qfnum); SSVAL(param, 2, level); SSVAL(param, 4, 0); - status = try_trans2_len(cli, "qfnum", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; + status = try_trans2_len(cli, "qfnum", op, level, param, data, param_len, + &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a notify style */ param_len = 6; SSVAL(param, 0, dnum); SSVAL(param, 2, dnum); SSVAL(param, 4, level); - status = try_trans2_len(cli, "notify", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; + status = try_trans2_len(cli, "notify", op, level, param, data, + param_len, &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a file name */ param_len = 6; SSVAL(param, 0, level); SSVAL(param, 2, 0); SSVAL(param, 4, 0); - param_len += push_string(global_smb_iconv_convenience, ¶m[6], fname, sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), + ¶m[6], fname, PARAM_SIZE-7, + STR_TERMINATE|STR_UNICODE); - status = try_trans2_len(cli, "fname", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; + status = try_trans2_len(cli, "fname", op, level, param, data, param_len, + &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a new file name */ param_len = 6; SSVAL(param, 0, level); SSVAL(param, 2, 0); SSVAL(param, 4, 0); - param_len += push_string(global_smb_iconv_convenience, ¶m[6], "\\newfile.dat", sizeof(pstring)-7, STR_TERMINATE|STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), + ¶m[6], "\\newfile.dat", PARAM_SIZE-7, + STR_TERMINATE|STR_UNICODE); - status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); + status = try_trans2_len(cli, "newfile", op, level, param, data, + param_len, &data_len, &rparam_len, &rdata_len); smbcli_unlink(cli->tree, "\\newfile.dat"); smbcli_rmdir(cli->tree, "\\newfile.dat"); - if (NT_STATUS_IS_OK(status)) return true; + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try dfs style */ smbcli_mkdir(cli->tree, "\\testdir"); param_len = 2; SSVAL(param, 0, level); - param_len += push_string(global_smb_iconv_convenience, ¶m[2], "\\testdir", sizeof(pstring)-3, STR_TERMINATE|STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), + ¶m[2], "\\testdir", PARAM_SIZE-3, + STR_TERMINATE|STR_UNICODE); - status = try_trans2_len(cli, "dfs", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); + status = try_trans2_len(cli, "dfs", op, level, param, data, param_len, + &data_len, &rparam_len, &rdata_len); smbcli_rmdir(cli->tree, "\\testdir"); - if (NT_STATUS_IS_OK(status)) return true; + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } + talloc_free(mem_ctx); return false; } - -bool torture_trans2_scan(struct torture_context *torture, +bool torture_trans2_scan(struct torture_context *torture, struct smbcli_state *cli) { int op, level; @@ -361,7 +400,7 @@ static NTSTATUS try_nttrans(struct smbcli_state *cli, } -static NTSTATUS try_nttrans_len(struct smbcli_state *cli, +static NTSTATUS try_nttrans_len(struct smbcli_state *cli, const char *format, int op, int level, uint8_t *param, uint8_t *data, @@ -371,14 +410,14 @@ static NTSTATUS try_nttrans_len(struct smbcli_state *cli, NTSTATUS ret=NT_STATUS_OK; ret = try_nttrans(cli, op, param, data, param_len, - sizeof(pstring), rparam_len, rdata_len); -#if VERBOSE + PARAM_SIZE, rparam_len, rdata_len); +#if VERBOSE printf("op=%d level=%d ret=%s\n", op, level, nt_errstr(ret)); #endif if (!NT_STATUS_IS_OK(ret)) return ret; *data_len = 0; - while (*data_len < sizeof(pstring)) { + while (*data_len < PARAM_SIZE) { ret = try_nttrans(cli, op, param, data, param_len, *data_len, rparam_len, rdata_len); if (NT_STATUS_IS_OK(ret)) break; @@ -396,79 +435,108 @@ static NTSTATUS try_nttrans_len(struct smbcli_state *cli, /**************************************************************************** check for existance of a nttrans call ****************************************************************************/ -static bool scan_nttrans(struct smbcli_state *cli, int op, int level, +static bool scan_nttrans(struct smbcli_state *cli, int op, int level, int fnum, int dnum, const char *fname) { int data_len = 0; int param_len = 0; int rparam_len, rdata_len; - uint8_t param[1024], data[1024]; + uint8_t *param, *data; NTSTATUS status; + TALLOC_CTX *mem_ctx; - memset(data, 0, sizeof(data)); + mem_ctx = talloc_init("scan_nttrans"); + + param = talloc_array(mem_ctx, uint8_t, PARAM_SIZE); + data = talloc_array(mem_ctx, uint8_t, PARAM_SIZE); + memset(data, 0, PARAM_SIZE); data_len = 4; /* try with a info level only */ param_len = 2; SSVAL(param, 0, level); - status = try_nttrans_len(cli, "void", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; + status = try_nttrans_len(cli, "void", op, level, param, data, param_len, + &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a file descriptor */ param_len = 6; SSVAL(param, 0, fnum); SSVAL(param, 2, level); SSVAL(param, 4, 0); - status = try_nttrans_len(cli, "fnum", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; - + status = try_nttrans_len(cli, "fnum", op, level, param, data, param_len, + &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a notify style */ param_len = 6; SSVAL(param, 0, dnum); SSVAL(param, 2, dnum); SSVAL(param, 4, level); - status = try_nttrans_len(cli, "notify", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; + status = try_nttrans_len(cli, "notify", op, level, param, data, + param_len, &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a file name */ param_len = 6; SSVAL(param, 0, level); SSVAL(param, 2, 0); SSVAL(param, 4, 0); - param_len += push_string(global_smb_iconv_convenience, ¶m[6], fname, sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), + ¶m[6], fname, PARAM_SIZE, + STR_TERMINATE | STR_UNICODE); - status = try_nttrans_len(cli, "fname", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return true; + status = try_nttrans_len(cli, "fname", op, level, param, data, + param_len, &data_len, &rparam_len, &rdata_len); + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try with a new file name */ param_len = 6; SSVAL(param, 0, level); SSVAL(param, 2, 0); SSVAL(param, 4, 0); - param_len += push_string(global_smb_iconv_convenience, ¶m[6], "\\newfile.dat", sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), + ¶m[6], "\\newfile.dat", PARAM_SIZE, + STR_TERMINATE | STR_UNICODE); - status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); + status = try_nttrans_len(cli, "newfile", op, level, param, data, + param_len, &data_len, &rparam_len, &rdata_len); smbcli_unlink(cli->tree, "\\newfile.dat"); smbcli_rmdir(cli->tree, "\\newfile.dat"); - if (NT_STATUS_IS_OK(status)) return true; + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } /* try dfs style */ smbcli_mkdir(cli->tree, "\\testdir"); param_len = 2; SSVAL(param, 0, level); - param_len += push_string(global_smb_iconv_convenience, ¶m[2], "\\testdir", sizeof(pstring), STR_TERMINATE | STR_UNICODE); + param_len += push_string(lp_iconv_convenience(global_loadparm), + ¶m[2], "\\testdir", PARAM_SIZE, + STR_TERMINATE | STR_UNICODE); - status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len, &data_len, - &rparam_len, &rdata_len); + status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len, + &data_len, &rparam_len, &rdata_len); smbcli_rmdir(cli->tree, "\\testdir"); - if (NT_STATUS_IS_OK(status)) return true; + if (NT_STATUS_IS_OK(status)) { + talloc_free(mem_ctx); + return true; + } + talloc_free(mem_ctx); return false; } diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c index 244378dbc9..112cf323a1 100644 --- a/source4/torture/basic/utable.c +++ b/source4/torture/basic/utable.c @@ -24,6 +24,7 @@ #include "libcli/libcli.h" #include "torture/util.h" #include "pstring.h" +#include "param/param.h" bool torture_utable(struct torture_context *tctx, struct smbcli_state *cli) @@ -49,7 +50,7 @@ bool torture_utable(struct torture_context *tctx, SSVAL(c2, 0, c); fstrcpy(fname, "\\utable\\x"); p = fname+strlen(fname); - len = convert_string(global_smb_iconv_convenience, CH_UTF16, CH_UNIX, + len = convert_string(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, c2, 2, p, sizeof(fname)-strlen(fname)); p[len] = 0; @@ -108,7 +109,7 @@ static char *form_name(int c) p = fname+strlen(fname); SSVAL(c2, 0, c); - len = convert_string(global_smb_iconv_convenience, CH_UTF16, CH_UNIX, + len = convert_string(lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, c2, 2, p, sizeof(fname)-strlen(fname)); p[len] = 0; |