Skip to content

feat: add -x flag to strip xattr keys on non-client setxattr - #49

Open
flash7777 wants to merge 2 commits into
opencloud-eu:mainfrom
flash7777:feature/strip-xattr-keys
Open

feat: add -x flag to strip xattr keys on non-client setxattr#49
flash7777 wants to merge 2 commits into
opencloud-eu:mainfrom
flash7777:feature/strip-xattr-keys

Conversation

@flash7777

Copy link
Copy Markdown

Problem

File managers (Nautilus, Dolphin) copy all user.* xattrs on copy+paste. This causes user.openvfs.data to be copied verbatim, so the new file inherits the original's fileid and immutable state — which is incorrect for a copy.

Solution

Add a -x key1,key2,... CLI flag that lists msgpack keys to strip from user.openvfs.data when written by a non-client process:

openvfsfuse -x fileid,immutable -o owner /mountpoint

When Nautilus copies a file and sets user.openvfs.data, openvfs intercepts the setxattr, parses the msgpack, clears the listed keys, and writes the cleaned version. The registered desktop client PID (from VERSION handshake) is exempt so sync clients can write all keys.

Usage by cloudd

openvfsfuse -x fileid,immutable -o cloudd:server /mount

Changes

  • main.cpp: add -x to getopt, parse comma-separated keys into stripXattrKeys
  • openvfsfuse.h: add stripXattrKeys to Args
  • openvfsfuse.cpp: VFSFuseContext stores keys, setxattr handler strips them

3 files, +49/-2 lines.

Test plan

  • Builds clean
  • Without -x: setxattr passes through unchanged (backwards compatible)
  • With -x fileid,immutable: Nautilus copy+paste produces file without fileid/immutable

File managers like Nautilus copy all xattrs (including user.openvfs.data)
when doing copy+paste. This causes copied files to inherit the original's
fileId and immutable state, which is incorrect.

The new -x flag accepts a comma-separated list of msgpack keys that
should be cleared when a non-client process writes user.openvfs.data:

    openvfsfuse -x fileid,immutable -o owner /mountpoint

When a process other than the registered desktop client writes
user.openvfs.data, the specified keys are set to "" in the msgpack
payload before writing. This ensures copied files get fresh identity
on the next sync while preserving other attributes like size and etag.

The desktop client PID (from the VERSION handshake) is exempt, so
cloudd/sync clients can still write all keys.
@dragotin

dragotin commented Jul 2, 2026

Copy link
Copy Markdown
Member

Thanks a lot for you PR, good catch.

What I do not get completely: When the external applications such as nautilus copies the xattrs, why should we not completely remove the user xattrs of openvfs? Why do you want to filter for certain members?

Can you elaborate? Thanks.

… empty

Per review by @dragotin: "Why not completely remove the user xattrs?"

We strip selectively because user-set metadata (comments, tags, custom
properties) should survive copy+paste. Only system-managed per-file
identity fields need removal:
- fileid: unique per file, must not be duplicated
- immutable: protection state is per-file, not inheritable via copy
- syncerror: transient sync state

Fields like etag, pinstate, size are harmless to copy.

Also: use json::erase() instead of setting to "" — cleaner removal.
@dragotin

dragotin commented Jul 6, 2026

Copy link
Copy Markdown
Member

Thanks for updating the PR, but I am still not convinced, I still think you should remove the entire openVFS metadata that are inconsistent. The syncing application should, if the resource is still within a sync dir, set the data new anyway next moment.

User Metadata should not be part of the openVFS Namespace anyway. That is why we put our metadata into a JSON document instead into single values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants