From 9182f0e6c5fd839acc42ae5e75402885dbefb1a6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 28 Oct 2003 11:00:54 +0000 Subject: Add RPC-OPEN test as an example for using the new dcerpc client code. It's a bit icky so I suspect it won't last long. (-: (This used to be commit bc17a4a8ade1b003acb5681471568a94e81aad08) --- source4/Makefile.in | 3 +- source4/torture/torture.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/Makefile.in b/source4/Makefile.in index daf8904212..f5c4edb2c2 100644 --- a/source4/Makefile.in +++ b/source4/Makefile.in @@ -525,7 +525,8 @@ SMBTORTURE_RAW_OBJ = torture/raw/qfsinfo.o torture/raw/qfileinfo.o torture/raw/s SMBTORTURE_OBJ1 = torture/torture.o torture/torture_util.o torture/nbio.o torture/scanner.o \ torture/utable.o torture/denytest.o torture/mangle_test.o \ - torture/aliases.o libcli/raw/clirewrite.o $(SMBTORTURE_RAW_OBJ) + torture/aliases.o libcli/raw/clirewrite.o $(SMBTORTURE_RAW_OBJ) \ + rpc_parse/parse_lsa.o SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) \ $(LIBSMB_OBJ) $(LIBDFS_OBJ) $(PARAM_OBJ) $(LIB_OBJ) diff --git a/source4/torture/torture.c b/source4/torture/torture.c index fe1bddcc2a..21c0647282 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -3755,6 +3755,84 @@ static BOOL run_deny3test(int dummy) return True; } +/* Helper function for RPC-OPEN test */ + +static DATA_BLOB blob_lsa_open_policy_req(TALLOC_CTX *mem_ctx, BOOL sec_qos, + uint32 des_access) +{ + prs_struct qbuf; + LSA_Q_OPEN_POL q; + LSA_SEC_QOS qos; + + ZERO_STRUCT(q); + + /* Initialise parse structures */ + + prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); + + /* Initialise input parameters */ + + if (sec_qos) { + init_lsa_sec_qos(&qos, 2, 1, 0); + init_q_open_pol(&q, '\\', 0, des_access, &qos); + } else { + init_q_open_pol(&q, '\\', 0, des_access, NULL); + } + + if (lsa_io_q_open_pol("", &q, &qbuf, 0)) + return data_blob_talloc( + mem_ctx, prs_data_p(&qbuf), prs_offset(&qbuf)); + + return data_blob(NULL, 0); +} + +static BOOL torture_rpc_open(int dummy) +{ + struct cli_state *cli; + const char *pipe_name = "\\lsarpc"; + int fnum; + TALLOC_CTX *mem_ctx; + NTSTATUS status; + struct cli_dcerpc_pipe *p; + DATA_BLOB request; + + mem_ctx = talloc_init("rpc_open"); + + printf("starting rpc test\n"); + + if (!torture_open_connection(&cli)) + return False; + + fnum = cli_nt_create_full(cli, pipe_name, 0, SA_RIGHT_FILE_READ_DATA, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE, + NTCREATEX_DISP_OPEN_IF, 0, 0); + + if (fnum == -1) { + printf("Open of pipe %s failed with error (%s)\n", + pipe_name, cli_errstr(cli)); + return False; + } + + if (!(p = cli_dcerpc_pipe_init(cli->tree))) + return False; + + p->fnum = fnum; + + status = cli_dcerpc_bind_byname(p, pipe_name); + + request = blob_lsa_open_policy_req(mem_ctx, True, + SEC_RIGHTS_MAXIMUM_ALLOWED); + + status = cli_dcerpc_request(p, LSA_OPENPOLICY, request); + + talloc_destroy(mem_ctx); + + torture_close_connection(cli); + + return True; +} static double create_procs(BOOL (*fn)(int), BOOL *result) { @@ -3939,6 +4017,7 @@ static struct { {"SCAN-NTTRANS", torture_nttrans_scan, 0}, {"SCAN-ALIASES", torture_trans2_aliases, 0}, {"SCAN-SMB", torture_smb_scan, 0}, + {"RPC-OPEN", torture_rpc_open, 0}, {NULL, NULL, 0}}; -- cgit