December 28, 2007

Samba & Swat on Mac OSX

With PHP and Mysql installed, it was on to setting up file sharing on my G4 Server which now had 4 hard drives in it. A friend of mine already had a server set up a while ago, so I had a little knowledge of Samba configurations, and I figured it was similar to the webDav setup I had done on an eMac a while ago.

There is nothing to install because Samba is already installed in OSX and you can just turn on Windows File sharing in the Sharing preference panel to start it. However beyond that there is not much control over what is shared and who has access to what. To do that you need to edit the smb.conf file in /etc, but I am inexperienced/lazy and would like a better way of doing this. After doing some research found that Samba had a web GUI for it called Swat, and like in the case of PHP it is installed by default, but is not active.

To start the service you must set the Swat service as avalable and using tcp port 901. I used the page here to figure this out. "Configuring xinetd to launch swat requires just a few steps. You first need to check that your /etc/services file contains a port entry for swat. To do this, enter the following command in the Terminal: cat /etc/services | grep swat. This command should return one result, which will list the swat service as running on port 901/tcp. If you do not get a result for this, add such an entry to your /etc/services file by editing it with pico running under sudo or as root. Add an entry that lists the information above and then save your changes." I used VI because that is what I am most comfortable with. There is already a service specified by port 901, but it is not needed so remove the line with UDP and replace with swat.

After that I tried to set up a service in etc/xinetd.d for swat, and that worked, but the swat page at localhost:901 would not let me log on. I found that there was no password file associated to it, and quickly looked for a fix. Not only did I find a fix but an easier way to set it up. Mac os Hints had a good Article on Samba and in the comments is how to get around the problems. These are the steps I finally figured out, using the mix of suggestions on the page here.

1. Edit /etc/hostconfig
3. Save
4. Edit /etc/services
5. Find the line where port 901 is defined
6. delete the line where it says 901/udp
7. Change the 901/tcp line to read: swat 901/tcp
8. Save the file
9. cd to "/etc/pam.d"
10. run "sudo cp ./passwd ./samba"
11. run "/sbin/service swat start"
12. reboot
13. goto http://localhost:901

After this it is all working and I can now use swat to set up my Samba shares.

No comments: