/* * The Solaris nfsacl protocol represents some ACLs slightly differently * than POSIX 1003.1e draft 17 does (and we do): * * - Minimal ACLs always have an ACL_MASK entry, so they have * four instead of three entries. * - The ACL_MASK entry in such minimal ACLs always has the same * permissions as the ACL_GROUP_OBJ entry. (In extended ACLs * the ACL_MASK and ACL_GROUP_OBJ entries may differ.) * - The identifier fields of the ACL_USER_OBJ and ACL_GROUP_OBJ * entries contain the identifiers of the owner and owning group. * (In POSIX ACLs we always set them to ACL_UNDEFINED_ID). * - ACL entries in the kernel are kept sorted in ascending order * of (e_tag, e_id). Solaris ACLs are unsorted.
*/
/* Avoid the use of posix_acl_alloc(). nfsacl_encode() is * invoked in contexts where a memory allocation failure is * fatal. Fortunately this fake ACL is small enough to
* construct on the stack. */
posix_acl_init(acl2, 4);
/* Avoid the use of posix_acl_alloc(). nfsacl_encode() is * invoked in contexts where a memory allocation failure is * fatal. Fortunately this fake ACL is small enough to
* construct on the stack. */
posix_acl_init(acl2, 4);
switch(entry->e_tag) { case ACL_USER:
entry->e_uid = make_kuid(&init_user_ns, id); if (!uid_valid(entry->e_uid)) return -EINVAL; break; case ACL_GROUP:
entry->e_gid = make_kgid(&init_user_ns, id); if (!gid_valid(entry->e_gid)) return -EINVAL; break; case ACL_USER_OBJ: case ACL_GROUP_OBJ: case ACL_OTHER: if (entry->e_perm & ~S_IRWXO) return -EINVAL; break; case ACL_MASK: /* Solaris sometimes sets additional bits in the mask */
entry->e_perm &= S_IRWXO; break; default: return -EINVAL;
}
/* Find the ACL_GROUP_OBJ and ACL_MASK entries. */
FOREACH_ACL_ENTRY(pa, acl, pe) { switch(pa->e_tag) { case ACL_USER_OBJ: break; case ACL_GROUP_OBJ:
group_obj = pa; break; case ACL_MASK:
mask = pa;
fallthrough; case ACL_OTHER: break;
}
} if (acl->a_count == 4 && group_obj && mask &&
mask->e_perm == group_obj->e_perm) { /* remove bogus ACL_MASK entry */
memmove(mask, mask+1, (3 - (mask - acl->a_entries)) * sizeof(struct posix_acl_entry));
acl->a_count = 3;
} return 0;
}
/** * nfsacl_decode - Decode an NFSv3 ACL * * @buf: xdr_buf containing XDR'd ACL data to decode * @base: byte offset in xdr_buf where XDR'd ACL begins * @aclcnt: count of ACEs in decoded posix_acl * @pacl: buffer in which to place decoded posix_acl * * Returns the length of the decoded ACL in bytes, or a negative errno value.
*/ int nfsacl_decode(struct xdr_buf *buf, unsignedint base, unsignedint *aclcnt, struct posix_acl **pacl)
{ struct nfsacl_decode_desc nfsacl_desc = {
.desc = {
.elem_size = 12,
.xcode = pacl ? xdr_nfsace_decode : NULL,
},
};
u32 entries; int err;
if (xdr_decode_word(buf, base, &entries) ||
entries > NFS_ACL_MAX_ENTRIES) return -EINVAL;
nfsacl_desc.desc.array_maxlen = entries;
err = xdr_decode_array2(buf, base + 4, &nfsacl_desc.desc); if (err) return err; if (pacl) { if (entries != nfsacl_desc.desc.array_len ||
posix_acl_from_nfsacl(nfsacl_desc.acl) != 0) {
posix_acl_release(nfsacl_desc.acl); return -EINVAL;
}
*pacl = nfsacl_desc.acl;
} if (aclcnt)
*aclcnt = entries; return 8 + nfsacl_desc.desc.elem_size *
nfsacl_desc.desc.array_len;
}
EXPORT_SYMBOL_GPL(nfsacl_decode);
/** * nfs_stream_decode_acl - Decode an NFSv3 ACL * * @xdr: an xdr_stream positioned at an encoded ACL * @aclcnt: OUT: count of ACEs in decoded posix_acl * @pacl: OUT: a dynamically-allocated buffer containing the decoded posix_acl * * Return values: * %false: The encoded ACL is not valid * %true: @pacl contains a decoded ACL, and @xdr is advanced * * On a successful return, caller must release *pacl using posix_acl_release().
*/ bool nfs_stream_decode_acl(struct xdr_stream *xdr, unsignedint *aclcnt, struct posix_acl **pacl)
{ const size_t elem_size = XDR_UNIT * 3; struct nfsacl_decode_desc nfsacl_desc = {
.desc = {
.elem_size = elem_size,
.xcode = pacl ? xdr_nfsace_decode : NULL,
},
}; unsignedint base;
u32 entries;
if (xdr_stream_decode_u32(xdr, &entries) < 0) returnfalse; if (entries > NFS_ACL_MAX_ENTRIES) returnfalse;
base = xdr_stream_pos(xdr); if (!xdr_inline_decode(xdr, XDR_UNIT + elem_size * entries)) returnfalse;
nfsacl_desc.desc.array_maxlen = entries; if (xdr_decode_array2(xdr->buf, base, &nfsacl_desc.desc)) returnfalse;
if (pacl) { if (entries != nfsacl_desc.desc.array_len ||
posix_acl_from_nfsacl(nfsacl_desc.acl) != 0) {
posix_acl_release(nfsacl_desc.acl); returnfalse;
}
*pacl = nfsacl_desc.acl;
} if (aclcnt)
*aclcnt = entries; returntrue;
}
EXPORT_SYMBOL_GPL(nfs_stream_decode_acl);
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.26Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.