Next update of VFS modules development guide
[samba.git] / docs-xml / Samba3-HOWTO / TOSHARG-SWAT.xml
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">
3 <chapter id="SWAT">
4 <chapterinfo>
5         &author.jht;
6         <pubdate>April 21, 2003</pubdate>
7 </chapterinfo>
8
9 <title>SWAT: The Samba Web Administration Tool</title>
10
11 <para>
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.
20 </para>
21
22 <sect1>
23 <title>Features and Benefits</title>
24
25 <para>
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.
30 </para>
31
32 <para>
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.
38 </para>
39
40 <para>
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.
51 </para>
52
53 <note><para>
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.
58 </para></note>
59
60 </sect1>
61
62 <sect1>
63 <title>Guidelines and Technical Tips</title>
64
65 <para>
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.
69 </para>
70
71 <sect2>
72 <title>Validate SWAT Installation</title>
73
74 <para>
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.
81 </para>
82
83 <para>
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. 
90 </para>
91
92 <para>
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. 
98 </para>
99
100 <sect3>
101 <title>Locating the <command>SWAT</command> File</title>
102
103 <para>
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>
109 <para><simplelist>
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>
113 </simplelist>
114 </para>
115
116 <para>
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.
119 </para>
120
121 <para>
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.
124 </para>
125
126 <para>
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:
132 <screen>
133 frodo:~ # swat -?
134 Usage: swat [OPTION...]
135   -a, --disable-authentication         Disable authentication (demo mode)
136
137 Help options:
138   -?, --help                           Show this help message
139   --usage                              Display brief usage message
140
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
146 </screen>
147 </para>
148
149 </sect3>
150
151 <sect3>
152 <title>Locating the SWAT Support Files</title>
153
154 <para>
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:
157 <screen>
158 frodo:~ # whereis swat
159 swat: /usr/sbin/swat /usr/share/man/man8/swat.8.gz
160 </screen>
161 </para>
162
163 <para>
164 If the above measures fail to locate the <command>swat</command> binary, another approach
165 is needed. The following may be used:
166 <screen>
167 frodo:/ # find / -name swat -print
168 /etc/xinetd.d/swat
169 /usr/sbin/swat
170 /usr/share/samba/swat
171 frodo:/ #
172 </screen>
173 </para>
174
175 <para>
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>.
180 </para>
181
182 <para>
183 We must now check where <command>swat</command> expects to find its support files. This can
184 be done as follows:
185 <screen>
186 frodo:/ # strings /usr/sbin/swat | grep "/swat"
187 /swat/
188 ...
189 /usr/share/samba/swat
190 frodo:/ #
191 </screen>
192 </para>
193
194 <para>
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
197 list is as shown:
198 <screen>
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
208 ...
209 /usr/share/samba/swat/lang/ja/include
210 /usr/share/samba/swat/lang/ja/include/header.nocss.html
211 ...
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
217 ...
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
221 ...
222 /usr/share/samba/swat/images
223 /usr/share/samba/swat/images/home.gif
224 ...
225 /usr/share/samba/swat/include
226 /usr/share/samba/swat/include/footer.html
227 /usr/share/samba/swat/include/header.html
228 jht@frodo:/>
229 </screen>
230 </para>
231
232 <para>
233 If the files needed are not available, it is necessary to obtain and install them
234 before SWAT can be used.
235 </para>
236
237 </sect3>
238 </sect2>
239
240 <sect2 id="xinetd">
241 <title>Enabling SWAT for Use</title>
242
243 <para>
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.
247 </para>
248
249 <para>
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.
254 </para>
255
256 <para>
257 The control entry for the older style file might be:
258 <indexterm><primary>swat</primary><secondary>enable</secondary></indexterm>
259 </para>
260
261
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>
266
267 <para>
268 A control file for the newer style xinetd could be:
269 </para>
270
271 <para>
272 <programlisting>
273 # default: off
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.
277 service swat
278 {
279         port    = 901
280         socket_type     = stream
281         wait    = no
282         only_from = localhost
283         user    = root
284         server  = /usr/sbin/swat
285         log_on_failure  += USERID
286         disable = no
287 }
288 </programlisting>
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>
291 as shown.
292 </para>
293
294 <para>
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>.
305 </para>
306
307 <para>
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>.
316 </para>
317
318 <para>
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>.
323 </para>
324
325 </sect2>
326
327 <sect2>
328 <title>Securing SWAT through SSL</title>
329
330
331 <para>
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.
336 </para>
337
338 <para>
339 Modifications to the SWAT setup are as follows: 
340 </para>
341
342 <procedure>
343         <step><para>
344 <indexterm><primary>OpenSSL</primary></indexterm>
345         Install OpenSSL.
346         </para></step>
347
348         <step><para>
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>
353 <screen>
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>
358
359         <step><para>
360         Remove SWAT entry from [x]inetd.
361         </para></step>
362
363         <step><para>
364 <indexterm><primary>stunnel</primary></indexterm>
365         Start <command>stunnel</command>.
366
367 <screen>
368 &rootprompt;<userinput>stunnel -p /etc/stunnel/stunnel.pem -d 901 \
369          -l /usr/local/samba/bin/swat swat </userinput>
370 </screen></para></step>
371 </procedure>
372
373 <para>
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.
376 </para>
377
378 </sect2>
379
380 <sect2>
381 <title>Enabling SWAT Internationalization Support</title>
382
383 <para>
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.
387 </para>
388
389 <para>
390 To enable this feature:
391 </para>
392
393 <itemizedlist>
394         <listitem><para>
395         Install  the proper <command>msg</command> files from the Samba
396         <filename>source/po</filename> directory into $LIBDIR.
397         </para></listitem>
398
399         <listitem><para>
400         Set your browsers language setting.
401         </para></listitem>
402 </itemizedlist>
403
404 <para>
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.
411 </para>
412
413 <para>
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:
420 <screen>
421 msgid "Set Default"
422 msgstr "Imposta Default"
423 </screen>
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.
427 </para>
428
429 <para>
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.
435 </para>
436
437 </sect2>
438
439 </sect1>
440
441 <sect1>
442 <title>Overview and Quick Tour</title>
443
444 <para>
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.
448 </para>
449
450 <sect2>
451 <title>The SWAT Home Page</title>
452
453 <para>
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>
457 </para>
458
459 <para>
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>.
464 </para>
465
466 <warning><para>
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>
472 </para></warning>
473
474 </sect2>
475
476 <sect2>
477 <title>Global Settings</title>
478
479 <para>
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:
482 </para>
483
484 <itemizedlist>
485         <listitem><para>
486         <guibutton>Basic</guibutton> &smbmdash; exposes common configuration options.
487         </para></listitem>
488
489         <listitem><para>
490         <guibutton>Advanced</guibutton> &smbmdash; exposes configuration options needed in more 
491         complex environments.
492         </para></listitem>
493 </itemizedlist>
494
495 <para>
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.
498 </para>
499
500 <para>
501 After making any changes to configuration parameters, make sure that
502 you click on the 
503 <guibutton>Commit Changes</guibutton> button before moving to another area; otherwise,
504 your changes will be lost.
505 </para>
506
507 <note><para>
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.
511 </para></note>
512
513 </sect2>
514
515 <sect2>
516 <title>Share Settings</title>
517
518 <para>
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,
522 click on the
523 <guibutton>Choose Share</guibutton> button. To delete the share, simply press the
524 <guibutton>Delete Share</guibutton> button.
525 </para>
526
527 <para>
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.
531 </para>
532
533 </sect2>
534
535 <sect2>
536 <title>Printers Settings</title>
537
538 <para>
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,
542 click on the
543 <guibutton>Choose Printer</guibutton> button. To delete the share, simply press the
544 <guibutton>Delete Printer</guibutton> button.
545 </para>
546
547 <para>
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.
551 </para>
552
553 </sect2>
554
555 <sect2>
556 <title>The SWAT Wizard</title>
557
558 <para>
559 The purpose of the SWAT Wizard is to help the Microsoft-knowledgeable network administrator
560 to configure Samba with a minimum of effort.
561 </para>
562
563 <para>
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.
568 </para>
569
570 <para>
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.
573 </para>
574
575 <para>
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
579 home directories.
580 </para>
581
582 </sect2>
583
584 <sect2>
585 <title>The Status Page</title>
586
587 <para>
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;.
590 </para>
591
592 <para>
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.
597 </para>
598
599 <para>
600 Finally, the status page may be used to terminate specific smbd client connections in order to
601 free files that may be locked.
602 </para>
603
604 </sect2>
605
606 <sect2>
607 <title>The View Page</title>
608
609 <para>
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.
613 </para>
614
615 </sect2>
616
617 <sect2>
618 <title>The Password Change Page</title>
619
620 <para>
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.
624 </para>
625
626 <para>
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
629 required.
630 </para>
631
632 <para>
633 One popular use for this tool is to change user passwords across a range of remote MS Windows
634 servers.
635 </para>
636
637 </sect2>
638 </sect1>
639
640 </chapter>