![无法写入 Samba 共享](https://linux22.com/image/1341164/%E6%97%A0%E6%B3%95%E5%86%99%E5%85%A5%20Samba%20%E5%85%B1%E4%BA%AB.png)
在 Red Hat Enterprise 6.1 上运行 samba 3.5 时,我在共享两个文件夹时遇到问题。以下是输出testparm
:
[global]
workgroup = DOMAINNAME
server string = Samba Server Version %v
interfaces = lo, eth1
bind interfaces only = Yes
map to guest = Bad User
log file = /var/log/samba/log.%m
max log size = 50
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
hosts allow = 10.50.183.48, 10.50.184.41, 10.50.184.199, 10.50.183.160, 127.0.0.1
hosts deny = 0.0.0.0/0
cups options = raw
[test]
comment = test folder
path = /usr/local/samba
valid users = claudio
write list = claudio
force user = claudio
read only = No
create mask = 0775
directory mask = 0775
[test2]
comment = another test
path = /home/claudio/tst
valid users = claudio
write list = claudio
force user = claudio
read only = No
create mask = 0775
从我所连接的 Windows XP 机器上,我可以读取test
但不能写入,而test2
我甚至无法访问该文件夹(虽然我可以看到它被列出)。
ls -l /usr/local
...
drwxrwxrwx. 2 claudio claudio 4096 Dec 3 10:39 samba
...
ls -l /user/local/samba
total 32
-rwxrwxrwx. 1 claudio claudio 9 Nov 29 16:26 asd.txt
-rwxrwxrwx. 1 claudio claudio 728 Dec 3 10:16 out.txt
...
ls -l /home/claudio/
...
drwxrwxr-x. 2 claudio claudio 4096 Dec 3 09:57 tst
...
ls -l /home/claudio/tst
total 4
-rw-rw-r--. 1 claudio claudio 4 Dec 3 09:57 asd.txt
有什么建议吗?
答案1
Red Hat Enterprise 默认启用了 SELinux,它提供了强制访问控制机制 (正如您可以从指南中读到的那样)。
这意味着共享文件/文件夹需要用正确的类型标记,以便能够正确共享它们(您可以通过向命令smbd
添加选项来检查)。这可以通过以下命令实现Z
ls
chcon -t samba_share_t /path
允许在共享上写入(添加-R
递归标记选项)。