1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

added the dfs_GetInfo all - all levels

This commit is contained in:
Andrew Tridgell 0001-01-01 00:00:00 +00:00
parent e66daf5273
commit 638eae6bae
7 changed files with 867 additions and 406 deletions

View File

@ -17,11 +17,11 @@
/******************/
/* Function: 0x01 */
NTSTATUS dfs_Add (
[in] unistr *path,
[in] unistr *server,
[in] unistr *share,
[in] unistr *comment,
[in] uint32 flags
[in,ref] unistr *path,
[in,ref] unistr *server,
[in] unistr *share,
[in] unistr *comment,
[in] uint32 flags
);
/******************/
@ -38,25 +38,11 @@
/******************/
/* Function: 0x04 */
NTSTATUS dfs_Info (
[in,ref] unistr_noterm *path,
[in] unistr *server,
[in] unistr *share,
[in] uint16 level
);
/******************/
/* Function: 0x05 */
typedef struct {
unistr *path;
} dfs_Info1;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info1 *s;
} dfs_EnumArray1;
typedef struct {
unistr *path;
unistr *comment;
@ -64,11 +50,6 @@
uint32 num_stores;
} dfs_Info2;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info2 *s;
} dfs_EnumArray2;
typedef struct {
uint32 state;
unistr *server;
@ -83,11 +64,6 @@
[size_is(num_stores)] dfs_StorageInfo *stores;
} dfs_Info3;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info3 *s;
} dfs_EnumArray3;
typedef struct {
unistr *path;
unistr *comment;
@ -99,24 +75,74 @@
} dfs_Info4;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info4 *s;
} dfs_EnumArray4;
unistr *comment;
} dfs_Info100;
typedef struct {
uint32 state;
} dfs_Info101;
typedef struct {
uint32 timeout;
} dfs_Info102;
typedef struct {
unistr *dom_root;
} dfs_Info200;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info200 *s;
} dfs_EnumArray200;
typedef struct {
uint32 flags;
unistr *dom_root;
} dfs_Info300;
typedef union {
case(1) dfs_Info1 *info1;
case(2) dfs_Info2 *info2;
case(3) dfs_Info3 *info3;
case(4) dfs_Info4 *info4;
case(100) dfs_Info100 *info100;
case(101) dfs_Info101 *info101;
case(102) dfs_Info102 *info102;
case(200) dfs_Info200 *info200;
case(300) dfs_Info300 *info300;
} dfs_Info;
NTSTATUS dfs_GetInfo (
[in,ref] unistr *path,
[in] unistr *server,
[in] unistr *share,
[in] uint32 level,
[out,switch_is(level)] dfs_Info info
);
/******************/
/* Function: 0x05 */
typedef struct {
uint32 count;
[size_is(count)] dfs_Info1 *s;
} dfs_EnumArray1;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info2 *s;
} dfs_EnumArray2;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info3 *s;
} dfs_EnumArray3;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info4 *s;
} dfs_EnumArray4;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info200 *s;
} dfs_EnumArray200;
typedef struct {
uint32 count;
[size_is(count)] dfs_Info300 *s;

File diff suppressed because it is too large Load Diff

View File

@ -48,29 +48,10 @@ struct dfs_UNKNOWN3 {
};
struct dfs_Info {
struct {
const char *path;
const char *server;
const char *share;
uint16 level;
} in;
struct {
NTSTATUS result;
} out;
};
struct dfs_Info1 {
const char *path;
};
struct dfs_EnumArray1 {
uint32 count;
struct dfs_Info1 *s;
};
struct dfs_Info2 {
const char *path;
const char *comment;
@ -78,11 +59,6 @@ struct dfs_Info2 {
uint32 num_stores;
};
struct dfs_EnumArray2 {
uint32 count;
struct dfs_Info2 *s;
};
struct dfs_StorageInfo {
uint32 state;
const char *server;
@ -97,11 +73,6 @@ struct dfs_Info3 {
struct dfs_StorageInfo *stores;
};
struct dfs_EnumArray3 {
uint32 count;
struct dfs_Info3 *s;
};
struct dfs_Info4 {
const char *path;
const char *comment;
@ -112,25 +83,79 @@ struct dfs_Info4 {
struct dfs_StorageInfo *stores;
};
struct dfs_EnumArray4 {
uint32 count;
struct dfs_Info4 *s;
struct dfs_Info100 {
const char *comment;
};
struct dfs_Info101 {
uint32 state;
};
struct dfs_Info102 {
uint32 timeout;
};
struct dfs_Info200 {
const char *dom_root;
};
struct dfs_EnumArray200 {
uint32 count;
struct dfs_Info200 *s;
};
struct dfs_Info300 {
uint32 flags;
const char *dom_root;
};
union dfs_Info {
/* [case(1)] */ struct dfs_Info1 *info1;
/* [case(2)] */ struct dfs_Info2 *info2;
/* [case(3)] */ struct dfs_Info3 *info3;
/* [case(4)] */ struct dfs_Info4 *info4;
/* [case(100)] */ struct dfs_Info100 *info100;
/* [case(101)] */ struct dfs_Info101 *info101;
/* [case(102)] */ struct dfs_Info102 *info102;
/* [case(200)] */ struct dfs_Info200 *info200;
/* [case(300)] */ struct dfs_Info300 *info300;
};
struct dfs_GetInfo {
struct {
const char *path;
const char *server;
const char *share;
uint32 level;
} in;
struct {
union dfs_Info info;
NTSTATUS result;
} out;
};
struct dfs_EnumArray1 {
uint32 count;
struct dfs_Info1 *s;
};
struct dfs_EnumArray2 {
uint32 count;
struct dfs_Info2 *s;
};
struct dfs_EnumArray3 {
uint32 count;
struct dfs_Info3 *s;
};
struct dfs_EnumArray4 {
uint32 count;
struct dfs_Info4 *s;
};
struct dfs_EnumArray200 {
uint32 count;
struct dfs_Info200 *s;
};
struct dfs_EnumArray300 {
uint32 count;
struct dfs_Info300 *s;
@ -171,5 +196,5 @@ struct dfs_Enum {
#define DCERPC_DFS_ADD 1
#define DCERPC_DFS_REMOVE 2
#define DCERPC_DFS_UNKNOWN3 3
#define DCERPC_DFS_INFO 4
#define DCERPC_DFS_GETINFO 4
#define DCERPC_DFS_ENUM 5

View File

@ -171,13 +171,13 @@ static NTSTATUS ndr_pull_Struct1(struct ndr_pull *ndr, int ndr_flags, struct Str
NDR_CHECK(ndr_pull_uint32(ndr, &r->level));
{ uint16 _level;
NDR_CHECK(ndr_pull_echo_EnumInfo(ndr, NDR_SCALARS, &_level, &r->e));
if (_level != r->level) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in e");
if (((NDR_SCALARS) & NDR_SCALARS) && (_level != r->level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in e");
}
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
{ uint16 _level;
NDR_CHECK(ndr_pull_echo_EnumInfo(ndr, NDR_BUFFERS, &_level, &r->e));
if (_level != r->level) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in e");
if (((NDR_BUFFERS) & NDR_SCALARS) && (_level != r->level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in e");
}
done:
return NT_STATUS_OK;

View File

@ -107,7 +107,7 @@ buffers:
NDR_CHECK(ndr_push_security_descriptor(ndr, r->sec_desc));
}
if (r->sec_qos) {
NDR_CHECK(ndr_push_lsa_QosInfo(ndr, ndr_flags, r->sec_qos));
NDR_CHECK(ndr_push_lsa_QosInfo(ndr, NDR_SCALARS|NDR_BUFFERS, r->sec_qos));
}
ndr_push_save(ndr, &_save3);
ndr_push_restore(ndr, &_save2);
@ -263,7 +263,7 @@ static NTSTATUS ndr_push_lsa_TranslatedName(struct ndr_push *ndr, int ndr_flags,
NDR_CHECK(ndr_push_uint32(ndr, r->sid_index));
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_push_lsa_Name(ndr, ndr_flags, &r->name));
NDR_CHECK(ndr_push_lsa_Name(ndr, NDR_BUFFERS, &r->name));
done:
return NT_STATUS_OK;
}
@ -553,7 +553,7 @@ static NTSTATUS ndr_pull_lsa_PrivEntry(struct ndr_pull *ndr, int ndr_flags, stru
NDR_CHECK(ndr_pull_uint32(ndr, &r->luid_high));
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name));
done:
return NT_STATUS_OK;
}
@ -695,7 +695,7 @@ static NTSTATUS ndr_pull_lsa_DomainInfo(struct ndr_pull *ndr, int ndr_flags, str
}
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name));
if (r->sid) {
NDR_CHECK(ndr_pull_dom_sid2(ndr, r->sid));
}
@ -710,7 +710,7 @@ static NTSTATUS ndr_pull_lsa_PDAccountInfo(struct ndr_pull *ndr, int ndr_flags,
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name));
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name));
done:
return NT_STATUS_OK;
}
@ -734,8 +734,8 @@ static NTSTATUS ndr_pull_lsa_ReplicaSourceInfo(struct ndr_pull *ndr, int ndr_fla
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->account));
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->source));
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->account));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->source));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->account));
done:
return NT_STATUS_OK;
}
@ -808,10 +808,10 @@ static NTSTATUS ndr_pull_lsa_DnsDomainInfo(struct ndr_pull *ndr, int ndr_flags,
}
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->dns_domain));
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->dns_forest));
NDR_CHECK(ndr_pull_GUID(ndr, ndr_flags, &r->domain_guid));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->dns_domain));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->dns_forest));
NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->domain_guid));
if (r->sid) {
NDR_CHECK(ndr_pull_dom_sid2(ndr, r->sid));
}
@ -945,7 +945,7 @@ NTSTATUS ndr_pull_lsa_QueryInfoPolicy(struct ndr_pull *ndr, struct lsa_QueryInfo
if (r->out.info) {
{ uint16 _level;
NDR_CHECK(ndr_pull_lsa_PolicyInformation(ndr, NDR_SCALARS|NDR_BUFFERS, &_level, r->out.info));
if (_level != r->in.level) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in info");
if (((NDR_SCALARS|NDR_BUFFERS) & NDR_SCALARS) && (_level != r->in.level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in info");
}
}
NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result));
@ -1053,7 +1053,7 @@ static NTSTATUS ndr_pull_lsa_DomainInformation(struct ndr_pull *ndr, int ndr_fla
}
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name));
if (r->sid) {
NDR_CHECK(ndr_pull_dom_sid2(ndr, r->sid));
}
@ -1155,7 +1155,7 @@ static NTSTATUS ndr_pull_lsa_TrustInformation(struct ndr_pull *ndr, int ndr_flag
}
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name));
if (r->sid) {
NDR_CHECK(ndr_pull_dom_sid2(ndr, r->sid));
}
@ -1221,7 +1221,7 @@ static NTSTATUS ndr_pull_lsa_TranslatedName(struct ndr_pull *ndr, int ndr_flags,
NDR_CHECK(ndr_pull_uint32(ndr, &r->sid_index));
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name));
done:
return NT_STATUS_OK;
}
@ -1309,7 +1309,7 @@ static NTSTATUS ndr_pull_lsa_LUIDAttribute(struct ndr_pull *ndr, int ndr_flags,
NDR_CHECK(ndr_pull_uint32(ndr, &r->attribute));
buffers:
if (!(ndr_flags & NDR_BUFFERS)) goto done;
NDR_CHECK(ndr_pull_lsa_LUID(ndr, ndr_flags, &r->luid));
NDR_CHECK(ndr_pull_lsa_LUID(ndr, NDR_BUFFERS, &r->luid));
done:
return NT_STATUS_OK;
}

