Add allowed and denied parms to access check routines

Affects:

fsal_test_access
fsal_check_access
cache_inode_access_sw

These parms allow access check to return the specific access mask bits
that were allowed and denied if the caller desires.

These will be used by high level permission checking to make some
more complex decisions, also, it will allow the protocol ACCESS routines
to make a single access check and be able to identify which bits should
be returned to the client.

Also, a flag is added to allow ACL interpretation to not stop at first
applicable DENY ACE. This will be used by NFS v3 and v4 ACCESS ops to
determine access in a single pass.

Ported from 1.5 c322e1b753befb0614318b0b49cbcbbca5b02f36

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add a LogFullDebug of file type to nfs4_op_putfh

Borrowed from 1.5 989c2a846991daf34c15dde005c496ea12e980b0

The rest of that patch was irrelevant, but this debug seems useful.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Fixup some error translations

New error: CACHE_INODE_BADNAME

ERR_FSAL_ISDIR -> CACHE_INODE_IS_A_DIRECTORY
ERR_FSAL_ISDIR -> STATE_IS_A_DIRECTORY

CACHE_INODE_BADNAME -> STATE_INVALID_ARGUMENT
CACHE_INODE_BADNAME -> NFS4ERR_BADNAME
CACHE_INODE_BADNAME -> NFS3ERR_INVAL (v3 doesn't have BADNAME)
CACHE_INODE_BADNAME -> NFSERR_IO (v2 doesn't even have INVAL)

In nfs4_sanity_check_FH, if required_type is DIRECTORY, return
NFS4ERR_SYMLINK or NFS4ERR_NOTDIR as appropriate.

Ported from 1.5 5cc398a1ab074772d4e875d910c3d96fa8faa3fe

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Have cache_inode_get_changeid4 check trust of attrs

This makes changeid more resilient to attr changes outside Ganesha.

Ported from 1.5 1219cc9bea64a3d34fd8b876174ea99c3930f684

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Use allowed/denied return from cache_inode_access_sw to simplify v3/4 ACCESS

By using the ability of cache_inode_access_sw to return the set of
allowed bits combined with the ability to ask for ACL evaluation to not
terminate on an applicable DENY ACE, we can make the access determination
for ACCESS with a single permission evaluation.

Also, provide a shared routine for performing the ACCESS logic.

Ported from 1.5 9d65778036b6466ffece9fbee7a6b40c35085214

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Add ATTRS_NFS3 to cover all attrs in fattr3 structure

In some cases we need to make sure we get all the FSAL attr flags
corresponding to the attributes present in NFS v3 fattr3 structure.

Ported from 1.5 3954450c52b8310184da2323b56de4d6de9a727d

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Properly permission check cache_inode_readdir

Must have rx mode or ACE4_LIST_DIR | ACE4_EXECUTE (SEARCH) permission to
get the handle or attributes of entries in a directory. Additionally,
for NFS v4, if the ACL attribute is requested, we also require
ACE4_READ_ACL.

Intentionally. we never check ACE4_READ_ATTR. Per section 6.2.1.
Attribute 12: acl of RFC 3530 bis, a server may silently ignore an ACL
mask bit if it can not enforce that. Since Linux pretty much always
allows attributes, we choose not to enforce ACE4_READ_ATTR.

Must have r mode or ACE4_LIST_DIR to get the names in a directory. If
the ACL attribute is requested, then must also have ACE4_READ_ACL.

Do not provide ACL for a file if file does not have READ_ACL permission.

Ported from 1.5 aa4aeb561d996dbe94471148d1dea326581ae7f5

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Properly permission check cache_inode_getattr

Intentionally. we never check ACE4_READ_ATTR. Per section 6.2.1.
Attribute 12: acl of RFC 3530 bis, a server may silently ignore an ACL
mask bit if it can not enforce that. Since Linux pretty much always
allows attributes, we choose not to enforce ACE4_READ_ATTR.

We do require ACE4_READ_ACL be allowed in order to fetch the ACL
attribute. Otherwise, we assume that the attributes are available
to the client.

Ported from 1.5 8723374acebf0ada866b49940d86c3a51e4a74d0

Note that with the code re-organization, we only bother to check permissions
for NFS v4 operations that call cache_entry_To_Fattr. nfs4_readdir_callback
already does this permission check for readdir. This change actually correctly
adds this permission check to PseudoFS readdir for junction entries which was
not properly handled in 1.5 code.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
NOT A PORT Fix return code issues in nfs_proto_tools.c including fix to nfs4_Fattr_cmp

Fix up some int/bool return codes.

nfs4_Fattr_cmp had a major issue, it tried to determine if attr were the
same by accumulating:

cmp += memcmp(something);

And then checking cmp == 0 at the end. Problem is that memcmp can return
-1, 0, or 1, so two differences, one that resulted in -1 and one that
resulted in 1 would negate each other and make it appear there were no
differences in attributes.

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>
Properly permission check cache_inode_lookup

Correct permissions for lookup are x mode or ACE4_EXECUTE ACL.

Also check object type correctly.

Ported from 1.5 18652a5fc3676b75ae4db78155bf3f60a6dce09b

Signed-off-by: Frank S. Filz <ffilzlnx@mindspring.com>