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;
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,
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
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,
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);
#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))
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);
return NULL;
}
ret = SMB_VFS_GETXATTR(handle->conn,
- smb_fname->base_name, name,
+ smb_fname, name,
buf, size);
}
}
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) {
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)
}
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;
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;
}
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);
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)
#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;
}
}
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;
}
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;
* 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);
}
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:
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) {
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) {
}
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;
}
/* 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,
* 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;
}
}
/* 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;
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) {
* 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;
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;
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);
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);
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)) {
{
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);
}
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,
}
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);
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;
}
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);
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;
}
* 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;
}
if (!check_valid ||
- file_is_valid(handle, smb_fname->base_name)) {
+ file_is_valid(handle, smb_fname)) {
return result;
}
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)) {
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);
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;
}
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;
}
/* 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;
/* 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;
}
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)));
/* 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;
status = get_ea_value(names,
handle->conn,
fsp,
- smb_fname->base_name,
+ smb_fname,
names[i],
&ea);
if (!NT_STATUS_IS_OK(status)) {
(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));
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;
}
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));
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;
}
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));
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;
}
}
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;
}
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;
}
}
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;
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. */
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,
}
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;
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;
/* 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) {
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);
}
************************************************************************/
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;
}
do {
- ret = SMB_VFS_GETXATTR(conn, fname,
+ ret = SMB_VFS_GETXATTR(conn, smb_fname,
SAMBA_POSIX_INHERITANCE_EA_NAME,
pai_buf, pai_buf_size);
}
} 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. */
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);
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,
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,
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;
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) {
status = get_ea_value(listp,
conn,
fsp,
- smb_fname->base_name,
+ smb_fname,
names[i],
&listp->ea);
}
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,
{
uint8_t *buf;
ssize_t ret;
+ struct smb_filename *smb_fname = NULL;
if (argc != 3) {
printf("Usage: getxattr <path> <xattr>\n");
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;
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;