diff options
author | Rafal Szczesniak <mimir@samba.org> | 2005-08-03 03:28:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:31:02 -0500 |
commit | d1743c93df5e4061110dbb5ace8a1dab58f90989 (patch) | |
tree | 4e851df1104d7f785dd56ca4fc74f870ef72d950 | |
parent | 916505f66197b8ed9d767ea45e13cb3fd8319ae7 (diff) | |
download | samba-d1743c93df5e4061110dbb5ace8a1dab58f90989.tar.gz samba-d1743c93df5e4061110dbb5ace8a1dab58f90989.tar.bz2 samba-d1743c93df5e4061110dbb5ace8a1dab58f90989.zip |
r8975: Very basic test for delshare function based on code submitted
by Gregory LEOCADIE <gleocadie@idealx.com>.
rafal
(This used to be commit 4d4d1ab37d68b6054b7b0459e2e7e86141f9b462)
-rw-r--r-- | source4/torture/libnet/libnet_share.c | 59 | ||||
-rw-r--r-- | source4/torture/torture.c | 1 |
2 files changed, 56 insertions, 4 deletions
diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c index d0214a102a..874f62d93c 100644 --- a/source4/torture/libnet/libnet_share.c +++ b/source4/torture/libnet/libnet_share.c @@ -161,30 +161,81 @@ done: } +BOOL test_addshare(struct dcerpc_pipe *pipe, TALLOC_CTX *mem_ctx, const char *host, + const char* share) +{ + NTSTATUS status; + struct srvsvc_NetShareAdd add; + struct srvsvc_NetShareInfo2 i; + + i.name = share; + i.type = STYPE_DISKTREE; + i.path = "C:\\WINDOWS\\TEMP"; + i.max_users = 5; + i.comment = "Comment to the test share"; + i.password = NULL; + i.permissions = 0x0; + + add.in.server_unc = host; + add.in.level = 2; + add.in.info.info2 = &i; + + status = dcerpc_srvsvc_NetShareAdd(pipe, mem_ctx, &add); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to add a new share\n"); + return False; + } + + printf("share added\n"); + return True; +} + + BOOL torture_delshare(void) { + struct dcerpc_pipe *p; + struct dcerpc_binding *bind; struct libnet_context* libnetctx; - const char* host; + const char *host, *binding; TALLOC_CTX *mem_ctx; NTSTATUS status; BOOL ret = True; struct libnet_DelShare share; mem_ctx = talloc_init("test_listshares"); - host = lp_parm_string(-1, "torture", "host"); + binding = lp_parm_string(-1, "torture", "binding"); + status = dcerpc_parse_binding(mem_ctx, binding, &bind); + if (!NT_STATUS_IS_OK(status)) { + printf("Error while parsing the binding string\n"); + ret = False; + goto done; + } libnetctx = libnet_context_init(NULL); libnetctx->cred = cmdline_credentials; - share.in.server_name = host; + status = torture_rpc_connection(mem_ctx, + &p, + DCERPC_SRVSVC_NAME, + DCERPC_SRVSVC_UUID, + DCERPC_SRVSVC_VERSION); + + if (!test_addshare(p, mem_ctx, host, TEST_SHARENAME)) { + ret = False; + goto done; + } + + share.in.server_name = bind->host; share.in.share_name = TEST_SHARENAME; status = libnet_DelShare(libnetctx, mem_ctx, &share); if (!NT_STATUS_IS_OK(status)) { ret = False; + goto done; } - talloc_free(mem_ctx); +done: + talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/torture.c b/source4/torture/torture.c index c25d808ee8..436c7281bd 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -2346,6 +2346,7 @@ static struct { {"NET-API-CREATEUSER", torture_createuser, 0}, {"NET-API-RPCCONNECT", torture_rpc_connect, 0}, {"NET-API-LISTSHARES", torture_listshares, 0}, + {"NET-API-DELSHARE", torture_delshare, 0}, {NULL, NULL, 0}}; |