summaryrefslogtreecommitdiff
path: root/source3/smbd/open.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-04-14 20:47:30 +0000
committerJeremy Allison <jra@samba.org>2001-04-14 20:47:30 +0000
commit2df39394fe01de6fb19cd919554272f407ecee4a (patch)
treeff3741febe9a5b334a78d2953a97685fe9cfb2f9 /source3/smbd/open.c
parented449b8ca7697d64ab3cfe8289287dd18566c91e (diff)
downloadsamba-2df39394fe01de6fb19cd919554272f407ecee4a.tar.gz
samba-2df39394fe01de6fb19cd919554272f407ecee4a.tar.bz2
samba-2df39394fe01de6fb19cd919554272f407ecee4a.zip
This little piece of insanity is inspired by the
fact that an NT client can open a file for O_RDONLY, but set the create disposition to FILE_EXISTS_TRUNCATE. If the client *can* write to the file, then it expects to truncate the file, even though it is opening for readonly. Quicken uses this stupid trick in backup file creation... Thanks *greatly* to "David W. Chapman Jr." <dwcjr@inethouston.net> for helping track this one down. It didn't bite us in 2.0.x as we always opened files read-write in that release. Jeremy. (This used to be commit 5baef56831f9bc4fa10a851abd5f9305b974fb3b)
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r--source3/smbd/open.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index f450e74e58..cebb37ab29 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -48,8 +48,8 @@ static int fd_open(struct connection_struct *conn, char *fname,
fd = conn->vfs_ops.open(conn,dos_to_unix(fname,False),flags,mode);
}
- DEBUG(10,("fd_open: name %s, mode = %d, fd = %d. %s\n", fname, (int)mode, fd,
- (fd == -1) ? strerror(errno) : "" ));
+ DEBUG(10,("fd_open: name %s, flags = 0%o mode = 0%o, fd = %d. %s\n", fname,
+ flags, (int)mode, fd, (fd == -1) ? strerror(errno) : "" ));
return fd;
}
@@ -647,7 +647,22 @@ files_struct *open_file_shared(connection_struct *conn,char *fname, SMB_STRUCT_S
flags = O_RDWR;
break;
default:
- flags = O_RDONLY;
+ /*
+ * This little piece of insanity is inspired by the
+ * fact that an NT client can open a file for O_RDONLY,
+ * but set the create disposition to FILE_EXISTS_TRUNCATE.
+ * If the client *can* write to the file, then it expects to
+ * truncate the file, even though it is opening for readonly.
+ * Quicken uses this stupid trick in backup file creation...
+ * Thanks *greatly* to "David W. Chapman Jr." <dwcjr@inethouston.net>
+ * for helping track this one down. It didn't bite us in 2.0.x
+ * as we always opened files read-write in that release. JRA.
+ */
+
+ if (flags2 & O_TRUNC)
+ flags = O_RDWR;
+ else
+ flags = O_RDONLY;
break;
}