Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#define NO_SYSLOG
-
#include "includes.h"
+extern char *optarg;
+extern int optind;
+
static fstring host, workgroup, share, password, username, myname;
static int max_protocol = PROTOCOL_NT1;
static const char *sockops="TCP_NODELAY";
int shmid;
void *ret;
- shmid = shmget(IPC_PRIVATE, size, SHM_R | SHM_W);
+ shmid = shmget(IPC_PRIVATE, size, S_IRUSR | S_IWUSR);
if (shmid == -1) {
printf("can't get shared memory\n");
exit(1);
uint8 eclass, uint32 ecode, NTSTATUS nterr)
{
if (cli_is_dos_error(c)) {
- uint8 class;
+ uint8 cclass;
uint32 num;
/* Check DOS error */
- cli_dos_error(c, &class, &num);
+ cli_dos_error(c, &cclass, &num);
- if (eclass != class || ecode != num) {
+ if (eclass != cclass || ecode != num) {
printf("unexpected error code class=%d code=%d\n",
- (int)class, (int)num);
+ (int)cclass, (int)num);
printf(" expected %d/%d %s (line=%d)\n",
(int)eclass, (int)ecode, nt_errstr(nterr), line);
return False;
static BOOL run_readwritetest(int dummy)
{
static struct cli_state *cli1, *cli2;
- BOOL test1, test2;
+ BOOL test1, test2 = False;
if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
return False;
static struct cli_state *cli1;
int fnum1;
const char *lockfname = "\\large.dat";
- size_t fsize;
+ SMB_OFF_T fsize;
char buf[126*1024];
BOOL correct = True;
{
struct cli_state *cli;
int i;
- fstring fname;
pstring line;
char cname[20];
FILE *f;
nb_setup(cli);
- slprintf(cname,sizeof(fname), "client%d", client);
+ slprintf(cname,sizeof(cname)-1, "client%d", client);
f = fopen(client_txt, "r");
static BOOL run_maxfidtest(int dummy)
{
struct cli_state *cli;
- const char *template = "\\maxfid.%d.%d";
+ const char *ftemplate = "\\maxfid.%d.%d";
fstring fname;
int fnums[0x11000], i;
int retries=4;
cli_sockopt(cli, sockops);
for (i=0; i<0x11000; i++) {
- slprintf(fname,sizeof(fname)-1,template, i,(int)getpid());
+ slprintf(fname,sizeof(fname)-1,ftemplate, i,(int)getpid());
if ((fnums[i] = cli_open(cli, fname,
O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) ==
-1) {
printf("cleaning up\n");
for (;i>=0;i--) {
- slprintf(fname,sizeof(fname)-1,template, i,(int)getpid());
+ slprintf(fname,sizeof(fname)-1,ftemplate, i,(int)getpid());
cli_close(cli, fnums[i]);
if (!cli_unlink(cli, fname)) {
printf("unlink of %s failed (%s)\n",
{
struct cli_state *cli;
int fnum;
- size_t size;
+ SMB_OFF_T size;
time_t c_time, a_time, m_time, w_time, m_time2;
const char *fname = "\\trans2.tst";
const char *dname = "\\trans2";
sleep(2);
- /* Ensure cli1 processes the break. */
+ /* Ensure cli1 processes the break. Empty file should always return 0
+ * bytes. */
- if (cli_read(cli1, fnum1, buf, 0, 4) != 4) {
+ if (cli_read(cli1, fnum1, buf, 0, 4) != 0) {
printf("read on fnum1 failed (%s)\n", cli_errstr(cli1));
correct = False;
}
FILE_OVERWRITE_IF, 0, 0);
if (fnum1 == -1) {
- printf("[8] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[8] open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
correct = False;
goto fail;
}
FILE_OPEN, 0, 0);
if (fnum2 == -1) {
- printf("[8] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ printf("[8] open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
correct = False;
goto fail;
}
correct = False;
} else
printf("tenth delete on close test succeeded.\n");
+
+ cli_setatr(cli1, fname, 0, 0);
+ cli_unlink(cli1, fname);
+
+ /* What error do we get when attempting to open a read-only file with
+ delete access ? */
+
+ /* Create a readonly file. */
+ fnum1 = cli_nt_create_full(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA,
+ FILE_ATTRIBUTE_READONLY, FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0);
+ if (fnum1 == -1) {
+ printf("[11] open of %s failed (%s)\n", fname, cli_errstr(cli1));
+ correct = False;
+ goto fail;
+ }
+
+ if (!cli_close(cli1, fnum1)) {
+ printf("[11] close failed (%s)\n", cli_errstr(cli1));
+ correct = False;
+ goto fail;
+ }
+
+ /* Now try open for delete access. */
+ fnum1 = cli_nt_create_full(cli1, fname, 0, FILE_READ_ATTRIBUTES|DELETE_ACCESS,
+ 0, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ FILE_OVERWRITE_IF, 0, 0);
+
+ if (fnum1 != -1) {
+ printf("[11] open of %s succeeded should have been denied with ACCESS_DENIED!\n", fname);
+ cli_close(cli1, fnum1);
+ goto fail;
+ correct = False;
+ } else {
+ NTSTATUS nterr = cli_nt_error(cli1);
+ if (!NT_STATUS_EQUAL(nterr,NT_STATUS_ACCESS_DENIED)) {
+ printf("[11] open of %s should have been denied with ACCESS_DENIED! Got error %s\n", fname, nt_errstr(nterr));
+ goto fail;
+ correct = False;
+ } else {
+ printf("eleventh delete on close test succeeded.\n");
+ }
+ }
+
printf("finished delete test\n");
fail:
const char *fname = "\\readonly.file";
int fnum1, fnum2;
char buf[20];
- size_t fsize;
+ SMB_OFF_T fsize;
BOOL correct = True;
char *tmp_path;
return correct;
}
-static void list_fn(file_info *finfo, const char *name, void *state)
+static void list_fn(const char *mnt, file_info *finfo, const char *name, void *state)
{
}
return correct;
}
-static void del_fn(file_info *finfo, const char *mask, void *state)
+static void del_fn(const char *mnt, file_info *finfo, const char *mask, void *state)
{
struct cli_state *pcli = (struct cli_state *)state;
fstring fname;
{
int i;
+ printf("WARNING samba4 test suite is much more complete nowadays.\n");
+ printf("Please use samba4 torture.\n\n");
+
printf("Usage: smbtorture //server/share <options> TEST1 TEST2 ...\n");
printf("\t-d debuglevel\n");
char *p;
int gotuser = 0;
int gotpass = 0;
- extern char *optarg;
- extern int optind;
BOOL correct = True;
dbf = x_stdout;