1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
6
<pubdate>April 21, 2003</pubdate>
9
<title>SWAT: The Samba Web Administration Tool</title>
12
<indexterm><primary>configuration tool</primary></indexterm>
13
<indexterm><primary>SWAT</primary></indexterm>
14
<indexterm><primary>Web-based configuration</primary></indexterm>
15
There are many and varied opinions regarding the usefulness of SWAT. No matter how hard one tries to produce
16
the perfect configuration tool, it remains an object of personal taste. SWAT is a tool that allows Web-based
17
configuration of Samba. It has a wizard that may help to get Samba configured quickly, it has
18
context-sensitive help on each &smb.conf; parameter, it provides for monitoring of current state of connection
19
information, and it allows networkwide MS Windows network password management.
23
<title>Features and Benefits</title>
26
<indexterm><primary>internetworking super daemon</primary></indexterm>
27
SWAT is a facility that is part of the Samba suite. The main executable is called
28
<command>swat</command> and is invoked by the internetworking super daemon.
29
See <link linkend="xinetd">appropriate section</link> for details.
33
<indexterm><primary>man</primary></indexterm>
34
SWAT uses integral Samba components to locate parameters supported by the particular
35
version of Samba. Unlike tools and utilities that are external to Samba, SWAT is always
36
up to date as known Samba parameters change. SWAT provides context-sensitive help for each
37
configuration parameter, directly from <command>man</command> page entries.
41
<indexterm><primary>documentation</primary></indexterm>
42
<indexterm><primary>configuration files</primary></indexterm>
43
<indexterm><primary>internal ordering</primary></indexterm>
44
Some network administrators believe that it is a good idea to write systems
45
documentation inside configuration files, and for them SWAT will always be a nasty tool. SWAT
46
does not store the configuration file in any intermediate form; rather, it stores only the
47
parameter settings, so when SWAT writes the &smb.conf; file to disk, it writes only
48
those parameters that are at other than the default settings. The result is that all comments,
49
as well as parameters that are no longer supported, will be lost from the &smb.conf; file.
50
Additionally, the parameters will be written back in internal ordering.
54
<indexterm><primary>stripped of comments</primary></indexterm>
55
Before using SWAT, please be warned &smbmdash; SWAT will completely replace your &smb.conf; with
56
a fully optimized file that has been stripped of all comments you might have placed there
57
and only nondefault settings will be written to the file.
63
<title>Guidelines and Technical Tips</title>
66
<indexterm><primary>internationalization support</primary></indexterm>
67
This section aims to unlock the dark secrets behind how SWAT may be made to work,
68
how it can be made more secure, and how to solve internationalization support problems.
72
<title>Validate SWAT Installation</title>
75
<indexterm><primary>SWAT binary support</primary></indexterm>
76
The very first step that should be taken before attempting to configure a host
77
system for SWAT operation is to check that it is installed. This may seem a trivial
78
point to some, but several Linux distributions do not install SWAT by default,
79
even though they do ship an installable binary support package containing SWAT
80
on the distribution media.
84
<indexterm><primary>swat</primary></indexterm>
85
When you have confirmed that SWAT is installed, it is necessary to validate
86
that the installation includes the binary <command>swat</command> file as well
87
as all the supporting text and Web files. A number of operating system distributions
88
in the past have failed to include the necessary support files, even though the
89
<command>swat</command> binary executable file was installed.
93
<indexterm><primary>inetd</primary></indexterm>
94
<indexterm><primary>xinetd</primary></indexterm>
95
Finally, when you are sure that SWAT has been fully installed, please check that SWAT
96
is enabled in the control file for the internetworking super-daemon (inetd or xinetd)
97
that is used on your operating system platform.
101
<title>Locating the <command>SWAT</command> File</title>
104
<indexterm><primary>/usr/local/samba/bin</primary></indexterm>
105
<indexterm><primary>/usr/sbin</primary></indexterm>
106
<indexterm><primary>/opt/samba/bin</primary></indexterm>
107
To validate that SWAT is installed, first locate the <command>swat</command> binary
108
file on the system. It may be found under the following directories:</para>
110
<member><filename>/usr/local/samba/bin</filename> &smbmdash; the default Samba location</member>
111
<member><filename>/usr/sbin</filename> &smbmdash; the default location on most Linux systems</member>
112
<member><filename>/opt/samba/bin</filename></member>
117
The actual location is much dependent on the choice of the operating system vendor or as determined
118
by the administrator who compiled and installed Samba.
122
There are a number of methods that may be used to locate the <command>swat</command> binary file.
123
The following methods may be helpful.
127
<indexterm><primary>swat</primary></indexterm>
128
<indexterm><primary>operating system search path</primary></indexterm>
129
<indexterm><primary>swat command-line options</primary></indexterm>
130
If <command>swat</command> is in your current operating system search path, it will be easy to
131
find it. You can ask what are the command-line options for <command>swat</command> as shown here:
134
Usage: swat [OPTION...]
135
-a, --disable-authentication Disable authentication (demo mode)
138
-?, --help Show this help message
139
--usage Display brief usage message
141
Common samba options:
142
-d, --debuglevel=DEBUGLEVEL Set debug level
143
-s, --configfile=CONFIGFILE Use alternative configuration file
144
-l, --log-basename=LOGFILEBASE Basename for log/debug files
145
-V, --version Print version
152
<title>Locating the SWAT Support Files</title>
155
Now that you have found that <command>swat</command> is in the search path, it is easy
156
to identify where the file is located. Here is another simple way this may be done:
158
frodo:~ # whereis swat
159
swat: /usr/sbin/swat /usr/share/man/man8/swat.8.gz
164
If the above measures fail to locate the <command>swat</command> binary, another approach
165
is needed. The following may be used:
167
frodo:/ # find / -name swat -print
170
/usr/share/samba/swat
176
This list shows that there is a control file for <command>xinetd</command>, the internetwork
177
super-daemon that is installed on this server. The location of the SWAT binary file is
178
<filename>/usr/sbin/swat</filename>, and the support files for it are located under the
179
directory <filename>/usr/share/samba/swat</filename>.
183
We must now check where <command>swat</command> expects to find its support files. This can
186
frodo:/ # strings /usr/sbin/swat | grep "/swat"
189
/usr/share/samba/swat
195
The <filename>/usr/share/samba/swat/</filename> entry shown in this listing is the location of the
196
support files. You should verify that the support files exist under this directory. A sample
199
jht@frodo:/> find /usr/share/samba/swat -print
200
/usr/share/samba/swat
201
/usr/share/samba/swat/help
202
/usr/share/samba/swat/lang
203
/usr/share/samba/swat/lang/ja
204
/usr/share/samba/swat/lang/ja/help
205
/usr/share/samba/swat/lang/ja/help/welcome.html
206
/usr/share/samba/swat/lang/ja/images
207
/usr/share/samba/swat/lang/ja/images/home.gif
209
/usr/share/samba/swat/lang/ja/include
210
/usr/share/samba/swat/lang/ja/include/header.nocss.html
212
/usr/share/samba/swat/lang/tr
213
/usr/share/samba/swat/lang/tr/help
214
/usr/share/samba/swat/lang/tr/help/welcome.html
215
/usr/share/samba/swat/lang/tr/images
216
/usr/share/samba/swat/lang/tr/images/home.gif
218
/usr/share/samba/swat/lang/tr/include
219
/usr/share/samba/swat/lang/tr/include/header.html
220
/usr/share/samba/swat/using_samba
222
/usr/share/samba/swat/images
223
/usr/share/samba/swat/images/home.gif
225
/usr/share/samba/swat/include
226
/usr/share/samba/swat/include/footer.html
227
/usr/share/samba/swat/include/header.html
233
If the files needed are not available, it is necessary to obtain and install them
234
before SWAT can be used.
241
<title>Enabling SWAT for Use</title>
244
SWAT should be installed to run via the network super-daemon. Depending on which system
245
your UNIX/Linux system has, you will have either an <command>inetd</command>- or
246
<command>xinetd</command>-based system.
250
The nature and location of the network super-daemon varies with the operating system
251
implementation. The control file (or files) can be located in the file
252
<filename>/etc/inetd.conf</filename> or in the directory <filename>/etc/[x]inet[d].d</filename>
253
or in a similar location.
257
The control entry for the older style file might be:
258
<indexterm><primary>swat</primary><secondary>enable</secondary></indexterm>
262
<para><programlisting>
263
# swat is the Samba Web Administration Tool
264
swat stream tcp nowait.400 root /usr/sbin/swat swat
265
</programlisting></para>
268
A control file for the newer style xinetd could be:
274
# description: SWAT is the Samba Web Admin Tool. Use swat \
275
# to configure your Samba server. To use SWAT, \
276
# connect to port 901 with your favorite web browser.
282
only_from = localhost
284
server = /usr/sbin/swat
285
log_on_failure += USERID
289
In the above, the default setting for <parameter>disable</parameter> is <constant>yes</constant>.
290
This means that SWAT is disabled. To enable use of SWAT, set this parameter to <constant>no</constant>
295
<indexterm><primary>swat</primary></indexterm>
296
<indexterm><primary>/usr/sbin</primary></indexterm>
297
<indexterm><primary>/usr/share/samba/swat</primary></indexterm>
298
<indexterm><primary>/usr/local/samba/swat</primary></indexterm>
299
Both of the previous examples assume that the <command>swat</command> binary has been
300
located in the <filename>/usr/sbin</filename> directory. In addition to the above,
301
SWAT will use a directory access point from which it will load its Help files
302
as well as other control information. The default location for this on most Linux
303
systems is in the directory <filename>/usr/share/samba/swat</filename>. The default
304
location using Samba defaults will be <filename>/usr/local/samba/swat</filename>.
308
<indexterm><primary>SWAT permission allowed</primary></indexterm>
309
<indexterm><primary>password change facility</primary></indexterm>
310
Access to SWAT will prompt for a logon. If you log onto SWAT as any non-root user,
311
the only permission allowed is to view certain aspects of configuration as well as
312
access to the password change facility. The buttons that will be exposed to the non-root
313
user are <guibutton>HOME</guibutton>, <guibutton>STATUS</guibutton>, <guibutton>VIEW</guibutton>, and
314
<guibutton>PASSWORD</guibutton>. The only page that allows
315
change capability in this case is <guibutton>PASSWORD</guibutton>.
319
As long as you log onto SWAT as the user <emphasis>root</emphasis>, you should obtain
320
full change and commit ability. The buttons that will be exposed include
321
<guibutton>HOME</guibutton>, <guibutton>GLOBALS</guibutton>, <guibutton>SHARES</guibutton>, <guibutton>PRINTERS</guibutton>,
322
<guibutton>WIZARD</guibutton>, <guibutton>STATUS</guibutton>, <guibutton>VIEW</guibutton>, and <guibutton>PASSWORD</guibutton>.
328
<title>Securing SWAT through SSL</title>
332
<indexterm><primary>SSL</primary></indexterm>
333
<indexterm><primary>swat</primary><secondary>security</secondary></indexterm>
334
Many people have asked about how to set up SWAT with SSL to allow for secure remote
335
administration of Samba. Here is a method that works, courtesy of Markus Krieger.
339
Modifications to the SWAT setup are as follows:
344
<indexterm><primary>OpenSSL</primary></indexterm>
349
<indexterm><primary>certificate</primary></indexterm>
350
<indexterm><primary>private key</primary></indexterm>
351
Generate certificate and private key.
352
<indexterm><primary>/usr/bin/openssl</primary></indexterm>
354
&rootprompt;<userinput>/usr/bin/openssl req -new -x509 -days 365 -nodes -config \
355
/usr/share/doc/packages/stunnel/stunnel.cnf \
356
-out /etc/stunnel/stunnel.pem -keyout /etc/stunnel/stunnel.pem</userinput>
357
</screen></para></step>
360
Remove SWAT entry from [x]inetd.
364
<indexterm><primary>stunnel</primary></indexterm>
365
Start <command>stunnel</command>.
368
&rootprompt;<userinput>stunnel -p /etc/stunnel/stunnel.pem -d 901 \
369
-l /usr/local/samba/bin/swat swat </userinput>
370
</screen></para></step>
374
Afterward, simply connect to SWAT by using the URL <ulink noescape="1"
375
url="https://myhost:901">https://myhost:901</ulink>, accept the certificate, and the SSL connection is up.
381
<title>Enabling SWAT Internationalization Support</title>
384
SWAT can be configured to display its messages to match the settings of
385
the language configurations of your Web browser. It will be passed to SWAT
386
in the Accept-Language header of the HTTP request.
390
To enable this feature:
395
Install the proper <command>msg</command> files from the Samba
396
<filename>source/po</filename> directory into $LIBDIR.
400
Set your browsers language setting.
405
<indexterm><primary>msg file</primary></indexterm>
406
<indexterm><primary>Japanese</primary></indexterm>
407
<indexterm><primary>French</primary></indexterm>
408
<indexterm><primary>English</primary></indexterm>
409
The name of the <command>msg</command> file is the same as the language ID sent by the browser. For
410
example, <emphasis>en</emphasis> means English, <emphasis>ja</emphasis> means Japanese, <emphasis>fr</emphasis> means French.
414
<indexterm><primary>locale</primary></indexterm>
415
If you do not like some of messages, or there are no <command>msg</command> files for
416
your locale, you can create them simply by copying the <command>en.msg</command> files
417
to the directory for <quote>your language ID.msg</quote> and filling in proper strings
418
to each <quote>msgstr</quote>. For example, in <filename>it.msg</filename>, the
419
<command>msg</command> file for the Italian locale, just set:
422
msgstr "Imposta Default"
424
<indexterm><primary>msg</primary></indexterm>
425
and so on. If you find a mistake or create a new <command>msg</command> file, please email it
426
to us so we will consider it in the next release of Samba. The <command>msg</command> file should be encoded in UTF-8.
430
<indexterm><primary>UTF-8 encoding</primary></indexterm>
431
Note that if you enable this feature and the <smbconfoption name="display charset"/> is not
432
matched to your browser's setting, the SWAT display may be corrupted. In a future version of
433
Samba, SWAT will always display messages with UTF-8 encoding. You will then not need to set
434
this &smb.conf; file parameter.
442
<title>Overview and Quick Tour</title>
445
SWAT is a tool that may be used to configure Samba or just to obtain useful links
446
to important reference materials such as the contents of this book as well as other
447
documents that have been found useful for solving Windows networking problems.
451
<title>The SWAT Home Page</title>
454
The SWAT title page provides access to the latest Samba documentation. The manual page for
455
each Samba component is accessible from this page, as are the Samba3-HOWTO (this
456
document) as well as the O'Reilly book <quote>Using Samba.</quote>
460
Administrators who wish to validate their Samba configuration may obtain useful information
461
from the man pages for the diagnostic utilities. These are available from the SWAT home page
462
also. One diagnostic tool that is not mentioned on this page but that is particularly
463
useful is <ulink url="http://www.ethereal.com/"><command>ethereal</command></ulink>.
467
SWAT can be configured to run in <emphasis>demo</emphasis> mode. This is not recommended
468
because it runs SWAT without authentication and with full administrative ability. It allows
469
changes to &smb.conf; as well as general operation with root privileges. The option that
470
creates this ability is the <option>-a</option> flag to SWAT. <emphasis>Do not use this in a
471
production environment.</emphasis>
477
<title>Global Settings</title>
480
The <guibutton>GLOBALS</guibutton> button exposes a page that allows configuration of the global parameters
481
in &smb.conf;. There are two levels of exposure of the parameters:
486
<guibutton>Basic</guibutton> &smbmdash; exposes common configuration options.
490
<guibutton>Advanced</guibutton> &smbmdash; exposes configuration options needed in more
491
complex environments.
496
To switch to other than <guibutton>Basic</guibutton> editing ability, click on <guibutton>Advanced</guibutton>.
497
You may also do this by clicking on the radio button, then click on the <guibutton>Commit Changes</guibutton> button.
501
After making any changes to configuration parameters, make sure that
503
<guibutton>Commit Changes</guibutton> button before moving to another area; otherwise,
504
your changes will be lost.
508
SWAT has context-sensitive help. To find out what each parameter is
509
for, simply click on the
510
<guibutton>Help</guibutton> link to the left of the configuration parameter.
516
<title>Share Settings</title>
519
To affect a currently configured share, simply click on the pull-down button between the
520
<guibutton>Choose Share</guibutton> and the <guibutton>Delete Share</guibutton> buttons and
521
select the share you wish to operate on. To edit the settings,
523
<guibutton>Choose Share</guibutton> button. To delete the share, simply press the
524
<guibutton>Delete Share</guibutton> button.
528
To create a new share, next to the button labeled <guibutton>Create Share</guibutton>, enter
529
into the text field the name of the share to be created, then click on the
530
<guibutton>Create Share</guibutton> button.
536
<title>Printers Settings</title>
539
To affect a currently configured printer, simply click on the pull-down button between the
540
<guibutton>Choose Printer</guibutton> and the <guibutton>Delete Printer</guibutton> buttons and
541
select the printer you wish to operate on. To edit the settings,
543
<guibutton>Choose Printer</guibutton> button. To delete the share, simply press the
544
<guibutton>Delete Printer</guibutton> button.
548
To create a new printer, next to the button labeled <guibutton>Create Printer</guibutton>, enter
549
into the text field the name of the share to be created, then click on the
550
<guibutton>Create Printer</guibutton> button.
556
<title>The SWAT Wizard</title>
559
The purpose of the SWAT Wizard is to help the Microsoft-knowledgeable network administrator
560
to configure Samba with a minimum of effort.
564
The Wizard page provides a tool for rewriting the &smb.conf; file in fully optimized format.
565
This will also happen if you press the <guibutton>Commit</guibutton> button. The two differ
566
because the <guibutton>Rewrite</guibutton> button ignores any changes that may have been made,
567
while the <guibutton>Commit</guibutton> button causes all changes to be affected.
571
The <guibutton>Edit</guibutton> button permits the editing (setting) of the minimal set of
572
options that may be necessary to create a working Samba server.
576
Finally, there are a limited set of options that determine what type of server Samba
577
will be configured for, whether it will be a WINS server, participate as a WINS client, or
578
operate with no WINS support. By clicking one button, you can elect to expose (or not) user
585
<title>The Status Page</title>
588
The status page serves a limited purpose. First, it allows control of the Samba daemons.
589
The key daemons that create the Samba server environment are &smbd;, &nmbd;, and &winbindd;.
593
The daemons may be controlled individually or as a total group. Additionally, you may set
594
an automatic screen refresh timing. As MS Windows clients interact with Samba, new smbd processes
595
are continually spawned. The auto-refresh facility allows you to track the changing
596
conditions with minimal effort.
600
Finally, the status page may be used to terminate specific smbd client connections in order to
601
free files that may be locked.
607
<title>The View Page</title>
610
The view page allows you to view the optimized &smb.conf; file and, if you are
611
particularly masochistic, permits you also to see all possible global configuration
612
parameters and their settings.
618
<title>The Password Change Page</title>
621
The password change page is a popular tool that allows the creation, deletion, deactivation,
622
and reactivation of MS Windows networking users on the local machine. You can also use
623
this tool to change a local password for a user account.
627
When logged in as a non-root account, the user must provide the old password as well as
628
the new password (twice). When logged in as <emphasis>root</emphasis>, only the new password is
633
One popular use for this tool is to change user passwords across a range of remote MS Windows