mirror of
https://github.com/samba-team/samba.git
synced 2025-01-22 22:04:08 +03:00
- added a raw smb scanner
- its not a root_fid in ntrename (This used to be commit 74be55efdc77d4ba7e70d0554cbd72472522abff)
This commit is contained in:
parent
a33f570776
commit
4b3d329ca2
@ -151,7 +151,7 @@ union smb_rename {
|
||||
struct {
|
||||
uint16 attrib;
|
||||
uint16 flags; /* see RENAME_FLAG_* */
|
||||
uint32 root_fid; /* is it? */
|
||||
uint32 unknown;
|
||||
const char *old_name;
|
||||
const char *new_name;
|
||||
} in;
|
||||
|
@ -48,7 +48,7 @@ struct cli_request *smb_raw_rename_send(struct cli_tree *tree,
|
||||
SETUP_REQUEST(SMBntrename, 4, 0);
|
||||
SSVAL(req->out.vwv, VWV(0), parms->ntrename.in.attrib);
|
||||
SSVAL(req->out.vwv, VWV(1), parms->ntrename.in.flags);
|
||||
SIVAL(req->out.vwv, VWV(2), parms->ntrename.in.root_fid);
|
||||
SIVAL(req->out.vwv, VWV(2), parms->ntrename.in.unknown);
|
||||
cli_req_append_ascii4(req, parms->ntrename.in.old_name, STR_TERMINATE);
|
||||
cli_req_append_ascii4(req, parms->ntrename.in.new_name, STR_TERMINATE);
|
||||
break;
|
||||
|
@ -1256,7 +1256,7 @@ static BOOL handler_ntrename(int instance)
|
||||
parm[0].ntrename.in.old_name = gen_fname();
|
||||
parm[0].ntrename.in.new_name = gen_fname();
|
||||
parm[0].ntrename.in.attrib = gen_attrib();
|
||||
parm[0].ntrename.in.root_fid = gen_root_fid(instance);
|
||||
parm[0].ntrename.in.unknown = gen_bits_mask2(0, 0xFFFFFFF);
|
||||
parm[0].ntrename.in.flags = gen_rename_flags();
|
||||
|
||||
GEN_COPY_PARM;
|
||||
|
@ -512,3 +512,52 @@ BOOL torture_nttrans_scan(int dummy)
|
||||
printf("nttrans scan finished\n");
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/* scan for valid base SMB requests */
|
||||
BOOL torture_smb_scan(int dummy)
|
||||
{
|
||||
static struct cli_state *cli;
|
||||
int op;
|
||||
struct cli_request *req;
|
||||
NTSTATUS status;
|
||||
|
||||
for (op=0x0;op<=0xFF;op++) {
|
||||
if (op == SMBreadbraw) continue;
|
||||
|
||||
if (!torture_open_connection(&cli)) {
|
||||
return False;
|
||||
}
|
||||
|
||||
req = cli_request_setup(cli->tree, op, 0, 0);
|
||||
|
||||
if (!cli_request_send(req)) {
|
||||
cli_request_destroy(req);
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(10000);
|
||||
if (cli_transport_pending(cli->transport)) {
|
||||
status = cli_request_simple_recv(req);
|
||||
printf("op=0x%x status=%s\n", op, nt_errstr(status));
|
||||
torture_close_connection(cli);
|
||||
continue;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
if (cli_transport_pending(cli->transport)) {
|
||||
status = cli_request_simple_recv(req);
|
||||
printf("op=0x%x status=%s\n", op, nt_errstr(status));
|
||||
} else {
|
||||
printf("op=0x%x no reply\n", op);
|
||||
cli_request_destroy(req);
|
||||
continue; /* don't attempt close! */
|
||||
}
|
||||
|
||||
torture_close_connection(cli);
|
||||
}
|
||||
|
||||
|
||||
printf("smb scan finished\n");
|
||||
return True;
|
||||
}
|
||||
|
@ -3929,6 +3929,7 @@ static struct {
|
||||
{"SCAN-TRANS2", torture_trans2_scan, 0},
|
||||
{"SCAN-NTTRANS", torture_nttrans_scan, 0},
|
||||
{"SCAN-ALIASES", torture_trans2_aliases, 0},
|
||||
{"SCAN-SMB", torture_smb_scan, 0},
|
||||
{NULL, NULL, 0}};
|
||||
|
||||
|
||||
|
@ -35,6 +35,41 @@ double end_timer(void)
|
||||
(tp2.tv_usec - tp1.tv_usec)*1.0e-6);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
create a directory, returning a handle to it
|
||||
*/
|
||||
int create_directory_handle(struct cli_state *cli, const char *dname)
|
||||
{
|
||||
NTSTATUS status;
|
||||
union smb_open io;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
|
||||
mem_ctx = talloc_init("create_directory_handle");
|
||||
|
||||
io.generic.level = RAW_OPEN_NTCREATEX;
|
||||
io.ntcreatex.in.root_fid = 0;
|
||||
io.ntcreatex.in.flags = 0;
|
||||
io.ntcreatex.in.access_mask = SA_RIGHT_FILE_ALL_ACCESS;
|
||||
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
|
||||
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
|
||||
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
|
||||
io.ntcreatex.in.alloc_size = 0;
|
||||
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
|
||||
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
|
||||
io.ntcreatex.in.security_flags = 0;
|
||||
io.ntcreatex.in.fname = dname;
|
||||
|
||||
status = smb_raw_open(cli->tree, mem_ctx, &io);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
talloc_destroy(mem_ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
return io.ntcreatex.out.fnum;
|
||||
}
|
||||
|
||||
/*
|
||||
sometimes we need a fairly complex file to work with, so we can test
|
||||
all possible attributes.
|
||||
|
Loading…
x
Reference in New Issue
Block a user