From cc58a19565870d62b3d3476b4b718fcd1ff94a46 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 4 Sep 2012 09:26:28 +0200 Subject: s3: Slightly simplify calculate_open_access_flags --- source3/smbd/open.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 2785d6f3d1..8c24ef9ff1 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1874,26 +1874,30 @@ static int calculate_open_access_flags(uint32_t access_mask, uint32_t private_flags) { int flags; + bool need_write; /* * 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; - } + need_write = + ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) || + (oplock_request & FORCE_OPLOCK_BREAK_TO_NONE)); + + if (!need_write) { + return O_RDONLY; + } + + /* 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_RDONLY; + flags = O_WRONLY; } return flags; } -- cgit