Linux.com

Everything Linux and Open Source

SWAT your Samba problems

January 31, 2008 (9:00:00 AM)  -  1 year, 9 months ago

By: Federico Kereki

If you need to share files or printers with Windows machines, you're likely using Samba and know how to administer and configure it by editing configuration files and starting and stopping the daemon. However, there's an easier, graphical way to configure your box: the Samba Web Administration Tool.

SWAT allows you to set up all aspects of your Samba server through an intuitive Web interface in a style similar to Webmin. (In fact, if you use Webmin, you can access SWAT by going to Servers -> Samba Windows File Sharing and then clicking on the hammer icon for SWAT.)

Among its interesting features, SWAT includes a wizard that can you help you configure Samba quickly with a basic setup. It also provides context-sensitive help for all parameters (taken directly from the man pages), and it lets you monitor the current state of connections and users. Since it is an integral part of the Samba suite, all available parameters are always up to date.

While SWAT offers convenience, it won't help you learn about Samba. You need to know about Samba before you use SWAT; if you don't know what you're doing, you're likely to do more harm than good.

Installation and configuration

SWAT comes with Samba, so unless you're running a really old version of Samba, you will already have it installed. You can check its availability, though, by using the swat --help command. You can also use the following commands to find the program:

# whereis swat swat: /usr/sbin/swat /usr/share/man/man8/swat.8.gz # find / -name swat /etc/webmin/samba/swat /etc/xinetd.d/swat /usr/sbin/swat /usr/share/samba/swat

The /usr/sbin/swat file is the SWAT executable program itself. (I'm using openSUSE 10.3. In other distributions you might find SWAT somewhere else.) You will have the (root access only) /etc/webmin/samba/swat file only if you have Webmin installed; this is where Webmin keeps your Samba user and password. Finally, you must edit /etc/xinetd.d/swat so that SWAT will be available through xinetd. Working as root, edit it so it looks like this:

# SWAT is the Samba Web Administration Tool. service swat { port = 901 groups = yes socket_type = stream protocol = tcp wait = no user = root server = /usr/sbin/swat only_from = 127.0.0.1 log_on_failure += USERID disable = no }

Note that in the server line, I put the path I found earlier with whereis or find. It's likely that the last line will read disable=yes because many distributions don't enable SWAT by default. My version of this file was missing the port and groups lines, so I had to add them. When you're done editing the file, run /etc/init.d/xinetd restart, and SWAT will be ready to work.

Note: On older systems, you might have inetd instead of xinetd; in that case, look for /etc/inetd.conf, which should include an entry like this:

# swat is the Samba Web Administration Tool swat stream tcp nowait.400 root /usr/sbin/swat swat

Use /etc/init.d/inetd restart to activate your edits.

Using SWAT

SWAT works by rewriting the configuration files at /etc/samba/smb.conf and restarting Samba as needed. Note, however, that when it rewrites the file, it wipes away all comments, so if you're the kind of sysadmin who likes to include documentation within configuration files, you'll have a reason to hate SWAT. Unsupported parameters are deleted, parameters that have the default value are ignored, and SWAT changes the order of the parameters, so your carefully handcrafted configuration file may look rather bleak after SWAT is done with it.

Access SWAT by opening a browser and going to http://127.0.0.1:901. The home page provides access to the man documentation pages and some extra Samba documentation, including some complete books. You'll have to install the samba-doc additional package to get the latter.

Here's a list of SWAT's other pages and the functions you can use:

Conclusion

Whether you're just starting out with Samba or are an experimented sysadmin, SWAT can you help you configure your box more easily through its graphical interface.

Read in the original layout at: http://www.linux.com/archive/feature/125452