BOOL cli_unlink(struct cli_state *cli, char *fname);
BOOL cli_mkdir(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);
BOOL cli_close(struct cli_state *cli, int fnum);
BOOL cli_lock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout);
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_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw);
-void NTLMSSPhash( unsigned char hash[256], unsigned char const key[5]);
-void NTLMSSPcalc( unsigned char hash[256], unsigned char *data, int len);
+void NTLMSSPhash( unsigned char hash[258], unsigned char key[5]);
+void NTLMSSPcalc( unsigned char hash[258], unsigned char *data, int len);
void SamOEMhash( unsigned char *data, unsigned char *key, int val);
/*The following definitions come from libsmb/smbencrypt.c */
+/****************************************************************************
+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
****************************************************************************/
int fnum;
/******************* open the pipe *****************/
- if ((fnum = cli_open(cli, pipe_name, O_CREAT|O_RDWR, DENY_NONE)) == -1)
+ if (IS_BITS_SET_ALL(cli->capabilities, CAP_NT_SMBS))
{
- DEBUG(0,("cli_nt_session_open: cli_open failed on pipe %s to machine %s. Error was %s\n",
- pipe_name, cli->desthost, cli_errstr(cli)));
- return False;
+ 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)
+ {
+ DEBUG(0,("cli_nt_session_open: cli_open failed on pipe %s to machine %s. Error was %s\n",
+ pipe_name, cli->desthost, cli_errstr(cli)));
+ return False;
+ }
- cli->nt_pipe_fnum = (uint16)fnum;
+ cli->nt_pipe_fnum = (uint16)fnum;
+
+ /**************** Set Named Pipe State ***************/
+ if (!rpc_pipe_set_hnd_state(cli, pipe_name, 0x4300))
+ {
+ DEBUG(0,("cli_nt_session_open: pipe hnd state failed. Error was %s\n",
+ cli_errstr(cli)));
+ cli_close(cli, cli->nt_pipe_fnum);
+ return False;
+ }
- /**************** Set Named Pipe State ***************/
- if (!rpc_pipe_set_hnd_state(cli, pipe_name, 0x4300))
- {
- DEBUG(0,("cli_nt_session_open: pipe hnd state failed. Error was %s\n",
- cli_errstr(cli)));
- cli_close(cli, cli->nt_pipe_fnum);
- return False;
}
/******************* bind request on pipe *****************/
{
bzero(smb_cli, sizeof(smb_cli));
cli_initialise(smb_cli);
+ smb_cli->capabilities |= CAP_NT_SMBS;
}
/****************************************************************************
uint32 create_options = IVAL(inbuf,smb_ntcreate_CreateOptions);
uint32 fname_len = MIN(((uint32)SVAL(inbuf,smb_ntcreate_NameLength)),
((uint32)sizeof(fname)-1));
- uint16 root_dir_fid = (uint16)IVAL(inbuf,smb_ntcreate_RootDirectoryFid);
+ uint16 root_dir_fid = (uint16)IVAL(inbuf,smb_ntcreate_RootDirectoryFid);
int smb_ofun;
int smb_open_mode;
int smb_attr = (file_attributes & SAMBA_ATTRIBUTES_MASK);