View File

@ -53,12 +53,12 @@ NTSTATUS dcerpc_dfs_UNKNOWN3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct
return r->out.result;
}
NTSTATUS dcerpc_dfs_Info(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct dfs_Info *r)
NTSTATUS dcerpc_dfs_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct dfs_GetInfo *r)
{
NTSTATUS status;
status = dcerpc_ndr_request(p, DCERPC_DFS_INFO, mem_ctx,
(ndr_push_fn_t) ndr_push_dfs_Info,
(ndr_pull_fn_t) ndr_pull_dfs_Info,
status = dcerpc_ndr_request(p, DCERPC_DFS_GETINFO, mem_ctx,
(ndr_push_fn_t) ndr_push_dfs_GetInfo,
(ndr_pull_fn_t) ndr_pull_dfs_GetInfo,
r);
if (!NT_STATUS_IS_OK(status)) {
return status;

View File

@ -41,6 +41,43 @@ static BOOL test_Exist(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
return True;
}
static BOOL test_InfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16 level,
const char *root)
{
NTSTATUS status;
struct dfs_GetInfo r;
r.in.path = root;
r.in.server = NULL;
r.in.share = NULL;
r.in.level = level;
printf("Testing GetInfo level %u on '%s'\n", level, root);
status = dcerpc_dfs_GetInfo(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("Info failed - %s\n", nt_errstr(status));
return False;
}
NDR_PRINT_UNION_DEBUG(dfs_Info, r.in.level, &r.out.info);
return True;
}
static BOOL test_Info(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root)
{
BOOL ret = True;
uint16 levels[] = {1, 2, 3, 4, 100, 101, 102, 200, 300};
int i;
for (i=0;i<ARRAY_SIZE(levels);i++) {
if (!test_InfoLevel(p, mem_ctx, levels[i], root)) {
ret = False;
}
}
return ret;
}
static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16 level)
{
NTSTATUS status;
@ -49,6 +86,7 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16 le
struct dfs_EnumStruct e;
struct dfs_Info1 s;
struct dfs_EnumArray1 e1;
BOOL ret = True;
r.in.level = level;
r.in.bufsize = (uint32)-1;
@ -72,9 +110,21 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16 le
NDR_PRINT_DEBUG(dfs_EnumStruct, r.out.info);
return True;
if (level == 1 && r.out.total) {
int i;
for (i=0;i<*r.out.total;i++) {
const char *root = r.out.info->e.info1->s[i].path;
if (!test_Info(p, mem_ctx, root)) {
ret = False;
}
}
}
return ret;
}
static BOOL test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
BOOL ret = True;
@ -88,6 +138,39 @@ static BOOL test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
return ret;
}
static BOOL test_Add(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
struct dfs_Add add;
struct dfs_Remove rem;
add.in.path = "\\\\win2003\\2nd root\\test";
add.in.server = "win2003";
add.in.share = "e$";
add.in.comment = "a test comment";
add.in.flags = 1;
status = dcerpc_dfs_Add(p, mem_ctx, &add);
if (!NT_STATUS_IS_OK(status)) {
printf("Add failed - %s\n", nt_errstr(status));
return False;
}
rem.in.path = add.in.path;
rem.in.server = add.in.server;
rem.in.share = add.in.share;
status = dcerpc_dfs_Remove(p, mem_ctx, &rem);
if (!NT_STATUS_IS_OK(status)) {
printf("Add failed - %s\n", nt_errstr(status));
return False;
}
return True;
}
BOOL torture_rpc_dfs(int dummy)
{
NTSTATUS status;
@ -106,6 +189,12 @@ BOOL torture_rpc_dfs(int dummy)
ret = False;
}
#if 0
if (!test_Add(p, mem_ctx)) {
ret = False;
}
#endif
if (!test_Enum(p, mem_ctx)) {
ret = False;
}