summaryrefslogtreecommitdiff
path: root/source4/torture/torture.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-10-28 11:00:54 +0000
committerTim Potter <tpot@samba.org>2003-10-28 11:00:54 +0000
commit9182f0e6c5fd839acc42ae5e75402885dbefb1a6 (patch)
tree6c5eaafce12d6491077229953f06df53b563394a /source4/torture/torture.c
parent4cac564d71f7387497fa23f2b6bcc0461a1978bc (diff)
downloadsamba-9182f0e6c5fd839acc42ae5e75402885dbefb1a6.tar.gz
samba-9182f0e6c5fd839acc42ae5e75402885dbefb1a6.tar.bz2
samba-9182f0e6c5fd839acc42ae5e75402885dbefb1a6.zip
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)
Diffstat (limited to 'source4/torture/torture.c')
-rw-r--r--source4/torture/torture.c79
1 files changed, 79 insertions, 0 deletions
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}};