svn commit: samba r8100 - in trunk/source: include locking printing
smbd
jra at samba.org
jra at samba.org
Sun Jul 3 20:34:49 GMT 2005
Author: jra
Date: 2005-07-03 20:34:48 +0000 (Sun, 03 Jul 2005)
New Revision: 8100
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8100
Log:
We *may* now pass NTDENY1 and NTDENY2 Samba4 torture tests, I need
to test some more to make sure. Ensure we look at the flags2 execute
bit, plus we now never open O_WRONLY so make sure we don't do POSIX
lock mapping based on that.
Jeremy.
Modified:
trunk/source/include/smb.h
trunk/source/include/smb_macros.h
trunk/source/locking/posix.c
trunk/source/printing/printfsp.c
trunk/source/smbd/reply.c
Changeset:
Modified: trunk/source/include/smb.h
===================================================================
--- trunk/source/include/smb.h 2005-07-03 17:35:19 UTC (rev 8099)
+++ trunk/source/include/smb.h 2005-07-03 20:34:48 UTC (rev 8100)
@@ -1331,7 +1331,7 @@
#define FLAGS2_IS_LONG_NAME 0x0040
#define FLAGS2_EXTENDED_SECURITY 0x0800
#define FLAGS2_DFS_PATHNAMES 0x1000
-#define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
+#define FLAGS2_READ_PERMIT_EXECUTE 0x2000
#define FLAGS2_32_BIT_ERROR_CODES 0x4000
#define FLAGS2_UNICODE_STRINGS 0x8000
Modified: trunk/source/include/smb_macros.h
===================================================================
--- trunk/source/include/smb_macros.h 2005-07-03 17:35:19 UTC (rev 8099)
+++ trunk/source/include/smb_macros.h 2005-07-03 20:34:48 UTC (rev 8100)
@@ -106,11 +106,12 @@
(fsp)->num_smb_operations++;\
} while(0)
-#define CHECK_READ(fsp) if (!(fsp)->can_read) \
- return(ERROR_DOS(ERRDOS,ERRbadaccess))
-#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \
- return(ERROR_DOS(ERRDOS,ERRbadaccess))
+#define CHECK_READ(fsp,inbuf) (((fsp)->fd != -1) && ((fsp)->can_read || \
+ ((SVAL((inbuf),smb_flg2) & FLAGS2_READ_PERMIT_EXECUTE) && \
+ (fsp->access_mask & FILE_EXECUTE))))
+#define CHECK_WRITE(fsp) ((fsp)->can_write && ((fsp)->fd != -1))
+
#define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \
NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) )
Modified: trunk/source/locking/posix.c
===================================================================
--- trunk/source/locking/posix.c 2005-07-03 17:35:19 UTC (rev 8099)
+++ trunk/source/locking/posix.c 2005-07-03 20:34:48 UTC (rev 8100)
@@ -524,13 +524,17 @@
*/
DEBUG(10,("map_posix_lock_type: Downgrading write lock to read due to read-only file.\n"));
return F_RDLCK;
- } else if((lock_type == READ_LOCK) && !fsp->can_read) {
+ }
+#if 0
+ /* We no longer open files write-only. */
+ else if((lock_type == READ_LOCK) && !fsp->can_read) {
/*
* Ditto for read locks on write only files.
*/
DEBUG(10,("map_posix_lock_type: Changing read lock to write due to write-only file.\n"));
return F_WRLCK;
}
+#endif
/*
* This return should be the most normal, as we attempt
Modified: trunk/source/printing/printfsp.c
===================================================================
--- trunk/source/printing/printfsp.c 2005-07-03 17:35:19 UTC (rev 8099)
+++ trunk/source/printing/printfsp.c 2005-07-03 20:34:48 UTC (rev 8100)
@@ -70,6 +70,7 @@
fsp->pos = -1;
fsp->can_lock = True;
fsp->can_read = False;
+ fsp->access_mask = FILE_GENERIC_WRITE;
fsp->can_write = True;
fsp->print_file = True;
fsp->modified = False;
Modified: trunk/source/smbd/reply.c
===================================================================
--- trunk/source/smbd/reply.c 2005-07-03 17:35:19 UTC (rev 8099)
+++ trunk/source/smbd/reply.c 2005-07-03 20:34:48 UTC (rev 8100)
@@ -2326,7 +2326,9 @@
START_PROFILE(SMBlockread);
CHECK_FSP(fsp,conn);
- CHECK_READ(fsp);
+ if (!CHECK_READ(fsp,inbuf)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
release_level_2_oplocks_on_change(fsp);
@@ -2420,7 +2422,9 @@
START_PROFILE(SMBread);
CHECK_FSP(fsp,conn);
- CHECK_READ(fsp);
+ if (!CHECK_READ(fsp,inbuf)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
numtoread = SVAL(inbuf,smb_vwv1);
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2);
@@ -2605,7 +2609,9 @@
}
CHECK_FSP(fsp,conn);
- CHECK_READ(fsp);
+ if (!CHECK_READ(fsp,inbuf)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
set_message(outbuf,12,0,True);
@@ -2685,7 +2691,9 @@
}
CHECK_FSP(fsp,conn);
- CHECK_WRITE(fsp);
+ if (!CHECK_WRITE(fsp)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
tcount = IVAL(inbuf,smb_vwv1);
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv3);
@@ -2819,7 +2827,9 @@
START_PROFILE(SMBwriteunlock);
CHECK_FSP(fsp,conn);
- CHECK_WRITE(fsp);
+ if (!CHECK_WRITE(fsp)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
numtowrite = SVAL(inbuf,smb_vwv1);
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2);
@@ -2833,10 +2843,11 @@
/* The special X/Open SMB protocol handling of
zero length writes is *NOT* done for
this call */
- if(numtowrite == 0)
+ if(numtowrite == 0) {
nwritten = 0;
- else
+ } else {
nwritten = write_file(fsp,data,startpos,numtowrite);
+ }
if (lp_syncalways(SNUM(conn)))
sync_file(conn,fsp);
@@ -2890,7 +2901,9 @@
}
CHECK_FSP(fsp,conn);
- CHECK_WRITE(fsp);
+ if (!CHECK_WRITE(fsp)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
numtowrite = SVAL(inbuf,smb_vwv1);
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2);
@@ -2971,7 +2984,9 @@
}
CHECK_FSP(fsp,conn);
- CHECK_WRITE(fsp);
+ if (!CHECK_WRITE(fsp)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
set_message(outbuf,6,0,True);
@@ -3276,7 +3291,9 @@
START_PROFILE(SMBwriteclose);
CHECK_FSP(fsp,conn);
- CHECK_WRITE(fsp);
+ if (!CHECK_WRITE(fsp)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
numtowrite = SVAL(inbuf,smb_vwv1);
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2);
@@ -3642,7 +3659,9 @@
}
CHECK_FSP(fsp,conn);
- CHECK_WRITE(fsp);
+ if (!CHECK_WRITE(fsp)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
numtowrite = SVAL(smb_buf(inbuf),1);
data = smb_buf(inbuf) + 3;
@@ -5255,7 +5274,9 @@
outsize = set_message(outbuf,8,0,True);
CHECK_FSP(fsp,conn);
- CHECK_READ(fsp);
+ if (!CHECK_READ(fsp,inbuf)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv1);
maxcount = SVAL(inbuf,smb_vwv3);
@@ -5383,7 +5404,9 @@
START_PROFILE(SMBwriteBmpx);
CHECK_FSP(fsp,conn);
- CHECK_WRITE(fsp);
+ if (!CHECK_WRITE(fsp)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
if (HAS_CACHED_ERROR(fsp)) {
return(CACHED_ERROR(fsp));
}
@@ -5487,7 +5510,9 @@
START_PROFILE(SMBwriteBs);
CHECK_FSP(fsp,conn);
- CHECK_WRITE(fsp);
+ if (!CHECK_WRITE(fsp)) {
+ return(ERROR_DOS(ERRDOS,ERRbadaccess));
+ }
tcount = SVAL(inbuf,smb_vwv1);
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv2);
More information about the samba-cvs
mailing list