From 7600fd8b0cef3f1de99204ebdd14115a5f36c958 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 4 Sep 2012 09:22:49 +0200 Subject: s3: Factor out calculate_open_access_flags Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Wed Sep 26 00:22:56 CEST 2012 on sn-devel-104 --- source3/smbd/open.c | 46 +++++++++++++++++++++++++++++++--------------- 1 file 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. -- cgit