return -1;
}
-static int skel_removexattr(vfs_handle_struct *handle, const char *path,
- const char *name)
+static int skel_removexattr(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *name)
{
errno = ENOSYS;
return -1;
return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
}
-static int skel_removexattr(vfs_handle_struct *handle, const char *path,
- const char *name)
+static int skel_removexattr(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *name)
{
- return SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+ return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
}
static int skel_fremovexattr(vfs_handle_struct *handle,
to const struct smb_filename * */
/* Version 37 - Change listxattr from const char *
to const struct smb_filename * */
+/* Version 37 - Change removexattr from const char *
+ to const struct smb_filename * */
#define SMB_VFS_INTERFACE_VERSION 37
char *list,
size_t size);
ssize_t (*flistxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size);
- int (*removexattr_fn)(struct vfs_handle_struct *handle, const char *path, const char *name);
+ int (*removexattr_fn)(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *name);
int (*fremovexattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name);
int (*setxattr_fn)(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags);
int (*fsetxattr_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags);
struct files_struct *fsp, char *list,
size_t size);
int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
- const char *path, const char *name);
+ const struct smb_filename *smb_fname,
+ const char *name);
int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
struct files_struct *fsp, const char *name);
int smb_vfs_call_setxattr(struct vfs_handle_struct *handle, const char *path,
#define SMB_VFS_NEXT_FLISTXATTR(handle,fsp,list,size) \
smb_vfs_call_flistxattr((handle)->next,(fsp),(list),(size))
-#define SMB_VFS_REMOVEXATTR(conn,path,name) \
- smb_vfs_call_removexattr((conn)->vfs_handles,(path),(name))
-#define SMB_VFS_NEXT_REMOVEXATTR(handle,path,name) \
- smb_vfs_call_removexattr((handle)->next,(path),(name))
+#define SMB_VFS_REMOVEXATTR(conn,smb_fname,name) \
+ smb_vfs_call_removexattr((conn)->vfs_handles,(smb_fname),(name))
+#define SMB_VFS_NEXT_REMOVEXATTR(handle,smb_fname,name) \
+ smb_vfs_call_removexattr((handle)->next,(smb_fname),(name))
#define SMB_VFS_FREMOVEXATTR(fsp,name) \
smb_vfs_call_fremovexattr((fsp)->conn->vfs_handles, (fsp), (name))
const struct smb_filename *smb_fname)
{
return SMB_VFS_REMOVEXATTR(handle->conn,
- smb_fname->base_name,
+ smb_fname,
ACL_EA_DEFAULT);
}
}
become_root();
- SMB_VFS_REMOVEXATTR(handle->conn, smb_fname->base_name,
+ SMB_VFS_REMOVEXATTR(handle->conn, smb_fname,
XATTR_NTACL_NAME);
unbecome_root();
return ret;
}
-static int cap_removexattr(vfs_handle_struct *handle, const char *path, const char *name)
+static int cap_removexattr(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *name)
{
- 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);
+ int ret;
+ int saved_errno = 0;
if (!cappath || !capname) {
errno = ENOMEM;
return -1;
}
- return SMB_VFS_NEXT_REMOVEXATTR(handle, cappath, capname);
+ 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_REMOVEXATTR(handle, cap_smb_fname, capname);
+ 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 int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path)
}
static int
-catia_removexattr(vfs_handle_struct *handle, const char *path,
- const char *name)
+catia_removexattr(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *name)
{
+ 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_REMOVEXATTR(handle, mapped_name, mapped_ea_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_REMOVEXATTR(handle, mapped_smb_fname,
+ mapped_ea_name);
+ 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;
}
}
}
-static int cephwrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
+static int cephwrap_removexattr(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *name)
{
int ret;
- DBG_DEBUG("[CEPH] removexattr(%p, %s, %s)\n", handle, path, name);
- ret = ceph_removexattr(handle->data, path, name);
+ DBG_DEBUG("[CEPH] removexattr(%p, %s, %s)\n", handle,
+ smb_fname->base_name, name);
+ ret = ceph_removexattr(handle->data, smb_fname->base_name, name);
DBG_DEBUG("[CEPH] removexattr(...) = %d\n", ret);
WRAP_RETURN(ret);
}
return flistxattr(fsp->fh->fd, list, size);
}
-static int vfswrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
+static int vfswrap_removexattr(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *name)
{
- return removexattr(path, name);
+ return removexattr(smb_fname->base_name, name);
}
static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
return -1;
}
- ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname->base_name, name);
+ ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
if (ret == -1 && errno == ENOATTR) {
ret = 0;
errno = 0;
const struct smb_filename *smb_fname)
{
return SMB_VFS_REMOVEXATTR(handle->conn,
- smb_fname->base_name,
+ smb_fname,
AFPINFO_EA_NETATALK);
}
if (ai_empty_finderinfo(ai)) {
ret = SMB_VFS_REMOVEXATTR(handle->conn,
- fsp->fsp_name->base_name,
+ fsp->fsp_name,
AFPINFO_EA_NETATALK);
if (ret != 0 && errno != ENOENT && errno != ENOATTR) {
}
static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
- const char *path,
+ const struct smb_filename *smb_fname,
const char *name)
{
int result;
- result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+ result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
- "%s|%s", path, name);
+ "%s|%s", smb_fname->base_name, name);
return result;
}
}
static int vfs_gluster_removexattr(struct vfs_handle_struct *handle,
- const char *path, const char *name)
+ const struct smb_filename *smb_fname,
+ const char *name)
{
- return glfs_removexattr(handle->data, path, name);
+ return glfs_removexattr(handle->data, smb_fname->base_name, name);
}
static int vfs_gluster_fremovexattr(struct vfs_handle_struct *handle,
* In this case, "name" is an attr name.
*/
static int mh_removexattr(struct vfs_handle_struct *handle,
- const char *path,
+ const struct smb_filename *smb_fname,
const char *name)
{
int status;
- char *clientPath;
- TALLOC_CTX *ctx;
+ struct smb_filename *clientFname = NULL;
DEBUG(MH_INFO_DEBUG, ("Entering mh_removexattr\n"));
- if (!is_in_media_files(path))
- {
- status = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+ if (!is_in_media_files(smb_fname->base_name)) {
+ status = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
goto out;
}
- clientPath = NULL;
- ctx = talloc_tos();
-
- if ((status = alloc_get_client_path(handle, ctx,
- path,
- &clientPath)))
- {
+ status = alloc_get_client_smb_fname(handle,
+ talloc_tos(),
+ smb_fname,
+ &clientFname);
+ if (status != 0) {
goto err;
}
-
- status = SMB_VFS_NEXT_REMOVEXATTR(handle, clientPath, name);
+ status = SMB_VFS_NEXT_REMOVEXATTR(handle, clientFname, name);
err:
- TALLOC_FREE(clientPath);
+ TALLOC_FREE(clientFname);
out:
return status;
}
}
static int posix_eadb_removexattr(struct vfs_handle_struct *handle,
- const char *path, const char *name)
+ const struct smb_filename *smb_fname,
+ const char *name)
{
struct tdb_wrap *db;
SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
- return posix_eadb_removeattr(db, path, -1, name);
+ return posix_eadb_removeattr(db, smb_fname->base_name, -1, name);
}
static int posix_eadb_fremovexattr(struct vfs_handle_struct *handle,
}
static int shadow_copy2_removexattr(vfs_handle_struct *handle,
- const char *fname, const char *aname)
+ const struct smb_filename *smb_fname,
+ const char *aname)
{
time_t timestamp = 0;
char *stripped = NULL;
int saved_errno = 0;
int ret;
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_REMOVEXATTR(handle, fname, aname);
+ return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, aname);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
+ 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_REMOVEXATTR(handle, conv_smb_fname, aname);
if (ret == -1) {
saved_errno = errno;
}
+ TALLOC_FREE(conv_smb_fname);
TALLOC_FREE(conv);
if (saved_errno != 0) {
errno = saved_errno;
}
static int snapper_gmt_removexattr(vfs_handle_struct *handle,
- const char *fname, const char *aname)
+ const struct smb_filename *smb_fname,
+ const char *aname)
{
- time_t timestamp;
- char *stripped;
- int ret, saved_errno;
- char *conv;
+ time_t timestamp = 0;
+ char *stripped = NULL;
+ ssize_t ret;
+ 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_REMOVEXATTR(handle, fname, aname);
+ return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, aname);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
- ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv, aname);
- 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_REMOVEXATTR(handle, conv_smb_fname, aname);
+ if (ret == -1) {
+ saved_errno = errno;
+ }
+ TALLOC_FREE(conv_smb_fname);
+ TALLOC_FREE(conv);
+ if (saved_errno != 0) {
+ errno = saved_errno;
+ }
return ret;
}
goto fail;
}
- ret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname->base_name, xattr_name);
+ ret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname, xattr_name);
if ((ret == -1) && (errno == ENOATTR)) {
errno = ENOENT;
}
/* remove the old stream */
- oret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname_src->base_name,
+ oret = SMB_VFS_REMOVEXATTR(handle->conn, smb_fname_src,
src_xattr_name);
if (oret < 0) {
if (errno == ENOATTR) {
}
static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
- const char *path, const char *name)
+ const struct smb_filename *smb_fname,
+ const char *name)
{
int result;
struct timespec ts1,ts2;
double timediff;
clock_gettime_mono(&ts1);
- result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+ result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
if (timediff > audit_timeout) {
- smb_time_audit_log_fname("removexattr", timediff, path);
+ smb_time_audit_log_fname("removexattr", timediff,
+ smb_fname->base_name);
}
return result;
}
static int um_removexattr(struct vfs_handle_struct *handle,
- const char *path,
+ const struct smb_filename *smb_fname,
const char *name)
{
int status;
- char *client_path = NULL;
+ struct smb_filename *client_fname = NULL;
DEBUG(10, ("Entering um_removexattr\n"));
- if (!is_in_media_files(path)) {
- return SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+ if (!is_in_media_files(smb_fname->base_name)) {
+ return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
}
- 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) {
goto err;
}
- status = SMB_VFS_NEXT_REMOVEXATTR(handle, client_path, name);
+ status = SMB_VFS_NEXT_REMOVEXATTR(handle, client_fname, name);
err:
- TALLOC_FREE(client_path);
+ TALLOC_FREE(client_fname);
return status;
}
}
is_dir = S_ISDIR(smb_fname->st.st_ex_mode);
- TALLOC_FREE(smb_fname);
ret = vxfs_setxattr_path(path, name, value, size, flags,
is_dir);
/*
* Now remve old style xattr if it exists
*/
- SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+ SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
+ TALLOC_FREE(smb_fname);
/*
* Do not bother about return value
*/
return ret;
}
+ TALLOC_FREE(smb_fname);
+
DEBUG(10, ("Fallback to xattr\n"));
if (strcmp(name, XATTR_NTACL_NAME) == 0) {
return SMB_VFS_NEXT_SETXATTR(handle, path, XATTR_USER_NTACL,
}
static int vxfs_remove_xattr(struct vfs_handle_struct *handle,
- const char *path, const char *name){
- struct smb_filename *smb_fname;
+ const struct smb_filename *smb_fname_in,
+ const char *name)
+{
bool is_dir = false;
int ret = 0, ret_new = 0, old_errno;
+ struct smb_filename *smb_fname = NULL;
DEBUG(10, ("In vxfs_remove_xattr\n"));
+ smb_fname = cp_smb_filename_nostream(talloc_tos(), smb_fname_in);
+ if (smb_fname == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
/* Remove with old way */
if (strcmp(name, XATTR_NTACL_NAME) == 0) {
- ret = SMB_VFS_NEXT_REMOVEXATTR(handle, path,
+ ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname,
XATTR_USER_NTACL);
} else {
if (strcasecmp(name, XATTR_USER_NTACL) != 0) {
- ret = SMB_VFS_NEXT_REMOVEXATTR(handle, path,
+ ret = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname,
name);
}
}
- old_errno = errno;
-
/* Remove with new way */
- smb_fname = synthetic_smb_fname(talloc_tos(), path, NULL, NULL, 0);
- if (smb_fname == NULL) {
- errno = ENOMEM;
- return -1;
- }
+ old_errno = errno;
if (SMB_VFS_NEXT_STAT(handle, smb_fname) != 0) {
TALLOC_FREE(smb_fname);
/*
* If both fail, return failuer else return whichever succeeded
*/
- ret_new = vxfs_removexattr_path(path, name, is_dir);
+ ret_new = vxfs_removexattr_path(smb_fname_in->base_name, name, is_dir);
if (errno == ENOTSUP || errno == ENOSYS) {
errno = old_errno;
}
}
static int xattr_tdb_removexattr(struct vfs_handle_struct *handle,
- const char *path, const char *name)
+ const struct smb_filename *smb_fname,
+ const char *name)
{
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 ret;
DEBUG(10,("set_ea: deleting ea name %s on file %s.\n",
unix_ea_name, smb_fname->base_name));
ret = SMB_VFS_REMOVEXATTR(conn,
- smb_fname->base_name,
+ smb_fname,
unix_ea_name);
}
#ifdef ENOATTR
}
int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
- const char *path, const char *name)
+ const struct smb_filename *smb_fname,
+ const char *name)
{
VFS_FIND(removexattr);
- return handle->fns->removexattr_fn(handle, path, name);
+ return handle->fns->removexattr_fn(handle, smb_fname, name);
}
int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
int argc, const char **argv)
{
ssize_t ret;
+ struct smb_filename *smb_fname = NULL;
if (argc != 3) {
printf("Usage: removexattr <path> <xattr>\n");
return NT_STATUS_OK;
}
- ret = SMB_VFS_REMOVEXATTR(vfs->conn, argv[1], argv[2]);
+ smb_fname = synthetic_smb_fname(talloc_tos(),
+ argv[1],
+ NULL,
+ NULL,
+ ssf_flags());
+
+ if (smb_fname == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ret = SMB_VFS_REMOVEXATTR(vfs->conn, smb_fname, argv[2]);
if (ret == -1) {
int err = errno;
printf("removexattr returned (%s)\n", strerror(err));