static int fake_acls_chown(vfs_handle_struct *handle, const struct smb_filename *smb_fname, uid_t uid, gid_t gid) { int ret; uint8_t id_buf[4]; if (uid != -1) { SIVAL(id_buf, 0, uid); ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname->base_name, FAKE_UID, id_buf, sizeof(id_buf), 0); if (ret != 0) { return ret; } } if (gid != -1) { SIVAL(id_buf, 0, gid); ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname->base_name, FAKE_GID, id_buf, sizeof(id_buf), 0); if (ret != 0) { return ret; } } return 0; }
static int cap_setxattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name, const void *value, size_t size, int flags) { pstring cappath, capname; capencode(cappath, path); capencode(capname, name); return SMB_VFS_NEXT_SETXATTR(handle, conn, cappath, capname, value, size, flags); }
static int vxfs_set_xattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags){ DEBUG(10, ("In vxfs_set_xattr\n")); if (strcmp(name, XATTR_NTACL_NAME) == 0) { return SMB_VFS_NEXT_SETXATTR(handle, path, XATTR_USER_NTACL, value, size, flags); } /* Clients can't set XATTR_USER_NTACL directly. */ if (strcasecmp(name, XATTR_USER_NTACL) == 0) { errno = EACCES; return -1; } return SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size, flags); }
static bool nfs4acl_smb4acl_set_fn(vfs_handle_struct *handle, files_struct *fsp, struct SMB4ACL_T *smb4acl) { struct nfs4acl_config *config = NULL; DATA_BLOB blob; NTSTATUS status; int saved_errno = 0; int ret; SMB_VFS_HANDLE_GET_DATA(handle, config, struct nfs4acl_config, return false); switch (config->encoding) { case NFS4ACL_ENCODING_NDR: status = nfs4acl_smb4acl_to_ndr_blob(handle, talloc_tos(), smb4acl, &blob); break; case NFS4ACL_ENCODING_XDR: status = nfs4acl_smb4acl_to_xdr_blob(handle, talloc_tos(), smb4acl, &blob); break; default: status = NT_STATUS_INTERNAL_ERROR; break; } if (!NT_STATUS_IS_OK(status)) { return false; } become_root(); if (fsp->fh->fd != -1) { ret = SMB_VFS_NEXT_FSETXATTR(handle, fsp, config->xattr_name, blob.data, blob.length, 0); } else { ret = SMB_VFS_NEXT_SETXATTR(handle, fsp->fsp_name, config->xattr_name, blob.data, blob.length, 0); } if (ret != 0) { saved_errno = errno; } unbecome_root(); data_blob_free(&blob); if (saved_errno != 0) { errno = saved_errno; } if (ret != 0) { DBG_ERR("can't store acl in xattr: %s\n", strerror(errno)); return false; } return true; }
static int fake_acls_lchown(vfs_handle_struct *handle, const struct smb_filename *smb_fname, uid_t uid, gid_t gid) { int ret; uint8_t id_buf[4]; if (uid != -1) { /* This isn't quite right (calling setxattr not * lsetxattr), but for the test purposes of this * module (fake NT ACLs from windows clients), it is * close enough. We removed the l*xattr functions * because linux doesn't support using them, but we * could fake them in xattr_tdb if we really wanted * to. */ SIVAL(id_buf, 0, uid); ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname->base_name, FAKE_UID, id_buf, sizeof(id_buf), 0); if (ret != 0) { return ret; } } if (gid != -1) { SIVAL(id_buf, 0, gid); ret = SMB_VFS_NEXT_SETXATTR(handle, smb_fname->base_name, FAKE_GID, id_buf, sizeof(id_buf), 0); if (ret != 0) { return ret; } } return 0; }
static bool nfs4acl_xattr_set_smb4acl(vfs_handle_struct *handle, const char *path, struct SMB4ACL_T *smbacl) { TALLOC_CTX *frame = talloc_stackframe(); struct nfs4acl *nfs4acl; int ret; bool denymissingspecial; DATA_BLOB blob; denymissingspecial = lp_parm_bool(handle->conn->params->service, "nfs4acl_xattr", "denymissingspecial", false); if (!nfs4acl_smb4acl2nfs4acl(frame, smbacl, &nfs4acl, denymissingspecial)) { DEBUG(0, ("Failed to convert smb ACL to nfs4 ACL.\n")); TALLOC_FREE(frame); return false; } blob = nfs4acl_acl2blob(frame, nfs4acl); if (!blob.data) { DEBUG(0, ("Failed to convert ACL to linear blob for xattr\n")); TALLOC_FREE(frame); errno = EINVAL; return false; } ret = SMB_VFS_NEXT_SETXATTR(handle, path, NFS4ACL_XATTR_NAME, blob.data, blob.length, 0); if (ret != 0) { DEBUG(0, ("can't store acl in xattr: %s\n", strerror(errno))); } TALLOC_FREE(frame); return ret == 0; }
static int fake_acls_sys_acl_set_file(vfs_handle_struct *handle, const char *path, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl) { int ret; const char *name = NULL; TALLOC_CTX *frame = talloc_stackframe(); DATA_BLOB blob = fake_acls_acl2blob(frame, theacl); if (!blob.data) { DEBUG(0, ("Failed to convert ACL to linear blob for xattr storage\n")); TALLOC_FREE(frame); errno = EINVAL; return -1; } switch (acltype) { case SMB_ACL_TYPE_ACCESS: name = FAKE_ACL_ACCESS_XATTR; break; case SMB_ACL_TYPE_DEFAULT: name = FAKE_ACL_DEFAULT_XATTR; break; } ret = SMB_VFS_NEXT_SETXATTR(handle, path, name, blob.data, blob.length, 0); TALLOC_FREE(frame); return ret; }
static int skel_setxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags) { return SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size, flags); }