Thursday, October 4, 2007

Samba, Samba why are you so bad

Today I've been wrestling with Samba again. On venus, one of my linux boxes (which runs Fedora core 6), I went to system-->administration-->server settings--> samba. It clearly shows a folder called /admin to be shared and visible and writable and everything. But....

When I try to do a directory listing of \\venus\admin from my Win XP box it says "Access denied " or "path not found" or some other such hokum. It's always something...

Here's what to do:

First, do ps -e | grep smb to see if samba is even running. Even though /admin appears to be shared according the the Fedora GUI, that is no guarantee that samba is actually running. I supposed I need to make sure samba runs all the time by adding it to the init.d process. That way it'll start automatically after every reboot. But to start it manually just type:

smbd
nmbd

Then make sure your directory is accessible to everybody by changing its permissions to the least restrictive:

chmod 777 /admin/shamrockacct

Finally, make sure you don't have a firewall issue. Iptables is the firewall on venus. To see what iptables is up to, type "iptables -L" at the command prompt. It will show a listing of the rules that iptables is currently enforcing.

In my case, iptables was blocking access from my Windows box even after I had samba started. So for a quick test, I turned iptables completely off and then I was able to see a listing of /admin by typing:

dir \\venus\admin

in a command window on my Window box.

Now I need to start iptables again but this time open whatever ports samba needs. First check the samba checkbox on the system-->administration-->server settings--> samba screen. Then go to the SELinux tab and click on "Modify SELinux Policy". Scroll down to and click on samba. There you will see several checkboxes. I checked the following:

Disable SELinux protection for smbd daemon
Disable SELinux protection for nmbd daemon
Disable SELinux protection for windbind daemon

Now it works! Windows can see and copy files to and from the /venus/admin, but the firewall on venus has opened just those ports (supposedly) that samba needs to operate. SELinux has also loosened up enough to allow samba to work.

No comments: