summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/smbd/nttrans.c18
-rw-r--r--source3/smbd/reply.c142
-rw-r--r--source3/smbd/server.c19
4 files changed, 104 insertions, 76 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 06f0015638..2c377bfb56 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1779,6 +1779,7 @@ int reply_printqueue(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_printwrite(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_mkdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_rmdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int rename_internals(char *inbuf, char *outbuf, char *name, char *newname);
int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_copy(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_setdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index bc7a504d1d..c452e945c7 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -48,11 +48,12 @@ static char *known_nt_pipes[] = {
};
/****************************************************************************
- Send the required number of replies back.
- We assume all fields other than the data fields are
- set correctly for the type of call.
- HACK ! Always assumes smb_setup field is zero.
+ Send the required number of replies back.
+ We assume all fields other than the data fields are
+ set correctly for the type of call.
+ HACK ! Always assumes smb_setup field is zero.
****************************************************************************/
+
static int send_nt_replies(char *outbuf, int bufsize, char *params,
int paramsize, char *pdata, int datasize)
{
@@ -751,16 +752,17 @@ static int call_nt_transact_rename(char *inbuf, char *outbuf, int bufsize, int c
char **setup, char **params, char **data)
{
char *params = *pparams;
- pstring fname;
+ pstring new_name;
+ pstring old_name;
int fnum = SVAL(params, 0);
uint16 rename_flags = SVAL(params,2);
uint32 total_parameter_count = IVAL(inbuf, smb_nt_TotalParameterCount);
uint32 fname_len = MIN((((uint32)IVAL(inbuf,smb_nt_TotalParameterCount)-4)),
((uint32)sizeof(fname)-1));
- StrnCpy(fname,params+4,fname_len);
- unix_convert(fname,cnum,0,&bad_path);
-
+ StrnCpy(new_name,params+4,fname_len);
+ unix_convert(new_name,cnum,0,&bad_path);
+
}
/****************************************************************************
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 9177b3cde1..ec3ad84c9a 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3152,33 +3152,28 @@ static BOOL can_rename(char *fname,int cnum)
}
/****************************************************************************
- reply to a mv
+ The guts of the rename command, split out so it may be called by the NT SMB
+ code.
****************************************************************************/
-int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+
+int rename_internals(char *inbuf, char *outbuf, char *name, char *newname)
{
- int outsize = 0;
- pstring name;
int cnum;
pstring directory;
- pstring mask,newname;
+ pstring mask;
pstring newname_last_component;
char *p;
- int count=0;
- int error = ERRnoaccess;
BOOL has_wild;
- BOOL exists=False;
BOOL bad_path1 = False;
BOOL bad_path2 = False;
+ int count=0;
+ int error = ERRnoaccess;
+ BOOL exists=False;
+
+ cnum = SVAL(inbuf,smb_tid);
*directory = *mask = 0;
- cnum = SVAL(inbuf,smb_tid);
-
- pstrcpy(name,smb_buf(inbuf) + 1);
- pstrcpy(newname,smb_buf(inbuf) + 3 + strlen(name));
-
- DEBUG(3,("reply_mv : %s -> %s\n",name,newname));
-
unix_convert(name,cnum,0,&bad_path1);
unix_convert(newname,cnum,newname_last_component,&bad_path2);
@@ -3223,7 +3218,7 @@ int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
pstrcpy(newname, tmpstr);
}
- DEBUG(3,("reply_mv : case_sensitive = %d, case_preserve = %d, short case preserve = %d, directory = %s, newname = %s, newname_last_component = %s, is_8_3 = %d\n",
+ DEBUG(3,("rename_internals: case_sensitive = %d, case_preserve = %d, short case preserve = %d, directory = %s, newname = %s, newname_last_component = %s, is_8_3 = %d\n",
case_sensitive, case_preserve, short_case_preserve, directory,
newname, newname_last_component, is_short_name));
@@ -3249,21 +3244,22 @@ int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
pstrcpy(newname_modified_last_component,p+1);
if(strcsequal(newname_modified_last_component,
- newname_last_component) == False) {
- /*
- * Replace the modified last component with
- * the original.
- */
+ newname_last_component) == False) {
+ /*
+ * Replace the modified last component with
+ * the original.
+ */
pstrcpy(p+1, newname_last_component);
}
}
if (resolve_wildcards(directory,newname) &&
- can_rename(directory,cnum) &&
- !file_exist(newname,NULL) &&
- !sys_rename(directory,newname)) count++;
+ can_rename(directory,cnum) &&
+ !file_exist(newname,NULL) &&
+ !sys_rename(directory,newname))
+ count++;
- DEBUG(3,("reply_mv : %s doing rename on %s -> %s\n",(count != 0) ? "succeeded" : "failed",
+ DEBUG(3,("rename_internals: %s doing rename on %s -> %s\n",(count != 0) ? "succeeded" : "failed",
directory,newname));
if (!count) exists = file_exist(directory,NULL);
@@ -3279,62 +3275,78 @@ int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
if (check_name(directory,cnum))
dirptr = OpenDir(cnum, directory, True);
- if (dirptr)
- {
- error = ERRbadfile;
+ if (dirptr) {
+ error = ERRbadfile;
- if (strequal(mask,"????????.???"))
- pstrcpy(mask,"*");
+ if (strequal(mask,"????????.???"))
+ pstrcpy(mask,"*");
- while ((dname = ReadDirName(dirptr)))
- {
- pstring fname;
- pstrcpy(fname,dname);
+ while ((dname = ReadDirName(dirptr))) {
+ pstring fname;
+ pstrcpy(fname,dname);
- if(!mask_match(fname, mask, case_sensitive, False)) continue;
-
- error = ERRnoaccess;
- slprintf(fname,sizeof(fname)-1,"%s/%s",directory,dname);
- if (!can_rename(fname,cnum)) {
- DEBUG(6,("rename %s refused\n", fname));
- continue;
- }
- pstrcpy(destname,newname);
+ if(!mask_match(fname, mask, case_sensitive, False))
+ continue;
+
+ error = ERRnoaccess;
+ slprintf(fname,sizeof(fname)-1,"%s/%s",directory,dname);
+ if (!can_rename(fname,cnum)) {
+ DEBUG(6,("rename %s refused\n", fname));
+ continue;
+ }
+ pstrcpy(destname,newname);
- if (!resolve_wildcards(fname,destname)) {
- DEBUG(6,("resolve_wildcards %s %s failed\n",
- fname, destname));
- continue;
- }
+ if (!resolve_wildcards(fname,destname)) {
+ DEBUG(6,("resolve_wildcards %s %s failed\n", fname, destname));
+ continue;
+ }
- if (file_exist(destname,NULL)) {
- DEBUG(6,("file_exist %s\n",
- destname));
- error = 183;
- continue;
- }
- if (!sys_rename(fname,destname)) count++;
- DEBUG(3,("reply_mv : doing rename on %s -> %s\n",fname,destname));
- }
- CloseDir(dirptr);
+ if (file_exist(destname,NULL)) {
+ DEBUG(6,("file_exist %s\n", destname));
+ error = 183;
+ continue;
+ }
+ if (!sys_rename(fname,destname))
+ count++;
+ DEBUG(3,("rename_internals: doing rename on %s -> %s\n",fname,destname));
}
+ CloseDir(dirptr);
+ }
}
-
+
if (count == 0) {
if (exists)
return(ERROR(ERRDOS,error));
- else
- {
- if((errno == ENOENT) && (bad_path1 || bad_path2))
- {
+ else {
+ if((errno == ENOENT) && (bad_path1 || bad_path2)) {
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
return(UNIXERROR(ERRDOS,error));
}
}
-
- outsize = set_message(outbuf,0,0,True);
+
+ return 0;
+}
+
+/****************************************************************************
+ Reply to a mv.
+****************************************************************************/
+
+int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+{
+ int outsize = 0;
+ pstring name;
+ pstring newname;
+
+ pstrcpy(name,smb_buf(inbuf) + 1);
+ pstrcpy(newname,smb_buf(inbuf) + 3 + strlen(name));
+
+ DEBUG(3,("reply_mv : %s -> %s\n",name,newname));
+
+ outsize = rename_internals(inbuf, outbuf, name, newname);
+ if(outsize == 0)
+ outsize = set_message(outbuf,0,0,True);
return(outsize);
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index e167941ccb..374c41c1f5 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -1327,7 +1327,7 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
* open fd table.
*/
if(sbuf == 0) {
- if(stat(fname, &statbuf) < 0) {
+ if(sys_stat(fname, &statbuf) < 0) {
if(errno != ENOENT) {
DEBUG(3,("Error doing stat on file %s (%s)\n",
fname,strerror(errno)));
@@ -1755,7 +1755,7 @@ BOOL check_file_sharing(int cnum,char *fname, BOOL rename_op)
if(!lp_share_modes(SNUM(cnum)))
return True;
- if (stat(fname,&sbuf) == -1) return(True);
+ if (sys_stat(fname,&sbuf) == -1) return(True);
dev = (uint32)sbuf.st_dev;
inode = (uint32)sbuf.st_ino;
@@ -4145,7 +4145,12 @@ reply for the nt protocol
int reply_nt1(char *outbuf)
{
/* dual names + lock_and_read + nt SMBs + remote API calls */
- int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS;
+ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS
+#ifdef HAVE_NT_SMBS
+ |CAP_NT_SMBS
+#endif /* HAVE_NT_SMBS */
+ ;
+
/*
other valid capabilities which we may support at some time...
CAP_LARGE_FILES|CAP_NT_SMBS|CAP_RPC_REMOTE_APIS;
@@ -4712,6 +4717,14 @@ struct smb_message_struct
{SMBtrans2, "SMBtrans2", reply_trans2, AS_USER },
{SMBtranss2, "SMBtranss2", reply_transs2, AS_USER},
+#ifdef HAVE_NT_SMBS
+ /* NT PROTOCOL FOLLOWS */
+ {SMBntcreateX, "SMBntcreateX", reply_ntcreate_and_X, AS_USER | CAN_IPC | QUEUE_IN_OPLOCK },
+ {SMBnttrans, "SMBnttrans", reply_nttrans, AS_USER | CAN_IPC },
+ {SMBnttranss, "SMBnttranss", reply_nttranss, AS_USER | CAN_IPC },
+ {SMBntcancel, "SMBntcancel", reply_ntcancel, AS_USER },
+#endif /* HAVE_NT_SMBS */
+
/* messaging routines */
{SMBsends,"SMBsends",reply_sends,AS_GUEST},
{SMBsendstrt,"SMBsendstrt",reply_sendstrt,AS_GUEST},