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

- fixed proto.h build on systems using a parallel make

- changed DENY1 and DENY2 tests to only report errors
This commit is contained in:
Andrew Tridgell 0001-01-01 00:00:00 +00:00
parent 842fcd94fa
commit 9341e5534d
4 changed files with 1590 additions and 197 deletions

View File

@ -318,8 +318,9 @@ UMOUNT_OBJ = client/smbumount.o \
NMBLOOKUP_OBJ = utils/nmblookup.o $(PARAM_OBJ) $(UBIQX_OBJ) \
$(LIBSMB_OBJ) $(LIB_OBJ)
SMBTORTURE_OBJ = torture/torture.o torture/nbio.o torture/scanner.o $(LIBSMB_OBJ) $(PARAM_OBJ) \
$(UBIQX_OBJ) $(LIB_OBJ)
SMBTORTURE_OBJ = torture/torture.o torture/nbio.o torture/scanner.o \
torture/denytest.o \
$(LIBSMB_OBJ) $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ)
MASKTEST_OBJ = torture/masktest.o $(LIBSMB_OBJ) $(PARAM_OBJ) \
$(UBIQX_OBJ) $(LIB_OBJ)
@ -414,7 +415,7 @@ WINBIND_NSS_PICOBJS = $(WINBIND_NSS_OBJ:.o=.po)
######################################################################
# now the rules...
######################################################################
all : CHECK include/proto.h $(SPROGS) $(PROGS) $(SHLIBS) nsswitch
all : CHECK $(SPROGS) $(PROGS) $(SHLIBS) nsswitch
pam_smbpass : CHECK bin/pam_smbpass.@SHLIBEXT@
@ -458,7 +459,7 @@ MAKEDIR = || exec false; \
mkdir "$$dir" || \
exec false; fi || exec false
.c.o:
.c.o:
@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
@echo Compiling $*.c
@ -710,7 +711,13 @@ winbindd_proto:
delproto:
@/bin/rm -f $(srcdir)/include/proto.h
include/proto.h:
# we want proto.h to be rebuilt if it doesn't exist, but not rebuilt every time
.proto.stamp: include/proto.h
@[ -f $@ ] || touch $@
$(PROTO_OBJ) : .proto.stamp
include/proto.h:
@echo rebuilding include/proto.h
@cd $(srcdir) && $(AWK) -f script/mkproto.awk `echo $(PROTO_OBJ) | tr ' ' '\n' | sed -e 's/\.o/\.c/g' | sort -u | egrep -v 'ubiqx/|wrapped'` > include/proto.h

View File

