Bug 11057 - The samba-vfs-gluster plug-in causes the case sensitivity setting for Samba to break.
Summary: The samba-vfs-gluster plug-in causes the case sensitivity setting for Samba t...
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 4.1.1
Hardware: All Linux
: P5 normal (vote)
Target Milestone: ---
Assignee: Ira Cooper
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-15 19:41 UTC by Jon
Modified: 2019-02-01 10:59 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon 2015-01-15 19:41:29 UTC
Description of problem:

The samba-vfs-gluster plug-in causes the case sensitivity setting for Samba to break. Windows clients are unable to stat or open a file when one of the directory names in the path is not the correct case (for example \\somehost/RELEASE_1234/someFile.xml vs \\somehost/release_1234/someFile.xml). For out instance the file system uses lowercase but incoming requests are sometimes upper, and those requests fail.

I first brought this to the Gluster mailing lists but the consensus was this was a bug in the VFS/Samba layer or at least the interaction between the two. Through my testing I've verified case sensitively works as expected until the VFS layer is introduced.

Version-Release number of selected component (if applicable):

rpm -qa | grep samba
samba-python-4.1.1-37.el7_0.x86_64
samba-winbind-clients-4.1.1-37.el7_0.x86_64
samba-4.1.1-37.el7_0.x86_64
samba-test-4.1.1-37.el7_0.x86_64
samba-pidl-4.1.1-37.el7_0.x86_64
samba-dc-libs-4.1.1-37.el7_0.x86_64
samba-dc-4.1.1-37.el7_0.x86_64
samba-client-4.1.1-37.el7_0.x86_64
samba-common-4.1.1-37.el7_0.x86_64
samba-winbind-modules-4.1.1-37.el7_0.x86_64
samba-test-devel-4.1.1-37.el7_0.x86_64
samba-vfs-glusterfs-4.1.1-37.el7_0.x86_64
samba-winbind-4.1.1-37.el7_0.x86_64
samba-devel-4.1.1-37.el7_0.x86_64
samba-libs-4.1.1-37.el7_0.x86_64
samba-winbind-krb5-locator-4.1.1-37.el7_0.x86_64

rpm -qa | grep gluster
glusterfs-server-3.5.2-1.el7.x86_64
glusterfs-api-3.5.2-1.el7.x86_64
glusterfs-fuse-3.5.2-1.el7.x86_64
glusterfs-libs-3.5.2-1.el7.x86_64
glusterfs-cli-3.5.2-1.el7.x86_64
samba-vfs-glusterfs-4.1.1-37.el7_0.x86_64
glusterfs-3.5.2-1.el7.x86_64

Running on CentOS 7

How reproducible:
Always

Steps to Reproduce:
1. Create gluster volume and create share using VFS plugin.
2. Attempt to open or stat a file using a UNC path with incorrect case in any part of the file path.


Actual results:
File is not found

Expected results:
File should be found

Additional info:

In /var/log/samba: 

Test 1)
testHost - Samba using vfs-gluster 
default case sensitivity - behaving as if case sensitivity is enabled 
Incoming request is using "RELEASE_2268"

[2014/10/30 11:52:13.488127, 3] smbd/process.c:1414(switch_message) 
switch message SMBtrans2 (pid 8411) conn 0x7f6ecee9a740 
[2014/10/30 11:52:13.488186, 4] smbd/uid.c:351(change_to_user) 
Skipping user change - already user 
[2014/10/30 11:52:13.488246, 3] smbd/trans2.c:5240(call_trans2qfilepathinfo) 
call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = 1004 
[2014/10/30 11:52:13.488310, 5] smbd/filename.c:257(unix_convert) 
unix_convert called on file "RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon" 
[2014/10/30 11:52:13.488371, 5] smbd/filename.c:416(unix_convert) 
unix_convert begin: name = RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon, dirpath = , start = RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon 
[2014/10/30 11:52:13.493304, 5] smbd/filename.c:682(unix_convert) 
Intermediate not found RELEASE_2268 
[2014/10/30 11:52:13.493424, 3] smbd/error.c:81(error_packet_set) 
error packet at smbd/trans2.c(5276) cmd=50 (SMBtrans2) NT_STATUS_UNSUCCESSFUL 

