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

a bunch of fixes from the sflight to seattle

in particular:
 - fixed NT status code for a bunch of ops
 - fixed handling of protocol levels in ms_fnmatch
(This used to be commit 3eba9606f7)
This commit is contained in:
Andrew Tridgell
2001-08-20 05:15:26 +00:00
parent 5f0b9d0830
commit 11ce0f4d2d
13 changed files with 699 additions and 676 deletions

View File

@ -1196,7 +1196,7 @@ static int file_find(struct file_list **list, const char *directory,
}
isdir = False;
if (!match || !ms_fnmatch(expression, dname)) {
if (!match || !gen_fnmatch(expression, dname)) {
if (recurse) {
ret = stat(path, &statbuf);
if (ret == 0) {

View File

@ -121,7 +121,6 @@ extern int max_xmit;
extern pstring cur_dir;
extern int get_total_time_ms;
extern int get_total_size;
extern int Protocol;
int blocksize=20;
int tarhandle;

1223
source3/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* include/config.h.in. Generated automatically from configure.in by autoheader. */
/* include/config.h.in. Generated automatically from configure.in by autoheader 2.13. */
/* Define if on AIX 3.
System headers sometimes define this.

View File

@ -111,7 +111,7 @@ static void interpret_interface(char *token)
/* first check if it is an interface name */
for (i=0;i<total_probed;i++) {
if (ms_fnmatch(token, probed_ifaces[i].name) == 0) {
if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
add_interface(probed_ifaces[i].ip,
probed_ifaces[i].netmask);
added = 1;

View File

@ -146,13 +146,12 @@ static int ms_fnmatch_lanman1(const smb_ucs2_t *pattern, const smb_ucs2_t *strin
Returns 0 on match, -1 on fail.
*/
static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string)
static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string, int protocol)
{
const smb_ucs2_t *p = pattern, *n = string;
smb_ucs2_t c;
extern int Protocol;
if (Protocol <= PROTOCOL_LANMAN2) {
if (protocol <= PROTOCOL_LANMAN2) {
return ms_fnmatch_lanman1(pattern, string);
}
@ -165,23 +164,23 @@ static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string)
case UCS2_CHAR('>'):
if (n[0] == UCS2_CHAR('.')) {
if (! n[1] && ms_fnmatch_w(p, n+1) == 0) return 0;
if (ms_fnmatch_w(p, n) == 0) return 0;
if (! n[1] && ms_fnmatch_w(p, n+1, protocol) == 0) return 0;
if (ms_fnmatch_w(p, n, protocol) == 0) return 0;
return -1;
}
if (! *n) return ms_fnmatch_w(p, n);
if (! *n) return ms_fnmatch_w(p, n, protocol);
n++;
break;
case UCS2_CHAR('*'):
for (; *n; n++) {
if (ms_fnmatch_w(p, n) == 0) return 0;
if (ms_fnmatch_w(p, n, protocol) == 0) return 0;
}
break;
case UCS2_CHAR('<'):
for (; *n; n++) {
if (ms_fnmatch_w(p, n) == 0) return 0;
if (ms_fnmatch_w(p, n, protocol) == 0) return 0;
if (*n == UCS2_CHAR('.') && !strchr_wa(n+1,'.')) {
n++;
break;
@ -190,7 +189,7 @@ static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string)
break;
case UCS2_CHAR('"'):
if (*n == 0 && ms_fnmatch_w(p, n) == 0) return 0;
if (*n == 0 && ms_fnmatch_w(p, n, protocol) == 0) return 0;
if (*n != UCS2_CHAR('.')) return -1;
n++;
break;
@ -207,12 +206,21 @@ static int ms_fnmatch_w(const smb_ucs2_t *pattern, const smb_ucs2_t *string)
}
int ms_fnmatch(const char *pattern, const char *string)
int ms_fnmatch(const char *pattern, const char *string, int protocol)
{
wpstring p, s;
int ret;
pstrcpy_wa(p, pattern);
pstrcpy_wa(s, string);
return ms_fnmatch_w(p, s);
ret = ms_fnmatch_w(p, s, protocol);
/* DEBUG(0,("ms_fnmatch(%s,%s) -> %d\n", pattern, string, ret)); */
return ret;
}
/* a generic fnmatch function - uses for non-CIFS pattern matching */
int gen_fnmatch(const char *pattern, const char *string)
{
return ms_fnmatch(pattern, string, PROTOCOL_NT1);
}

View File

@ -1782,19 +1782,21 @@ BOOL ms_has_wild(char *s)
*******************************************************************/
BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive)
{
extern int Protocol;
fstring p2, s2;
if (strcmp(string,"..") == 0) string = ".";
if (strcmp(pattern,".") == 0) return False;
if (is_case_sensitive) {
return ms_fnmatch(pattern, string) == 0;
return ms_fnmatch(pattern, string, Protocol) == 0;
}
fstrcpy(p2, pattern);
fstrcpy(s2, string);
strlower(p2);
strlower(s2);
return ms_fnmatch(p2, s2) == 0;
return ms_fnmatch(p2, s2, Protocol) == 0;
}
/*******************************************************************
@ -1804,12 +1806,13 @@ BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive)
BOOL wild_match(char *string, char *pattern)
{
pstring p2, s2;
extern int Protocol;
pstrcpy(p2, pattern);
pstrcpy(s2, string);
strlower(p2);
strlower(s2);
return ms_fnmatch(p2, s2) == 0;
return ms_fnmatch(p2, s2, Protocol) == 0;
}
#ifdef __INSURE__

View File

@ -414,7 +414,6 @@ BOOL cli_negprot(struct cli_state *cli)
cli->protocol = prots[SVAL(cli->inbuf,smb_vwv0)].prot;
if (cli->protocol >= PROTOCOL_NT1) {
/* NT protocol */
cli->sec_mode = CVAL(cli->inbuf,smb_vwv1);

View File

@ -216,7 +216,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
continue;
}
if (cli_is_error(cli))
if (cli_is_error(cli) || !rdata || !rparam)
return -1;
if (total_received == -1) total_received = 0;

View File

@ -171,16 +171,19 @@ BOOL cli_receive_trans(struct cli_state *cli,int trans,
* be treated as such.
*/
if (cli_is_dos_error(cli)) {
cli_dos_error(cli, &eclass, &ecode);
if (cli_is_error(cli)) {
if (cli_is_dos_error(cli)) {
cli_dos_error(cli, &eclass, &ecode);
if(cli->nt_pipe_fnum == 0)
return(False);
if(!(eclass == ERRDOS && ecode == ERRmoredata)) {
if (eclass != 0 && (ecode != (0x80000000 | STATUS_BUFFER_OVERFLOW)))
if(cli->nt_pipe_fnum == 0)
return(False);
if(!(eclass == ERRDOS && ecode == ERRmoredata)) {
if (eclass != 0 && (ecode != (0x80000000 | STATUS_BUFFER_OVERFLOW)))
return(False);
}
}
return False;
}
/* parse out the lengths */

View File

@ -22,7 +22,6 @@
#include "includes.h"
extern int DEBUGLEVEL;
extern int Protocol;
extern struct in_addr ipzero;
/* users from session setup */

View File

@ -125,7 +125,7 @@ int ms_fnmatch_lanman(char *pattern, char *string)
return ms_fnmatch_lanman_core(pattern, string);
}
static BOOL reg_match_one(char *pattern, char *file)
static BOOL reg_match_one(struct cli_state *cli, char *pattern, char *file)
{
/* oh what a weird world this is */
if (old_list && strcmp(pattern, "*.*") == 0) return True;
@ -138,20 +138,20 @@ static BOOL reg_match_one(char *pattern, char *file)
if (strcmp(file,"..") == 0) file = ".";
return ms_fnmatch(pattern, file)==0;
return ms_fnmatch(pattern, file, cli->protocol)==0;
}
static char *reg_test(char *pattern, char *long_name, char *short_name)
static char *reg_test(struct cli_state *cli, char *pattern, char *long_name, char *short_name)
{
static fstring ret;
fstrcpy(ret, "---");
pattern = 1+strrchr_m(pattern,'\\');
if (reg_match_one(pattern, ".")) ret[0] = '+';
if (reg_match_one(pattern, "..")) ret[1] = '+';
if (reg_match_one(pattern, long_name) ||
(*short_name && reg_match_one(pattern, short_name))) ret[2] = '+';
if (reg_match_one(cli, pattern, ".")) ret[0] = '+';
if (reg_match_one(cli, pattern, "..")) ret[1] = '+';
if (reg_match_one(cli, pattern, long_name) ||
(*short_name && reg_match_one(cli, pattern, short_name))) ret[2] = '+';
return ret;
}
@ -323,7 +323,7 @@ static void testpair(struct cli_state *cli, char *mask, char *file)
fstrcpy(res1, "---");
cli_list(cli, mask, aHIDDEN | aDIR, listfn, NULL);
res2 = reg_test(mask, long_name, short_name);
res2 = reg_test(cli, mask, long_name, short_name);
if (showall || strcmp(res1, res2)) {
DEBUG(0,("%s %s %d mask=[%s] file=[%s] rfile=[%s/%s]\n",

View File

@ -168,7 +168,7 @@ static BOOL close_connection(struct cli_state *c)
/* check if the server produced the expected error code */
static BOOL check_error(struct cli_state *c,
static BOOL check_error(int line, struct cli_state *c,
uint8 eclass, uint32 ecode, uint32 nterr)
{
if (cli_is_dos_error(c)) {
@ -182,8 +182,8 @@ static BOOL check_error(struct cli_state *c,
if (eclass != class || ecode != num) {
printf("unexpected error code class=%d code=%d\n",
(int)class, (int)num);
printf(" expected %d/%d %d\n",
(int)eclass, (int)ecode, (int)nterr);
printf(" expected %d/%d %d (line=%d)\n",
(int)eclass, (int)ecode, (int)nterr, line);
return False;
}
@ -196,7 +196,7 @@ static BOOL check_error(struct cli_state *c,
if (nterr != status) {
printf("unexpected error code 0x%08x\n", status);
printf(" expected 0x%08x\n", nterr);
printf(" expected 0x%08x (line=%d)\n", nterr, line);
return False;
}
}
@ -208,7 +208,7 @@ static BOOL check_error(struct cli_state *c,
static BOOL wait_lock(struct cli_state *c, int fnum, uint32 offset, uint32 len)
{
while (!cli_lock(c, fnum, offset, len, -1, WRITE_LOCK)) {
if (!check_error(c, ERRDOS, ERRlock, 0)) return False;
if (!check_error(__LINE__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
return True;
}
@ -802,7 +802,8 @@ static BOOL run_locktest1(int dummy)
printf("lock2 succeeded! This is a locking bug\n");
return False;
} else {
if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return False;
if (!check_error(__LINE__, &cli2, ERRDOS, ERRlock,
NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
@ -812,7 +813,8 @@ static BOOL run_locktest1(int dummy)
printf("lock3 succeeded! This is a locking bug\n");
return False;
} else {
if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return False;
if (!check_error(__LINE__, &cli2, ERRDOS, ERRlock,
NT_STATUS_FILE_LOCK_CONFLICT)) return False;
}
t2 = time(NULL);
@ -829,7 +831,8 @@ static BOOL run_locktest1(int dummy)
printf("lock4 succeeded! This is a locking bug\n");
return False;
} else {
if (!check_error(&cli2, ERRDOS, ERRlock, 0)) return False;
if (!check_error(__LINE__, &cli2, ERRDOS, ERRlock,
NT_STATUS_FILE_LOCK_CONFLICT)) return False;
}
if (!cli_close(&cli1, fnum1)) {
@ -996,21 +999,24 @@ static BOOL run_locktest2(int dummy)
printf("WRITE lock1 succeeded! This is a locking bug\n");
correct = False;
} else {
if (!check_error(&cli, ERRDOS, ERRlock, 0)) return False;
if (!check_error(__LINE__, &cli, ERRDOS, ERRlock,
NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
if (cli_lock(&cli, fnum2, 0, 4, 0, WRITE_LOCK)) {
printf("WRITE lock2 succeeded! This is a locking bug\n");
correct = False;
} else {
if (!check_error(&cli, ERRDOS, ERRlock, 0)) return False;
if (!check_error(__LINE__, &cli, ERRDOS, ERRlock,
NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
if (cli_lock(&cli, fnum2, 0, 4, 0, READ_LOCK)) {
printf("READ lock2 succeeded! This is a locking bug\n");
correct = False;
} else {
if (!check_error(&cli, ERRDOS, ERRlock, 0)) return False;
if (!check_error(__LINE__, &cli, ERRDOS, ERRlock,
NT_STATUS_FILE_LOCK_CONFLICT)) return False;
}
if (!cli_lock(&cli, fnum1, 100, 4, 0, WRITE_LOCK)) {
@ -1026,21 +1032,25 @@ static BOOL run_locktest2(int dummy)
printf("unlock1 succeeded! This is a locking bug\n");
correct = False;
} else {
if (!check_error(&cli, ERRDOS, ERRnotlocked, 0)) return False;
if (!check_error(__LINE__, &cli,
ERRDOS, ERRnotlocked,
NT_STATUS_RANGE_NOT_LOCKED)) return False;
}
if (cli_unlock(&cli, fnum1, 0, 8)) {
printf("unlock2 succeeded! This is a locking bug\n");
correct = False;
} else {
if (!check_error(&cli, ERRDOS, ERRnotlocked, 0)) return False;
if (!check_error(__LINE__, &cli,
ERRDOS, ERRnotlocked,
NT_STATUS_RANGE_NOT_LOCKED)) return False;
}
if (cli_lock(&cli, fnum3, 0, 4, 0, WRITE_LOCK)) {
printf("lock3 succeeded! This is a locking bug\n");
correct = False;
} else {
if (!check_error(&cli, ERRDOS, ERRlock, 0)) return False;
if (!check_error(__LINE__, &cli, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False;
}
cli_setpid(&cli, 1);
@ -1790,7 +1800,7 @@ static BOOL run_maxfidtest(int dummy)
static struct cli_state cli;
char *template = "\\maxfid.%d.%d";
fstring fname;
int fnum;
int fnums[0x11000], i;
int retries=4;
BOOL correct = True;
@ -1803,27 +1813,24 @@ static BOOL run_maxfidtest(int dummy)
cli_sockopt(&cli, sockops);
fnum = 0;
while (1) {
slprintf(fname,sizeof(fname)-1,template, fnum,(int)getpid());
if (cli_open(&cli, fname,
O_RDWR|O_CREAT|O_TRUNC, DENY_NONE) ==
for (i=0; i<0x11000; i++) {
slprintf(fname,sizeof(fname)-1,template, i,(int)getpid());
if ((fnums[i] = cli_open(&cli, fname,
O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) ==
-1) {
printf("open of %s failed (%s)\n",
fname, cli_errstr(&cli));
printf("maximum fnum is %d\n", fnum);
printf("maximum fnum is %d\n", i);
break;
}
fnum++;
if (fnum % 100 == 0) printf("%d\r", fnum);
if (i % 100 == 0) printf("%d\r", i);
}
printf("%d\n", fnum);
printf("%d\n", i);
printf("cleaning up\n");
while (fnum > 0) {
fnum--;
slprintf(fname,sizeof(fname)-1,template, fnum,(int)getpid());
cli_close(&cli, fnum);
for (;i>=0;i--) {
slprintf(fname,sizeof(fname)-1,template, i,(int)getpid());
cli_close(&cli, fnums[i]);
if (!cli_unlink(&cli, fname)) {
printf("unlink of %s failed (%s)\n",
fname, cli_errstr(&cli));
@ -2844,7 +2851,8 @@ static BOOL run_opentest(int dummy)
/* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */
fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_ALL);
if (check_error(&cli1, ERRDOS, ERRnoaccess, 0)) {
if (check_error(__LINE__, &cli1, ERRDOS, ERRnoaccess,
NT_STATUS_ACCESS_DENIED)) {
printf("correct error code ERRDOS/ERRnoaccess returned\n");
}
@ -2865,7 +2873,8 @@ static BOOL run_opentest(int dummy)
/* This will fail - but the error should be ERRshare. */
fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_ALL);
if (check_error(&cli1, ERRDOS, ERRbadshare, 0)) {
if (check_error(__LINE__, &cli1, ERRDOS, ERRbadshare,
NT_STATUS_SHARING_VIOLATION)) {
printf("correct error code ERRDOS/ERRbadshare returned\n");
}