Author: jra Date: 2006-06-27 00:10:40 +0000 (Tue, 27 Jun 2006) New Revision: 16539
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16539 Log: Fix some of Volker's INVALID_DEVICE_REQUEST replies on a directory handle. Jeremy. Modified: trunk/source/include/smb_macros.h trunk/source/locking/locking.c trunk/source/smbd/fake_file.c trunk/source/smbd/open.c Changeset: Modified: trunk/source/include/smb_macros.h =================================================================== --- trunk/source/include/smb_macros.h 2006-06-26 23:46:15 UTC (rev 16538) +++ trunk/source/include/smb_macros.h 2006-06-27 00:10:40 UTC (rev 16539) @@ -83,8 +83,6 @@ #define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n)) /* these are useful macros for checking validity of handles */ -#define OPEN_FSP(fsp) ((fsp) && !(fsp)->is_directory) -#define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) /* you must add the following extern declaration to files using this macro @@ -96,17 +94,19 @@ return(ERROR_DOS(ERRDOS,ERRbadfid));\ } while(0) -#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) +#define FNUM_OK(fsp,c) ((fsp) && !(fsp)->is_directory && (c)==(fsp)->conn && current_user.vuid==(fsp)->vuid) /* you must add the following extern declaration to files using this macro * extern struct current_user current_user; */ #define CHECK_FSP(fsp,conn) do {\ extern struct current_user current_user;\ - if (!FNUM_OK(fsp,conn)) \ - return(ERROR_DOS(ERRDOS,ERRbadfid)); \ + if ((fsp) && (fsp)->is_directory) \ + return ERROR_NT(NT_STATUS_INVALID_DEVICE_REQUEST); \ + else if (!FNUM_OK(fsp,conn)) \ + return ERROR_NT(NT_STATUS_INVALID_HANDLE); \ else if((fsp)->fh->fd == -1) \ - return(ERROR_DOS(ERRDOS,ERRbadaccess));\ + return ERROR_NT(NT_STATUS_ACCESS_DENIED); \ (fsp)->num_smb_operations++;\ } while(0) Modified: trunk/source/locking/locking.c =================================================================== --- trunk/source/locking/locking.c 2006-06-26 23:46:15 UTC (rev 16538) +++ trunk/source/locking/locking.c 2006-06-27 00:10:40 UTC (rev 16539) @@ -150,8 +150,8 @@ struct byte_range_lock *br_lck = NULL; NTSTATUS status = NT_STATUS_LOCK_NOT_GRANTED; - if (!OPEN_FSP(fsp) || !fsp->can_lock) { - return NT_STATUS_INVALID_HANDLE; + if (!fsp->can_lock) { + return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE; } if (!lp_locking(SNUM(fsp->conn))) { @@ -190,8 +190,8 @@ struct byte_range_lock *br_lck = NULL; NTSTATUS status = NT_STATUS_LOCK_NOT_GRANTED; - if (!OPEN_FSP(fsp) || !fsp->can_lock) { - return NT_STATUS_INVALID_HANDLE; + if (!fsp->can_lock) { + return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE; } if (!lp_locking(SNUM(fsp->conn))) { @@ -294,14 +294,14 @@ BOOL ok = False; struct byte_range_lock *br_lck = NULL; + if (!fsp->can_lock) { + return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE; + } + if (!lp_locking(SNUM(fsp->conn))) { return NT_STATUS_OK; } - if (!OPEN_FSP(fsp) || !fsp->can_lock) { - return NT_STATUS_INVALID_HANDLE; - } - DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for fnum %d file %s\n", (double)offset, (double)count, fsp->fnum, fsp->fsp_name )); Modified: trunk/source/smbd/fake_file.c =================================================================== --- trunk/source/smbd/fake_file.c 2006-06-26 23:46:15 UTC (rev 16538) +++ trunk/source/smbd/fake_file.c 2006-06-27 00:10:40 UTC (rev 16539) @@ -130,7 +130,7 @@ fsp->fh->fd = -1; fsp->vuid = current_user.vuid; fsp->fh->pos = -1; - fsp->can_lock = True; /* Should this be true ? */ + fsp->can_lock = False; /* Should this be true ? - No, JRA */ fsp->access_mask = access_mask; string_set(&fsp->fsp_name,fname); Modified: trunk/source/smbd/open.c =================================================================== --- trunk/source/smbd/open.c 2006-06-26 23:46:15 UTC (rev 16538) +++ trunk/source/smbd/open.c 2006-06-27 00:10:40 UTC (rev 16539) @@ -1951,7 +1951,7 @@ fsp->dev = psbuf->st_dev; fsp->vuid = current_user.vuid; fsp->file_pid = global_smbpid; - fsp->can_lock = True; + fsp->can_lock = False; fsp->can_read = False; fsp->can_write = False;