Test 2)
case sensitivity = no - still not finding the file 
Incoming request is using "RELEASE_2268"

[2014/10/30 11:53:11.096059, 5] auth/token_util.c:527(debug_unix_user_token) 
UNIX token of user 270 
Primary group is 501 and contains 0 supplementary groups 
[2014/10/30 11:53:11.096376, 5] smbd/uid.c:317(change_to_user_internal) 
Impersonated user: uid=(0,270), gid=(0,501) 
[2014/10/30 11:53:11.096458, 3] smbd/trans2.c:5240(call_trans2qfilepathinfo) 
call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = 1004 
[2014/10/30 11:53:11.096607, 5] smbd/filename.c:257(unix_convert) 
unix_convert called on file "RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon" 
[2014/10/30 11:53:11.096703, 5] smbd/filename.c:416(unix_convert) 
unix_convert begin: name = RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon, dirpath = , start = RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon 
[2014/10/30 11:53:11.101561, 5] smbd/filename.c:682(unix_convert) 
Intermediate not found RELEASE_2268 
[2014/10/30 11:53:11.101678, 3] smbd/error.c:81(error_packet_set) 
error packet at smbd/trans2.c(5276) cmd=50 (SMBtrans2) NT_STATUS_UNSUCCESSFUL 
[2014/10/30 11:53:11.101743, 5] lib/util.c:332(show_msg)

Test 3) 
case sensitivity = yes - file not found, but is expected. I did this test to see what the output would be when I expected the lookup to fail.
Incoming request is using "RELEASE_2268"

[2014/10/30 11:50:04.600218,  5] auth/token_util.c:527(debug_unix_user_token)
  UNIX token of user 270
  Primary group is 501 and contains 0 supplementary groups
[2014/10/30 11:50:04.600319,  5] smbd/uid.c:317(change_to_user_internal)
  Impersonated user: uid=(0,270), gid=(0,501)
[2014/10/30 11:50:04.600395,  4] smbd/vfs.c:780(vfs_ChDir)
  vfs_ChDir to /mnt/gv-00
[2014/10/30 11:50:04.600483,  3] smbd/trans2.c:5111(call_trans2qfilepathinfo)
  call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = 1004
[2014/10/30 11:50:04.600578,  5] smbd/filename.c:257(unix_convert)
  unix_convert called on file "RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon"
[2014/10/30 11:50:04.600651,  5] smbd/filename.c:416(unix_convert)
  unix_convert begin: name = RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon, dirpath = , start = RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon
[2014/10/30 11:50:04.606808,  3] smbd/error.c:81(error_packet_set)
  error packet at smbd/trans2.c(5147) cmd=50 (SMBtrans2) NT_STATUS_OBJECT_PATH_NOT_FOUND 

Test 4)
same host as previous tests but using Samba to mount the Gluster volume, which itself is mounted locall via FUSE.
Incoming request is using "RELEASE_2268" but it gets transformed to lower-case at the "check_reduced_name"
default case sensitivity - works as expected. To me this show Sama v4 is working correctly.

[2014/10/30 11:46:50.302252,  3] smbd/process.c:1467(switch_message)
  switch message SMBtrans2 (pid 23296) conn 0x7ff2f5310a40
[2014/10/30 11:46:50.302357,  4] smbd/uid.c:351(change_to_user)
  Skipping user change - already user
[2014/10/30 11:46:50.302461,  3] smbd/trans2.c:5111(call_trans2qfilepathinfo)
  call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = 1034
[2014/10/30 11:46:50.302567,  5] smbd/filename.c:257(unix_convert)
  unix_convert called on file "RELEASE_2268/150373E7A0148258/150817BC917FFB00.zon"
