summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-07-17 22:21:24 +0000
committerJeremy Allison <jra@samba.org>1998-07-17 22:21:24 +0000
commit471087c9d28a4058efc16f98784cb179ffc1e4c4 (patch)
treeaccca93b43b77c8a46b2b78891d64a822ec3a403 /source3/smbd/reply.c
parent18067a7f0c7153d5298ab1e6530ace4f25f926e7 (diff)
downloadsamba-471087c9d28a4058efc16f98784cb179ffc1e4c4.tar.gz
samba-471087c9d28a4058efc16f98784cb179ffc1e4c4.tar.bz2
samba-471087c9d28a4058efc16f98784cb179ffc1e4c4.zip
Code added to fix the renaming of a directory under NT SMB calls.
local.h: Changed MAXDIR to MAX_OPEN_DIRECTORIES - shmem size also tuned by this. dir.c: Use MAX_OPEN_DIRECTORIES. nttrans.c: Allow opening of a directory to succeed. Doesn't actually open a file descriptor but takes a files_struct slot marked as an fd. reply.c: Changed to close any outstanding is_directory files. reply_close changed to understand directory files. server.c: Added open_directory(), close_directory() calls. smb.h: Added is_directory to files_struct. Changed OPEN_FNUM to check that target is !is_directory (this prevents the normal file calls from processing a directory files_struct. Jeremy. (This used to be commit e01ce693f47e75e277f3440d46e32b0bd866b550)
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 07b72738c5..a0d1775b21 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1490,10 +1490,15 @@ int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize)
open by this user */
if ((vuser != 0) && (lp_security() != SEC_SHARE)) {
int i;
- for (i=0;i<MAX_OPEN_FILES;i++)
- if ((Files[i].vuid == vuid) && Files[i].open) {
- close_file(i,False);
+ for (i=0;i<MAX_OPEN_FILES;i++) {
+ files_struct *fsp = &Files[i];
+ if ((fsp->vuid == vuid) && fsp->open) {
+ if(!fsp->is_directory)
+ close_file(i,False);
+ else
+ close_directory(i);
}
+ }
}
invalidate_vuid(vuid);
@@ -2416,14 +2421,16 @@ int reply_exit(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
- reply to a close
+ Reply to a close - has to deal with closing a directory opened by NT SMB's.
****************************************************************************/
+
int reply_close(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int fnum,cnum;
int outsize = 0;
time_t mtime;
int32 eclass = 0, err = 0;
+ files_struct *fsp = NULL;
outsize = set_message(outbuf,0,0,True);
@@ -2435,23 +2442,43 @@ int reply_close(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
fnum = GETFNUM(inbuf,smb_vwv0);
- CHECK_FNUM(fnum,cnum);
+ /*
+ * We can only use CHECK_FNUM if we know it's not a directory.
+ */
+
+ if(!(VALID_FNUM(fnum) && Files[fnum].open && Files[fnum].is_directory))
+ CHECK_FNUM(fnum,cnum);
+
+ fsp = &Files[fnum];
if(HAS_CACHED_ERROR(fnum)) {
- eclass = Files[fnum].wbmpx_ptr->wr_errclass;
- err = Files[fnum].wbmpx_ptr->wr_error;
+ eclass = fsp->wbmpx_ptr->wr_errclass;
+ err = fsp->wbmpx_ptr->wr_error;
}
- mtime = make_unix_date3(inbuf+smb_vwv1);
+ if(fsp->is_directory) {
+ /*
+ * Special case - close NT SMB directory
+ * handle.
+ */
+ DEBUG(3,("%s close directory fnum=%d cnum=%d\n",
+ timestring(), fnum, cnum ));
+ close_directory(fnum);
+ } else {
+ /*
+ * Close ordinary file.
+ */
+ mtime = make_unix_date3(inbuf+smb_vwv1);
- /* try and set the date */
- set_filetime(cnum, Files[fnum].name,mtime);
+ /* try and set the date */
+ set_filetime(cnum, fsp->name,mtime);
- DEBUG(3,("%s close fd=%d fnum=%d cnum=%d (numopen=%d)\n",
- timestring(),Files[fnum].fd_ptr->fd,fnum,cnum,
- Connections[cnum].num_files_open));
+ DEBUG(3,("%s close fd=%d fnum=%d cnum=%d (numopen=%d)\n",
+ timestring(),fsp->fd_ptr->fd,fnum,cnum,
+ Connections[cnum].num_files_open));
- close_file(fnum,True);
+ close_file(fnum,True);
+ }
/* We have a cached error */
if(eclass || err)