1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-12 12:23:50 +03:00

basic client-side ntcreateX function (hard-wired values except filename)

This commit is contained in:
Luke Leighton
-
parent 32d0f5e4a5
commit caeb99201a
5 changed files with 77 additions and 16 deletions

View File

@@ -385,6 +385,7 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst);
BOOL cli_unlink(struct cli_state *cli, char *fname); BOOL cli_unlink(struct cli_state *cli, char *fname);
BOOL cli_mkdir(struct cli_state *cli, char *dname); BOOL cli_mkdir(struct cli_state *cli, char *dname);
BOOL cli_rmdir(struct cli_state *cli, char *dname); BOOL cli_rmdir(struct cli_state *cli, char *dname);
int cli_nt_create(struct cli_state *cli, char *fname);
int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode); int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode);
BOOL cli_close(struct cli_state *cli, int fnum); BOOL cli_close(struct cli_state *cli, int fnum);
BOOL cli_lock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout); BOOL cli_lock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout);
@@ -498,8 +499,8 @@ void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out);
void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key); void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key);
void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key); void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key);
void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw); void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw);
void NTLMSSPhash( unsigned char hash[256], unsigned char const key[5]); void NTLMSSPhash( unsigned char hash[258], unsigned char key[5]);
void NTLMSSPcalc( unsigned char hash[256], unsigned char *data, int len); void NTLMSSPcalc( unsigned char hash[258], unsigned char *data, int len);
void SamOEMhash( unsigned char *data, unsigned char *key, int val); void SamOEMhash( unsigned char *data, unsigned char *key, int val);
/*The following definitions come from libsmb/smbencrypt.c */ /*The following definitions come from libsmb/smbencrypt.c */

View File

@@ -973,6 +973,50 @@ BOOL cli_rmdir(struct cli_state *cli, char *dname)
/****************************************************************************
open a file
****************************************************************************/
int cli_nt_create(struct cli_state *cli, char *fname)
{
char *p;
bzero(cli->outbuf,smb_size);
bzero(cli->inbuf,smb_size);
set_message(cli->outbuf,24,1 + strlen(fname),True);
CVAL(cli->outbuf,smb_com) = SMBntcreateX;
SSVAL(cli->outbuf,smb_tid,cli->cnum);
cli_setup_packet(cli);
SSVAL(cli->outbuf,smb_vwv0,0xFF);
SIVAL(cli->outbuf,smb_ntcreate_Flags, 0x06);
SIVAL(cli->outbuf,smb_ntcreate_RootDirectoryFid, 0x0);
SIVAL(cli->outbuf,smb_ntcreate_DesiredAccess, 0x2019f);
SIVAL(cli->outbuf,smb_ntcreate_FileAttributes, 0x0);
SIVAL(cli->outbuf,smb_ntcreate_ShareAccess, 0x03);
SIVAL(cli->outbuf,smb_ntcreate_CreateDisposition, 0x01);
SIVAL(cli->outbuf,smb_ntcreate_CreateOptions, 0x0);
SIVAL(cli->outbuf,smb_ntcreate_ImpersonationLevel, 0x02);
SSVAL(cli->outbuf,smb_ntcreate_NameLength, strlen(fname));
p = smb_buf(cli->outbuf);
pstrcpy(p,fname);
p = skip_string(p,1);
send_smb(cli->fd,cli->outbuf);
if (!client_receive_smb(cli->fd,cli->inbuf,cli->timeout)) {
return -1;
}
if (CVAL(cli->inbuf,smb_rcls) != 0) {
return -1;
}
return SVAL(cli->inbuf,smb_vwv2 + 1);
}
/**************************************************************************** /****************************************************************************
open a file open a file
****************************************************************************/ ****************************************************************************/

View File

@@ -863,6 +863,19 @@ BOOL cli_nt_session_open(struct cli_state *cli, char *pipe_name, BOOL encrypted)
int fnum; int fnum;
/******************* open the pipe *****************/ /******************* open the pipe *****************/
if (IS_BITS_SET_ALL(cli->capabilities, CAP_NT_SMBS))
{
if ((fnum = cli_nt_create(cli, &(pipe_name[5]))) == -1)
{
DEBUG(0,("cli_nt_session_open: cli_nt_create failed on pipe %s to machine %s. Error was %s\n",
&(pipe_name[5]), cli->desthost, cli_errstr(cli)));
return False;
}
cli->nt_pipe_fnum = (uint16)fnum;
}
else
{
if ((fnum = cli_open(cli, pipe_name, O_CREAT|O_RDWR, DENY_NONE)) == -1) if ((fnum = cli_open(cli, pipe_name, O_CREAT|O_RDWR, DENY_NONE)) == -1)
{ {
DEBUG(0,("cli_nt_session_open: cli_open failed on pipe %s to machine %s. Error was %s\n", DEBUG(0,("cli_nt_session_open: cli_open failed on pipe %s to machine %s. Error was %s\n",
@@ -881,6 +894,8 @@ BOOL cli_nt_session_open(struct cli_state *cli, char *pipe_name, BOOL encrypted)
return False; return False;
} }
}
/******************* bind request on pipe *****************/ /******************* bind request on pipe *****************/
if (encrypted) if (encrypted)

View File

@@ -60,6 +60,7 @@ void rpcclient_init(void)
{ {
bzero(smb_cli, sizeof(smb_cli)); bzero(smb_cli, sizeof(smb_cli));
cli_initialise(smb_cli); cli_initialise(smb_cli);
smb_cli->capabilities |= CAP_NT_SMBS;
} }
/**************************************************************************** /****************************************************************************