mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
s3: VFS: Change SMB_VFS_GETXATTR to use const struct smb_filename * instead of const char *.
We need to migrate all pathname based VFS calls to use a struct to finish modernising the VFS with extra timestamp and flags parameters. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Jun 1 02:58:53 CEST 2017 on sn-devel-144
This commit is contained in:
@ -797,8 +797,11 @@ static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
static ssize_t skel_getxattr(vfs_handle_struct *handle, const char *path,
|
||||
const char *name, void *value, size_t size)
|
||||
static ssize_t skel_getxattr(vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
|
@ -933,10 +933,13 @@ static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle,
|
||||
return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
|
||||
}
|
||||
|
||||
static ssize_t skel_getxattr(vfs_handle_struct *handle, const char *path,
|
||||
const char *name, void *value, size_t size)
|
||||
static ssize_t skel_getxattr(vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
|
||||
}
|
||||
|
||||
static ssize_t skel_fgetxattr(vfs_handle_struct *handle,
|
||||
|
@ -211,7 +211,8 @@
|
||||
to const struct smb_filename * */
|
||||
/* Version 37 - Change setxattr from const char *
|
||||
to const struct smb_filename * */
|
||||
|
||||
/* Version 37 - Change getxattr from const char *
|
||||
to const struct smb_filename * */
|
||||
|
||||
#define SMB_VFS_INTERFACE_VERSION 37
|
||||
|
||||
@ -894,7 +895,11 @@ struct vfs_fn_pointers {
|
||||
const struct smb_filename *smb_fname);
|
||||
|
||||
/* EA operations. */
|
||||
ssize_t (*getxattr_fn)(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size);
|
||||
ssize_t (*getxattr_fn)(struct vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size);
|
||||
ssize_t (*fgetxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size);
|
||||
ssize_t (*listxattr_fn)(struct vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
@ -1365,8 +1370,10 @@ int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,
|
||||
int smb_vfs_call_sys_acl_delete_def_file(struct vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname);
|
||||
ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path, const char *name, void *value,
|
||||
size_t size);
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size);
|
||||
ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
|
||||
struct files_struct *fsp, const char *name,
|
||||
void *value, size_t size);
|
||||
|
@ -515,10 +515,10 @@
|
||||
#define SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname) \
|
||||
smb_vfs_call_sys_acl_delete_def_file((handle)->next, (smb_fname))
|
||||
|
||||
#define SMB_VFS_GETXATTR(conn,path,name,value,size) \
|
||||
smb_vfs_call_getxattr((conn)->vfs_handles,(path),(name),(value),(size))
|
||||
#define SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size) \
|
||||
smb_vfs_call_getxattr((handle)->next,(path),(name),(value),(size))
|
||||
#define SMB_VFS_GETXATTR(conn,smb_fname,name,value,size) \
|
||||
smb_vfs_call_getxattr((conn)->vfs_handles,(smb_fname),(name),(value),(size))
|
||||
#define SMB_VFS_NEXT_GETXATTR(handle,smb_fname,name,value,size) \
|
||||
smb_vfs_call_getxattr((handle)->next,(smb_fname),(name),(value),(size))
|
||||
|
||||
#define SMB_VFS_FGETXATTR(fsp,name,value,size) \
|
||||
smb_vfs_call_fgetxattr((fsp)->conn->vfs_handles, (fsp), (name),(value),(size))
|
||||
|
@ -360,10 +360,10 @@ SMB_ACL_T posixacl_xattr_acl_get_file(vfs_handle_struct *handle,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = SMB_VFS_GETXATTR(handle->conn, smb_fname->base_name,
|
||||
ret = SMB_VFS_GETXATTR(handle->conn, smb_fname,
|
||||
name, buf, size);
|
||||
if (ret < 0 && errno == ERANGE) {
|
||||
size = SMB_VFS_GETXATTR(handle->conn, smb_fname->base_name,
|
||||
size = SMB_VFS_GETXATTR(handle->conn, smb_fname,
|
||||
name, NULL, 0);
|
||||
if (size > 0) {
|
||||
buf = alloca(size);
|
||||
@ -371,7 +371,7 @@ SMB_ACL_T posixacl_xattr_acl_get_file(vfs_handle_struct *handle,
|
||||
return NULL;
|
||||
}
|
||||
ret = SMB_VFS_GETXATTR(handle->conn,
|
||||
smb_fname->base_name, name,
|
||||
smb_fname, name,
|
||||
buf, size);
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ static ssize_t getxattr_do(vfs_handle_struct *handle,
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
sizeret = SMB_VFS_FGETXATTR(fsp, xattr_name, val, size);
|
||||
} else {
|
||||
sizeret = SMB_VFS_GETXATTR(handle->conn, smb_fname->base_name,
|
||||
sizeret = SMB_VFS_GETXATTR(handle->conn, smb_fname,
|
||||
XATTR_NTACL_NAME, val, size);
|
||||
}
|
||||
if (sizeret == -1) {
|
||||
|
@ -652,16 +652,45 @@ static int cap_sys_acl_delete_def_file(vfs_handle_struct *handle,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t cap_getxattr(vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t size)
|
||||
static ssize_t cap_getxattr(vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
char *cappath = capencode(talloc_tos(), path);
|
||||
struct smb_filename *cap_smb_fname = NULL;
|
||||
char *cappath = capencode(talloc_tos(), smb_fname->base_name);
|
||||
char *capname = capencode(talloc_tos(), name);
|
||||
ssize_t ret;
|
||||
int saved_errno = 0;
|
||||
|
||||
if (!cappath || !capname) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, cappath, capname, value, size);
|
||||
cap_smb_fname = synthetic_smb_fname(talloc_tos(),
|
||||
cappath,
|
||||
NULL,
|
||||
NULL,
|
||||
smb_fname->flags);
|
||||
if (cap_smb_fname == NULL) {
|
||||
TALLOC_FREE(cappath);
|
||||
TALLOC_FREE(capname);
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, cap_smb_fname,
|
||||
capname, value, size);
|
||||
if (ret == -1) {
|
||||
saved_errno = errno;
|
||||
}
|
||||
TALLOC_FREE(cappath);
|
||||
TALLOC_FREE(capname);
|
||||
TALLOC_FREE(cap_smb_fname);
|
||||
if (saved_errno) {
|
||||
errno = saved_errno;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t cap_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path, void *value, size_t size)
|
||||
|
@ -1376,16 +1376,23 @@ catia_sys_acl_delete_def_file(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
catia_getxattr(vfs_handle_struct *handle, const char *path,
|
||||
const char *name, void *value, size_t size)
|
||||
catia_getxattr(vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
struct smb_filename *mapped_smb_fname = NULL;
|
||||
char *mapped_name = NULL;
|
||||
char *mapped_ea_name = NULL;
|
||||
NTSTATUS status;
|
||||
ssize_t ret;
|
||||
int saved_errno = 0;
|
||||
|
||||
status = catia_string_replace_allocate(handle->conn,
|
||||
path, &mapped_name, vfs_translate_to_unix);
|
||||
smb_fname->base_name,
|
||||
&mapped_name,
|
||||
vfs_translate_to_unix);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
errno = map_errno_from_nt_status(status);
|
||||
return -1;
|
||||
@ -1399,10 +1406,29 @@ catia_getxattr(vfs_handle_struct *handle, const char *path,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, mapped_name,
|
||||
mapped_smb_fname = synthetic_smb_fname(talloc_tos(),
|
||||
mapped_name,
|
||||
NULL,
|
||||
NULL,
|
||||
smb_fname->flags);
|
||||
if (mapped_smb_fname == NULL) {
|
||||
TALLOC_FREE(mapped_name);
|
||||
TALLOC_FREE(mapped_ea_name);
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, mapped_smb_fname,
|
||||
mapped_ea_name, value, size);
|
||||
if (ret == -1) {
|
||||
saved_errno = errno;
|
||||
}
|
||||
TALLOC_FREE(mapped_name);
|
||||
TALLOC_FREE(mapped_ea_name);
|
||||
TALLOC_FREE(mapped_smb_fname);
|
||||
if (saved_errno != 0) {
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1217,11 +1217,17 @@ static const char *cephwrap_connectpath(struct vfs_handle_struct *handle,
|
||||
Extended attribute operations.
|
||||
*****************************************************************/
|
||||
|
||||
static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
|
||||
static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
int ret;
|
||||
DBG_DEBUG("[CEPH] getxattr(%p, %s, %s, %p, %llu)\n", handle, path, name, value, llu(size));
|
||||
ret = ceph_getxattr(handle->data, path, name, value, size);
|
||||
DBG_DEBUG("[CEPH] getxattr(%p, %s, %s, %p, %llu)\n", handle,
|
||||
smb_fname->base_name, name, value, llu(size));
|
||||
ret = ceph_getxattr(handle->data,
|
||||
smb_fname->base_name, name, value, size);
|
||||
DBG_DEBUG("[CEPH] getxattr(...) = %d\n", ret);
|
||||
if (ret < 0) {
|
||||
WRAP_RETURN(ret);
|
||||
|
@ -2747,9 +2747,13 @@ static int vfswrap_sys_acl_delete_def_file(vfs_handle_struct *handle,
|
||||
Extended attribute operations.
|
||||
*****************************************************************/
|
||||
|
||||
static ssize_t vfswrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
|
||||
static ssize_t vfswrap_getxattr(struct vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
return getxattr(path, name, value, size);
|
||||
return getxattr(smb_fname->base_name, name, value, size);
|
||||
}
|
||||
|
||||
static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
|
||||
|
@ -36,12 +36,13 @@
|
||||
#define FAKE_ACL_DEFAULT_XATTR "system.fake_default_acl"
|
||||
|
||||
static int fake_acls_uid(vfs_handle_struct *handle,
|
||||
const char *path,
|
||||
struct smb_filename *smb_fname,
|
||||
uid_t *uid)
|
||||
{
|
||||
ssize_t size;
|
||||
uint8_t uid_buf[4];
|
||||
size = SMB_VFS_NEXT_GETXATTR(handle, path, FAKE_UID, uid_buf, sizeof(uid_buf));
|
||||
size = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
|
||||
FAKE_UID, uid_buf, sizeof(uid_buf));
|
||||
if (size == -1 && errno == ENOATTR) {
|
||||
return 0;
|
||||
}
|
||||
@ -53,13 +54,14 @@ static int fake_acls_uid(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static int fake_acls_gid(vfs_handle_struct *handle,
|
||||
const char *path,
|
||||
struct smb_filename *smb_fname,
|
||||
uid_t *gid)
|
||||
{
|
||||
ssize_t size;
|
||||
uint8_t gid_buf[4];
|
||||
|
||||
size = SMB_VFS_NEXT_GETXATTR(handle, path, FAKE_GID, gid_buf, sizeof(gid_buf));
|
||||
size = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
|
||||
FAKE_GID, gid_buf, sizeof(gid_buf));
|
||||
if (size == -1 && errno == ENOATTR) {
|
||||
return 0;
|
||||
}
|
||||
@ -131,12 +133,14 @@ static int fake_acls_stat(vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = fake_acls_uid(handle, path, &smb_fname->st.st_ex_uid);
|
||||
ret = fake_acls_uid(handle, &smb_fname_base,
|
||||
&smb_fname->st.st_ex_uid);
|
||||
if (ret != 0) {
|
||||
TALLOC_FREE(frame);
|
||||
return ret;
|
||||
}
|
||||
ret = fake_acls_gid(handle, path, &smb_fname->st.st_ex_gid);
|
||||
ret = fake_acls_gid(handle, &smb_fname_base,
|
||||
&smb_fname->st.st_ex_gid);
|
||||
if (ret != 0) {
|
||||
TALLOC_FREE(frame);
|
||||
return ret;
|
||||
@ -179,8 +183,10 @@ static int fake_acls_lstat(vfs_handle_struct *handle,
|
||||
* because linux doesn't support using them, but we
|
||||
* could fake them in xattr_tdb if we really wanted
|
||||
* to. We ignore errors because the link might not point anywhere */
|
||||
fake_acls_uid(handle, path, &smb_fname->st.st_ex_uid);
|
||||
fake_acls_gid(handle, path, &smb_fname->st.st_ex_gid);
|
||||
fake_acls_uid(handle, &smb_fname_base,
|
||||
&smb_fname->st.st_ex_uid);
|
||||
fake_acls_gid(handle, &smb_fname_base,
|
||||
&smb_fname->st.st_ex_gid);
|
||||
TALLOC_FREE(frame);
|
||||
}
|
||||
|
||||
@ -250,7 +256,6 @@ static SMB_ACL_T fake_acls_sys_acl_get_file(struct vfs_handle_struct *handle,
|
||||
ssize_t length;
|
||||
const char *name = NULL;
|
||||
struct smb_acl_t *acl = NULL;
|
||||
const char *path = smb_fname->base_name;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
switch (type) {
|
||||
case SMB_ACL_TYPE_ACCESS:
|
||||
@ -269,7 +274,8 @@ static SMB_ACL_T fake_acls_sys_acl_get_file(struct vfs_handle_struct *handle,
|
||||
TALLOC_FREE(frame);
|
||||
return NULL;
|
||||
}
|
||||
length = SMB_VFS_NEXT_GETXATTR(handle, path, name, blob.data, blob.length);
|
||||
length = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
|
||||
name, blob.data, blob.length);
|
||||
blob.length = length;
|
||||
} while (length == -1 && errno == ERANGE);
|
||||
if (length == -1 && errno == ENOATTR) {
|
||||
|
@ -796,7 +796,7 @@ static ssize_t ad_read_meta(struct adouble *ad,
|
||||
|
||||
DEBUG(10, ("reading meta xattr for %s\n", smb_fname->base_name));
|
||||
|
||||
ealen = SMB_VFS_GETXATTR(ad->ad_handle->conn, smb_fname->base_name,
|
||||
ealen = SMB_VFS_GETXATTR(ad->ad_handle->conn, smb_fname,
|
||||
AFPINFO_EA_NETATALK, ad->ad_data,
|
||||
AD_DATASZ_XATTR);
|
||||
if (ealen == -1) {
|
||||
|
@ -2256,15 +2256,15 @@ static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name, void *value, size_t size)
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
|
||||
result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
|
||||
|
||||
do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
|
||||
"%s|%s", path, name);
|
||||
"%s|%s", smb_fname->base_name, name);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1302,10 +1302,13 @@ static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
|
||||
/* EA Operations */
|
||||
|
||||
static ssize_t vfs_gluster_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path, const char *name,
|
||||
void *value, size_t size)
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
return glfs_getxattr(handle->data, path, name, value, size);
|
||||
return glfs_getxattr(handle->data, smb_fname->base_name,
|
||||
name, value, size);
|
||||
}
|
||||
|
||||
static ssize_t vfs_gluster_fgetxattr(struct vfs_handle_struct *handle,
|
||||
|
@ -2205,37 +2205,33 @@ out:
|
||||
* In this case, "name" is an attr name.
|
||||
*/
|
||||
static ssize_t mh_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
int status;
|
||||
struct smb_filename *clientFname = NULL;
|
||||
ssize_t ret;
|
||||
char *clientPath;
|
||||
TALLOC_CTX *ctx;
|
||||
|
||||
DEBUG(MH_INFO_DEBUG, ("Entering mh_getxattr\n"));
|
||||
if (!is_in_media_files(path))
|
||||
{
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, path, name, value,
|
||||
size);
|
||||
if (!is_in_media_files(smb_fname->base_name)) {
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
|
||||
name, value, size);
|
||||
goto out;
|
||||
}
|
||||
|
||||
clientPath = NULL;
|
||||
ctx = talloc_tos();
|
||||
|
||||
if (alloc_get_client_path(handle, ctx,
|
||||
path,
|
||||
&clientPath))
|
||||
{
|
||||
status = alloc_get_client_smb_fname(handle,
|
||||
talloc_tos(),
|
||||
smb_fname,
|
||||
&clientFname);
|
||||
if (status != 0) {
|
||||
ret = -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, clientPath, name, value, size);
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, clientFname, name, value, size);
|
||||
err:
|
||||
TALLOC_FREE(clientPath);
|
||||
TALLOC_FREE(clientFname);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
@ -148,8 +148,10 @@ static NTSTATUS nfs4_fget_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ct
|
||||
}
|
||||
|
||||
/* Fetch the NFSv4 ACL from the xattr, and convert into Samba's internal NFSv4 format */
|
||||
static NTSTATUS nfs4_get_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
|
||||
const char *path, struct SMB4ACL_T **ppacl)
|
||||
static NTSTATUS nfs4_get_nfs4_acl(vfs_handle_struct *handle,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const struct smb_filename *smb_fname,
|
||||
struct SMB4ACL_T **ppacl)
|
||||
{
|
||||
NTSTATUS status;
|
||||
DATA_BLOB blob = data_blob_null;
|
||||
@ -164,7 +166,8 @@ static NTSTATUS nfs4_get_nfs4_acl(vfs_handle_struct *handle, TALLOC_CTX *mem_ctx
|
||||
errno = ENOMEM;
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
length = SMB_VFS_NEXT_GETXATTR(handle, path, NFS4ACL_XATTR_NAME, blob.data, blob.length);
|
||||
length = SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
|
||||
NFS4ACL_XATTR_NAME, blob.data, blob.length);
|
||||
blob.length = length;
|
||||
} while (length == -1 && errno == ERANGE);
|
||||
if (length == -1) {
|
||||
@ -402,7 +405,7 @@ static struct SMB4ACL_T *nfs4acls_defaultacl(TALLOC_CTX *mem_ctx)
|
||||
* Todo: Really use mem_ctx after fixing interface of nfs4_acls
|
||||
*/
|
||||
static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
|
||||
const char *path,
|
||||
const struct smb_filename *smb_fname_in,
|
||||
TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
char *parent_dir = NULL;
|
||||
@ -412,12 +415,14 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
|
||||
SMB_ACE4PROP_T ace;
|
||||
bool isdir;
|
||||
struct smb_filename *smb_fname = NULL;
|
||||
struct smb_filename *smb_fname_parent = NULL;
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
DEBUG(10, ("nfs4acls_inheritacl invoked for %s\n", path));
|
||||
smb_fname = synthetic_smb_fname(frame, path, NULL, NULL, 0);
|
||||
DEBUG(10, ("nfs4acls_inheritacl invoked for %s\n",
|
||||
smb_fname_in->base_name));
|
||||
smb_fname = cp_smb_filename_nostream(frame, smb_fname_in);
|
||||
if (smb_fname == NULL) {
|
||||
TALLOC_FREE(frame);
|
||||
errno = ENOMEM;
|
||||
@ -436,7 +441,7 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
|
||||
isdir = S_ISDIR(smb_fname->st.st_ex_mode);
|
||||
|
||||
if (!parent_dirname(talloc_tos(),
|
||||
path,
|
||||
smb_fname->base_name,
|
||||
&parent_dir,
|
||||
NULL)) {
|
||||
TALLOC_FREE(frame);
|
||||
@ -444,11 +449,24 @@ static struct SMB4ACL_T *nfs4acls_inheritacl(vfs_handle_struct *handle,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = nfs4_get_nfs4_acl(handle, frame, parent_dir, &pparentacl);
|
||||
smb_fname_parent = synthetic_smb_fname(talloc_tos(),
|
||||
parent_dir,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
if (smb_fname_parent == NULL) {
|
||||
TALLOC_FREE(frame);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = nfs4_get_nfs4_acl(handle, frame, smb_fname_parent,
|
||||
&pparentacl);
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)
|
||||
&& strncmp(parent_dir, ".", 2) != 0) {
|
||||
pparentacl = nfs4acls_inheritacl(handle, parent_dir,
|
||||
frame);
|
||||
pparentacl = nfs4acls_inheritacl(handle,
|
||||
smb_fname_parent,
|
||||
frame);
|
||||
}
|
||||
else if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
|
||||
pparentacl = nfs4acls_defaultacl(frame);
|
||||
@ -527,7 +545,7 @@ static NTSTATUS nfs4acl_xattr_fget_nt_acl(struct vfs_handle_struct *handle,
|
||||
|
||||
status = nfs4_fget_nfs4_acl(handle, frame, fsp, &pacl);
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
|
||||
pacl = nfs4acls_inheritacl(handle, fsp->fsp_name->base_name,
|
||||
pacl = nfs4acls_inheritacl(handle, fsp->fsp_name,
|
||||
frame);
|
||||
}
|
||||
else if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -549,12 +567,11 @@ static NTSTATUS nfs4acl_xattr_get_nt_acl(struct vfs_handle_struct *handle,
|
||||
{
|
||||
struct SMB4ACL_T *pacl;
|
||||
NTSTATUS status;
|
||||
const char *name = smb_fname->base_name;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
status = nfs4_get_nfs4_acl(handle, frame, name, &pacl);
|
||||
status = nfs4_get_nfs4_acl(handle, frame, smb_fname, &pacl);
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
|
||||
pacl = nfs4acls_inheritacl(handle, name, frame);
|
||||
pacl = nfs4acls_inheritacl(handle, smb_fname, frame);
|
||||
}
|
||||
else if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(frame);
|
||||
|
@ -77,14 +77,17 @@ static ssize_t posix_eadb_getattr(struct tdb_wrap *db_ctx,
|
||||
}
|
||||
|
||||
static ssize_t posix_eadb_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path, const char *name,
|
||||
void *value, size_t size)
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
struct tdb_wrap *db;
|
||||
|
||||
SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
|
||||
|
||||
return posix_eadb_getattr(db, path, -1, name, value, size);
|
||||
return posix_eadb_getattr(db, smb_fname->base_name,
|
||||
-1, name, value, size);
|
||||
}
|
||||
|
||||
static ssize_t posix_eadb_fgetxattr(struct vfs_handle_struct *handle,
|
||||
|
@ -2333,21 +2333,27 @@ static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
|
||||
}
|
||||
|
||||
static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
|
||||
const char *fname, const char *aname,
|
||||
void *value, size_t size)
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *aname,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
time_t timestamp = 0;
|
||||
char *stripped = NULL;
|
||||
ssize_t ret;
|
||||
int saved_errno = 0;
|
||||
char *conv;
|
||||
struct smb_filename *conv_smb_fname = NULL;
|
||||
|
||||
if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
|
||||
×tamp, &stripped)) {
|
||||
if (!shadow_copy2_strip_snapshot(talloc_tos(),
|
||||
handle,
|
||||
smb_fname->base_name,
|
||||
×tamp,
|
||||
&stripped)) {
|
||||
return -1;
|
||||
}
|
||||
if (timestamp == 0) {
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, aname, value,
|
||||
size);
|
||||
}
|
||||
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
|
||||
@ -2355,10 +2361,22 @@ static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
|
||||
if (conv == NULL) {
|
||||
return -1;
|
||||
}
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
|
||||
|
||||
conv_smb_fname = synthetic_smb_fname(talloc_tos(),
|
||||
conv,
|
||||
NULL,
|
||||
NULL,
|
||||
smb_fname->flags);
|
||||
if (conv_smb_fname == NULL) {
|
||||
TALLOC_FREE(conv);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, conv_smb_fname, aname, value, size);
|
||||
if (ret == -1) {
|
||||
saved_errno = errno;
|
||||
}
|
||||
TALLOC_FREE(conv_smb_fname);
|
||||
TALLOC_FREE(conv);
|
||||
if (saved_errno != 0) {
|
||||
errno = saved_errno;
|
||||
|
@ -2669,21 +2669,27 @@ static int snapper_gmt_chflags(vfs_handle_struct *handle, const char *fname,
|
||||
}
|
||||
|
||||
static ssize_t snapper_gmt_getxattr(vfs_handle_struct *handle,
|
||||
const char *fname, const char *aname,
|
||||
void *value, size_t size)
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *aname,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
time_t timestamp;
|
||||
char *stripped;
|
||||
time_t timestamp = 0;
|
||||
char *stripped = NULL;
|
||||
ssize_t ret;
|
||||
int saved_errno;
|
||||
char *conv;
|
||||
int saved_errno = 0;
|
||||
char *conv = NULL;
|
||||
struct smb_filename *conv_smb_fname = NULL;
|
||||
|
||||
if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
|
||||
×tamp, &stripped)) {
|
||||
if (!snapper_gmt_strip_snapshot(talloc_tos(),
|
||||
handle,
|
||||
smb_fname->base_name,
|
||||
×tamp,
|
||||
&stripped)) {
|
||||
return -1;
|
||||
}
|
||||
if (timestamp == 0) {
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, fname, aname, value,
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, aname, value,
|
||||
size);
|
||||
}
|
||||
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
|
||||
@ -2691,10 +2697,25 @@ static ssize_t snapper_gmt_getxattr(vfs_handle_struct *handle,
|
||||
if (conv == NULL) {
|
||||
return -1;
|
||||
}
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, conv, aname, value, size);
|
||||
saved_errno = errno;
|
||||
conv_smb_fname = synthetic_smb_fname(talloc_tos(),
|
||||
conv,
|
||||
NULL,
|
||||
NULL,
|
||||
smb_fname->flags);
|
||||
TALLOC_FREE(conv);
|
||||
errno = saved_errno;
|
||||
if (conv_smb_fname == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, conv_smb_fname, aname, value, size);
|
||||
if (ret == -1) {
|
||||
saved_errno = errno;
|
||||
}
|
||||
TALLOC_FREE(conv_smb_fname);
|
||||
TALLOC_FREE(conv);
|
||||
if (saved_errno != 0) {
|
||||
errno = saved_errno;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -67,13 +67,14 @@ static uint32_t hash_fn(DATA_BLOB key)
|
||||
* an option to put in a special ACL entry for a non-existing group.
|
||||
*/
|
||||
|
||||
static bool file_is_valid(vfs_handle_struct *handle, const char *path)
|
||||
static bool file_is_valid(vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname)
|
||||
{
|
||||
char buf;
|
||||
|
||||
DEBUG(10, ("file_is_valid (%s) called\n", path));
|
||||
DEBUG(10, ("file_is_valid (%s) called\n", smb_fname->base_name));
|
||||
|
||||
if (SMB_VFS_GETXATTR(handle->conn, path, SAMBA_XATTR_MARKER,
|
||||
if (SMB_VFS_GETXATTR(handle->conn, smb_fname, SAMBA_XATTR_MARKER,
|
||||
&buf, sizeof(buf)) != sizeof(buf)) {
|
||||
DEBUG(10, ("GETXATTR failed: %s\n", strerror(errno)));
|
||||
return false;
|
||||
@ -228,7 +229,7 @@ static char *stream_dir(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
if (!check_valid ||
|
||||
file_is_valid(handle, smb_fname->base_name)) {
|
||||
file_is_valid(handle, smb_fname)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -79,14 +79,14 @@ static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
|
||||
|
||||
static ssize_t get_xattr_size(connection_struct *conn,
|
||||
files_struct *fsp,
|
||||
const char *fname,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *xattr_name)
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct ea_struct ea;
|
||||
ssize_t result;
|
||||
|
||||
status = get_ea_value(talloc_tos(), conn, fsp, fname,
|
||||
status = get_ea_value(talloc_tos(), conn, fsp, smb_fname,
|
||||
xattr_name, &ea);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -190,8 +190,8 @@ static bool streams_xattr_recheck(struct stream_io *sio)
|
||||
TALLOC_FREE(sio->base);
|
||||
sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
|
||||
xattr_name);
|
||||
sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
|
||||
sio->fsp->fsp_name->base_name);
|
||||
sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp),
|
||||
sio->fsp->fsp_name->base_name);
|
||||
sio->fsp_name_ptr = sio->fsp->fsp_name;
|
||||
|
||||
TALLOC_FREE(xattr_name);
|
||||
@ -259,15 +259,16 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
|
||||
ret = SMB_VFS_STAT(handle->conn, smb_fname_base);
|
||||
}
|
||||
*sbuf = smb_fname_base->st;
|
||||
TALLOC_FREE(smb_fname_base);
|
||||
|
||||
if (ret == -1) {
|
||||
TALLOC_FREE(smb_fname_base);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sbuf->st_ex_size = get_xattr_size(handle->conn, fsp,
|
||||
io->base, io->xattr_name);
|
||||
smb_fname_base, io->xattr_name);
|
||||
if (sbuf->st_ex_size == -1) {
|
||||
TALLOC_FREE(smb_fname_base);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -278,6 +279,7 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
|
||||
sbuf->st_ex_mode |= S_IFREG;
|
||||
sbuf->st_ex_blocks = sbuf->st_ex_size / STAT_ST_BLOCKSIZE + 1;
|
||||
|
||||
TALLOC_FREE(smb_fname_base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -317,7 +319,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle,
|
||||
|
||||
/* Augment the base file's stat information before returning. */
|
||||
smb_fname->st.st_ex_size = get_xattr_size(handle->conn, NULL,
|
||||
smb_fname->base_name,
|
||||
smb_fname,
|
||||
xattr_name);
|
||||
if (smb_fname->st.st_ex_size == -1) {
|
||||
errno = ENOENT;
|
||||
@ -368,7 +370,7 @@ static int streams_xattr_lstat(vfs_handle_struct *handle,
|
||||
|
||||
/* Augment the base file's stat information before returning. */
|
||||
smb_fname->st.st_ex_size = get_xattr_size(handle->conn, NULL,
|
||||
smb_fname->base_name,
|
||||
smb_fname,
|
||||
xattr_name);
|
||||
if (smb_fname->st.st_ex_size == -1) {
|
||||
errno = ENOENT;
|
||||
@ -470,7 +472,7 @@ static int streams_xattr_open(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
status = get_ea_value(talloc_tos(), handle->conn, NULL,
|
||||
smb_fname->base_name, xattr_name, &ea);
|
||||
smb_fname, xattr_name, &ea);
|
||||
|
||||
DEBUG(10, ("get_ea_value returned %s\n", nt_errstr(status)));
|
||||
|
||||
@ -654,7 +656,7 @@ static int streams_xattr_rename(vfs_handle_struct *handle,
|
||||
|
||||
/* read the old stream */
|
||||
status = get_ea_value(talloc_tos(), handle->conn, NULL,
|
||||
smb_fname_src->base_name, src_xattr_name, &ea);
|
||||
smb_fname_src, src_xattr_name, &ea);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
errno = ENOENT;
|
||||
goto fail;
|
||||
@ -744,7 +746,7 @@ static NTSTATUS walk_xattr_streams(vfs_handle_struct *handle,
|
||||
status = get_ea_value(names,
|
||||
handle->conn,
|
||||
fsp,
|
||||
smb_fname->base_name,
|
||||
smb_fname,
|
||||
names[i],
|
||||
&ea);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -950,6 +952,7 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
|
||||
(struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
|
||||
struct ea_struct ea;
|
||||
NTSTATUS status;
|
||||
struct smb_filename *smb_fname_base = NULL;
|
||||
int ret;
|
||||
|
||||
DEBUG(10, ("streams_xattr_pwrite called for %d bytes\n", (int)n));
|
||||
@ -962,8 +965,19 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create an smb_filename with stream_name == NULL. */
|
||||
smb_fname_base = synthetic_smb_fname(talloc_tos(),
|
||||
sio->base,
|
||||
NULL,
|
||||
NULL,
|
||||
fsp->fsp_name->flags);
|
||||
if (smb_fname_base == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
status = get_ea_value(talloc_tos(), handle->conn, fsp,
|
||||
sio->base, sio->xattr_name, &ea);
|
||||
smb_fname_base, sio->xattr_name, &ea);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return -1;
|
||||
}
|
||||
@ -1014,6 +1028,7 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle,
|
||||
struct ea_struct ea;
|
||||
NTSTATUS status;
|
||||
size_t length, overlap;
|
||||
struct smb_filename *smb_fname_base = NULL;
|
||||
|
||||
DEBUG(10, ("streams_xattr_pread: offset=%d, size=%d\n",
|
||||
(int)offset, (int)n));
|
||||
@ -1026,8 +1041,19 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create an smb_filename with stream_name == NULL. */
|
||||
smb_fname_base = synthetic_smb_fname(talloc_tos(),
|
||||
sio->base,
|
||||
NULL,
|
||||
NULL,
|
||||
fsp->fsp_name->flags);
|
||||
if (smb_fname_base == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
status = get_ea_value(talloc_tos(), handle->conn, fsp,
|
||||
sio->base, sio->xattr_name, &ea);
|
||||
smb_fname_base, sio->xattr_name, &ea);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return -1;
|
||||
}
|
||||
@ -1219,6 +1245,7 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
|
||||
NTSTATUS status;
|
||||
struct stream_io *sio =
|
||||
(struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp);
|
||||
struct smb_filename *smb_fname_base = NULL;
|
||||
|
||||
DEBUG(10, ("streams_xattr_ftruncate called for file %s offset %.0f\n",
|
||||
fsp_str_dbg(fsp), (double)offset));
|
||||
@ -1231,8 +1258,19 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create an smb_filename with stream_name == NULL. */
|
||||
smb_fname_base = synthetic_smb_fname(talloc_tos(),
|
||||
sio->base,
|
||||
NULL,
|
||||
NULL,
|
||||
fsp->fsp_name->flags);
|
||||
if (smb_fname_base == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
status = get_ea_value(talloc_tos(), handle->conn, fsp,
|
||||
sio->base, sio->xattr_name, &ea);
|
||||
smb_fname_base, sio->xattr_name, &ea);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -2321,20 +2321,23 @@ static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path, const char *name,
|
||||
void *value, size_t size)
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
ssize_t result;
|
||||
struct timespec ts1,ts2;
|
||||
double timediff;
|
||||
|
||||
clock_gettime_mono(&ts1);
|
||||
result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
|
||||
result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
|
||||
clock_gettime_mono(&ts2);
|
||||
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
|
||||
|
||||
if (timediff > audit_timeout) {
|
||||
smb_time_audit_log_fname("getxattr", timediff, path);
|
||||
smb_time_audit_log_fname("getxattr", timediff,
|
||||
smb_fname->base_name);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -1722,30 +1722,33 @@ err:
|
||||
}
|
||||
|
||||
static ssize_t um_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
ssize_t ret;
|
||||
char *client_path = NULL;
|
||||
struct smb_filename *client_fname = NULL;
|
||||
int status;
|
||||
|
||||
DEBUG(10, ("Entering um_getxattr\n"));
|
||||
if (!is_in_media_files(path)) {
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
|
||||
if (!is_in_media_files(smb_fname->base_name)) {
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
|
||||
name, value, size);
|
||||
}
|
||||
|
||||
status = alloc_get_client_path(handle, talloc_tos(),
|
||||
path, &client_path);
|
||||
status = alloc_get_client_smb_fname(handle,
|
||||
talloc_tos(),
|
||||
smb_fname,
|
||||
&client_fname);
|
||||
if (status != 0) {
|
||||
ret = -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, client_path, name, value, size);
|
||||
ret = SMB_VFS_NEXT_GETXATTR(handle, client_fname, name, value, size);
|
||||
err:
|
||||
TALLOC_FREE(client_path);
|
||||
TALLOC_FREE(client_fname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -621,12 +621,14 @@ static int vxfs_fset_xattr(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static ssize_t vxfs_get_xattr(struct vfs_handle_struct *handle,
|
||||
const char *path, const char *name,
|
||||
void *value, size_t size){
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size){
|
||||
int ret;
|
||||
|
||||
DEBUG(10, ("In vxfs_get_xattr\n"));
|
||||
ret = vxfs_getxattr_path(path, name, value, size);
|
||||
ret = vxfs_getxattr_path(smb_fname->base_name, name, value, size);
|
||||
if ((ret != -1) || ((errno != ENOTSUP) &&
|
||||
(errno != ENOSYS) && (errno != ENODATA))) {
|
||||
return ret;
|
||||
@ -634,8 +636,8 @@ static ssize_t vxfs_get_xattr(struct vfs_handle_struct *handle,
|
||||
|
||||
DEBUG(10, ("Fallback to xattr\n"));
|
||||
if (strcmp(name, XATTR_NTACL_NAME) == 0) {
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, path, XATTR_USER_NTACL,
|
||||
value, size);
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
|
||||
XATTR_USER_NTACL, value, size);
|
||||
}
|
||||
|
||||
/* Clients can't see XATTR_USER_NTACL directly. */
|
||||
@ -644,7 +646,7 @@ static ssize_t vxfs_get_xattr(struct vfs_handle_struct *handle,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
|
||||
return SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
|
||||
}
|
||||
|
||||
static ssize_t vxfs_fget_xattr(struct vfs_handle_struct *handle,
|
||||
|
@ -57,8 +57,10 @@ static int xattr_tdb_get_file_id(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
static ssize_t xattr_tdb_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path, const char *name,
|
||||
void *value, size_t size)
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
struct file_id id;
|
||||
struct db_context *db;
|
||||
@ -73,7 +75,7 @@ static ssize_t xattr_tdb_getxattr(struct vfs_handle_struct *handle,
|
||||
TALLOC_FREE(frame); return -1;
|
||||
});
|
||||
|
||||
ret = xattr_tdb_get_file_id(handle, path, &id);
|
||||
ret = xattr_tdb_get_file_id(handle, smb_fname->base_name, &id);
|
||||
if (ret == -1) {
|
||||
TALLOC_FREE(frame);
|
||||
return -1;
|
||||
|
@ -278,7 +278,7 @@ NTSTATUS get_ea_dos_attribute(connection_struct *conn,
|
||||
/* Don't reset pattr to zero as we may already have filename-based attributes we
|
||||
need to preserve. */
|
||||
|
||||
sizeret = SMB_VFS_GETXATTR(conn, smb_fname->base_name,
|
||||
sizeret = SMB_VFS_GETXATTR(conn, smb_fname,
|
||||
SAMBA_XATTR_DOS_ATTRIB, attrstr,
|
||||
sizeof(attrstr));
|
||||
if (sizeret == -1) {
|
||||
|
@ -629,7 +629,7 @@ static struct pai_val *fload_inherited_info(files_struct *fsp)
|
||||
pai_buf, pai_buf_size);
|
||||
} else {
|
||||
ret = SMB_VFS_GETXATTR(fsp->conn,
|
||||
fsp->fsp_name->base_name,
|
||||
fsp->fsp_name,
|
||||
SAMBA_POSIX_INHERITANCE_EA_NAME,
|
||||
pai_buf, pai_buf_size);
|
||||
}
|
||||
@ -681,7 +681,7 @@ static struct pai_val *fload_inherited_info(files_struct *fsp)
|
||||
************************************************************************/
|
||||
|
||||
static struct pai_val *load_inherited_info(const struct connection_struct *conn,
|
||||
const char *fname)
|
||||
const struct smb_filename *smb_fname)
|
||||
{
|
||||
char *pai_buf;
|
||||
size_t pai_buf_size = 1024;
|
||||
@ -697,7 +697,7 @@ static struct pai_val *load_inherited_info(const struct connection_struct *conn,
|
||||
}
|
||||
|
||||
do {
|
||||
ret = SMB_VFS_GETXATTR(conn, fname,
|
||||
ret = SMB_VFS_GETXATTR(conn, smb_fname,
|
||||
SAMBA_POSIX_INHERITANCE_EA_NAME,
|
||||
pai_buf, pai_buf_size);
|
||||
|
||||
@ -716,7 +716,8 @@ static struct pai_val *load_inherited_info(const struct connection_struct *conn,
|
||||
}
|
||||
} while (ret == -1);
|
||||
|
||||
DEBUG(10,("load_inherited_info: ret = %lu for file %s\n", (unsigned long)ret, fname));
|
||||
DEBUG(10,("load_inherited_info: ret = %lu for file %s\n",
|
||||
(unsigned long)ret, smb_fname->base_name));
|
||||
|
||||
if (ret == -1) {
|
||||
/* No attribute or not supported. */
|
||||
@ -736,7 +737,7 @@ static struct pai_val *load_inherited_info(const struct connection_struct *conn,
|
||||
if (paiv) {
|
||||
DEBUG(10,("load_inherited_info: ACL type 0x%x for file %s\n",
|
||||
(unsigned int)paiv->sd_type,
|
||||
fname));
|
||||
smb_fname->base_name));
|
||||
}
|
||||
|
||||
TALLOC_FREE(pai_buf);
|
||||
@ -3593,7 +3594,7 @@ NTSTATUS posix_get_nt_acl(struct connection_struct *conn,
|
||||
def_acl = free_empty_sys_acl(conn, def_acl);
|
||||
}
|
||||
|
||||
pal = load_inherited_info(conn, smb_fname->base_name);
|
||||
pal = load_inherited_info(conn, smb_fname);
|
||||
|
||||
status = posix_get_nt_acl_common(conn,
|
||||
smb_fname->base_name,
|
||||
|
@ -1143,8 +1143,10 @@ uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf);
|
||||
void aapl_force_zero_file_id(struct smbd_server_connection *sconn);
|
||||
bool samba_private_attr_name(const char *unix_ea_name);
|
||||
NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
|
||||
files_struct *fsp, const char *fname,
|
||||
const char *ea_name, struct ea_struct *pea);
|
||||
files_struct *fsp,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *ea_name,
|
||||
struct ea_struct *pea);
|
||||
NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx,
|
||||
connection_struct *conn,
|
||||
files_struct *fsp,
|
||||
|
@ -203,9 +203,12 @@ bool samba_private_attr_name(const char *unix_ea_name)
|
||||
Get one EA value. Fill in a struct ea_struct.
|
||||
****************************************************************************/
|
||||
|
||||
NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
|
||||
files_struct *fsp, const char *fname,
|
||||
const char *ea_name, struct ea_struct *pea)
|
||||
NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx,
|
||||
connection_struct *conn,
|
||||
files_struct *fsp,
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *ea_name,
|
||||
struct ea_struct *pea)
|
||||
{
|
||||
/* Get the value of this xattr. Max size is 64k. */
|
||||
size_t attr_size = 256;
|
||||
@ -222,7 +225,8 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
sizeret = SMB_VFS_FGETXATTR(fsp, ea_name, val, attr_size);
|
||||
} else {
|
||||
sizeret = SMB_VFS_GETXATTR(conn, fname, ea_name, val, attr_size);
|
||||
sizeret = SMB_VFS_GETXATTR(conn, smb_fname,
|
||||
ea_name, val, attr_size);
|
||||
}
|
||||
|
||||
if (sizeret == -1 && errno == ERANGE && attr_size != 65536) {
|
||||
@ -458,7 +462,7 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx,
|
||||
status = get_ea_value(listp,
|
||||
conn,
|
||||
fsp,
|
||||
smb_fname->base_name,
|
||||
smb_fname,
|
||||
names[i],
|
||||
&listp->ea);
|
||||
|
||||
|
@ -2503,11 +2503,13 @@ int smb_vfs_call_sys_acl_delete_def_file(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle,
|
||||
const char *path, const char *name, void *value,
|
||||
size_t size)
|
||||
const struct smb_filename *smb_fname,
|
||||
const char *name,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
VFS_FIND(getxattr);
|
||||
return handle->fns->getxattr_fn(handle, path, name, value, size);
|
||||
return handle->fns->getxattr_fn(handle, smb_fname, name, value, size);
|
||||
}
|
||||
|
||||
ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
|
||||
|
@ -1309,6 +1309,7 @@ static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
|
||||
{
|
||||
uint8_t *buf;
|
||||
ssize_t ret;
|
||||
struct smb_filename *smb_fname = NULL;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Usage: getxattr <path> <xattr>\n");
|
||||
@ -1317,7 +1318,13 @@ static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
|
||||
|
||||
buf = NULL;
|
||||
|
||||
ret = SMB_VFS_GETXATTR(vfs->conn, argv[1], argv[2], buf,
|
||||
smb_fname = synthetic_smb_fname_split(mem_ctx,
|
||||
argv[1],
|
||||
lp_posix_pathnames());
|
||||
if (smb_fname == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
ret = SMB_VFS_GETXATTR(vfs->conn, smb_fname, argv[2], buf,
|
||||
talloc_get_size(buf));
|
||||
if (ret == -1) {
|
||||
int err = errno;
|
||||
@ -1328,7 +1335,7 @@ static NTSTATUS cmd_getxattr(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
|
||||
if (buf == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
ret = SMB_VFS_GETXATTR(vfs->conn, argv[1], argv[2], buf,
|
||||
ret = SMB_VFS_GETXATTR(vfs->conn, smb_fname, argv[2], buf,
|
||||
talloc_get_size(buf));
|
||||
if (ret == -1) {
|
||||
int err = errno;
|
||||
|
Reference in New Issue
Block a user