summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-09-04 09:22:49 +0200
committerVolker Lendecke <vl@samba.org>2012-09-26 00:22:56 +0200
commit7600fd8b0cef3f1de99204ebdd14115a5f36c958 (patch)
tree971fb69f6b52839706d4ae9bb2de940ead7f1a8d
parente0de443af80ee6231f4deddc5c7b4534d8c11f83 (diff)
downloadsamba-7600fd8b0cef3f1de99204ebdd14115a5f36c958.tar.gz
samba-7600fd8b0cef3f1de99204ebdd14115a5f36c958.tar.bz2
samba-7600fd8b0cef3f1de99204ebdd14115a5f36c958.zip
s3: Factor out calculate_open_access_flags
Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Sep 26 00:22:56 CEST 2012 on sn-devel-104
-rw-r--r--source3/smbd/open.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index e33c4abcc1..2785d6f3d1 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1869,6 +1869,35 @@ static int disposition_to_open_flags(uint32_t create_disposition)
return ret;
}
+static int calculate_open_access_flags(uint32_t access_mask,
+ int oplock_request,
+ uint32_t private_flags)
+{
+ int flags;
+
+ /*
+ * Note that we ignore the append flag as append does not
+ * mean the same thing under DOS and Unix.
+ */
+
+ if ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ||
+ (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE)) {
+ /* DENY_DOS opens are always underlying read-write on the
+ file handle, no matter what the requested access mask
+ says. */
+ if ((private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
+ access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|
+ FILE_READ_EA|FILE_EXECUTE)) {
+ flags = O_RDWR;
+ } else {
+ flags = O_WRONLY;
+ }
+ } else {
+ flags = O_RDONLY;
+ }
+ return flags;
+}
+
/****************************************************************************
Open a file with a share mode. Passed in an already created files_struct *.
****************************************************************************/
@@ -2123,21 +2152,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
* mean the same thing under DOS and Unix.
*/
- if ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ||
- (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE)) {
- /* DENY_DOS opens are always underlying read-write on the
- file handle, no matter what the requested access mask
- says. */
- if ((private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
- access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|
- FILE_READ_EA|FILE_EXECUTE)) {
- flags = O_RDWR;
- } else {
- flags = O_WRONLY;
- }
- } else {
- flags = O_RDONLY;
- }
+ flags = calculate_open_access_flags(access_mask, oplock_request,
+ private_flags);
/*
* Currently we only look at FILE_WRITE_THROUGH for create options.