随笔 - 579  文章 - 2 评论 - 35 阅读 - 56万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

在实现《CentOS(RedHat) 6.2下Samba配置》的过程中,发现CentOS 6.2的Samba share总是没有权限写文件,已经试过在Windows XP/Windows 2003和2台CentOS。当然已经在CentOS端给了所有人完整的权限。而在RH 5.0系列是没有这个问题的。

samba share access denied

网上找了一下,参考以下2篇文章:

试了一下运行:

chcon -Rt samba_share_t /var/samba/resource

还是不行。

  • CentOS 6.0 samba share权限拒绝访问不能创建文件 原来是SELinux在作怪,修改/etc/selinux/config如下:
    [root@server1 ~]# cat /etc/selinux/config
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - SELinux is fully disabled.
    SELINUX=disabled
    # SELINUXTYPE= type of policy in use. Possible values are:
    #       targeted - Only targeted network daemons are protected.
    #       strict - Full SELinux protection.
    SELINUXTYPE=targeted

重启server后HOME 目录可以写了,可是建立的本地Samba share始终不能写入。

后来想到可能是smb.conf配置有问题,smb.conf配置如下:

[resource]
               comment = local resource
               path = /var/samba/resource
               writable = yes                    # OK to write

用testparm一测试果然有问题:

[resource]
        comment = local resource
        path = /var/samba/resource

“writable = yes” 哪里去了?看了看HOME的输出都是”read only = No”,于是把配置改成如下:

[resource]
               comment = local resource
               path = /var/samba/resource
               read only = No

重启SMB service后,问题搞定!,testparm也能正常输出:

[resource]
        comment = local resource
        path = /var/samba/resource
        read only = No

我这个版本Samba难道不认识writable = yes ,只认read only = No ,奇怪?

[root@server2 samba]# uname -a
Linux server2 2.6.32-220.el6.i686 #1 SMP Tue Dec 6 16:15:40 GMT 2011 i686 i686 i386 GNU/Linux
[root@server2 samba]# cat /etc/centos-release
CentOS release 6.2 (Final)
[root@server2 samba]# rpm -qa |grep samba
samba-common-3.5.10-125.el6.i686
samba-client-3.5.10-125.el6.i686
samba-3.5.10-125.el6.i686
samba4-libs-4.0.0-23.alpha11.el6.i686
samba-winbind-clients-3.5.10-125.el6.i686
[root@server2 samba]#

带着这个疑问,我又进行了测试,发现如果我指定了用户或组的情况下,writable = yes是可以的:

[resource]
               comment = local resource
               path = /var/samba/resource
;              read only = No
               writable = yes
               valid users=jonathan

testparm正常输出:

[root@server1 ~]# service smb stop
Shutting down SMB services:                                [  OK  ]
[root@server1 ~]# service smb start
Starting SMB services:                                     [  OK  ]
[root@server1 ~]# testparm
Load smb config files from /etc/samba/smb.conf
 
[resource]
        comment = local resource
        path = /var/samba/resource
        valid users = jonathan
        read only = No

对于这个设计我只能表示无奈,亦或是自己太无知了。

posted on   Dufe王彬  阅读(1489)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
历史上的今天:
2009-04-18 redhat as4下Mysql5+php5+apache2.2.4+GD2安装(转)
2009-04-18 mysql自动备份脚本
点击右上角即可分享
微信分享提示