summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/rpc/dfs.c125
1 files changed, 83 insertions, 42 deletions
diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c
index eb6e0285b2..56b0febb4d 100644
--- a/source4/torture/rpc/dfs.c
+++ b/source4/torture/rpc/dfs.c
@@ -1,19 +1,19 @@
-/*
+/*
Unix SMB/CIFS implementation.
test suite for rpc dfs operations
Copyright (C) Andrew Tridgell 2003
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -43,7 +43,10 @@
return true;\
}\
-static bool test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *sharename, const char *dir)
+static bool test_NetShareAdd(TALLOC_CTX *mem_ctx,
+ const char *host,
+ const char *sharename,
+ const char *dir)
{
NTSTATUS status;
struct srvsvc_NetShareInfo2 i;
@@ -73,7 +76,7 @@ static bool test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *
status = libnet_AddShare(libnetctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("Failed to add new share: %s (%s)\n",
+ d_printf("Failed to add new share: %s (%s)\n",
nt_errstr(status), r.out.error_string);
return false;
}
@@ -81,7 +84,9 @@ static bool test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *
return true;
}
-static bool test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
+static bool test_NetShareDel(TALLOC_CTX *mem_ctx,
+ const char *host,
+ const char *sharename)
{
NTSTATUS status;
struct libnet_context* libnetctx;
@@ -100,7 +105,7 @@ static bool test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *
status = libnet_DelShare(libnetctx, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("Failed to delete share: %s (%s)\n",
+ d_printf("Failed to delete share: %s (%s)\n",
nt_errstr(status), r.out.error_string);
return false;
}
@@ -108,10 +113,10 @@ static bool test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *
return true;
}
-static bool test_CreateDir(TALLOC_CTX *mem_ctx,
- struct smbcli_state **cli,
- const char *host,
- const char *share,
+static bool test_CreateDir(TALLOC_CTX *mem_ctx,
+ struct smbcli_state **cli,
+ const char *host,
+ const char *share,
const char *dir)
{
printf("Creating directory %s\n", dir);
@@ -127,19 +132,23 @@ static bool test_CreateDir(TALLOC_CTX *mem_ctx,
return true;
}
-static bool test_DeleteDir(struct smbcli_state *cli, const char *dir)
+static bool test_DeleteDir(struct smbcli_state *cli,
+ const char *dir)
{
printf("Deleting directory %s\n", dir);
if (smbcli_deltree(cli->tree, dir) == -1) {
- printf("Unable to delete dir %s - %s\n", dir, smbcli_errstr(cli->tree));
+ printf("Unable to delete dir %s - %s\n", dir,
+ smbcli_errstr(cli->tree));
return false;
}
return true;
}
-static bool test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum dfs_ManagerVersion *version)
+static bool test_GetManagerVersion(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ enum dfs_ManagerVersion *version)
{
NTSTATUS status;
struct dfs_GetManagerVersion r;
@@ -155,7 +164,9 @@ static bool test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, e
return true;
}
-static bool test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
+static bool test_ManagerInitialize(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ const char *host)
{
NTSTATUS status;
enum dfs_ManagerVersion version;
@@ -175,7 +186,8 @@ static bool test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c
printf("ManagerInitialize failed - %s\n", nt_errstr(status));
return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("dfs_ManagerInitialize failed - %s\n", win_errstr(r.out.result));
+ printf("dfs_ManagerInitialize failed - %s\n",
+ win_errstr(r.out.result));
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result);
return false;
}
@@ -183,7 +195,9 @@ static bool test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c
return true;
}
-static bool test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level,
+static bool test_GetInfoLevel(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ uint16_t level,
const char *root)
{
NTSTATUS status;
@@ -200,7 +214,7 @@ static bool test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16
if (!NT_STATUS_IS_OK(status)) {
printf("GetInfo failed - %s\n", nt_errstr(status));
return false;
- } else if (!W_ERROR_IS_OK(r.out.result) &&
+ } else if (!W_ERROR_IS_OK(r.out.result) &&
!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) {
printf("dfs_GetInfo failed - %s\n", win_errstr(r.out.result));
return false;
@@ -209,7 +223,9 @@ static bool test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16
return true;
}
-static bool test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root)
+static bool test_GetInfo(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ const char *root)
{
bool ret = true;
/* 103, 104, 105, 106 is only available on Set */
@@ -224,7 +240,10 @@ static bool test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char
return ret;
}
-static bool test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, const char *dfs_name)
+static bool test_EnumLevelEx(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ uint16_t level,
+ const char *dfs_name)
{
NTSTATUS status;
struct dfs_EnumEx rex;
@@ -233,7 +252,7 @@ static bool test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
struct dfs_Info1 s;
struct dfs_EnumArray1 e1;
bool ret = true;
-
+
rex.in.level = level;
rex.in.bufsize = (uint32_t)-1;
rex.in.total = &total;
@@ -257,7 +276,8 @@ static bool test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
if (level == 1 && rex.out.total) {
int i;
for (i=0;i<*rex.out.total;i++) {
- const char *root = talloc_strdup(mem_ctx, rex.out.info->e.info1->s[i].path);
+ const char *root = talloc_strdup(mem_ctx,
+ rex.out.info->e.info1->s[i].path);
if (!test_GetInfo(p, mem_ctx, root)) {
ret = false;
}
@@ -268,9 +288,12 @@ static bool test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
int i,k;
for (i=0;i<*rex.out.total;i++) {
uint16_t levels[] = {1, 2, 3, 4, 200}; /* 300 */
- const char *root = talloc_strdup(mem_ctx, rex.out.info->e.info300->s[i].dom_root);
+ const char *root = talloc_strdup(mem_ctx,
+ rex.out.info->e.info300->s[i].dom_root);
for (k=0;k<ARRAY_SIZE(levels);k++) {
- if (!test_EnumLevelEx(p, mem_ctx, levels[k], root)) {
+ if (!test_EnumLevelEx(p, mem_ctx,
+ levels[k], root))
+ {
ret = false;
}
}
@@ -284,7 +307,9 @@ static bool test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_
}
-static bool test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level)
+static bool test_EnumLevel(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ uint16_t level)
{
NTSTATUS status;
struct dfs_Enum r;
@@ -293,7 +318,7 @@ static bool test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
struct dfs_Info1 s;
struct dfs_EnumArray1 e1;
bool ret = true;
-
+
r.in.level = level;
r.in.bufsize = (uint32_t)-1;
r.in.total = &total;
@@ -304,14 +329,14 @@ static bool test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
e.e.info1->count = 0;
e.e.info1->s = &s;
s.path = NULL;
-
+
printf("Testing Enum level %u\n", level);
status = dcerpc_dfs_Enum(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Enum failed - %s\n", nt_errstr(status));
return false;
- } else if (!W_ERROR_IS_OK(r.out.result) &&
+ } else if (!W_ERROR_IS_OK(r.out.result) &&
!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) {
printf("dfs_Enum failed - %s\n", win_errstr(r.out.result));
return false;
@@ -325,7 +350,7 @@ static bool test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t
ret = false;
}
}
-
+
}
return ret;
@@ -347,7 +372,9 @@ static bool test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
return ret;
}
-static bool test_EnumEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
+static bool test_EnumEx(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ const char *host)
{
bool ret = true;
uint16_t levels[] = {1, 2, 3, 4, 5, 6, 200, 300};
@@ -362,7 +389,10 @@ static bool test_EnumEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *
return ret;
}
-static bool test_RemoveStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
+static bool test_RemoveStdRoot(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ const char *host,
+ const char *sharename)
{
struct dfs_RemoveStdRoot r;
NTSTATUS status;
@@ -378,14 +408,18 @@ static bool test_RemoveStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const
printf("RemoveStdRoot failed - %s\n", nt_errstr(status));
return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("dfs_RemoveStdRoot failed - %s\n", win_errstr(r.out.result));
+ printf("dfs_RemoveStdRoot failed - %s\n",
+ win_errstr(r.out.result));
return false;
}
return true;
}
-static bool test_AddStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
+static bool test_AddStdRoot(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ const char *host,
+ const char *sharename)
{
NTSTATUS status;
struct dfs_AddStdRoot r;
@@ -402,14 +436,18 @@ static bool test_AddStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const ch
printf("AddStdRoot failed - %s\n", nt_errstr(status));
return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("dfs_AddStdRoot failed - %s\n", win_errstr(r.out.result));
+ printf("dfs_AddStdRoot failed - %s\n",
+ win_errstr(r.out.result));
return false;
}
return true;
}
-static bool test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename)
+static bool test_AddStdRootForced(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ const char *host,
+ const char *sharename)
{
NTSTATUS status;
struct dfs_AddStdRootForced r;
@@ -431,7 +469,8 @@ static bool test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, co
printf("AddStdRootForced failed - %s\n", nt_errstr(status));
return false;
} else if (!W_ERROR_IS_OK(r.out.result)) {
- printf("dfs_AddStdRootForced failed - %s\n", win_errstr(r.out.result));
+ printf("dfs_AddStdRootForced failed - %s\n",
+ win_errstr(r.out.result));
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result);
return false;
}
@@ -439,10 +478,10 @@ static bool test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, co
return test_RemoveStdRoot(p, mem_ctx, host, sharename);
}
-static void test_cleanup_stdroot(struct dcerpc_pipe *p,
- TALLOC_CTX *mem_ctx,
- const char *host,
- const char *sharename,
+static void test_cleanup_stdroot(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ const char *host,
+ const char *sharename,
const char *dir)
{
struct smbcli_state *cli;
@@ -456,7 +495,9 @@ static void test_cleanup_stdroot(struct dcerpc_pipe *p,
torture_close_connection(cli);
}
-static bool test_StdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host)
+static bool test_StdRoot(struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
+ const char *host)
{
const char *sharename = SMBTORTURE_DFS_SHARENAME;
const char *dir = SMBTORTURE_DFS_DIRNAME;