Merge Samba3 and Samba4 together
[amitay/samba.git] / docs-xml / using_samba / ch02.xml
1 <chapter label="2" id="SAMBA-CH-2">
2 <title>Installing Samba on a Unix System</title>
3
4
5
6
7 <para>
8 <indexterm id="ch02-idx-947293-0" class="startofrange"><primary>installing Samba</primary></indexterm>
9 <indexterm id="ch02-idx-947293-1"><primary>Samba</primary><secondary>installing</secondary><see>installing Samba</see></indexterm>Now that you know what Samba can do for you and your users, it's time to get your own network set up. Let's start with the installation of Samba itself on a Unix system. When dancing the samba, one learns by taking small steps. It's just the same when installing Samba; we need to teach it step by step. This chapter will help you to start off on the right foot.</para>
10
11
12 <para>For illustrative purposes, we will be installing the 2.0.4 version of the Samba server on a <indexterm id="ch02-idx-947307-0"><primary>Linux</primary><secondary>installing Samba on Linux system</secondary></indexterm>Linux<footnote label="1" id="ch02-pgfId-939741">
13
14
15 <para>If you haven't heard of Linux yet, then you're in for a treat. Linux is a freely distributed Unix-like operating system that runs on the Intel x86, Motorola PowerPC, and Sun Sparc platforms. The operating system is relatively easy to configure, extremely robust, and is gaining in popularity. You can get more information on the Linux operating system at <systemitem role="url">http://www.linux.org/</systemitem>.</para>
16
17
18 </footnote> system running version 2.0.31 of the kernel. However, the installation steps are the same for all of the platforms that Samba supports. A typical installation will take about an <indexterm id="ch02-idx-947305-0"><primary>installing Samba</primary><secondary>time required</secondary></indexterm>hour to complete, including downloading the source files and compiling them, setting up the configuration files, and testing the server.</para>
19
20
21 <para>
22 <indexterm id="ch02-idx-947306-0"><primary>installing Samba</primary><secondary>steps in</secondary></indexterm>Here is an overview of the steps:</para>
23
24
25 <orderedlist>
26 <listitem><para>Download the source or binary files.</para></listitem>
27 <listitem><para>Read the installation documentation.</para></listitem>
28 <listitem><para>Configure a makefile.</para></listitem>
29 <listitem><para>Compile the server code.</para></listitem>
30 <listitem><para>Install the server files.</para></listitem>
31 <listitem><para>Create a Samba configuration file.</para></listitem>
32 <listitem><para>Test the configuration file.</para></listitem>
33 <listitem><para>Start the Samba daemons.</para></listitem>
34 <listitem><para>Test the Samba daemons.</para></listitem>
35 </orderedlist>
36
37
38
39
40
41
42
43
44
45
46
47 <sect1 role="" label="2.1" id="ch02-85028">
48 <title>Downloading the Samba Distribution</title>
49
50
51 <para>
52 <indexterm id="ch02-idx-947308-0" class="startofrange"><primary>Samba</primary><secondary>downloading</secondary></indexterm>
53 <indexterm id="ch02-idx-947308-1" class="startofrange"><primary>Samba</primary><secondary>distribution</secondary></indexterm>
54
55 <!-- CD-ROM REFERENCE COMMENTED OUT FOR SAFARI VERSION OF THIS TITLE.
56
57 If
58 you want to get started quickly, the <indexterm
59 id="ch02-idx-947316-0" id="IXT-2-126769"><primary>CD-ROM with this
60 book</primary><secondary>Samba
61 distribution</secondary></indexterm>CD-ROM packaged with this book
62 contains both the sources and binaries of Samba that were available as
63 this book went to print. The CD is a mirror image of the files and
64 directories on the Samba download server: <systemitem
65 role="url">ftp.samba.org</systemitem> <indexterm
66 id="ch02-idx-947317-0" id="IXT-2-126770"><primary>FTP (File Transfer
67 Protocol)</primary><secondary>sites for Samba
68 downloads</secondary></indexterm> <indexterm
69 id="ch02-idx-947317-1" id="IXT-2-126771"><primary>downloads</primary><secondary>Samba</secondary></indexterm>.</para>
70
71 <para>On the other hand, if
72
73 --></para>
74
75
76 <para>If you want to download the latest version, the primary web site
77 for the Samba software is <indexterm id="ch02-idx-947318-0"><primary>URLs (uniform resource
78 locators)</primary><secondary>Samba</secondary></indexterm><systemitem role="url">http://www.samba.org</systemitem>. Once connected to this
79 page, you'll see links to several Samba mirror sites across the
80 world, both for the standard Samba web pages and sites devoted
81 exclusively to downloading Samba. For the best performance, choose a
82 site that is closest to your own geographic location.</para>
83
84
85 <para>The standard <indexterm id="ch02-idx-947320-0"><primary>Samba</primary><secondary>web
86 site</secondary></indexterm> <indexterm id="ch02-idx-947320-1"><primary>resources for further
87 information</primary><secondary>Samba</secondary></indexterm>Samba web
88 sites have Samba documentation and tutorials, mailing list archives,
89 and the latest Samba news, as well as source and binary distributions
90 of Samba. The download sites (sometimes called <emphasis>FTP
91 sites</emphasis>) have only the source and binary
92 distributions. Unless you specifically want an older version of the
93 Samba server or are going to install a binary distribution, download
94 the latest source distribution from the closest mirror site. This
95 distribution is always named:</para>
96
97
98 <programlisting>samba-latest.tar.gz</programlisting>
99
100
101 <!-- CD-ROM REFERENCE COMMENTED OUT FOR SAFARI VERSION OF THIS TITLE.
102
103 <para>If you choose to use the version of Samba that is located on the
104 CD-ROM packaged with this book, you should find the latest Samba
105 distribution in the base directory.</para>
106
107 -->
108
109 <sect2 role="" label="2.1.1" id="ch02-SECT-1.1">
110 <title>Binary or Source?</title>
111
112
113 <para>
114 <indexterm id="ch02-idx-947323-0"><primary>binary vs. source files</primary></indexterm>
115 <indexterm id="ch02-idx-947323-1"><primary>source vs. binary files</primary></indexterm>Precompiled packages are also available for a large number of Unix platforms. These packages contain binaries for each of the Samba executables as well as the standard Samba documentation. Note that while installing a binary distribution can save you a fair amount of trouble and time, there are a couple of issues that you should keep in mind when deciding whether to use the binary or compile the source yourself:</para>
116
117
118 <itemizedlist>
119 <listitem><para>The binary packages can lag behind the latest version
120 of the software by one or two (maybe more) minor releases, especially
121 after a series of small changes and for less popular
122 platforms. Compare the release notes for the source and binary
123 packages to make sure that there aren't any new features that
124 you need on your platform.
125
126 <!-- CD-ROM REFERENCE COMMENTED OUT FOR SAFARI VERSION OF THIS TITLE.
127
128 This is especially true of the sources and
129 binaries on the CD-ROM: at the time this book went to print, they were
130 from the latest production release of Samba. However, development is
131 ongoing, so the beta-test versions on the Internet will be
132 newer.
133
134 --></para></listitem>
135 <listitem><para>If you use a precompiled binary, you will need to ensure that you have the correct libraries required by the executables. On some platforms the executables are statically linked so this isn't an issue, but on modern Unix operating systems (e.g., Linux, SGI Irix, Solaris, HP-UX, etc.), libraries are often <indexterm id="ch02-idx-947325-0"><primary>dynamically linked libraries</primary></indexterm>dynamically linked. This means that the binary looks for the right version of each library on your system, so you may have to install a new version of a library. The <filename>README</filename> file or <filename>makefile</filename>
136 <indexterm id="ch02-idx-947333-0"><primary>makefiles</primary></indexterm> that accompanies the binary distribution should list any special requirements.<footnote label="2" id="ch02-pgfId-943622">
137
138
139 <para>This is especially true with programs that use <emphasis>glibc-2.1</emphasis> (which comes standard with Red Hat Linux 6). This library caused quite a consternation in the development community when it was released because it was incompatable with previous versions of <emphasis>g</emphasis><filename>libc</filename>.</para>
140
141
142 </footnote></para>
143
144
145 <para>Many machines with shared libraries come with a nifty tool called <emphasis>ldd</emphasis>
146 <indexterm id="ch02-idx-947322-0"><primary>ldd tool</primary></indexterm>. This tool will tell you which libraries a specific binary requires and which libraries on the system satisfy that requirement. For example, checking the <emphasis>smbd</emphasis> program on our test machine gave us:</para></listitem>
147 </itemizedlist>
148
149 <programlisting>$ <emphasis role="bold">ldd smbd</emphasis>
150 libreadline.so.3 =&gt; /usr/lib/libreadline.so.3
151 libdl.so.2 =&gt; /lib/libdl.so.2
152 libcrypt.so.1 =&gt; /lib/libcrypt.so.1
153 libc.so.6 =&gt; /lib/libc.so.6
154 libtermcap.so.2 =&gt; /lib/libtermcap.so.2
155 /lib/ld-linux.so.2 =&gt; /lib/ld-linux.so.2</programlisting>
156
157
158 <itemizedlist>
159 <listitem><para>If there are any incompatibilities between Samba and specific libraries on your machine, the distribution-specific documentation should highlight those.</para></listitem>
160 <listitem><para>Keep in mind that each binary distribution carries preset values about the target platform, such as default directories and configuration option values. Again, check the documentation and the makefile included in the source directory to see which directives and variables were used when the binary was compiled. In some cases, these will not be appropriate for your situation.</para>
161
162
163 <para>A few configuration items can be reset with command-line options at runtime instead of at compile time. For example, if your binary tries to place any log, lock, or status files in the "wrong" place (for example, in <filename>/usr/local</filename>  ), you can override this without recompiling.</para></listitem>
164 </itemizedlist>
165
166 <para>One point worth mentioning is that the Samba source requires an <indexterm id="ch02-idx-947324-0"><primary>ANSI C compilers</primary></indexterm>
167 <indexterm id="ch02-idx-947324-1"><primary>non-ANSI compilers</primary></indexterm>
168 <indexterm id="ch02-idx-947324-2"><primary>compilers</primary></indexterm>ANSI C compiler. If you are on a platform with a non-ANSI compiler, such as the <emphasis>cc</emphasis> compiler on SunOS version 4, you'll have to install an ANSI-compliant compiler such as <emphasis>gcc</emphasis> before you do anything else.<footnote label="3" id="ch02-pgfId-939049">
169
170
171 <para><emphasis>gcc</emphasis> binaries are available for almost every modern machine. See <systemitem role="url">http://www.gnu.org/</systemitem> for a list of sites with <emphasis>gcc</emphasis> and other GNU software.</para>
172
173
174 </footnote> If installing a compiler isn't something you want to wrestle with, you can start off with a binary package. However, for the most flexibility and compatibility on your system, we always recommend compiling from the latest source.</para>
175 </sect2>
176
177
178
179
180
181 <sect2 role="" label="2.1.2" id="ch02-SECT-1.2">
182 <title>Read the Documentation</title>
183
184
185 <para>
186 <indexterm id="ch02-idx-947327-0"><primary>documentation for Samba</primary><secondary>importance of reading</secondary></indexterm>
187 <indexterm id="ch02-idx-947327-1"><primary>reading documentation, importance of</primary></indexterm>
188 <indexterm id="ch02-idx-947327-2"><primary>Samba</primary><secondary>documentation, importance of reading</secondary></indexterm>This sounds like an obvious thing to say, but there have probably been times where you have uncompressed a package, blindly typed <literal>configure</literal>, <literal>make</literal>, and <literal>make</literal> <literal>install</literal>, and walked away to get another cup of coffee. We'll be the first to admit that we do that, many more times than we should. It's a bad idea&mdash;especially when planning a network with Samba.</para>
189
190
191 <para>Samba 2.0 automatically configures itself prior to compilation. This reduces the likelihood of a machine-specific problem, but there may be an option mentioned in the <filename>README</filename> file that you end up wishing for after Samba's been installed. With both source and binary packages you'll find a large number of documents in the <filename>docs</filename>
192 <indexterm id="ch02-idx-947328-0"><primary>docs directory</primary></indexterm> directory, in a variety of formats. The most important files to look at in the distribution are:</para>
193
194
195 <programlisting><indexterm id="ch02-idx-947329-0"><primary>Samba</primary><secondary>new features file</secondary></indexterm>
196 <indexterm id="ch02-idx-947329-1"><primary>installing Samba</primary><secondary>common problems</secondary></indexterm>WHATSNEW.txt
197 docs/textdocs/UNIX_INSTALL.txt</programlisting>
198
199
200 <para>These files tell you what features you can expect in your Samba distribution, and will highlight common installation problems that you're likely to face. Be sure to look over both of them before you start the compilation process.<indexterm id="ch02-idx-947311-0" class="endofrange" startref="ch02-idx-947308-0"/></para>
201 </sect2>
202 </sect1>
203
204
205
206
207
208
209
210
211
212 <sect1 role="" label="2.2" id="ch02-28558">
213 <title>Configuring Samba</title>
214
215
216 <para>
217 <indexterm id="ch02-idx-947339-0" class="startofrange"><primary>configuring Samba</primary></indexterm>
218 <indexterm id="ch02-idx-947339-1"><primary>configuring Samba</primary><secondary>configuration file</secondary><seealso>smb.conf (Samba configuration) file</seealso></indexterm>The <indexterm id="ch02-idx-947330-0"><primary>Samba</primary><secondary>configuring</secondary><see>configuring Samba</see></indexterm>source distribution of Samba 2.0 and above doesn't initially have a <indexterm id="ch02-idx-947337-0"><primary>makefiles</primary></indexterm>makefile. Instead, one is generated through a GNU <filename>configure</filename>
219 <indexterm id="ch02-idx-947338-0"><primary>configuring Samba</primary><secondary>configure script</secondary><tertiary>GNU</tertiary></indexterm>
220 <indexterm id="ch02-idx-947338-1"><primary>GNU configure script</primary></indexterm> script, which is located in the <filename>samba-2.0.x /source/</filename> directory. The <firstterm>configure</firstterm> script, which must be run as root, takes care of the machine-specific issues of building Samba. However, you still may want to decide on some global options. Global options can be set by passing options on the command-line:</para>
221
222
223 <programlisting># ./configure --with-ssl</programlisting>
224
225
226 <para>For example, this will configure the Samba makefile with support for the<indexterm id="ch02-idx-947347-0"><primary>SSL (Secure Sockets Layer) protocol</primary><secondary>support for</secondary></indexterm>
227 <indexterm id="ch02-idx-947347-1"><primary>Secure Sockets Layer protocol</primary><see>SSL</see></indexterm> Secure Sockets Layer (SSL) encryption protocol. If you would like a complete list of <indexterm id="ch02-idx-947348-0" class="startofrange"><primary>configuring Samba</primary><secondary>options</secondary></indexterm>options, type the following:</para>
228
229
230 <programlisting>#./configure --help</programlisting>
231
232
233 <para>
234 <indexterm id="ch02-idx-947349-0"><primary>enabling/disabling features</primary></indexterm>
235 <indexterm id="ch02-idx-947349-1"><primary>disabling/enabling features</primary></indexterm>Each of these options enable or disable various features. You typically enable a feature by specifying the <literal>--with-</literal><replaceable>feature</replaceable> option, which will cause the feature to be compiled and installed. Likewise, if you specify a <literal>--without-</literal><replaceable>feature</replaceable> option, the feature will be disabled. As of Samba 2.0.5, each of the following features is disabled by default:</para>
236
237
238 <variablelist>
239 <varlistentry><term><literal>--with-smbwrapper</literal></term>
240 <listitem><para>Include SMB <indexterm id="ch02-idx-947350-0"><primary>SMB (Server Message Block)</primary><secondary>wrapper support</secondary></indexterm>
241 <indexterm id="ch02-idx-947350-1"><primary>wrapper support for SMB (Server Message Block)</primary></indexterm>wrapper support, which allows executables on the Unix side to access <indexterm id="ch02-idx-947351-0"><primary>SMB/CIFS protocol</primary><secondary>filesystems</secondary></indexterm>SMB/CIFS filesystems as if they were regular Unix filesystems. We recommend using this option. However, at this time this book went to press, there were several incompatibilities between the <filename>smbwrapper</filename>
242 <indexterm id="ch02-idx-947352-0"><primary>smbwrapper package</primary></indexterm> package and the GNU <filename>libc</filename> version 2.1, and it would not compile on Red Hat 6.0. Look for more information on these incompatibilities on the Samba home page.</para></listitem>
243 </varlistentry>
244
245
246 <varlistentry><term><literal>--with-afs</literal></term>
247 <listitem><para>Include support of the <indexterm id="ch02-idx-947353-0"><primary>Andrew Filesystem</primary><see>AFS files</see></indexterm>Andrew Filesystem from <indexterm id="ch02-idx-947354-0"><primary>Carnegie Mellon University</primary></indexterm>Carnegie Mellon University. If you're going to serve <indexterm id="ch02-idx-947355-0"><primary>AFS files, support for</primary></indexterm>AFS files via Samba, we recommend compiling Samba once first without enabling this feature to ensure that everything runs smoothly. Once that version is working smoothly, recompile Samba with this feature enabled and compare any errors you might receive against the previous setup.</para></listitem>
248 </varlistentry>
249
250
251 <varlistentry><term><literal>--with-dfs</literal></term>
252 <listitem><para>Include support for <indexterm id="ch02-idx-947356-0"><primary>DFS, support for</primary></indexterm>DFS, a later version of AFS, used by <indexterm id="ch02-idx-947357-0"><primary>OSF/1 (Digital Unix)</primary></indexterm>OSF/1 (Digital Unix). Note that this is <emphasis>not</emphasis> the same as Microsoft DFS, which is an entirely different filesystem. Again, we recommend compiling Samba once first without this feature to ensure that everything runs smoothly, then recompile with this feature to compare any errors against the previous setup.</para></listitem>
253 </varlistentry>
254
255
256 <varlistentry><term><literal>--with-krb4</literal>=<replaceable>base-directory</replaceable></term>
257 <listitem><para>Include support for <indexterm id="ch02-idx-947358-0"><primary>Kerberos, support for</primary></indexterm>Kerberos version 4.0, explicitly specifying the base directory of the distribution. Kerberos is a network security protocol from <indexterm id="ch02-idx-947359-0"><primary>MIT</primary></indexterm>MIT that uses <indexterm id="ch02-idx-947360-0"><primary>private key cryptography</primary></indexterm>
258 <indexterm id="ch02-idx-947360-1"><primary>cryptography, private key</primary></indexterm>private key cryptography to provide strong security between nodes. Incidentally, Microsoft has announced that Kerberos 5.0 will be the standard <indexterm id="ch02-idx-947362-0"><primary>authentication</primary><secondary>mechanisms for</secondary></indexterm>authentication mechanism for Microsoft Windows 2000 (NT 5.0). However, the Kerberos 5.0 authentication mechanisms are quite different from the Kerberos 4.0 <indexterm id="ch02-idx-947363-0"><primary>security</primary></indexterm>security mechanisms. If you have Kerberos version 4 on your system, the Samba team recommends that you upgrade and use the <literal>--with-krb5</literal> option (see the next item). You can find more information on <indexterm id="ch02-idx-947364-0"><primary>URLs (uniform resource locators)</primary><secondary>Kerberos</secondary></indexterm>Kerberos at <systemitem role="url">http://web.mit.edu/kerberos/www</systemitem>.</para></listitem>
259 </varlistentry>
260
261
262 <varlistentry><term><literal>--with-krb5</literal>=<replaceable>base-directory</replaceable></term>
263 <listitem><para>Include support for Kerberos version 5.0, explicitly specifying the base directory of the distribution. Microsoft has announced that Kerberos 5.0 will be the standard authentication mechanism for Microsoft Windows 2000 (NT 5.0). However, there is no guarantee that Microsoft will not extend Kerberos for their own needs in the future. Currently, Samba's Kerberos support only uses a plaintext password interface and not an encrypted one. You can find more information on Kerberos at its home page: <systemitem role="url">http://web.mit.edu/kerberos/www</systemitem>.</para></listitem>
264 </varlistentry>
265
266
267 <varlistentry><term><literal>--with-automount</literal></term>
268 <listitem><para>Include support for <indexterm id="ch02-idx-947365-0"><primary>automounter, support for</primary></indexterm>automounter, a feature often used on sites that offer NFS.</para></listitem>
269 </varlistentry>
270
271
272 <varlistentry><term><literal>--with-smbmount</literal></term>
273 <listitem><para>Include <emphasis>smbmount</emphasis>
274 <indexterm id="ch02-idx-947366-0"><primary>smbmount, support for</primary></indexterm> support, which is for <indexterm id="ch02-idx-947367-0"><primary>Linux</primary><secondary>submount and</secondary></indexterm>Linux only. This feature wasn't being maintained at the time the book was written, so the Samba team made it an optional feature and provided <emphasis>smbwrapper</emphasis> instead. The <emphasis>smbwrapper</emphasis> feature works on more Unix platforms than <emphasis>smbmount</emphasis>, so you'll usually want to use <literal>--with-smbwrapper</literal> instead of this option.</para></listitem>
275 </varlistentry>
276
277
278 <varlistentry><term><literal>--with-pam</literal></term>
279 <listitem><para>Include support for <indexterm id="ch02-idx-947368-0"><primary>pluggable authentication modules (PAM)</primary><secondary>support for</secondary></indexterm>
280 <indexterm id="ch02-idx-947368-1"><primary>PAM (pluggable authentication modules)</primary><secondary>support for</secondary></indexterm>pluggable authentication modules (PAM), an authentication feature common in the Linux operating system.</para></listitem>
281 </varlistentry>
282
283
284 <varlistentry><term><literal>--with-ldap</literal></term>
285 <listitem><para>Include support for the <indexterm id="ch02-idx-947369-0"><primary>Lightweight Directory Access Protocol</primary><see>LDAP</see></indexterm>
286 <indexterm id="ch02-idx-947369-1"><primary>LDAP (Lightweight Directory Access Protocol)</primary><secondary>support for</secondary></indexterm>Lightweight Directory Access Protocol (LDAP). A future version of LDAP will be used in the Windows 2000 (NT 5.0) operating system; this Samba support is experimental. LDAP is a flexible client-server directory protocol that can carry information such as certificates and group memberships.<footnote label="4" id="ch02-pgfId-943655">
287
288
289 <para>By <emphasis>directory</emphasis>, we don't mean a directory in a file system, but instead an indexed directory (such as a phone directory). Information is stored and can be easily retrieved in a public LDAP system.</para>
290
291
292 </footnote></para></listitem>
293 </varlistentry>
294
295
296 <varlistentry><term><literal>--with-nis</literal></term>
297 <listitem><para>Include support for getting password-file information from <indexterm id="ch02-idx-947370-0"><primary>NIS/NIS+ protocol</primary></indexterm>NIS (network yellow pages).</para></listitem>
298 </varlistentry>
299
300
301 <varlistentry><term><literal>--with-nisplus</literal></term>
302 <listitem><para>Include support for obtaining password-file information from NIS+, the successor to NIS.</para></listitem>
303 </varlistentry>
304
305
306 <varlistentry><term><literal>--with-ssl</literal></term>
307 <listitem><para>Include experimental support for the <indexterm id="ch02-idx-947374-0"><primary>SSL (Secure Sockets Layer) protocol</primary><secondary>support for</secondary></indexterm>Secure Sockets Layer (SSL), which is used to provide encrypted connections from client to server. <link linkend="SAMBA-AP-A">Appendix A</link>, describes setting up Samba with SSL support.</para></listitem>
308 </varlistentry>
309
310
311 <varlistentry><term><literal>--with-nisplus-home</literal></term>
312 <listitem><para>Include support for locating which server contains a particular user's <indexterm id="ch02-idx-947380-0"><primary>home directory, user's</primary></indexterm>
313 <indexterm id="ch02-idx-947380-1"><primary>users</primary><secondary>home directory</secondary></indexterm>home directory and telling the client to connect to it. Requires <literal>--with-nis</literal> and, usually, <literal>--with-automounter</literal>.</para></listitem>
314 </varlistentry>
315
316
317 <varlistentry><term><literal>--with-mmap</literal></term>
318 <listitem><para>Include experimental<indexterm id="ch02-idx-947381-0"><primary>mmap code</primary></indexterm> memory mapping code. This is not required for <indexterm id="ch02-idx-947382-0"><primary>fast locking</primary></indexterm>fast locking, which already uses mmap or System V shared memory.</para></listitem>
319 </varlistentry>
320
321
322 <varlistentry><term><literal>--with-syslog</literal></term>
323 <listitem><para>Include support for using the <indexterm id="ch02-idx-947383-0"><primary>SYSLOG utility</primary><secondary>support for</secondary></indexterm>SYSLOG utility for logging information generated from the Samba server. There are a couple of Samba configuration options that you can use to enable SYSLOG support; <link linkend="ch04-21486">Chapter 4</link>, discusses these options.</para></listitem>
324 </varlistentry>
325
326
327 <varlistentry><term><literal>--with-netatalk</literal></term>
328 <listitem><para>Include experimental support for interoperating with the (Macintosh) <indexterm id="ch02-idx-947412-0"><primary>Netatalk (Macintosh), support for interoperating with</primary></indexterm>Netatalk file server.</para></listitem>
329 </varlistentry>
330
331
332 <varlistentry><term><literal>--with-quotas</literal></term>
333 <listitem><para>Include <indexterm id="ch02-idx-947413-0"><primary>disk quotas, support for</primary></indexterm>disk-quota support.</para></listitem>
334 </varlistentry>
335 </variablelist>
336
337
338 <para>Because each of these options is disabled by default, none of these features are essential to Samba. However, you may want to come back and build a modified version of Samba if you discover that you need one at a later time.</para>
339
340
341 <para>In addition, <link linkend="ch02-85125">Table 2.1</link> shows some other parameters that you can give the <filename>configure</filename> script if you wish to store parts of the Samba distribution in different places, perhaps to make use of multiple disks or partitions. Note that the defaults sometimes refer to a prefix specified earlier in the table.</para>
342
343
344 <table label="2.1" id="ch02-85125">
345 <title>Additional Configure Options </title>
346
347 <tgroup cols="3">
348 <colspec colnum="1" colname="col1"/>
349 <colspec colnum="2" colname="col2"/>
350 <colspec colnum="3" colname="col3"/>
351 <thead>
352 <row>
353
354 <entry colname="col1"><para>Option</para></entry>
355
356 <entry colname="col2"><para>Meaning</para></entry>
357
358 <entry colname="col3"><para>Default</para></entry>
359
360 </row>
361
362 </thead>
363
364 <tbody>
365 <row>
366
367 <entry colname="col1"><para><literal>--prefix</literal>=<replaceable>directory</replaceable></para></entry>
368
369 <entry colname="col2"><para>Install architecture-independent files at the base directory specified.</para></entry>
370
371 <entry colname="col3"><para><filename>/usr/local/samba</filename></para></entry>
372
373 </row>
374
375 <row>
376
377 <entry colname="col1"><para><literal>--eprefix</literal>=<replaceable>directory</replaceable></para></entry>
378
379 <entry colname="col2"><para>Install architecture-dependent files at the base directory specified.</para></entry>
380
381 <entry colname="col3"><para><filename>/usr/local/samba</filename></para></entry>
382
383 </row>
384
385 <row>
386
387 <entry colname="col1"><para><literal>--bindir</literal>=<replaceable>directory</replaceable></para></entry>
388
389 <entry colname="col2"><para>Install user executables in the directory specified.</para></entry>
390
391 <entry colname="col3"><para><replaceable>eprefix</replaceable><filename>/bin</filename></para></entry>
392
393 </row>
394
395 <row>
396
397 <entry colname="col1"><para><literal>--sbindir</literal>=<replaceable>directory</replaceable></para></entry>
398
399 <entry colname="col2"><para>Install administrator executables in the directory specified.</para></entry>
400
401 <entry colname="col3"><para><replaceable>eprefix</replaceable><filename>/bin</filename></para></entry>
402
403 </row>
404
405 <row>
406
407 <entry colname="col1"><para><literal>--libexecdir</literal>=<replaceable>directory</replaceable></para></entry>
408
409 <entry colname="col2"><para>Install program executables in the directory specified.</para></entry>
410
411 <entry colname="col3"><para><replaceable>eprefix</replaceable><filename>/libexec</filename></para></entry>
412
413 </row>
414
415 <row>
416
417 <entry colname="col1"><para><literal>--datadir</literal>=<replaceable>directory</replaceable></para></entry>
418
419 <entry colname="col2"><para>Install read-only architecture independent data in the directory specified.</para></entry>
420
421 <entry colname="col3"><para><replaceable>prefix</replaceable><filename>/share</filename></para></entry>
422
423 </row>
424
425 <row>
426
427 <entry colname="col1"><para><literal>--libdir</literal>=<replaceable>directory</replaceable></para></entry>
428
429 <entry colname="col2"><para>Install program libraries in the directory specified.</para></entry>
430
431 <entry colname="col3"><para><replaceable>eprefix</replaceable><filename>/lib</filename></para></entry>
432
433 </row>
434
435 <row>
436
437 <entry colname="col1"><para><literal>--includedir</literal>=<replaceable>directory</replaceable></para></entry>
438
439 <entry colname="col2"><para>Install package include files in the directory specified.</para></entry>
440
441 <entry colname="col3"><para><replaceable>prefix</replaceable><filename>/include</filename></para></entry>
442
443 </row>
444
445 <row>
446
447 <entry colname="col1"><para><literal>--infodir</literal>=<replaceable>directory</replaceable></para></entry>
448
449 <entry colname="col2"><para>Install additional information files in the directory specified.</para></entry>
450
451 <entry colname="col3"><para><replaceable>prefix</replaceable><filename>/info</filename></para></entry>
452
453 </row>
454
455 <row>
456
457 <entry colname="col1"><para><literal>--mandir</literal>=<replaceable>directory</replaceable></para></entry>
458
459 <entry colname="col2"><para>Install manual pages in the directory specified.<indexterm id="ch02-idx-947428-0" class="endofrange" startref="ch02-idx-947348-0"/></para></entry>
460
461 <entry colname="col3"><para><replaceable>prefix</replaceable><filename>/man</filename></para></entry>
462
463 </row>
464
465 </tbody>
466 </tgroup>
467 </table>
468
469
470 <para>Again, before running the <filename>configure</filename> script, it is important that you are the <indexterm id="ch02-idx-947433-0"><primary>root user</primary></indexterm>root user on the system. Otherwise, you may get a warning such as:</para>
471
472
473 <programlisting>configure: warning: running as non-root will disable some tests</programlisting>
474
475
476 <para>You don't want any test to be disabled when the Samba makefile is being created; this leaves the potential for errors down the road when compiling or running Samba on your system.</para>
477
478
479 <para>Here is a sample execution of the <filename>configure</filename>
480 <indexterm id="ch02-idx-947434-0"><primary>configuring Samba</primary><secondary>configure script</secondary><tertiary>sample execution</tertiary></indexterm> script, which creates a Samba 2.0.4 makefile for the Linux platform. Note that you must run the configure script in the <emphasis>source</emphasis> directory, and that several lines from the middle of the excerpt have been omitted:</para>
481
482
483 <programlisting># cd samba-2.0.4b/source/
484 # ./configure | tee mylog
485
486 loading cache ./config.cache
487 checking for gcc... (cached) gcc
488 checking whether the C compiler (gcc -O ) works... yes
489 checking whether the C compiler (gcc -O ) is a cross-compiler... no
490 checking whether we are using GNU C... (cached) yes
491 checking whether gcc accepts -g... (cached) yes
492 checking for a BSD compatible install... (cached) /usr/bin/install -c
493
494 <emphasis>...(content omitted)...</emphasis>
495
496 checking configure summary
497 configure OK
498 creating ./config.status
499 creating include/stamp-h
500 creating Makefile
501 creating include/config.h</programlisting>
502
503
504 <para>In general, any message from <filename>configure</filename> that doesn't begin with the words <literal>checking</literal> or <literal>creating</literal> is an error; it often helps to redirect the output of the configure script to a file so you can quickly search for <indexterm id="ch02-idx-947435-0"><primary>errors</primary><secondary>searching for</secondary></indexterm>errors, as we did with the <literal>tee</literal> command above. If there was an error during configuration, more detailed information about it can be found in the <filename>config.log</filename> file, which is written to the local directory by the <filename>configure</filename> script.</para>
505
506
507 <para>If the configuration works, you'll see a <literal>checking</literal> <literal>configure</literal> <literal>summary</literal> message followed by a <literal>configure</literal> <literal>OK</literal> message and four or five file creation messages. So far, so good.... Next step: compiling.<indexterm id="ch02-idx-947719-0" class="endofrange" startref="ch02-idx-947339-0"/></para>
508 </sect1>
509
510
511
512
513
514
515
516
517
518 <sect1 role="" label="2.3" id="ch02-13217">
519 <title>Compiling and Installing Samba</title>
520
521
522 <para>
523 <indexterm id="ch02-idx-947438-0" class="startofrange"><primary>compiling Samba</primary></indexterm>At <indexterm id="ch02-idx-947440-0"><primary>Samba</primary><secondary>compiling</secondary><see>compiling Samba</see></indexterm>this point you should be ready to build the Samba executables. Compiling is also easy: in the <filename>source</filename> directory, type <literal>make</literal> on the command line. The <filename>make</filename>
524 <indexterm id="ch02-idx-947436-0"><primary>make utility</primary></indexterm> utility will produce a stream of explanatory and success messages, beginning with:</para>
525
526
527 <programlisting>Using FLAGS = -O -Iinclude ...</programlisting>
528
529
530 <para>This build includes compiles for both <emphasis>smbd</emphasis> and <emphasis>nmbd</emphasis>, and ends in a linking command for <filename>bin/make_ printerdef</filename>. For example, here is a sample make of Samba version 2.0.4 on a Linux server:</para>
531
532
533 <programlisting># make
534 Using FLAGS =  -O -Iinclude -I./include -I./ubiqx -I./smbwrapper -DSMBLOGFILE="/
535 usr/local/samba/var/log.smb" -DNMBLOGFILE="/usr/local/samba/var/log.nmb" -
536 DCONFIGFILE="/usr/local/samba/lib/smb.conf" -DLMHOSTSFILE="/usr/local/samba/lib/
537 lmhosts"   -DSWATDIR="/usr/local/samba/swat" -DSBINDIR="/usr/local/samba/bin" -
538 DLOCKDIR="/usr/local/samba/var/locks" -DSMBRUN="/usr/local/samba/bin/smbrun" -
539 DCODEPAGEDIR="/usr/local/samba/lib/codepages" -DDRIVERFILE="/usr/local/samba/lib/
540 printers.def" -DBINDIR="/usr/local/samba/bin" -DHAVE_INCLUDES_H -DPASSWD_
541 PROGRAM="/bin/passwd" -DSMB_PASSWD_FILE="/usr/local/samba/private/smbpasswd"
542 Using FLAGS32 =  -O -Iinclude -I./include -I./ubiqx -I./smbwrapper  -
543 DSMBLOGFILE="/usr/local/samba/var/log.smb" -DNMBLOGFILE="/usr/local/samba/var/log.
544 nmb" -DCONFIGFILE="/usr/local/samba/lib/smb.conf" -DLMHOSTSFILE="/usr/local/samba/
545 lib/lmhosts"   -DSWATDIR="/usr/local/samba/swat" -DSBINDIR="/usr/local/samba/bin"
546 -DLOCKDIR="/usr/local/samba/var/locks" -DSMBRUN="/usr/local/samba/bin/smbrun" -
547 DCODEPAGEDIR="/usr/local/samba/lib/codepages" -DDRIVERFILE="/usr/local/samba/lib/
548 printers.def" -DBINDIR="/usr/local/samba/bin" -DHAVE_INCLUDES_H -DPASSWD_
549 PROGRAM="/bin/passwd" -DSMB_PASSWD_FILE="/usr/local/samba/private/smbpasswd"
550 Using LIBS = -lreadline -ldl  -lcrypt -lpam
551 Compiling smbd/server.c
552 Compiling smbd/files.c
553 Compiling smbd/chgpasswd.c
554
555 <emphasis>...(content omitted)...</emphasis>
556
557 Compiling rpcclient/cmd_samr.c
558 Compiling rpcclient/cmd_reg.c
559 Compiling rpcclient/cmd_srvsvc.c
560 Compiling rpcclient/cmd_netlogon.c
561 Linking bin/rpcclient
562 Compiling utils/smbpasswd.c
563 Linking bin/smbpasswd
564 Compiling utils/make_smbcodepage.c
565 Linking bin/make_smbcodepage
566 Compiling utils/nmblookup.c
567 Linking bin/nmblookup
568 Compiling utils/make_printerdef.c
569 Linking bin/make_printerdef</programlisting>
570
571
572 <para>If you encounter problems when compiling, check the Samba documentation to see if it is easily fixable. Another possibility is to search or post to the <indexterm id="ch02-idx-947437-0"><primary>mailing lists</primary><secondary>posting to</secondary></indexterm>Samba mailing lists, which are given at the end of <link linkend="SAMBA-AP-D">Appendix D</link>, and on the Samba home page. Most compilation issues are system specific and almost always easy to overcome.</para>
573
574
575 <para>Now that the files have been compiled, you can install them into the directories you identified with the command:</para>
576
577
578 <programlisting>#<userinput> make install</userinput></programlisting>
579
580
581 <para>If you happen to be upgrading, your old Samba files will be saved with the extension <emphasis>.old</emphasis> <indexterm id="ch02-idx-947448-0"><primary sortas="old files">.old files</primary></indexterm>, and you can go back to that previous version with the command <literal>make</literal> <literal>revert</literal>. After doing a <literal>make</literal> <literal>install</literal>, you should copy the <emphasis>.old</emphasis> files (if they exist) to a new location or name. Otherwise, the next time you install Samba, the original <emphasis>.old</emphasis>  will be overwritten without warning and you could lose your earlier version. If you configured Samba to use the default locations for files, the new files will be installed in the directories listed in <link linkend="SAMBA-CH-2-TBL-2.2">Table 2.2</link>. Remember that you need to  perform the installation from an account that has <indexterm id="ch02-idx-947451-0"><primary>write privileges</primary></indexterm>write privileges on these target <indexterm id="ch02-idx-947452-0"><primary>directories</primary><secondary>target</secondary></indexterm>directories; this is typically the root account.</para>
582
583
584 <table label="2.2" id="SAMBA-CH-2-TBL-2.2">
585 <title>Samba Installation Directories </title>
586
587 <tgroup cols="2">
588 <colspec colnum="1" colname="col1"/>
589 <colspec colnum="2" colname="col2"/>
590 <thead>
591 <row>
592
593 <entry colname="col1"><para>Directory</para></entry>
594
595 <entry colname="col2"><para>Description</para></entry>
596
597 </row>
598
599 </thead>
600
601 <tbody>
602 <row>
603
604 <entry colname="col1"><para><emphasis>/usr/local/samba</emphasis></para></entry>
605
606 <entry colname="col2"><para>
607 <indexterm id="ch02-idx-947450-0"><primary>installing Samba</primary><secondary>installation directories</secondary></indexterm>
608 <indexterm id="ch02-idx-947450-1"><primary>directories</primary><secondary>installation</secondary></indexterm>Main tree</para></entry>
609
610 </row>
611
612 <row>
613
614 <entry colname="col1"><para><emphasis>/usr/local/samba/bin</emphasis></para></entry>
615
616 <entry colname="col2"><para>Binaries</para></entry>
617
618 </row>
619
620 <row>
621
622 <entry colname="col1"><para><emphasis>/usr/local/samba/lib</emphasis></para></entry>
623
624 <entry colname="col2"><para><emphasis>smb.conf</emphasis>, <emphasis>lmhosts</emphasis>, configuration files, etc.</para></entry>
625
626 </row>
627
628 <row>
629
630 <entry colname="col1"><para><emphasis>/usr/local/samba/man</emphasis></para></entry>
631
632 <entry colname="col2"><para>Samba documentation</para></entry>
633
634 </row>
635
636 <row>
637
638 <entry colname="col1"><para><emphasis>/usr/local/samba/private</emphasis></para></entry>
639
640 <entry colname="col2"><para>Samba encrypted password file</para></entry>
641
642 </row>
643
644 <row>
645
646 <entry colname="col1"><para><emphasis>/usr/local/samba/swat</emphasis></para></entry>
647
648 <entry colname="col2"><para>SWAT files</para></entry>
649
650 </row>
651
652 <row>
653
654 <entry colname="col1"><para><emphasis>/usr/local/samba/var</emphasis></para></entry>
655
656 <entry colname="col2"><para>Samba log files, lock files, browse list info, shared memory files, process ID files</para></entry>
657
658 </row>
659
660 </tbody>
661 </tgroup>
662 </table>
663
664
665 <para>Throughout the remainder of the book, we occasionally refer to the location of the <indexterm id="ch02-idx-947454-0"><primary>main tree</primary></indexterm>main tree as <replaceable>samba_dir</replaceable>. In most configurations, this is the <indexterm id="ch02-idx-947479-0"><primary>base directory</primary></indexterm>base directory of the installed Samba package: <filename>/usr/local/samba </filename>
666 <indexterm id="ch02-idx-947455-0"><primary sortas="usr/local/samba file">/usr/local/samba file</primary></indexterm>.</para>
667
668
669 <warning role="ora">
670 <para>Watch out if you've made <filename>/usr</filename> a <indexterm id="ch02-idx-947472-0"><primary>read-only partitions</primary></indexterm>read-only partition. You will want to put the logs, locks, and password files somewhere else.</para>
671
672 </warning>
673
674 <para>Here is the installation that we performed on our machine. You can see that we used <filename>/usr/local/samba</filename> as the base directory for the distribution (e.g., <replaceable>samba_dir</replaceable>):</para>
675
676
677 <programlisting># <userinput>make install</userinput>
678 Using FLAGS = -O -Iinclude -I./include -I./ubiqx -I./smbwrapper -DSMBLOGFILE="/
679 usr/local/samba/var/log.smb" -DNMBLOGFILE="/usr/local/samba/var/log.nmb" -
680 DCONFIGFILE="/usr/local/samba/lib/smb.conf" -
681
682 <lineannotation>...(content omitted)...</lineannotation>
683
684 The binaries are installed. You may restore the old binaries
685 (if there were any) using the command "make revert". You may
686 uninstall the binaries using the command "make uninstallbin"
687 or "make uninstall" to uninstall binaries, man pages and shell
688 scripts.
689
690 <lineannotation>...(content omitted)...</lineannotation>
691
692 ============================================================
693 The SWAT files have been installed. Remember to read the
694 README for information on enabling and using SWAT.
695 ============================================================</programlisting>
696
697
698 <para>If the last message is about SWAT, you've successfully installed all the files. Congratulations! You now have Samba on your system!</para>
699
700
701 <sect2 role="" label="2.3.1" id="ch02-SECT-3.1">
702 <title>Final Installation Steps</title>
703
704
705 <para>
706 <indexterm id="ch02-idx-947480-0"><primary>installing Samba</primary><secondary>steps in</secondary><tertiary>final</tertiary></indexterm>There are a couple of final steps to perform. Specifically, add the <indexterm id="ch02-idx-947486-0"><primary>SWAT tool</primary><secondary>adding to configuration files</secondary></indexterm>
707 <indexterm id="ch02-idx-947486-1"><primary>Samba Web Administration Tool</primary><see>SWAT tool</see></indexterm>Samba Web Administration Tool (SWAT) to the <filename>/etc/services</filename>
708 <indexterm id="ch02-idx-947491-0"><primary sortas="etc.services configuration files">/etc/services configuration file, adding SWAT tool to</primary></indexterm> and <filename>/etc/inetd.conf</filename>
709 <indexterm id="ch02-idx-947493-0"><primary sortas="etc/inetd.conf configuration file">/etc/inetd.conf configuration files</primary><secondary>adding SWAT tool to</secondary></indexterm> configuration files. SWAT runs as a daemon under <emphasis>inetd</emphasis> and provides a forms-based editor in your web browser for creating and modifying SMB configuration files.</para>
710
711
712 <orderedlist>
713 <listitem><para>To add SWAT, add the following line to the end of the <filename>/etc/services</filename> file:</para>
714
715 <programlisting>swat   901/tcp</programlisting></listitem>
716
717 <listitem><para>Add these lines to <filename>/etc/inetd.conf.</filename> (Check your <filename>inetd.conf</filename> manual page to see the exact format of the<filename> inetd.conf</filename> file if it differs from the following example.) Don't forget to change the path to the SWAT binary if you installed it in a different location from the default <filename>/usr/local/samba</filename>.</para>
718
719
720 <programlisting>swat   stream  tcp  nowait.400  root  /usr/local/samba/bin/swat  swat</programlisting></listitem>
721 </orderedlist>
722
723 <para>And that's pretty much it for the installation. Before you can start up Samba, however, you need to create a configuration file for it.<indexterm id="ch02-idx-947442-0" class="endofrange" startref="ch02-idx-947438-0"/></para>
724 </sect2>
725 </sect1>
726
727
728
729
730
731
732
733
734
735 <sect1 role="" label="2.4" id="ch02-13464">
736 <title>A Basic Samba Configuration File</title>
737
738
739 <para>The <indexterm id="ch02-idx-947692-0" class="startofrange"><primary>configuring Samba</primary><secondary>configuration file</secondary><tertiary>creating</tertiary></indexterm>key to configuring Samba is its lone configuration file: <filename>smb.conf</filename>
740 <indexterm id="ch02-idx-947693-0"><primary>smb.conf (Samba configuration) file</primary></indexterm>. This configuration file can be very simple or extremely complex, and the rest of this book is devoted to helping you get deeply personal with this file. For now, however, we'll show you how to set up a single file service, which will allow you to fire up the Samba daemons and see that everything is running as it should be. In later chapters, you will see how to configure Samba for more complicated and interesting tasks.</para>
741
742
743 <para>The installation process does not automatically create an <filename>smb.conf</filename> configuration file, although several example files are included in the Samba distribution. <indexterm id="ch02-idx-947541-0" class="startofrange"><primary>testing</primary><secondary>Samba</secondary></indexterm>To test the server software, though, we'll use the following file. It should be named <filename>smb.conf</filename> and placed in the <emphasis>/usr/local/samba/lib</emphasis> directory.<footnote label="5" id="ch02-pgfId-943223">
744
745
746 <para>If you did not compile Samba, but instead downloaded a binary, check with the documentation for the package to find out where it expects the <filename>smb.conf</filename> file. If Samba came preinstalled with your Unix system, there is probably already an <filename>smb.conf</filename> file somewhere on your system.</para>
747
748
749 </footnote></para>
750
751
752 <programlisting>[global]
753         workgroup = SIMPLE
754 [test]
755         comment = For testing only, please
756         path = /export/samba/test
757         read only = no
758         guest ok = yes</programlisting>
759
760
761 <para>This brief configuration file tells the Samba server to offer the directory <filename>/export/samba/test</filename>
762 <indexterm id="ch02-idx-947498-0"><primary sortas="export/samba/test directory">/export/samba/test directory</primary></indexterm> on the server as an SMB/CIFS share called <indexterm id="ch02-idx-947499-0"><primary>test share</primary></indexterm><literal>test</literal>. The server also becomes part of the named workgroup SIMPLE, which each of the clients must also be a part of. (Use your own workgroup here if you already know what it is.) We'll use the <literal>[test]</literal> share in the next chapter to set up the Windows clients. For now, you can complete the setup by performing the following commands as root on your Unix server:</para>
763
764
765 <programlisting># <userinput>mkdir /export/samba/test</userinput>
766 # <userinput>chmod 777 /export/samba/test</userinput></programlisting>
767
768
769 <para>We should point out that in terms of system security, this is the worst setup possible. For the moment, however, we only wish to test Samba, so we'll leave security out of the picture. In addition, there are some encrypted password issues that we will encounter with Windows clients later on, so this setup will afford us the least amount of headaches.</para>
770
771
772 <tip role="ora">
773 <para>If you are using Windows 98 or Windows NT Service Pack 3 or above, you must add the following entry to the <literal>[global]</literal> section of the Samba configuration file: <literal>encrypt passwords = yes</literal>. In addition, you must use the <filename>smbpassword</filename> program (typically located in    <filename>/usr/local/samba/bin/ </filename>) to reenter the username/password combinations of those users on the Unix server who should be able to access shares into Samba's encrypted client database. For example, if you wanted to allow Unix user <literal>steve</literal> to access shares from an SMB client, you could type: <literal>smbpassword -a steve</literal>. The first time a user is added, the program will output an error saying that the encrypted password database does not exist. Don't worry, it will then create the database for you. Make sure that the username/password combinations that you add to the encrypted database match the usernames and passwords that you intend to use on the Windows client side.</para>
774
775 </tip>
776
777 <sect2 role="" label="2.4.1" id="ch02-SECT-4.1">
778 <title>Using SWAT</title>
779
780
781 <para>
782 <indexterm id="ch02-idx-947510-0" class="startofrange"><primary>SWAT tool</primary><secondary>creating configuration file with</secondary></indexterm>With Samba 2.0, creating a configuration file is even easier than writing a configuration file by hand. You can use your browser to connect to <emphasis>http://localhost:901</emphasis>, and log on as the root account, as shown in <link linkend="ch02-60915">Figure 2.1</link>.</para>
783
784
785 <figure label="2.1" id="ch02-60915">
786 <title>SWAT login</title>
787
788 <graphic width="502" depth="188" fileref="figs/sam.0201.gif"></graphic>
789 </figure>
790
791 <para>After logging in, press the GLOBALS button at the top of the screen. You should see the Global Variables page shown in <link linkend="ch02-49138">Figure 2.2</link>.</para>
792
793
794 <figure label="2.2" id="ch02-49138">
795 <title>SWAT Global Variables page</title>
796
797 <graphic width="502" depth="455" fileref="figs/sam.0202.gif"></graphic>
798 </figure>
799
800 <para>In this example, set the workgroup field to SIMPLE and the security field to USER. The only other option you need to change from the menu is one determining which system on the LAN resolves NetBIOS addresses; this system is called the <emphasis>WINS server</emphasis>
801 <indexterm id="ch02-idx-947528-0"><primary>WINS (Windows Internet Name Service)</primary><secondary>server</secondary></indexterm>. At the very bottom of the page, set the wins support field to Yes, unless you already have a WINS server on your network. If you do, put the WINS server's IP address in the wins server field instead. Then return to the top and press the Commit Changes button to write the changes out to the <emphasis>smb.conf</emphasis> file.</para>
802
803
804 <figure label="2.3" id="ch02-29175">
805 <title>SWAT Share Creation screen</title>
806
807 <graphic width="502" depth="392" fileref="figs/sam.0203.gif"></graphic>
808 </figure>
809
810 <para>Next, press the Shares icon. You should see a page similar to <link linkend="ch02-29175">Figure 2.3</link>. Choose Test in the field beside the Choose Share button. You will see the Share Parameters screen, as shown in <link linkend="ch02-37186">Figure 2.4</link>. We added a comment to remind us that this is a test share in the <filename>smb.conf</filename> file. SWAT has copies of all that information here.</para>
811
812
813 <figure label="2.4" id="ch02-37186">
814 <title>SWAT Share Parameters screen</title>
815
816 <graphic width="502" depth="407" fileref="figs/sam.0204.gif"></graphic>
817 </figure>
818
819 <para>If you press the View button, SWAT shows you the following <filename>smb.conf</filename> file:</para>
820
821
822 <programlisting># Samba config file created using SWAT
823 # from localhost (127.0.0.1)
824 # Date: 1998/11/27 15:42:40
825
826 # Global parameters
827         workgroup = SIMPLE
828 [test]
829         comment = For testing only, please
830         path = /export/samba/test
831         read only = no
832         guest ok = yes</programlisting>
833
834
835 <para>Once this configuration file is completed, you can skip the next step because the output of SWAT is guaranteed to be syntactically correct.<indexterm id="ch02-idx-947704-0" class="endofrange" startref="ch02-idx-947692-0"/></para>
836 </sect2>
837
838
839
840
841
842 <sect2 role="" label="2.4.2" id="ch02-SECT-4.2">
843 <title>Testing the Configuration File</title>
844
845
846 <para>
847 <indexterm id="ch02-idx-947573-0"><primary>configuring Samba</primary><secondary>configuration file</secondary><tertiary>testing</tertiary></indexterm>
848 <indexterm id="ch02-idx-947573-1"><primary>testing</primary><secondary>configuration file</secondary></indexterm>If you didn't use SWAT to create your configuration file, you should probably test it to ensure that it is syntactically correct. It may seem silly to run a test program against an eight-line configuration file, but it's good practice for the real ones that we'll be writing later on.</para>
849
850
851 <para>The<indexterm id="ch02-idx-947577-0"><primary>test parser</primary></indexterm> test parser, <filename>testparm</filename>
852 <indexterm id="ch02-idx-947578-0"><primary>testparm test parser</primary></indexterm>, examines an <filename>smb.conf</filename> file for <indexterm id="ch02-idx-947583-0"><primary>syntax errors</primary></indexterm>
853 <indexterm id="ch02-idx-947583-1"><primary>errors</primary><secondary>syntax</secondary></indexterm>syntax errors and reports any it finds along with a list of the <indexterm id="ch02-idx-947579-0"><primary>services</primary><secondary>list of enabled on machine</secondary></indexterm>services enabled on your machine. An example follows; you'll notice that in our haste to get the server running we mistyped <literal>workgroup</literal> as <literal>workgrp</literal> (the output is often lengthy, so we recommend capturing the last parts with the <literal>tee</literal> command):</para>
854
855
856 <programlisting>Load smb config files from smb.conf
857 Unknown parameter encountered: "workgrp"
858 Ignoring unknown parameter "workgrp"
859 Processing section "[test]"
860 Loaded services file OK.
861 Press enter to see a dump of your service definitions
862 # Global parameters
863 [global]
864         workgroup = WORKGROUP
865         netbios name =
866         netbios aliases =
867         server string = Samba 2.0.5a
868         interfaces =
869         bind interfaces only = No
870
871 <lineannotation>...(content omitted)...</lineannotation>
872
873 [test]
874         comment = For testing only, please
875     path = /export/samba/test
876         read only = No
877         guest ok = Yes</programlisting>
878
879
880 <para>The interesting parts are at the top and bottom. The top of the output will flag any syntax errors that you may have made, and the bottom lists the services that the server thinks it should offer. A word of advice: make sure that you and the server have the same expectations.<indexterm id="ch02-idx-947566-0" class="endofrange" startref="ch02-idx-947541-0"/></para>
881
882
883 <para>If everything looks good, then you are ready to fire up the server daemons!</para>
884 </sect2>
885 </sect1>
886
887
888
889
890
891
892
893
894
895 <sect1 role="" label="2.5" id="ch02-29069">
896 <title>Starting the Samba Daemons</title>
897
898
899 <para>There <indexterm id="ch02-idx-947584-0" class="startofrange"><primary>daemons</primary><secondary>starting</secondary></indexterm>
900 <indexterm id="ch02-idx-947584-1"><primary>Samba</primary><secondary>daemons</secondary><see>daemons</see></indexterm>are two Samba processes, <emphasis>smbd</emphasis>
901 <indexterm id="ch02-idx-947586-0"><primary>smbd daemon</primary><secondary>starting</secondary></indexterm> and <emphasis>nmbd</emphasis>
902 <indexterm id="ch02-idx-947587-0"><primary>nmbd daemon</primary><secondary>starting</secondary></indexterm>, that need to be running for Samba to work correctly. There are three ways to start:</para>
903
904
905 <itemizedlist>
906 <listitem><para>By hand</para></listitem>
907 <listitem><para>As stand-alone daemons</para></listitem>
908 <listitem><para>From <emphasis>inetd</emphasis></para></listitem>
909 </itemizedlist>
910
911 <sect2 role="" label="2.5.1" id="ch02-SECT-5.1">
912 <title>Starting the Daemons by Hand</title>
913
914
915 <para>If you're in a hurry, you can start the Samba daemons by hand. As root, simply enter the following commands:</para>
916
917
918 <programlisting>#<userinput> /usr/local/samba/bin/smbd -D</userinput>
919 #<userinput> /usr/local/samba/bin/nmbd -D</userinput></programlisting>
920
921
922 <para>At this point, Samba will be running on your system and will be ready to accept connections.</para>
923 </sect2>
924
925
926
927
928
929 <sect2 role="" label="2.5.2" id="ch02-SECT-5.2">
930 <title>Stand-alone Daemons</title>
931
932
933 <para>To run the Samba processes as <indexterm id="ch02-idx-947591-0"><primary>stand-alone daemons</primary></indexterm>
934 <indexterm id="ch02-idx-947591-1"><primary>daemons</primary><secondary>stand-alone</secondary></indexterm>stand-alone daemons, you need to add the commands listed in the previous section to your standard Unix startup scripts. This varies depending on whether you have a BSD-style <indexterm id="ch02-idx-947596-0"><primary>Unix</primary><secondary>System V</secondary></indexterm>Unix system or a System V Unix.</para>
935
936
937 <sect3 role="" label="2.5.2.1" id="ch02-SECT-5.2.1">
938 <title>BSD Unix</title>
939
940
941 <para>WIth a <indexterm id="ch02-idx-947597-0"><primary>BSD-style Unix system</primary></indexterm>BSD-style Unix, you need to append the following code to the <filename>rc.local </filename>
942 <indexterm id="ch02-idx-947598-0"><primary>rc.local file</primary></indexterm>file, which is typically found in the <filename>/etc</filename>
943 <indexterm id="ch02-idx-947599-0"><primary sortas="etc directory">/etc directory</primary></indexterm>
944 <indexterm id="ch02-idx-947599-1"><primary sortas="etc/rc/d directory">/etc/rc.d directory</primary></indexterm> or <filename>/etc/rc.d</filename> directories:</para>
945
946
947 <programlisting>if [ -x /usr/local/samba/bin/smbd]; then
948         echo "Starting smbd..."
949         /usr/local/samba/bin/smbd -D
950         echo "Starting nmbd..."
951         /usr/local/samba/bin/nmbd -D
952 fi</programlisting>
953
954
955 <para>This code is very simple; it checks to see if the <filename>smbd</filename>
956 <indexterm id="ch02-idx-947600-0"><primary>smbd daemon</primary><secondary>file</secondary></indexterm> file has <indexterm id="ch02-idx-947601-0"><primary>execute permissions</primary></indexterm>execute permissions on it, and if it does, it starts up each of the Samba daemons on system boot.</para>
957 </sect3>
958
959
960
961 <sect3 role="" label="2.5.2.2" id="ch02-SECT-5.2.2">
962 <title>System V Unix</title>
963
964
965 <para>With<indexterm id="ch02-idx-947602-0"><primary>System V Unix</primary></indexterm> System V, things can get a little more complex. System V typically uses scripts to start and stop daemons on the system. Hence, you need to instruct Samba how to operate when it starts and when it stops. You can modify the contents of the <filename>/etc/rc.local</filename> directory and add something similar to the following program entitled <filename>smb </filename>:</para>
966
967
968 <programlisting>#!/bin/sh
969
970 # Contains the "killproc" function on Red Hat Linux
971 ./etc/rc.d/init.d/functions
972
973 PATH="/usr/local/samba/bin:$PATH"
974
975 case $1 in
976         'start')
977                 echo "Starting smbd..."
978                 smbd -D
979                 echo "Starting nmbd..."
980                 nmbd -D
981                 ;;
982         'stop')
983                 echo "Stopping smbd and nmbd..."
984                 killproc smbd
985                 killproc nmbd
986                 rm -f /usr/local/samba/var/locks/smbd.pid
987                 rm -f /usr/local/samba/var/locks/nmbd.pid
988                 ;;
989         *)
990                 echo "usage: smb {start|stop}"
991                 ;;
992 esac</programlisting>
993
994
995 <para>With this script, you can start and stop the SMB service with the following commands:</para>
996
997
998 <programlisting># /etc/rc.local/smb start
999 Starting smbd...
1000 Starting nmbd...
1001 # /etc/rc.local/smb stop
1002 Stopping smbd and nmbd...</programlisting>
1003 </sect3>
1004 </sect2>
1005
1006
1007
1008
1009
1010 <sect2 role="" label="2.5.3" id="ch02-SECT-5.3">
1011 <title>Starting From Inetd</title>
1012
1013
1014 <para>The <emphasis>inetd</emphasis>
1015 <indexterm id="ch02-idx-947588-0"><primary>inetd daemon, starting other daemons from</primary></indexterm> daemon is a Unix system's Internet "super daemon." It listens on TCP ports defined in <filename>/etc/services</filename>
1016 <indexterm id="ch02-idx-947610-0"><primary sortas="etc.services configuration files">/etc/services configuration file, adding SWAT tool to</primary></indexterm> and executes the appropriate program for each port, which is defined in <filename>/etc/inetd.conf</filename>
1017 <indexterm id="ch02-idx-947618-0"><primary sortas="etc/inetd.conf configuration file">/etc/inetd.conf configuration files</primary></indexterm>. The advantage of this scheme is that you can have a large number of daemons ready to answer queries, but they don't all have to be running. Instead, the <emphasis>inetd</emphasis> daemon listens in places of all the others. The penalty is a small overhead cost of creating a new daemon process, and the fact that you need to edit two files rather than one to set things up. This is handy if you have only one or two users or your machine has too many daemons already. It's also easier to perform an upgrade without disturbing an existing connection.</para>
1018
1019
1020 <para>If you wish to start from <filename>inetd</filename>, first open <filename>/etc/services</filename> in your text editor. If you don't already have them defined, add the following two lines:</para>
1021
1022
1023 <programlisting>netbios-ssn     139/tcp
1024 netbios-ns      137/udp</programlisting>
1025
1026
1027 <para>Next, edit <filename>/etc/inetd.conf</filename>. Look for the following two lines and add them if they don't exist. If you already have <literal>smbd</literal> and <literal>nmbd</literal> lines in the file, edit them to point at the new <emphasis>smbd</emphasis> and <emphasis>nmbd</emphasis> you've installed. Your brand of Unix may use a slightly different syntax in this file; use the existing entries and the <filename>inetd.conf </filename><command> </command>manual page<command> </command>as a guide:</para>
1028
1029
1030 <programlisting>netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd
1031 netbios-ns  dgram  udp wait   root /usr/local/samba/bin/nmbd nmbd</programlisting>
1032
1033
1034 <para>Finally, kill any <emphasis>smbd</emphasis>
1035 <indexterm id="ch02-idx-947623-0"><primary>smbd daemon</primary><secondary>killing</secondary></indexterm> or <emphasis>nmbd</emphasis>
1036 <indexterm id="ch02-idx-947634-0"><primary>nmbd daemon</primary><secondary>killing</secondary></indexterm>
1037 <indexterm id="ch02-idx-947634-1"><primary>daemons</primary><secondary>killing</secondary></indexterm> processes and send the <emphasis>inetd</emphasis> process a <indexterm id="ch02-idx-947624-0"><primary>hangup (HUP) signal</primary></indexterm>
1038 <indexterm id="ch02-idx-947624-1"><primary>HUP (hangup) signal</primary></indexterm>hangup (HUP) signal. (The <emphasis>inetd</emphasis> daemon rereads its configuration file on a HUP signal.) To do this, use the <literal>ps</literal> command to find its process ID, then signal it with the following command:</para>
1039
1040
1041 <programlisting># <userinput>kill -HUP process_id</userinput></programlisting>
1042
1043
1044 <para>After that, Samba should be up and running.<indexterm id="ch02-idx-947585-0" class="endofrange" startref="ch02-idx-947584-0"/></para>
1045 </sect2>
1046 </sect1>
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056 <sect1 role="" label="2.6" id="ch02-67898">
1057 <title>Testing the Samba Daemons</title>
1058
1059
1060 <para>
1061 <indexterm id="ch02-idx-947635-0"><primary>daemons</primary><secondary>testing</secondary></indexterm>
1062 <indexterm id="ch02-idx-947635-1"><primary>testing</primary><secondary>daemons</secondary></indexterm>It's hard to believe, but we're nearly done with the Samba server setup. All that's left to do is to make sure that everything is working as we think it should. A convenient way to do this is to use the <filename>smbclient</filename>
1063 <indexterm id="ch02-idx-947636-0"><primary>smbclient program</primary></indexterm> program to examine what the server is offering to the network. If everything is set up properly, you should be able to do the following:</para>
1064
1065
1066 <programlisting><userinput># smbclient -U% -L localhost</userinput>
1067
1068 Added interface ip=192.168.220.100 bcast=192.168.220.255 nmask=255.255.255.0
1069 Domain=[SIMPLE] OS=[Unix] Server=[Samba 2.0.5a]
1070
1071         Sharename      Type      Comment
1072         ---------      ----      -------
1073         test           Disk      For testing only, please
1074         IPC$           IPC       IPC Service (Samba 2.0.5a)
1075
1076         Server                      Comment
1077         ---------                   -------
1078         HYDRA                       Samba 2.0.5a
1079
1080         Workgroup                   Master
1081         ---------                   -------
1082         SIMPLE                      HYDRA</programlisting>
1083
1084
1085 <para>If there is a problem, don't panic! Try to start the daemons manually, and check the system output or the <indexterm id="ch02-idx-947637-0"><primary>debug files</primary></indexterm>debug files at <filename>/usr/local/samba/var/log.smb</filename>
1086 <indexterm id="ch02-idx-947638-0"><primary sortas="usr/local/samba/var/log.smb file">/usr/local/samba/var/log.smb file</primary></indexterm> to see if you can determine what happened. If you think it may be a more serious problem, skip to <link linkend="SAMBA-CH-7">Chapter 7</link>, for help on troubleshooting the Samba daemons.</para>
1087
1088
1089 <para>If it worked, congratulations! You now have successfully set up the Samba server with a <indexterm id="ch02-idx-947664-0"><primary>disk shares</primary></indexterm>disk share. It's a simple one, but we can use it to set up and test the Windows 95 and NT clients in the next chapter. Then we will start making it more interesting by adding services such as home directories, printers, and security, and seeing how to integrate the server into a larger Windows domain.<indexterm id="ch02-idx-947297-0" class="endofrange" startref="ch02-idx-947293-0"/></para>
1090 </sect1>
1091 </chapter>