From c6eef915f9a65a21963907a9c21d346a08e84a7f Mon Sep 17 00:00:00 2001 From: flash Date: Mon, 26 Oct 2026 18:46:35 +0100 Subject: [PATCH] fix: drop user.openvfs.data written by processes other than the desktop client File managers copy all user.* xattrs on copy and paste, so a copied file inherited the fileid and state of the original. Once a desktop client is registered, a setxattr of user.openvfs.data from any other process now removes the entry instead of writing it. The client sets it again for files inside the sync root. --- src/openvfsfuse/openvfsfuse.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/openvfsfuse/openvfsfuse.cpp b/src/openvfsfuse/openvfsfuse.cpp index 1b1913d..b168053 100644 --- a/src/openvfsfuse/openvfsfuse.cpp +++ b/src/openvfsfuse/openvfsfuse.cpp @@ -703,6 +703,19 @@ static int openVFSfuse_fsync(const char *orig_path, int isdatasync, struct fuse_ static int openVFSfuse_setxattr(const char *orig_path, const char *name, const char *value, size_t size, int flags) { const auto path = getInternalPath(orig_path); + + // File managers copy all user.* xattrs on copy and paste. A copied + // user.openvfs.data would carry the fileid and state of the original, so + // only the desktop client may write it. Other writers drop the entry, the + // client sets it again for files inside the sync root. + const auto desktopClientPid = _jobs.desktopClientPid(); + if (std::string_view(name) == OpenVFS::Constants::XAttributeNames::Data && desktopClientPid > 0 + && !callerBelongsToProcess(fuse_get_context()->pid, desktopClientPid)) { + openvfsfuse_log(path, "setxattr", 0, "dropped %s written by pid %d", name, fuse_get_context()->pid); + Xattr::removexattr(path, name); + return 0; + } + return Xattr::setxattr(path, name, value, size, flags); }