summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-07-06 08:00:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:49 -0500
commitaf0a9eb52955cfae570bfdc01821f56385c860cf (patch)
tree9a798fd727753c3d9ceb44512579dc5b3e7fbebf /source4/libcli
parent51e0ae33acf3cd09ae0eb9ef5077cecab4780a3e (diff)
downloadsamba-af0a9eb52955cfae570bfdc01821f56385c860cf.tar.gz
samba-af0a9eb52955cfae570bfdc01821f56385c860cf.tar.bz2
samba-af0a9eb52955cfae570bfdc01821f56385c860cf.zip
r16834: split the level's of smb_search_first/smb_search_next and the levels
of smb_search_data metze (This used to be commit 78c201db8a47a71908698c4dda2add4cf85694d9)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/clilist.c57
-rw-r--r--source4/libcli/raw/interfaces.h74
-rw-r--r--source4/libcli/raw/rawsearch.c120
-rw-r--r--source4/libcli/smb2/find.c14
4 files changed, 156 insertions, 109 deletions
diff --git a/source4/libcli/clilist.c b/source4/libcli/clilist.c
index f18ec84db9..16986e9428 100644
--- a/source4/libcli/clilist.c
+++ b/source4/libcli/clilist.c
@@ -29,7 +29,7 @@ struct search_private {
int dirlist_len;
int ff_searchcount; /* total received in 1 server trip */
int total_received; /* total received all together */
- enum smb_search_level info_level;
+ enum smb_search_data_level data_level;
const char *last_name; /* used to continue trans2 search */
struct smb_search_id id; /* used for old-style search */
};
@@ -38,7 +38,7 @@ struct search_private {
/****************************************************************************
Interpret a long filename structure.
****************************************************************************/
-static BOOL interpret_long_filename(enum smb_search_level level,
+static BOOL interpret_long_filename(enum smb_search_data_level level,
union smb_search_data *info,
struct clilist_file_info *finfo)
{
@@ -48,7 +48,7 @@ static BOOL interpret_long_filename(enum smb_search_level level,
ZERO_STRUCTP(finfo);
switch (level) {
- case RAW_SEARCH_STANDARD:
+ case RAW_SEARCH_DATA_STANDARD:
finfo->size = info->standard.size;
finfo->mtime = info->standard.write_time;
finfo->attrib = info->standard.attrib;
@@ -56,7 +56,7 @@ static BOOL interpret_long_filename(enum smb_search_level level,
finfo->short_name = info->standard.name.s;
break;
- case RAW_SEARCH_BOTH_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO:
finfo->size = info->both_directory_info.size;
finfo->mtime = nt_time_to_unix(info->both_directory_info.write_time);
finfo->attrib = info->both_directory_info.attrib;
@@ -89,7 +89,7 @@ static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file)
state->dirlist = tdl;
state->dirlist_len++;
- interpret_long_filename(state->info_level, file, &state->dirlist[state->total_received]);
+ interpret_long_filename(state->data_level, file, &state->dirlist[state->total_received]);
state->last_name = state->dirlist[state->total_received].name;
state->total_received++;
@@ -99,7 +99,7 @@ static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file)
}
int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute,
- enum smb_search_level level,
+ enum smb_search_data_level level,
void (*fn)(struct clilist_file_info *, const char *, void *),
void *caller_state)
{
@@ -122,21 +122,22 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
state.dirlist = talloc_new(state.mem_ctx);
mask = talloc_strdup(state.mem_ctx, Mask);
- if (level == RAW_SEARCH_GENERIC) {
+ if (level == RAW_SEARCH_DATA_GENERIC) {
if (tree->session->transport->negotiate.capabilities & CAP_NT_SMBS) {
- level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
+ level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO;
} else {
- level = RAW_SEARCH_STANDARD;
+ level = RAW_SEARCH_DATA_STANDARD;
}
}
- state.info_level = level;
+ state.data_level = level;
while (1) {
state.ff_searchcount = 0;
if (first) {
NTSTATUS status;
- first_parms.t2ffirst.level = state.info_level;
+ first_parms.t2ffirst.level = RAW_SEARCH_TRANS2;
+ first_parms.t2ffirst.data_level = state.data_level;
first_parms.t2ffirst.in.max_count = max_matches;
first_parms.t2ffirst.in.search_attrib = attribute;
first_parms.t2ffirst.in.pattern = mask;
@@ -162,7 +163,8 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
} else {
NTSTATUS status;
- next_parms.t2fnext.level = state.info_level;
+ next_parms.t2fnext.level = RAW_SEARCH_TRANS2;
+ next_parms.t2fnext.data_level = state.data_level;
next_parms.t2fnext.in.max_count = max_matches;
next_parms.t2fnext.in.last_name = state.last_name;
next_parms.t2fnext.in.handle = ff_dir_handle;
@@ -201,20 +203,29 @@ int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
Interpret a short filename structure.
The length of the structure is returned.
****************************************************************************/
-static BOOL interpret_short_filename(int level,
- union smb_search_data *info,
- struct clilist_file_info *finfo)
+static BOOL interpret_short_filename(enum smb_search_data_level level,
+ union smb_search_data *info,
+ struct clilist_file_info *finfo)
{
struct clilist_file_info finfo2;
if (!finfo) finfo = &finfo2;
ZERO_STRUCTP(finfo);
+
+ switch (level) {
+ case RAW_SEARCH_DATA_SEARCH:
+ finfo->mtime = info->search.write_time;
+ finfo->size = info->search.size;
+ finfo->attrib = info->search.attrib;
+ finfo->name = info->search.name;
+ finfo->short_name = info->search.name;
+ break;
+
+ default:
+ DEBUG(0,("Unhandled level %d in interpret_short_filename\n", (int)level));
+ return False;
+ }
- finfo->mtime = info->search.write_time;
- finfo->size = info->search.size;
- finfo->attrib = info->search.attrib;
- finfo->name = info->search.name;
- finfo->short_name = info->search.name;
return True;
}
@@ -236,7 +247,7 @@ static BOOL smbcli_list_old_callback(void *private, union smb_search_data *file)
state->dirlist = tdl;
state->dirlist_len++;
- interpret_short_filename(state->info_level, file, &state->dirlist[state->total_received]);
+ interpret_short_filename(state->data_level, file, &state->dirlist[state->total_received]);
state->total_received++;
state->ff_searchcount++;
@@ -273,6 +284,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
NTSTATUS status;
first_parms.search_first.level = RAW_SEARCH_SEARCH;
+ first_parms.search_first.data_level = RAW_SEARCH_DATA_SEARCH;
first_parms.search_first.in.max_count = num_asked;
first_parms.search_first.in.search_attrib = attribute;
first_parms.search_first.in.pattern = mask;
@@ -294,6 +306,7 @@ int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribu
NTSTATUS status;
next_parms.search_next.level = RAW_SEARCH_SEARCH;
+ next_parms.search_next.data_level = RAW_SEARCH_DATA_SEARCH;
next_parms.search_next.in.max_count = num_asked;
next_parms.search_next.in.search_attrib = attribute;
next_parms.search_next.in.id = state.id;
@@ -336,5 +349,5 @@ int smbcli_list(struct smbcli_tree *tree, const char *Mask,uint16_t attribute,
{
if (tree->session->transport->negotiate.protocol <= PROTOCOL_LANMAN1)
return smbcli_list_old(tree, Mask, attribute, fn, state);
- return smbcli_list_new(tree, Mask, attribute, RAW_SEARCH_GENERIC, fn, state);
+ return smbcli_list_new(tree, Mask, attribute, RAW_SEARCH_DATA_GENERIC, fn, state);
}
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index c581978b81..f77d31a1c7 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -2146,33 +2146,41 @@ struct smb_notify {
} out;
};
-enum smb_search_level {RAW_SEARCH_GENERIC = 0xF000,
- RAW_SEARCH_SEARCH, /* SMBsearch */
- RAW_SEARCH_FFIRST, /* SMBffirst */
- RAW_SEARCH_FUNIQUE, /* SMBfunique */
- RAW_SEARCH_SMB2, /* SMB2 Find */
- RAW_SEARCH_STANDARD = SMB_FIND_STANDARD,
- RAW_SEARCH_EA_SIZE = SMB_FIND_EA_SIZE,
- RAW_SEARCH_EA_LIST = SMB_FIND_EA_LIST,
- RAW_SEARCH_DIRECTORY_INFO = SMB_FIND_DIRECTORY_INFO,
- RAW_SEARCH_FULL_DIRECTORY_INFO = SMB_FIND_FULL_DIRECTORY_INFO,
- RAW_SEARCH_NAME_INFO = SMB_FIND_NAME_INFO,
- RAW_SEARCH_BOTH_DIRECTORY_INFO = SMB_FIND_BOTH_DIRECTORY_INFO,
- RAW_SEARCH_ID_FULL_DIRECTORY_INFO = SMB_FIND_ID_FULL_DIRECTORY_INFO,
- RAW_SEARCH_ID_BOTH_DIRECTORY_INFO = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
- RAW_SEARCH_UNIX_INFO = SMB_FIND_UNIX_INFO};
+enum smb_search_level {
+ RAW_SEARCH_SEARCH, /* SMBsearch */
+ RAW_SEARCH_FFIRST, /* SMBffirst */
+ RAW_SEARCH_FUNIQUE, /* SMBfunique */
+ RAW_SEARCH_TRANS2, /* SMBtrans2 */
+ RAW_SEARCH_SMB2 /* SMB2 Find */
+};
+enum smb_search_data_level {
+ RAW_SEARCH_DATA_GENERIC = 0x10000, /* only used in the smbcli_ code */
+ RAW_SEARCH_DATA_SEARCH,
+ RAW_SEARCH_DATA_STANDARD = SMB_FIND_STANDARD,
+ RAW_SEARCH_DATA_EA_SIZE = SMB_FIND_EA_SIZE,
+ RAW_SEARCH_DATA_EA_LIST = SMB_FIND_EA_LIST,
+ RAW_SEARCH_DATA_DIRECTORY_INFO = SMB_FIND_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_FULL_DIRECTORY_INFO = SMB_FIND_FULL_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_NAME_INFO = SMB_FIND_NAME_INFO,
+ RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO = SMB_FIND_BOTH_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO = SMB_FIND_ID_FULL_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO = SMB_FIND_ID_BOTH_DIRECTORY_INFO,
+ RAW_SEARCH_DATA_UNIX_INFO = SMB_FIND_UNIX_INFO
+};
/* union for file search */
union smb_search_first {
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
} generic;
/* search (old) findfirst interface.
Also used for ffirst and funique. */
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
uint16_t max_count;
@@ -2187,6 +2195,7 @@ union smb_search_first {
/* trans2 findfirst interface */
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
uint16_t search_attrib;
@@ -2207,7 +2216,7 @@ union smb_search_first {
} t2ffirst;
/*
- SMB2 uses different level numbers for the same old SMB search levels
+ SMB2 uses different level numbers for the same old SMB trans2 search levels
*/
#define SMB2_FIND_DIRECTORY_INFO 0x01
#define SMB2_FIND_FULL_DIRECTORY_INFO 0x02
@@ -2218,6 +2227,7 @@ union smb_search_first {
/* SMB2 Find */
struct smb2_find {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
union smb_handle file;
@@ -2228,7 +2238,7 @@ union smb_search_first {
uint32_t unknown; /* perhaps a continue token? */
/* struct smb2_handle handle; */
/* uint16_t pattern_ofs; */
- /* uint32_t pattern_size; */
+ /* uint16_t pattern_size; */
uint32_t max_response_size;
/* dynamic body */
@@ -2250,12 +2260,14 @@ union smb_search_first {
union smb_search_next {
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
} generic;
/* search (old) findnext interface. Also used
for ffirst when continuing */
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
uint16_t max_count;
@@ -2276,6 +2288,7 @@ union smb_search_next {
/* trans2 findnext interface */
struct {
enum smb_search_level level;
+ enum smb_search_data_level data_level;
struct {
uint16_t handle;
@@ -2297,7 +2310,10 @@ union smb_search_next {
/* union for search reply file data */
union smb_search_data {
- /* search (old) findfirst */
+ /*
+ * search (old) findfirst
+ * RAW_SEARCH_DATA_SEARCH
+ */
struct {
uint16_t attrib;
time_t write_time;
@@ -2305,8 +2321,8 @@ union smb_search_data {
struct smb_search_id id;
const char *name;
} search;
-
- /* trans2 findfirst RAW_SEARCH_STANDARD level */
+
+ /* trans2 findfirst RAW_SEARCH_DATA_STANDARD level */
struct {
uint32_t resume_key;
time_t create_time;
@@ -2318,7 +2334,7 @@ union smb_search_data {
struct smb_wire_string name;
} standard;
- /* trans2 findfirst RAW_SEARCH_EA_SIZE level */
+ /* trans2 findfirst RAW_SEARCH_DATA_EA_SIZE level */
struct {
uint32_t resume_key;
time_t create_time;
@@ -2331,7 +2347,7 @@ union smb_search_data {
struct smb_wire_string name;
} ea_size;
- /* trans2 findfirst RAW_SEARCH_EA_LIST level */
+ /* trans2 findfirst RAW_SEARCH_DATA_EA_LIST level */
struct {
uint32_t resume_key;
time_t create_time;
@@ -2344,7 +2360,7 @@ union smb_search_data {
struct smb_wire_string name;
} ea_list;
- /* RAW_SEARCH_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
@@ -2357,7 +2373,7 @@ union smb_search_data {
struct smb_wire_string name;
} directory_info;
- /* RAW_SEARCH_FULL_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_FULL_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
@@ -2371,13 +2387,13 @@ union smb_search_data {
struct smb_wire_string name;
} full_directory_info;
- /* RAW_SEARCH_NAME_INFO interface */
+ /* RAW_SEARCH_DATA_NAME_INFO interface */
struct {
uint32_t file_index;
struct smb_wire_string name;
} name_info;
- /* RAW_SEARCH_BOTH_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
@@ -2392,7 +2408,7 @@ union smb_search_data {
struct smb_wire_string name;
} both_directory_info;
- /* RAW_SEARCH_ID_FULL_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
@@ -2407,7 +2423,7 @@ union smb_search_data {
struct smb_wire_string name;
} id_full_directory_info;
- /* RAW_SEARCH_ID_BOTH_DIRECTORY_INFO interface */
+ /* RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO interface */
struct {
uint32_t file_index;
NTTIME create_time;
@@ -2423,7 +2439,7 @@ union smb_search_data {
struct smb_wire_string name;
} id_both_directory_info;
- /* RAW_SEARCH_UNIX_INFO interface */
+ /* RAW_SEARCH_DATA_UNIX_INFO interface */
struct {
uint32_t file_index;
uint64_t size;
diff --git a/source4/libcli/raw/rawsearch.c b/source4/libcli/raw/rawsearch.c
index 5e05d7c3c5..4836766a93 100644
--- a/source4/libcli/raw/rawsearch.c
+++ b/source4/libcli/raw/rawsearch.c
@@ -194,7 +194,6 @@ static NTSTATUS smb_raw_search_close_old(struct smbcli_tree *tree,
static NTSTATUS smb_raw_search_first_blob(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx, /* used to allocate output blobs */
union smb_search_first *io,
- uint16_t info_level,
DATA_BLOB *out_param_blob,
DATA_BLOB *out_data_blob)
{
@@ -211,7 +210,15 @@ static NTSTATUS smb_raw_search_first_blob(struct smbcli_tree *tree,
tp.in.max_data = 0xFFFF;
tp.in.setup = &setup;
- if (info_level == RAW_SEARCH_EA_LIST) {
+ if (io->t2ffirst.level != RAW_SEARCH_TRANS2) {
+ return NT_STATUS_INVALID_LEVEL;
+ }
+
+ if (io->t2ffirst.data_level >= RAW_SEARCH_DATA_GENERIC) {
+ return NT_STATUS_INVALID_LEVEL;
+ }
+
+ if (io->t2ffirst.data_level == RAW_SEARCH_DATA_EA_LIST) {
if (!ea_push_name_list(mem_ctx,
&tp.in.data,
io->t2ffirst.in.num_names,
@@ -219,7 +226,7 @@ static NTSTATUS smb_raw_search_first_blob(struct smbcli_tree *tree,
return NT_STATUS_NO_MEMORY;
}
}
-
+
tp.in.params = data_blob_talloc(mem_ctx, NULL, 12);
if (!tp.in.params.data) {
return NT_STATUS_NO_MEMORY;
@@ -228,7 +235,7 @@ static NTSTATUS smb_raw_search_first_blob(struct smbcli_tree *tree,
SSVAL(tp.in.params.data, 0, io->t2ffirst.in.search_attrib);
SSVAL(tp.in.params.data, 2, io->t2ffirst.in.max_count);
SSVAL(tp.in.params.data, 4, io->t2ffirst.in.flags);
- SSVAL(tp.in.params.data, 6, info_level);
+ SSVAL(tp.in.params.data, 6, io->t2ffirst.data_level);
SIVAL(tp.in.params.data, 8, io->t2ffirst.in.storage_type);
smbcli_blob_append_string(tree->session, mem_ctx, &tp.in.params,
@@ -255,7 +262,6 @@ static NTSTATUS smb_raw_search_first_blob(struct smbcli_tree *tree,
static NTSTATUS smb_raw_search_next_blob(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
union smb_search_next *io,
- uint16_t info_level,
DATA_BLOB *out_param_blob,
DATA_BLOB *out_data_blob)
{
@@ -272,7 +278,15 @@ static NTSTATUS smb_raw_search_next_blob(struct smbcli_tree *tree,
tp.in.max_data = 0xFFFF;
tp.in.setup = &setup;
- if (info_level == RAW_SEARCH_EA_LIST) {
+ if (io->t2fnext.level != RAW_SEARCH_TRANS2) {
+ return NT_STATUS_INVALID_LEVEL;
+ }
+
+ if (io->t2fnext.data_level >= RAW_SEARCH_DATA_GENERIC) {
+ return NT_STATUS_INVALID_LEVEL;
+ }
+
+ if (io->t2fnext.data_level == RAW_SEARCH_DATA_EA_LIST) {
if (!ea_push_name_list(mem_ctx,
&tp.in.data,
io->t2fnext.in.num_names,
@@ -287,8 +301,8 @@ static NTSTATUS smb_raw_search_next_blob(struct smbcli_tree *tree,
}
SSVAL(tp.in.params.data, 0, io->t2fnext.in.handle);
- SSVAL(tp.in.params.data, 2, io->t2fnext.in.max_count);
- SSVAL(tp.in.params.data, 4, info_level);
+ SSVAL(tp.in.params.data, 2, io->t2fnext.in.max_count);
+ SSVAL(tp.in.params.data, 4, io->t2fnext.data_level);
SIVAL(tp.in.params.data, 6, io->t2fnext.in.resume_key);
SSVAL(tp.in.params.data, 10, io->t2fnext.in.flags);
@@ -315,7 +329,7 @@ static NTSTATUS smb_raw_search_next_blob(struct smbcli_tree *tree,
SMB2
*/
NTSTATUS smb_raw_search_common(TALLOC_CTX *mem_ctx,
- enum smb_search_level level,
+ enum smb_search_data_level level,
const DATA_BLOB *blob,
union smb_search_data *data,
uint_t *next_ofs,
@@ -335,7 +349,7 @@ NTSTATUS smb_raw_search_common(TALLOC_CTX *mem_ctx,
}
switch (level) {
- case RAW_SEARCH_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_DIRECTORY_INFO:
if (blen < 65) return NT_STATUS_INFO_LENGTH_MISMATCH;
data->directory_info.file_index = IVAL(blob->data, 4);
data->directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
@@ -353,7 +367,7 @@ NTSTATUS smb_raw_search_common(TALLOC_CTX *mem_ctx,
}
return NT_STATUS_OK;
- case RAW_SEARCH_FULL_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_FULL_DIRECTORY_INFO:
if (blen < 69) return NT_STATUS_INFO_LENGTH_MISMATCH;
data->full_directory_info.file_index = IVAL(blob->data, 4);
data->full_directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
@@ -372,7 +386,7 @@ NTSTATUS smb_raw_search_common(TALLOC_CTX *mem_ctx,
}
return NT_STATUS_OK;
- case RAW_SEARCH_NAME_INFO:
+ case RAW_SEARCH_DATA_NAME_INFO:
if (blen < 13) return NT_STATUS_INFO_LENGTH_MISMATCH;
data->name_info.file_index = IVAL(blob->data, 4);
len = smbcli_blob_pull_string(NULL, mem_ctx, blob,
@@ -384,7 +398,7 @@ NTSTATUS smb_raw_search_common(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
- case RAW_SEARCH_BOTH_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO:
if (blen < 95) return NT_STATUS_INFO_LENGTH_MISMATCH;
data->both_directory_info.file_index = IVAL(blob->data, 4);
data->both_directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
@@ -407,7 +421,7 @@ NTSTATUS smb_raw_search_common(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
- case RAW_SEARCH_ID_FULL_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO:
if (blen < 81) return NT_STATUS_INFO_LENGTH_MISMATCH;
data->id_full_directory_info.file_index = IVAL(blob->data, 4);
data->id_full_directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
@@ -427,7 +441,7 @@ NTSTATUS smb_raw_search_common(TALLOC_CTX *mem_ctx,
}
return NT_STATUS_OK;
- case RAW_SEARCH_ID_BOTH_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO:
if (blen < 105) return NT_STATUS_INFO_LENGTH_MISMATCH;
data->id_both_directory_info.file_index = IVAL(blob->data, 4);
data->id_both_directory_info.create_time = smbcli_pull_nttime(blob->data, 8);
@@ -467,7 +481,7 @@ NTSTATUS smb_raw_search_common(TALLOC_CTX *mem_ctx,
*/
static int parse_trans2_search(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
- enum smb_search_level level,
+ enum smb_search_data_level level,
uint16_t flags,
DATA_BLOB *blob,
union smb_search_data *data)
@@ -478,15 +492,12 @@ static int parse_trans2_search(struct smbcli_tree *tree,
NTSTATUS status;
switch (level) {
- case RAW_SEARCH_GENERIC:
- case RAW_SEARCH_SEARCH:
- case RAW_SEARCH_FFIRST:
- case RAW_SEARCH_FUNIQUE:
- case RAW_SEARCH_SMB2:
+ case RAW_SEARCH_DATA_GENERIC:
+ case RAW_SEARCH_DATA_SEARCH:
/* handled elsewhere */
return -1;
- case RAW_SEARCH_STANDARD:
+ case RAW_SEARCH_DATA_STANDARD:
if (flags & FLAG_TRANS2_FIND_REQUIRE_RESUME) {
if (blob->length < 4) return -1;
data->standard.resume_key = IVAL(blob->data, 0);
@@ -508,7 +519,7 @@ static int parse_trans2_search(struct smbcli_tree *tree,
22, 23, STR_LEN8BIT | STR_TERMINATE | STR_LEN_NOTERM);
return len + 23;
- case RAW_SEARCH_EA_SIZE:
+ case RAW_SEARCH_DATA_EA_SIZE:
if (flags & FLAG_TRANS2_FIND_REQUIRE_RESUME) {
if (blob->length < 4) return -1;
data->ea_size.resume_key = IVAL(blob->data, 0);
@@ -531,7 +542,7 @@ static int parse_trans2_search(struct smbcli_tree *tree,
26, 27, STR_LEN8BIT | STR_TERMINATE | STR_NOALIGN);
return len + 27 + 1;
- case RAW_SEARCH_EA_LIST:
+ case RAW_SEARCH_DATA_EA_LIST:
if (flags & FLAG_TRANS2_FIND_REQUIRE_RESUME) {
if (blob->length < 4) return -1;
data->ea_list.resume_key = IVAL(blob->data, 0);
@@ -569,7 +580,7 @@ static int parse_trans2_search(struct smbcli_tree *tree,
STR_LEN8BIT | STR_NOALIGN);
return len + ea_size + 23 + 1;
- case RAW_SEARCH_UNIX_INFO:
+ case RAW_SEARCH_DATA_UNIX_INFO:
if (blob->length < 109) return -1;
ofs = IVAL(blob->data, 0);
data->unix_info.file_index = IVAL(blob->data, 4);
@@ -594,12 +605,12 @@ static int parse_trans2_search(struct smbcli_tree *tree,
}
return ofs;
- case RAW_SEARCH_DIRECTORY_INFO:
- case RAW_SEARCH_FULL_DIRECTORY_INFO:
- case RAW_SEARCH_NAME_INFO:
- case RAW_SEARCH_BOTH_DIRECTORY_INFO:
- case RAW_SEARCH_ID_FULL_DIRECTORY_INFO:
- case RAW_SEARCH_ID_BOTH_DIRECTORY_INFO: {
+ case RAW_SEARCH_DATA_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_FULL_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_NAME_INFO:
+ case RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO:
+ case RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO: {
uint_t str_flags = STR_UNICODE;
if (!(tree->session->transport->negotiate.capabilities & CAP_UNICODE)) {
str_flags = STR_ASCII;
@@ -622,7 +633,7 @@ static int parse_trans2_search(struct smbcli_tree *tree,
****************************************************************************/
static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
- enum smb_search_level level,
+ enum smb_search_data_level level,
uint16_t flags,
int16_t count,
DATA_BLOB *blob,
@@ -668,22 +679,24 @@ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree,
union smb_search_first *io, void *private,
BOOL (*callback)(void *private, union smb_search_data *file))
{
- uint16_t info_level = 0;
DATA_BLOB p_blob, d_blob;
NTSTATUS status;
-
- if (io->generic.level == RAW_SEARCH_SEARCH ||
- io->generic.level == RAW_SEARCH_FFIRST ||
- io->generic.level == RAW_SEARCH_FUNIQUE) {
+
+ switch (io->generic.level) {
+ case RAW_SEARCH_SEARCH:
+ case RAW_SEARCH_FFIRST:
+ case RAW_SEARCH_FUNIQUE:
return smb_raw_search_first_old(tree, mem_ctx, io, private, callback);
- }
- if (io->generic.level >= RAW_SEARCH_GENERIC) {
+
+ case RAW_SEARCH_TRANS2:
+ break;
+
+ case RAW_SEARCH_SMB2:
return NT_STATUS_INVALID_LEVEL;
}
- info_level = (uint16_t)io->generic.level;
status = smb_raw_search_first_blob(tree, mem_ctx,
- io, info_level, &p_blob, &d_blob);
+ io, &p_blob, &d_blob);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -698,9 +711,9 @@ NTSTATUS smb_raw_search_first(struct smbcli_tree *tree,
io->t2ffirst.out.handle = SVAL(p_blob.data, 0);
io->t2ffirst.out.count = SVAL(p_blob.data, 2);
io->t2ffirst.out.end_of_search = SVAL(p_blob.data, 4);
-
+
status = smb_raw_t2search_backend(tree, mem_ctx,
- io->generic.level,
+ io->generic.data_level,
io->t2ffirst.in.flags, io->t2ffirst.out.count,
&d_blob, private, callback);
@@ -714,21 +727,26 @@ NTSTATUS smb_raw_search_next(struct smbcli_tree *tree,
union smb_search_next *io, void *private,
BOOL (*callback)(void *private, union smb_search_data *file))
{
- uint16_t info_level = 0;
DATA_BLOB p_blob, d_blob;
NTSTATUS status;
- if (io->generic.level == RAW_SEARCH_SEARCH ||
- io->generic.level == RAW_SEARCH_FFIRST) {
+ switch (io->generic.level) {
+ case RAW_SEARCH_SEARCH:
+ case RAW_SEARCH_FFIRST:
return smb_raw_search_next_old(tree, mem_ctx, io, private, callback);
- }
- if (io->generic.level >= RAW_SEARCH_GENERIC) {
+
+ case RAW_SEARCH_FUNIQUE:
+ return NT_STATUS_INVALID_LEVEL;
+
+ case RAW_SEARCH_TRANS2:
+ break;
+
+ case RAW_SEARCH_SMB2:
return NT_STATUS_INVALID_LEVEL;
}
- info_level = (uint16_t)io->generic.level;
status = smb_raw_search_next_blob(tree, mem_ctx,
- io, info_level, &p_blob, &d_blob);
+ io, &p_blob, &d_blob);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -744,7 +762,7 @@ NTSTATUS smb_raw_search_next(struct smbcli_tree *tree,
io->t2fnext.out.end_of_search = SVAL(p_blob.data, 2);
status = smb_raw_t2search_backend(tree, mem_ctx,
- io->generic.level,
+ io->generic.data_level,
io->t2fnext.in.flags, io->t2fnext.out.count,
&d_blob, private, callback);
diff --git a/source4/libcli/smb2/find.c b/source4/libcli/smb2/find.c
index 8f4d6c8301..794e31bed3 100644
--- a/source4/libcli/smb2/find.c
+++ b/source4/libcli/smb2/find.c
@@ -101,27 +101,27 @@ NTSTATUS smb2_find_level_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
struct smb2_find f;
NTSTATUS status;
DATA_BLOB b;
- enum smb_search_level smb_level;
+ enum smb_search_data_level smb_level;
uint_t next_ofs=0;
switch (level) {
case SMB2_FIND_DIRECTORY_INFO:
- smb_level = RAW_SEARCH_DIRECTORY_INFO;
+ smb_level = RAW_SEARCH_DATA_DIRECTORY_INFO;
break;
case SMB2_FIND_FULL_DIRECTORY_INFO:
- smb_level = RAW_SEARCH_FULL_DIRECTORY_INFO;
+ smb_level = RAW_SEARCH_DATA_FULL_DIRECTORY_INFO;
break;
case SMB2_FIND_BOTH_DIRECTORY_INFO:
- smb_level = RAW_SEARCH_BOTH_DIRECTORY_INFO;
+ smb_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO;
break;
case SMB2_FIND_NAME_INFO:
- smb_level = RAW_SEARCH_NAME_INFO;
+ smb_level = RAW_SEARCH_DATA_NAME_INFO;
break;
case SMB2_FIND_ID_FULL_DIRECTORY_INFO:
- smb_level = RAW_SEARCH_ID_FULL_DIRECTORY_INFO;
+ smb_level = RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO;
break;
case SMB2_FIND_ID_BOTH_DIRECTORY_INFO:
- smb_level = RAW_SEARCH_ID_BOTH_DIRECTORY_INFO;
+ smb_level = RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO;
break;
default:
return NT_STATUS_INVALID_INFO_CLASS;