summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-08-30 19:29:59 +0000
committerJeremy Allison <jra@samba.org>2002-08-30 19:29:59 +0000
commit35b7dfaa203689f761d38d7d243b4f335543bf4c (patch)
tree976f1f8a31c1a1ca60076ba3e017458aac9e191c
parent8e33a5d6cc45d15f5c9088ce896132aa288d7700 (diff)
downloadsamba-35b7dfaa203689f761d38d7d243b4f335543bf4c.tar.gz
samba-35b7dfaa203689f761d38d7d243b4f335543bf4c.tar.bz2
samba-35b7dfaa203689f761d38d7d243b4f335543bf4c.zip
Fix bug with stat mode open being done on read-only open with
truncate. Jeremy. (This used to be commit 18b9cbd857177a911ef95c9322bdf0709161cd84)
-rw-r--r--source3/smbd/open.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 47e859d04b..8cc73a681d 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -139,18 +139,20 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
* as we always opened files read-write in that release. JRA.
*/
- if ((accmode == O_RDONLY) && ((flags & O_TRUNC) == O_TRUNC))
+ if ((accmode == O_RDONLY) && ((flags & O_TRUNC) == O_TRUNC)) {
+ DEBUG(10,("open_file: truncate requested on read-only open for file %s\n",fname ));
local_flags = (flags & ~O_ACCMODE)|O_RDWR;
+ }
- /*
- * We can't actually truncate here as the file may be locked.
- * open_file_shared will take care of the truncate later. JRA.
- */
+ if ((desired_access & (FILE_READ_DATA|FILE_WRITE_DATA|FILE_APPEND_DATA|FILE_EXECUTE)) ||
+ (local_flags & O_CREAT) || ((local_flags & O_TRUNC) == O_TRUNC) ) {
- local_flags &= ~O_TRUNC;
+ /*
+ * We can't actually truncate here as the file may be locked.
+ * open_file_shared will take care of the truncate later. JRA.
+ */
- if ((desired_access & (FILE_READ_DATA|FILE_WRITE_DATA|FILE_APPEND_DATA|FILE_EXECUTE)) ||
- (local_flags & O_CREAT)) {
+ local_flags &= ~O_TRUNC;
/* actually do the open */
fsp->fd = fd_open(conn, fname, local_flags, mode);