Problem: When trying to do a listing after connecting to a samba share from the local system via smbclient, the following error is seen.
[user@server ~]$ smbclient //localhost/samba-test
Enter CENTRIFY\user's password:
Domain=[CENTRIFY] OS=[Windows 6.1] Server=[Samba 4.6.2]
smb: \> ls
NT_STATUS_ACCESS_DENIED listing \*
Cause:
This is caused by SELinux not being configured to allow Samba or smbclient to see the share listing.
Resolution:
1. SELinux can be set to permissive. (Will need to be run as root or root equivalent user).
[root@server ~]# setenforce permissive
or
2. SELinux can be allowed to work with Samba
Search for the SELinux settings for Samba with the following command:
[user@server ~]$ getsebool -a | grep 'samba\|smb'
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_load_libgfapi --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
smbd_anon_write --> off
tmpreaper_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off
Set the samba_export_all_ro setting to on. (Will need to be root or root equivalent user).
[root@server ~]# setsebool -P samba_export_all_ro on
The listing should now show the share contents.
[user@server ~]$ smbclient //localhost/samba-test
Enter CENTRIFY\user's password:
Domain=[CENTRIFY] OS=[Windows 6.1] Server=[Samba 4.6.2]
smb: \> ls
. D 0 Mon Sep 18 13:48:40 2017
.. DR 0 Mon Sep 18 13:48:40 2017
15718400 blocks of size 1024. 11682584 blocks available
smb: \>