The following are the tests passed. (This experiment shows that network data transmission is directly related to "file permissions", iptables, and SElinux.) 1. servicesmbstart2. open the samba port of iptables. (the command line method is not found, you can configure system-config-securitylevel-tui in graphic mode in command line mode.) ud
The following are the tests passed.
(This experiment shows that network data transmission and "file permissions ",Iptables, SElinux has a direct relationship)
1. service smb start
2. open the samba port of iptables (the command line method is not found. you can configure system-config-securitylevel-tui in graphic mode by starting the command line mode) udp133, udp138, tcp139, and tcp445. View/etc/sysconfig/iptables
(Check the ports opened by the samba service: netstat-tlnp | grep smb. check the ports 139 and 445. I don't know why they are different from the ports opened by iptables)
3. configure/etc/samba/smb. conf
Security = share
[Php]
Comment = HomeDirectories
Path =/var/www/html
Browseable = yes
Writable = yes
Guest OK = yes (add this sentence)
------------
Security = user
[Php]
Comment = HomeDirectories
Path =/var/www/html
Browseable = yes
Writable = yes
Valid users = aaa)
Method for adding samba users:
# Cat/etc/passwd | mksmbpasswd. sh>/etc/samba/smbpasswd (the system user password is imported to the samba user)
# Chown root. root/etc/samba/smbpasswd (change folder and file attributes)
# Chmod 600/etc/samba/smbpasswd
# Chmod 600/etc/samba
# Useradd aaa (add new user)
# Passwd aaa
# Smbpasswd-a aaa (add samba users)
4. configure SElinux
[Root @ localhost samba] # getsebool-a | grep samba
Samba_domain_controller --> off
Samba_enable_home_dirs --> off
Samba_export_all_ro --> off
Samba_export_all_rw --> off
Samba_cmd_nfs --> off
Use_samba_home_dirs --> off
Export _use_samba --> off
[Root @ localhost samba] # setsebool-Psamba_export_all_rw = 1 (= 0 is disabled)
[Root @ localhost samba] # setsebool-P samba_export_all_ro = 1
[Root @ localhost samba] # getsebool-a | grep samba
Samba_domain_controller --> off
Samba_enable_home_dirs --> off
Samba_export_all_ro --> on (if only this option is enabled for a read-only shared file)
Samba_export_all_rw --> on .)
Samba_cmd_nfs --> off
Use_samba_home_dirs --> off
Export _use_samba --> off
If you do not want to share files, run the following statement:
[Root @ localhost samba] # setsebool-P samba_export_all_rw = 0
[Root @ localhost samba] # setsebool-P samba_export_all_ro = 0
++ ++
There is a post with the following sections
Http://blog.163.com/koumm@126/blog/static/9540383720095107497849/
1. the files shared by samba must be marked with the correct selinux security context.
Chcon-R-t samba_cmd_t/tmp/abc (I think it is a bit inappropriate to use this to change the context. if the httpd process of these shared files still needs to be used, I wonder if it cannot be accessed, no tests, just conjecture)
If/home/abc is shared, you need to set the security context of the entire main directory.
Chcon-R-r samba_t _t/home
2. modify the policy (only modify the policy of the home directory)
Setsebool-P samba_enable_home_dirs = 1
Setsebool-P allow_smbd_anon_write = 1
Getsebool view
Samba_enable_home_dirs --> on
Allow_smbd_anon_write --> on/* allow anonymous access and write */
++ ++ +
There is also a post with the following sections
Http://hi.baidu.com/yuyong1982912/blog/item/38e5b58a3b7b74dafd1f10eb.html
Method 2: disable SELinux to configure samba (not tested)
Enable the following two lines in smb. conf (remove the; sign from the beginning of the line)
After setsebool-P samba_domain_controller onsetsebool-P samba_enable_home_dirs on takes effect, the home directory can be read and written normally.
If you want to set the/home/samba/temp directory to full sharing, you should write the input in the character state: chcon-t samba_cmd_t/home/samba/temp do not forget to set the/home/samba/temp directory attribute to 777 at the same time. It should be no different from other FC versions.
By default, SELinux prohibits write operations on the shared directory on the Samba server on the network, even if you allow this operation in smb. conf.
If you have configured a shared directory/share and allow users to read and write data, but you do not want to disable SELinux, you can try the following operations:
Program
#/Usr/sbin/setsebool-P allow_smbd_anon_write = 1
# Chcon-t public_content_rw_t/share
The first statement sets the SELinux release to mark the content of public_content_rw_t, and the second statement marks the/share directory to be shared as public_content_rw_t.