Search This Blog

Saturday, December 3, 2011

How SWAT Makes Samba Simpler - PART3


SWAT, Samba's web based configuration tool enables you configure your smb.conf file without you needing to remember all the formatting. Each SWAT screen is actually a form that covers a separate section of the smb.conf file into which you fill in the desired parameters. For ease of use, each parameter box has its own online help. Figure 10-1 shows the main SWAT login screen.

Figure 10-1 Samba SWAT Main Menu

Swat-main.gif

Basic SWAT Setup

You must always remember that SWAT edits the smb.conf file but also strips out any comments you may have manually entered into it beforehand. The original Samba smb.conf file has many worthwhile comments in it, you should save a copy as a reference before proceeding with SWAT. For example, you could save the original file with the name /etc/samba/smb.conf.original as in:
[root@bigboy tmp]# cp /etc/samba/smb.conf /etc/samba/smb.conf.original
As you can see, using SWAT requires some understanding of the smb.conf file parameters because it eliminates these comments. Become familiar with the most important options in this file before proceeding with SWAT.
SWAT doesn't encrypt your login password. Because this could be a security concern in a corporate environment you might want to create a Samba administrator user that has no root privileges or only enable SWAT access from the GUI console or localhost.
The enabling and disabling, starting and stopping of SWAT is controlled by xinetd, which is covered in Chapter 16, "Telnet, TFTP, and xinetd", via a configuration file named /etc/xinetd.d/swat. Here is a sample:
service swat
{

   port            = 901
   socket_type     = stream
   protocol        = tcp
   wait            = no
   user            = root
   server          = /usr/sbin/swat
   log_on_failure  += USERID
   disable         = no
   only_from       = localhost

}
The file's formatting is fairly easy to understand, especially as there are only two entries of interest.
  • The disable parameter must be set to no to accept connections. This can automatically be switched between yes and no as we will see later.
  • The default configuration only allows SWAT web access from the VGA console only as user root on port 901 with the Linux root password. This means you'll have to enter "http://127.0.0.1:901" in your browser to get the login screen.
You can make SWAT accessible from other servers by adding IP address entries to the only_from parameter of the SWAT configuration file. Here's an example of an entry to allow connections only from 192.168.1.3 and localhost. Notice that there are no commas between the entries.
only_from = localhost 192.168.1.3
Therefore in this case you can also configure Samba on your Linux server bigboy IP with address 192.168.1.100 from PC 192.168.1.3 using the URL http://192.168.1.100:901.
Remember that most firewalls don't allow TCP port 901 through their filters. You may have to adjust your rules for this traffic to pass.

Controlling SWAT

As with all xinetd-controlled applications, the chkconfig command automatically modifies the disable field accordingly in the configuration file and activates the change.
Before SWAT can be used, the xinetd program which controls it must be activated in advance. You can start/stop/restart xinetd after boot time using the xinetd initialization script as in the examples below:
[root@bigboy tmp]# service xinetd start
[root@bigboy tmp]# service xinetd stop
[root@bigboy tmp]# service xinetd restart
Just like most Linux systems applications, you can configure xinetd to start at boot time using the chkconfig command:
[root@bigboy tmp]# chkconfig xinetd on
To activate SWAT use:
[root@bigboy tmp] chkconfig swat on
To deactivate SWAT use:
[root@bigboy tmp] chkconfig swat off

No comments: