Bug 12715 - Office document opens as read-only on macOS due to CNID semantics
Summary: Office document opens as read-only on macOS due to CNID semantics
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.6.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-23 12:38 UTC by Uri Simchoni
Modified: 2019-07-05 16:00 UTC (History)
3 users (show)

See Also:


Attachments
git-am fix for 4.5.next and 4.6.next (12.99 KB, patch)
2017-03-27 03:11 UTC, Uri Simchoni
slow: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Uri Simchoni 2017-03-23 12:38:32 UTC
It doesn't happen 100% of the time, but if multiple users open the same Excel document, it may sometimes open as read-only and leave a temp file behind.

It must be stressed that when the document is opened as read-only, no other user has the document open, so it's not a sharing (non-)issue. Instead, one user edits the document, saves and closes, then without rushing things, another user opens the document - and it opens as read-only.

It's been observed with AD users, with macOS El-Capitan, and also with Sierra as the "first opener".

Although we don't have full analysis, we see that the issue is resolved when setting /etc/nsmb.conf on ALL the mac machines as follows:

[default]
file_ids_off=yes

This setting tells the client to stop trusting server-supplied on-disk file ID. The SMB server returns file-id via the QFid create context, or via FILE_INTERNAL_INFORMATION infolevel.

The file id plays a key role in Mac applications because of the HFS+ heritage, where files are identified by CNID. However the HFS CNID is a monotonically-increasing number and Samba provides a file ID made up of the inode number, which can be reused. See https://sambaxp.org/archive_data/SambaXP2016-SLIDES/wed/sambaxp2016-wed-Ralph_Boehme-JuicingTheFruit.pdf slide 30.

What we're looking for with this bug report is for a way to fix the issue without changing things at the client. It's been observed that if the Mac SMB client receives 0 in response for its query, it behaves just as if the "file_ids_off=yes" has been set - both operations clear a bit in the connection details, one at mount time and one afterwards.

See https://github.com/slowfranklin/apple-smb2/blob/master/kernel/smbfs/smbfs_subr_2.c#L68

And also:
https://github.com/slowfranklin/apple-smb2/blob/master/kernel/smbfs/smbfs_vfsops.c#L815

We've also verified experimentally that this fixes the issue in the same way that configuring the client does.

Patch to follow....
Comment 1 Uri Simchoni 2017-03-27 03:11:55 UTC
Created attachment 13107 [details]
git-am fix for 4.5.next and 4.6.next
Comment 2 Ralph Böhme 2017-03-27 05:19:16 UTC
Reassigning to Karolin for inclusion in 4.5 and 4.6.
Comment 3 Karolin Seeger 2017-03-28 10:17:35 UTC
(In reply to Ralph Böhme from comment #2)
Pushed to autobuild-v4-{6,5}-test.
Comment 4 Karolin Seeger 2017-03-29 08:20:03 UTC
(In reply to Karolin Seeger from comment #3)
Pushed to v4-{6,5}-test.
Closing out bug report.