From: Jeremy Allison Date: Mon, 13 Apr 2020 19:24:14 +0000 (-0700) Subject: s3: VFS: acl_xattr.c: Add fget_acl_blob(). X-Git-Tag: ldb-2.2.0~624 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=936b9aee5e699fba92cd70885e1a16971252d1d9;p=thirdparty%2Fsamba.git s3: VFS: acl_xattr.c: Add fget_acl_blob(). Separate from get_acl_blob() which took both an fsp and a pathname. Commented out so we still compile. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c index 7ac7a8dca60..d6005cead72 100644 --- a/source3/modules/vfs_acl_xattr.c +++ b/source3/modules/vfs_acl_xattr.c @@ -64,6 +64,66 @@ static ssize_t getxattr_do(vfs_handle_struct *handle, return sizeret; } +#if 0 +static NTSTATUS fget_acl_blob(TALLOC_CTX *ctx, + vfs_handle_struct *handle, + files_struct *fsp, + DATA_BLOB *pblob) +{ + size_t size = 4096; + uint8_t *val = NULL; + uint8_t *tmp; + ssize_t sizeret; + + ZERO_STRUCTP(pblob); + + again: + + tmp = talloc_realloc(ctx, val, uint8_t, size); + if (tmp == NULL) { + TALLOC_FREE(val); + return NT_STATUS_NO_MEMORY; + } + val = tmp; + + sizeret = + getxattr_do(handle, fsp, NULL, XATTR_NTACL_NAME, val, size); + + if (sizeret >= 0) { + pblob->data = val; + pblob->length = sizeret; + return NT_STATUS_OK; + } + + if (errno != ERANGE) { + goto err; + } + + /* Too small, try again. */ + sizeret = + getxattr_do(handle, fsp, NULL, XATTR_NTACL_NAME, NULL, 0); + if (sizeret < 0) { + goto err; + } + + if (size < sizeret) { + size = sizeret; + } + + if (size > 65536) { + /* Max ACL size is 65536 bytes. */ + errno = ERANGE; + goto err; + } + + goto again; + err: + /* Real error - exit here. */ + TALLOC_FREE(val); + return map_nt_error_from_unix(errno); +} +#endif + static NTSTATUS get_acl_blob(TALLOC_CTX *ctx, vfs_handle_struct *handle, files_struct *fsp,