mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
added the ancient SMBcreate operation to the testsuite and client lib
This commit is contained in:
parent
b47737b00b
commit
3eef35e581
@ -1078,7 +1078,8 @@ union smb_fsinfo {
|
||||
|
||||
|
||||
enum open_level {RAW_OPEN_OPEN, RAW_OPEN_OPENX,
|
||||
RAW_OPEN_MKNEW, RAW_OPEN_CTEMP, RAW_OPEN_SPLOPEN,
|
||||
RAW_OPEN_MKNEW, RAW_OPEN_CREATE,
|
||||
RAW_OPEN_CTEMP, RAW_OPEN_SPLOPEN,
|
||||
RAW_OPEN_NTCREATEX, RAW_OPEN_T2OPEN};
|
||||
|
||||
/* the generic interface is defined to be equal to the NTCREATEX interface */
|
||||
@ -1213,7 +1214,7 @@ union smb_open {
|
||||
struct {
|
||||
uint16 fnum;
|
||||
} out;
|
||||
} mknew;
|
||||
} mknew, create;
|
||||
|
||||
/* SMBctemp interface */
|
||||
struct {
|
||||
|
@ -330,6 +330,13 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par
|
||||
put_dos_date3(req->out.vwv, VWV(1), parms->mknew.in.write_time);
|
||||
cli_req_append_ascii4(req, parms->mknew.in.fname, STR_TERMINATE);
|
||||
break;
|
||||
|
||||
case RAW_OPEN_CREATE:
|
||||
SETUP_REQUEST(SMBcreate, 3, 0);
|
||||
SSVAL(req->out.vwv, VWV(0), parms->create.in.attrib);
|
||||
put_dos_date3(req->out.vwv, VWV(1), parms->create.in.write_time);
|
||||
cli_req_append_ascii4(req, parms->create.in.fname, STR_TERMINATE);
|
||||
break;
|
||||
|
||||
case RAW_OPEN_CTEMP:
|
||||
SETUP_REQUEST(SMBctemp, 3, 0);
|
||||
@ -421,6 +428,11 @@ NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union s
|
||||
parms->mknew.out.fnum = SVAL(req->in.vwv, VWV(0));
|
||||
break;
|
||||
|
||||
case RAW_OPEN_CREATE:
|
||||
CLI_CHECK_WCT(req, 1);
|
||||
parms->create.out.fnum = SVAL(req->in.vwv, VWV(0));
|
||||
break;
|
||||
|
||||
case RAW_OPEN_CTEMP:
|
||||
CLI_CHECK_WCT(req, 1);
|
||||
parms->ctemp.out.fnum = SVAL(req->in.vwv, VWV(0));
|
||||
|
@ -795,6 +795,61 @@ done:
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
test RAW_OPEN_CREATE
|
||||
*/
|
||||
static BOOL test_create(struct cli_state *cli, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
union smb_open io;
|
||||
const char *fname = BASEDIR "\\torture_create.txt";
|
||||
NTSTATUS status;
|
||||
int fnum;
|
||||
BOOL ret = True;
|
||||
time_t basetime = (time(NULL) + 3600*24*3) & ~1;
|
||||
union smb_fileinfo finfo;
|
||||
|
||||
printf("Checking RAW_OPEN_CREATE\n");
|
||||
|
||||
io.create.level = RAW_OPEN_CREATE;
|
||||
io.create.in.attrib = 0;
|
||||
io.create.in.write_time = 0;
|
||||
io.create.in.fname = fname;
|
||||
status = smb_raw_open(cli->tree, mem_ctx, &io);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
fnum = io.create.out.fnum;
|
||||
|
||||
status = smb_raw_open(cli->tree, mem_ctx, &io);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
|
||||
cli_close(cli, io.create.out.fnum);
|
||||
cli_close(cli, fnum);
|
||||
cli_unlink(cli, fname);
|
||||
|
||||
/* make sure write_time works */
|
||||
io.create.in.write_time = basetime;
|
||||
status = smb_raw_open(cli->tree, mem_ctx, &io);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
fnum = io.create.out.fnum;
|
||||
CHECK_TIME(basetime, write_time);
|
||||
|
||||
cli_close(cli, fnum);
|
||||
cli_unlink(cli, fname);
|
||||
|
||||
/* make sure file_attrs works */
|
||||
io.create.in.attrib = FILE_ATTRIBUTE_HIDDEN;
|
||||
status = smb_raw_open(cli->tree, mem_ctx, &io);
|
||||
CHECK_STATUS(status, NT_STATUS_OK);
|
||||
fnum = io.create.out.fnum;
|
||||
CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE, attrib);
|
||||
|
||||
done:
|
||||
cli_close(cli, fnum);
|
||||
cli_unlink(cli, fname);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
test RAW_OPEN_CTEMP
|
||||
*/
|
||||
@ -882,6 +937,10 @@ BOOL torture_raw_open(int dummy)
|
||||
ret = False;
|
||||
}
|
||||
|
||||
if (!test_create(cli, mem_ctx)) {
|
||||
ret = False;
|
||||
}
|
||||
|
||||
if (!test_ctemp(cli, mem_ctx)) {
|
||||
ret = False;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user