[2014/10/30 11:46:50.302747,  3] smbd/vfs.c:905(check_reduced_name)
  check_reduced_name [release_2268/150373E7A0148258/150817BC917FFB00.zon] [/mnt/gv-00]
[2014/10/30 11:46:50.302883,  3] smbd/vfs.c:1039(check_reduced_name)
  check_reduced_name: release_2268/150373E7A0148258/150817BC917FFB00.zon reduced to /mnt/gv-00/release_2268/150373E7A0148258/150817BC917FFB00.zon
[2014/10/30 11:46:50.303004,  3] smbd/trans2.c:5255(call_trans2qfilepathinfo)
  call_trans2qfilepathinfo release_2268/150373E7A0148258/150817BC917FFB00.zon (fnum = -1) level=1034 call=5 total_data=0
[2014/10/30 11:46:50.303112,  5] smbd/trans2.c:4223(smbd_do_qfilepathinfo)
  smbd_do_qfilepathinfo: release_2268/150373E7A0148258/150817BC917FFB00.zon (fnum = -1) level=1034 max_data=56

smb.conf settings
################

[global]
        workgroup = mycorp
        server string = testHost

        netbios name = testHost
        netbios aliases = testHost
        idmap backend = tdb2

        security = user
        map to guest = bad user
        guest account = smbuser
        password server = 1.2.3.4
        log file = /var/log/samba/log.%m
        max log size = 50
        log level = 5
        dns proxy = No
        hosts allow = 172.20. 172.22. 172.21. 172.30. 127. 192.168.50.
        unix extensions = no
        wide links = yes

[raid]
        wide links = no
        writeable = yes
        path = /
        public = yes
        read only = no
        guest ok = yes
        guest only = yes
        write list = @smbgroup
        create mode = 660
        directory mode = 770
        create mask = 0666
        directory mask = 0775
        preserve case = yes ;changed with testing
        short preserve case = yes
        unix extensions = no
        case sensitive = no 
        ;default case = lower
        kernel share modes = no
        posix locking = no
	;below removed for test #4 as a typical Samba share
        vfs objects = glusterfs
        glusterfs:volfile_server = localhost
        glusterfs:volume = gv-00
        glusterfs:logfile = /var/log/glusterfs/gv-00.log
        glusterfs:loglevel = 10
Comment 1 Jeremy Allison 2015-01-15 19:59:54 UTC
Reassigning to Michael.

The code you need to instrument is get_real_filename() which first calls into SMB_VFS_GET_REAL_FILENAME() to try case insensitive direct lookup, then should fall back to a directory scan.

Inside vfs_glusterfs.c we have: vfs_gluster_get_real_filename() which tries an xattr lookup on the EA user.glusterfs.get_real_filename:FILENAME, which should presumably return the real case version of the looked up name.

FILENAME can be in any case, so this requires the glusterfs EA lookup to be case insensitive - hmmm. Is it *really* ? :-).

This is almost certainly where the bug lives IMHO :-).
Comment 2 Ira Cooper 2015-01-15 20:08:27 UTC
(In reply to Jeremy Allison from comment #1)

This has been fixed in master.

af9ec9fea5a730023cdee6e236f9585e3a18b0e6 ; is the needed commit.

Assigning to me, because I worked with Talur on the issue.

-Ira
Comment 3 Jeremy Allison 2015-01-15 20:12:30 UTC
(In reply to Ira Cooper from comment #2)

Ah great ! At least I found *exactly* the right piece of code to blame :-).

Thanks Ira !
Comment 4 Guenther Deschner 2015-02-25 16:46:57 UTC
Note that the required fix has been published in the most recent 4.2.0rc5 release candidate and will be published probably also in the next 4.1.x release.
Comment 5 Guenther Deschner 2019-02-01 10:59:16 UTC
This has long been fixed now in released Samba versions.