Bug 11278 - Stream names with colon don't work with fruit:encoding = native
Summary: Stream names with colon don't work with fruit:encoding = native
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
: 11162 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-05-18 08:54 UTC by Ralph Böhme
Modified: 2015-08-18 11:35 UTC (History)
5 users (show)

See Also:


Attachments
Patch for master (12.16 KB, patch)
2015-08-04 12:22 UTC, Ralph Böhme
no flags Details
Patchset that is supposed to go into master (12.85 KB, patch)
2015-08-06 14:56 UTC, Ralph Böhme
no flags Details
Patch for 4.3 cherry-picked from master (13.12 KB, patch)
2015-08-10 16:34 UTC, Ralph Böhme
metze: review+
Details
Patch for 4.2 cherry-picked from master (13.12 KB, patch)
2015-08-10 16:36 UTC, Ralph Böhme
metze: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralph Böhme 2015-05-18 08:54:08 UTC
Stream names with colon don't work with fruit:encoding = native
===============================================================

OS X makes extensive use of colons (':') in xattr names. On SMB mounts with streams support, xattrs are mapped to named streams and the client maps the colon character (as any other illegal NTFS character) to the Unicode private range.

This means by default on a Samba share with vfs_streams_xattr, the stream is again mapped to a xattr and the colon in the xattr name is stored as an UTF8 encoded Unicode private range character. So far things work correct. :)

Example:

samba$ $ grep -A 3 '\[AAPL' /opt/samba/etc/smb.conf
[AAPL]
    path = /Volumes/aapl
    vfs objects = catia fruit streams_xattr
#    fruit:encoding = native

mac$ mount_smbfs -o nobrowse //fedora20.local/aapl mnt
mac$ touch mnt/file
mac$ xattr -w 'foo:bar' baz mnt/file 
mac$ xattr -l mnt/file
foo:bar: baz
mac$ 

samba$ getfattr /Volumes/aapl/file
getfattr: Removing leading '/' from absolute path names
# file: Volumes/aapl/file
user.DOSATTRIB
user.DosStream.foobar:$DATA

vfs_fruit can enable a builtin vfs_catia mapping (requires vfs_catia to be loaded of course) that maps the illegal NTFS characters between their mapped private range and the native ASCII representation. This applies both to filenames as well as xattr names, examples:

samba$ $ grep -A 3 '\[AAPL' /opt/samba/etc/smb.conf
[AAPL]
    path = /Volumes/aapl
    vfs objects = catia fruit streams_xattr
    fruit:encoding = native

mac$ mount_smbfs -o nobrowse //fedora20.local/aapl mnt
mac$ touch mnt/file
mac$ xattr -w 'foo:bar' baz mnt/file 
mac$ xattr -l mnt/file
foo:bar: baz
mac$ 

samba$ getfattr /Volumes/aapl/file
getfattr: Removing leading '/' from absolute path names
# file: Volumes/aapl/file
user.DOSATTRIB
user.DosStream.foo:bar:$DATA

We have two issues with this:
- we don't perform the reverse mapping from native ASCII to the private range when enumerating streams in getinfo calls
- vfs_streams_xattr uses strchr_m(':') instead of strrchr_m(':') at one point when looking for the streamname:streamtype seperator which won't work if the streamname contains a colon

Patches including a torture test are pending.
Comment 1 Ralph Böhme 2015-08-04 12:22:07 UTC
Created attachment 11305 [details]
Patch for master

Patch for testing, fixes the issue for me.
Comment 2 Ralph Böhme 2015-08-04 12:23:09 UTC
*** Bug 11162 has been marked as a duplicate of this bug. ***
Comment 3 Ralph Böhme 2015-08-06 14:56:13 UTC
Created attachment 11316 [details]
Patchset that is supposed to go into master
Comment 4 Ralph Böhme 2015-08-10 16:34:32 UTC
Created attachment 11325 [details]
Patch for 4.3 cherry-picked from master
Comment 5 Ralph Böhme 2015-08-10 16:36:47 UTC
Created attachment 11326 [details]
Patch for 4.2 cherry-picked from master
Comment 6 Stefan Metzmacher 2015-08-17 15:36:25 UTC
Pushed to autobuild-v4-3-test, doesn't apply to v4-2-test
Comment 7 Ralph Böhme 2015-08-17 16:33:46 UTC
(In reply to Stefan Metzmacher from comment #6)
Doesn't apply to 4-2 because it needs the changes from the copyfile patch you just pushed in bug 113167.
Please try again once the copyfile patchset is in 4-2, thanks!
Comment 8 Stefan Metzmacher 2015-08-17 20:15:30 UTC
Pushed to autobuild-v4-2-test
Comment 9 Stefan Metzmacher 2015-08-18 11:35:55 UTC
Pushed to v4-{2,3}-test