diff options
author | Volker Lendecke <vl@samba.org> | 2012-09-04 09:26:28 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2012-09-26 16:29:28 +0200 |
commit | cc58a19565870d62b3d3476b4b718fcd1ff94a46 (patch) | |
tree | 847b05ec5c906c94ceaa4b0bc3e000a710422d27 | |
parent | 50d324b7e070de4672eff3fb6231923e6dca807a (diff) | |
download | samba-cc58a19565870d62b3d3476b4b718fcd1ff94a46.tar.gz samba-cc58a19565870d62b3d3476b4b718fcd1ff94a46.tar.bz2 samba-cc58a19565870d62b3d3476b4b718fcd1ff94a46.zip |
s3: Slightly simplify calculate_open_access_flags
-rw-r--r-- | source3/smbd/open.c | 30 |
1 files changed, 17 insertions, 13 deletions
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; } |