Samba 4.1 process_usershare_file:/ var / lib / samba / usershares / share的stat失败。 即使用户可以列出该文件夹和stat文件

我有两个相同的用户,一个可以访问共享,而另一些则不能。 共享名称是storage_photos ,它位于文件夹/storage/photos/

 $ getfacl /storage/photos getfacl: Removing leading '/' from absolute path names # file: storage/photos # owner: root # group: photos user::rwx group::rwx group:photos:rwx mask::rwx other::r-- default:user::rwx default:group::rwx default:group:photos:rwx default:mask::rwx default:other::r-- 

有问题的两个用户都是photos组的成员:

 $ groups john john : john sambashare photos $ groups lisa lisa : lisa sambashare photos 

作为他们在sambashare文件夹中的成员,他们能够列出/var/lib/samba/usershares/

 sudo -u lisa ls -ltha /var/lib/samba/usershares/ total 24K drwxrwx--T 2 root sambashare 4.0K Oct 25 17:06 . -rw-r--r-- 1 root root 125 Oct 25 17:06 storage_photos 

考虑到这一点,奇怪的是发现一个用户无法访问共享,而另一个成功:

 smbclient //Server/storage_photos -U lisa%pass Domain=[ONE] OS=[Unix] Server=[Samba 4.1.6-Ubuntu] tree connect failed: NT_STATUS_ACCESS_DENIED smbclient //Server/storage_photos -U john%pass Domain=[ONE] OS=[Unix] Server=[Samba 4.1.6-Ubuntu] smb: \> 

在服务器端,日志级别为2的故障看起来像:

 [2015/10/25 23:12:20.646681, 0] ../source3/param/loadparm.c:4365(process_usershare_file) process_usershare_file: stat of /var/lib/samba/usershares/storage_photos failed. Permission denied [2015/10/25 23:12:20.649381, 2] ../source3/smbd/service.c:407(create_connection_session_info) guest user (from session setup) not permitted to access this share (storage_photos) [2015/10/25 23:12:20.649437, 1] ../source3/smbd/service.c:550(make_connection_snum) create_connection_session_info failed: NT_STATUS_ACCESS_DENIED 

同时成功是一件无聊的事情:

 [2015/10/25 23:14:30.321507, 2] ../source3/smbd/service.c:856(make_connection_snum) device (ipv4:192.168.1.5:46134) connect to service storage_photos initially as user john (uid=1000, gid=1000) (pid 5297) [2015/10/25 23:16:10.409218, 1] ../source3/smbd/service.c:1130(close_cnum) device (ipv4:192.168.1.5:46134) closed connection to service storage_photos 

现在失败中有趣的部分是: process_usershare_file: stat of /var/lib/samba/usershares/storage_photos failed. Permission denied process_usershare_file: stat of /var/lib/samba/usershares/storage_photos failed. Permission denied 。 即使用户可以统计文件,为什么访问失败:

 sudo -u lisa stat /var/lib/samba/usershares/storage_photos File: '/var/lib/samba/usershares/storage_photos' Size: 125 Blocks: 8 IO Block: 4096 regular file Device: 900h/2304d Inode: 137795 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2015-10-25 17:06:46.704318935 +0100 Modify: 2015-10-25 17:06:46.700318935 +0100 Change: 2015-10-25 17:06:46.700318935 +0100 Birth: - 

从这一点可以得出这样的结论:由于某种原因,当lisa尝试login时,samba没有使用正确的unix用户来统计文件,而是在john做的时候。

约翰和丽莎可以ssh到机器。 该机器确实安装了libpam-smbpass ,按照这个堆栈溢出问题的规定安装。 但重新启动服务器的问题依然存在。

所有这一切都使用以下非常默认的Ubuntu 14.04 smb.conf。 这些份额由拥有sharesmb参数的ZFS文件系统定义。

 [global] workgroup = ONE server string = %h server (Samba, Ubuntu) server role = standalone server map to guest = Bad User obey pam restrictions = Yes pam password change = Yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . unix password sync = Yes syslog = 0 log file = /var/log/samba/log.%m max log size = 1000 dns proxy = No usershare allow guests = Yes panic action = /usr/share/samba/panic-action %d idmap config * : backend = tdb 

出于某种原因重新安装winbind在服务器上解决了这个问题,但不是立即。 就好像有一些caching正在进行authentication。 所以解决scheme是运行以​​下,然后放松一段时间。

 sudo apt-get remove winbind && sudo apt-get install winbind 

我非常抱歉,但我不能想到为什么这将解决问题时,重新启动winbind没有,因为apt应该保留configuration文件,只要你不清除一个包。