This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: System Administration

SWAT your Samba problems

By Federico Kereki on January 31, 2008 (9:00:00 AM)

Share    Print    Comments   

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:

  • Globals: Provides access to the global parameters (what else?) in smb.conf. You can work at one of two levels: Basic, which shows only the more important options listed, or Advanced, which shows every available parameter. Click on the corresponding buttons to pick your desired level. You can click on the Help links to get specific help about each parameter. After making any edits, click on Commit Changes to save your choices, or Reset Values to go back to the original smb.conf values.
  • Shares: Lets you create, edit, or drop shares. To edit an existing share, pick it from the combo box, then click on Choose Share; clicking on Delete Share will delete it. When you add or edit a share, you can specify several parameters on either Basic or Advanced levels, such as name, path, valid and invalid users, and read-only or writable. Remember to click on Commit Changes (or Reset Values) before changing pages or your work will have been in vain.
  • Printers: Similar to Shares, but works with printers instead.
  • Wizard: Lets you do a quick server configuration. You can pick either a standalone server, a domain controller, or a domain member. You must also specify how the server will work with Windows Internet Name Service (WINS) and whether you want to expose your home directories. Click on "Rewrite smb.conf" or on Commit to save your values, and you will have a basic Samba server running, which you can then further tweak using the other options.
  • Status: Shows you which services are running: usually smbd (the Samba daemon itself) and nmbd (the NetBIOS nameserver support daemon), and possibly Winbind (to allow a Linux box to become a Windows domain member). You also get the listing of all active connections (which you may kill, if you need to), active shares, and open files. You can click on Auto Refresh so the page will refresh on its own every so many seconds (30 by default).
  • View: Lets you view the current configuration file. You can click on the View button to see it either in the normal view (minimalist, with only the nondefault attributes) or the full view (with all possible parameters).
  • Password: Allows you to create, delete, enable, or disable local Samba users and change passwords for a local or remote server.

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.

Federico Kereki is an Uruguayan systems engineer with more than 20 years' experience developing systems, doing consulting work, and teaching at universities.

Share    Print    Comments   

Comments

on SWAT your Samba problems

Note: Comments are owned by the poster. We are not responsible for their content.

SWAT your Samba problems

Posted by: Anonymous [ip: 209.37.138.50] on January 31, 2008 07:52 PM
1. Debian-based distros use inetd instead of xinetd. SWAT package for debian puts a line into /etc/inetd.conf file, which is usually commented out. To use SWAT, you need to uncomment it.
2. No need to restart inetd or xinetd. Just find out the process number and then use kill -HUP on this process to reread configuration files. Or use killall -HUP inetd.

#

SWAT your Samba problems

Posted by: Anonymous [ip: 81.174.243.45] on February 01, 2008 12:42 AM
On Ubuntu systems, you'll need to enable the root account for SWAT to work. You can do this by doing "sudo passwd root".

#

SWAT your Samba problems

Posted by: Anonymous [ip: 76.22.200.32] on February 01, 2008 02:32 AM
And on Fedora systems, it doesn't work at all!

I'd sure like to know what the hell the Fedora project did to break Samba... 'coz it doesn't work whether or not you use SWAT. I've been a diehard Fedora fan since the beginning, but I'm running OpenSuSE these days.

#

SWAT your Samba problems

Posted by: Anonymous [ip: 192.91.173.42] on February 01, 2008 12:25 PM
I have Samba running on Fedora. You have to allow access to the ports under SElinux. I have never, however, been able to get SWAT or Webmin running

#

Samba and Fedora

Posted by: Anonymous [ip: 12.34.246.39] on February 01, 2008 01:20 PM
I've also been running Samba on Fedora for ages. Works fine for me. I agree with the previous post that it is likely either SElinux or firewall rules interfering with Samba if you are having problems.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya