1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-04 08:23:50 +03:00

made some LANMAN1 wildcard progress

it now handles -M LANMAN1 -f '.x' -m '?x' nicely
This commit is contained in:
Andrew Tridgell
-
parent 2a94e8e02d
commit e7ccb9be6d
4 changed files with 24 additions and 15 deletions

View File

@@ -35,6 +35,7 @@
#define CLISTR_CONVERT 2 #define CLISTR_CONVERT 2
#define CLISTR_UPPER 4 #define CLISTR_UPPER 4
#define CLISTR_ASCII 8 #define CLISTR_ASCII 8
#define CLISTR_UNICODE 16
/* /*
* These definitions depend on smb.h * These definitions depend on smb.h

View File

@@ -133,10 +133,14 @@ static int interpret_long_filename(struct cli_state *cli,
p += 4; /* EA size */ p += 4; /* EA size */
slen = SVAL(p, 0); slen = SVAL(p, 0);
p += 2; p += 2;
clistr_pull(cli, finfo->short_name, p, {
sizeof(finfo->short_name), /* stupid NT bugs. grr */
24, int flags = CLISTR_CONVERT;
CLISTR_CONVERT); if (p[1] == 0 && namelen > 1) flags |= CLISTR_UNICODE;
clistr_pull(cli, finfo->short_name, p,
sizeof(finfo->short_name),
24, flags);
}
p += 24; /* short name? */ p += 24; /* short name? */
clistr_pull(cli, finfo->name, p, clistr_pull(cli, finfo->name, p,
sizeof(finfo->name), sizeof(finfo->name),
@@ -159,8 +163,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
void (*fn)(file_info *, const char *, void *), void *state) void (*fn)(file_info *, const char *, void *), void *state)
{ {
int max_matches = 512; int max_matches = 512;
/* NT uses 260, OS/2 uses 2. Both accept 1. */ int info_level;
int info_level = cli->protocol<PROTOCOL_NT1?1:260;
char *p, *p2; char *p, *p2;
pstring mask; pstring mask;
file_info finfo; file_info finfo;
@@ -179,6 +182,9 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
uint16 setup; uint16 setup;
pstring param; pstring param;
/* NT uses 260, OS/2 uses 2. Both accept 1. */
info_level = (cli->capabilities&CAP_NT_SMBS)?260:1;
pstrcpy(mask,Mask); pstrcpy(mask,Mask);
while (ff_eos == 0) { while (ff_eos == 0) {

View File

@@ -103,6 +103,7 @@ cli->capabilities) to a char* destination
flags can have: flags can have:
CLISTR_CONVERT means convert from dos to unix codepage CLISTR_CONVERT means convert from dos to unix codepage
CLISTR_TERMINATE means the string in src is null terminated CLISTR_TERMINATE means the string in src is null terminated
CLISTR_UNICODE means to force as unicode
if CLISTR_TERMINATE is set then src_len is ignored if CLISTR_TERMINATE is set then src_len is ignored
src_len is the length of the source area in bytes src_len is the length of the source area in bytes
return the number of bytes occupied by the string in src return the number of bytes occupied by the string in src
@@ -115,12 +116,12 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len
dest_len = sizeof(pstring); dest_len = sizeof(pstring);
} }
if (clistr_align(cli, PTR_DIFF(cli->inbuf, src))) { if (clistr_align(cli, PTR_DIFF(src, cli->inbuf))) {
src++; src++;
if (src_len > 0) src_len--; if (src_len > 0) src_len--;
} }
if (!(cli->capabilities & CAP_UNICODE)) { if (!(flags & CLISTR_UNICODE) && !(cli->capabilities & CAP_UNICODE)) {
/* the server doesn't want unicode */ /* the server doesn't want unicode */
if (flags & CLISTR_TERMINATE) { if (flags & CLISTR_TERMINATE) {
safe_strcpy(dest, src, dest_len); safe_strcpy(dest, src, dest_len);
@@ -159,7 +160,7 @@ if src_len is -1 then assume the source is null terminated
****************************************************************************/ ****************************************************************************/
int clistr_pull_size(struct cli_state *cli, const void *src, int src_len) int clistr_pull_size(struct cli_state *cli, const void *src, int src_len)
{ {
if (clistr_align(cli, PTR_DIFF(cli->inbuf, src))) { if (clistr_align(cli, PTR_DIFF(src, cli->inbuf))) {
src++; src++;
if (src_len > 0) src_len--; if (src_len > 0) src_len--;
} }

View File

@@ -39,13 +39,12 @@ int ms_fnmatch_lanman_core(char *pattern, char *string)
char *p = pattern, *n = string; char *p = pattern, *n = string;
char c; char c;
// printf("ms_fnmatch_lanman_core(%s, %s)\n", pattern, string); // printf("ms_fnmatch_lanman_core(%s, %s)\n", pattern, string);
while ((c = *p++)) { while ((c = *p++)) {
switch (c) { switch (c) {
case '?': case '?':
if (*n == 0 && ms_fnmatch_lanman_core(p, n) == 0) return 0; if (! *n) return ms_fnmatch_lanman_core(p, n);
if (! *n && !*p) return 0;
n++; n++;
break; break;
@@ -124,13 +123,13 @@ static BOOL reg_match_one(char *pattern, char *file)
/* oh what a weird world this is */ /* oh what a weird world this is */
if (old_list && strcmp(pattern, "*.*") == 0) return True; if (old_list && strcmp(pattern, "*.*") == 0) return True;
if (strcmp(file,"..") == 0) file = ".";
if (strcmp(pattern,".") == 0) return False;
if (max_protocol <= PROTOCOL_LANMAN2) { if (max_protocol <= PROTOCOL_LANMAN2) {
return ms_fnmatch_lanman(pattern, file)==0; return ms_fnmatch_lanman(pattern, file)==0;
} }
if (strcmp(file,"..") == 0) file = ".";
if (strcmp(pattern,".") == 0) return False;
return ms_fnmatch(pattern, file)==0; return ms_fnmatch(pattern, file)==0;
} }
@@ -263,6 +262,8 @@ void listfn(file_info *f, const char *s, void *state)
static void get_real_name(struct cli_state *cli, static void get_real_name(struct cli_state *cli,
pstring long_name, fstring short_name) pstring long_name, fstring short_name)
{ {
/* nasty hack to force level 260 listings - tridge */
cli->capabilities |= CAP_NT_SMBS;
if (max_protocol <= PROTOCOL_LANMAN1) { if (max_protocol <= PROTOCOL_LANMAN1) {
cli_list_new(cli, "\\masktest\\*.*", aHIDDEN | aDIR, listfn, NULL); cli_list_new(cli, "\\masktest\\*.*", aHIDDEN | aDIR, listfn, NULL);
} else { } else {