@ -53,6 +53,9 @@
/* pointer difference macro */
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
/* work out how many elements there are in a static array */
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
/* assert macros */
#define SMB_ASSERT(b) ((b)?(void)0: \
(DEBUG(0,("PANIC: assert failed at %s(%d)\n", \

1567
source/torture/denytest.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@ static struct cli_state current_cli;
static fstring randomfname;
static BOOL use_oplocks;
static BOOL use_level_II_oplocks;
BOOL torture_showall = False;
static double create_procs(BOOL (*fn)(int), BOOL *result);
@ -1501,195 +1502,6 @@ static BOOL run_locktest5(int dummy)
return correct;
}
/*
this produces a matrix of deny mode behaviour
*/
static BOOL run_denytest1(int dummy)
{
static struct cli_state cli1, cli2;
int fnum1, fnum2;
int f, d1, d2, o1, o2, x=0;
char *fnames[] = {"\\denytest1.exe", "\\denytest1.dat", NULL};
struct {
int v;
char *name;
} deny_modes[] = {
{DENY_DOS, "DENY_DOS"},
{DENY_ALL, "DENY_ALL"},
{DENY_WRITE, "DENY_WRITE"},
{DENY_READ, "DENY_READ"},
{DENY_NONE, "DENY_NONE"},
{DENY_FCB, "DENY_FCB"},
{-1, NULL}};
struct {
int v;
char *name;
} open_modes[] = {
{O_RDWR, "O_RDWR"},
{O_RDONLY, "O_RDONLY"},
{O_WRONLY, "O_WRONLY"},
{-1, NULL}};
BOOL correct = True;
if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
return False;
}
cli_sockopt(&cli1, sockops);
cli_sockopt(&cli2, sockops);
printf("starting denytest1\n");
for (f=0;fnames[f];f++) {
cli_unlink(&cli1, fnames[f]);
fnum1 = cli_open(&cli1, fnames[f], O_RDWR|O_CREAT, DENY_NONE);
cli_write(&cli1, fnum1, 0, fnames[f], 0, strlen(fnames[f]));
cli_close(&cli1, fnum1);
for (d1=0;deny_modes[d1].name;d1++)
for (o1=0;open_modes[o1].name;o1++)
for (d2=0;deny_modes[d2].name;d2++)
for (o2=0;open_modes[o2].name;o2++) {
fnum1 = cli_open(&cli1, fnames[f],
open_modes[o1].v,
deny_modes[d1].v);
fnum2 = cli_open(&cli2, fnames[f],
open_modes[o2].v,
deny_modes[d2].v);
printf("%s %8s %10s %8s %10s ",
fnames[f],
open_modes[o1].name,
deny_modes[d1].name,
open_modes[o2].name,
deny_modes[d2].name);
if (fnum1 == -1) {
printf("X");
} else if (fnum2 == -1) {
printf("-");
} else {
if (cli_read(&cli2, fnum2, (void *)&x, 0, 1) == 1) {
printf("R");
}
if (cli_write(&cli2, fnum2, 0, (void *)&x, 0, 1) == 1) {
printf("W");
}
}
printf("\n");
cli_close(&cli1, fnum1);
cli_close(&cli2, fnum2);
}
cli_unlink(&cli1, fnames[f]);
}
if (!torture_close_connection(&cli1)) {
correct = False;
}
if (!torture_close_connection(&cli2)) {
correct = False;
}
printf("finshed denytest1\n");
return correct;
}
/*
this produces a matrix of deny mode behaviour for two opens on the
same connection
*/
static BOOL run_denytest2(int dummy)
{
static struct cli_state cli1;
int fnum1, fnum2;
int f, d1, d2, o1, o2, x=0;
char *fnames[] = {"\\denytest2.exe", "\\denytest2.dat", NULL};
struct {
int v;
char *name;
} deny_modes[] = {
{DENY_DOS, "DENY_DOS"},
{DENY_ALL, "DENY_ALL"},
{DENY_WRITE, "DENY_WRITE"},
{DENY_READ, "DENY_READ"},
{DENY_NONE, "DENY_NONE"},
{DENY_FCB, "DENY_FCB"},
{-1, NULL}};
struct {
int v;
char *name;
} open_modes[] = {
{O_RDWR, "O_RDWR"},
{O_RDONLY, "O_RDONLY"},
{O_WRONLY, "O_WRONLY"},
{-1, NULL}};
BOOL correct = True;
if (!torture_open_connection(&cli1)) {
return False;
}
cli_sockopt(&cli1, sockops);
printf("starting denytest2\n");
for (f=0;fnames[f];f++) {
cli_unlink(&cli1, fnames[f]);
fnum1 = cli_open(&cli1, fnames[f], O_RDWR|O_CREAT, DENY_NONE);
cli_write(&cli1, fnum1, 0, fnames[f], 0, strlen(fnames[f]));
cli_close(&cli1, fnum1);
for (d1=0;deny_modes[d1].name;d1++)
for (o1=0;open_modes[o1].name;o1++)
for (d2=0;deny_modes[d2].name;d2++)
for (o2=0;open_modes[o2].name;o2++) {
fnum1 = cli_open(&cli1, fnames[f],
open_modes[o1].v,
deny_modes[d1].v);
fnum2 = cli_open(&cli1, fnames[f],
open_modes[o2].v,
deny_modes[d2].v);
printf("%s %8s %10s %8s %10s ",
fnames[f],
open_modes[o1].name,
deny_modes[d1].name,
open_modes[o2].name,
deny_modes[d2].name);
if (fnum1 == -1) {
printf("X");
} else if (fnum2 == -1) {
printf("-");
} else {
if (cli_read(&cli1, fnum2, (void *)&x, 0, 1) == 1) {
printf("R");
}
if (cli_write(&cli1, fnum2, 0, (void *)&x, 0, 1) == 1) {
printf("W");
}
}
printf("\n");
cli_close(&cli1, fnum1);
cli_close(&cli1, fnum2);
}
cli_unlink(&cli1, fnames[f]);
}
if (!torture_close_connection(&cli1)) {
correct = False;
}
printf("finshed denytest2\n");
return correct;
}
/*
test whether fnums and tids open on one VC are available on another (a major
security hole)
@ -3164,8 +2976,8 @@ static struct {
{"OPLOCK2", run_oplock2, 0},
{"OPLOCK3", run_oplock3, 0},
{"DIR", run_dirtest, 0},
{"DENY1", run_denytest1, 0},
{"DENY2", run_denytest2, 0},
{"DENY1", torture_denytest1, 0},
{"DENY2", torture_denytest2, 0},
{"TCON", run_tcon_test, 0},
{"RW1", run_readwritetest, 0},
{"RW2", run_readwritemulti, FLAG_MULTIPROC},
@ -3237,6 +3049,7 @@ static void usage(void)
printf("\t-O socket_options\n");
printf("\t-m maximum protocol\n");
printf("\t-L use oplocks\n");
printf("\t-A showall\n");
printf("\n\n");
printf("tests are:");
@ -3309,7 +3122,7 @@ static void usage(void)
fstrcpy(workgroup, lp_workgroup());
while ((opt = getopt(argc, argv, "hW:U:n:N:O:o:m:Ld:")) != EOF) {
while ((opt = getopt(argc, argv, "hW:U:n:N:O:o:m:Ld:A")) != EOF) {
switch (opt) {
case 'W':
fstrcpy(workgroup,optarg);
@ -3332,6 +3145,9 @@ static void usage(void)
case 'L':
use_oplocks = True;
break;
case 'A':
torture_showall = True;
break;
case 'n':
fstrcpy(myname, optarg);
break;