docs-xml: fix typos and format in smb.conf server max protocol man
[Samba/gebeck_regimport.git] / docs-xml / Samba3-HOWTO / TOSHARG-Compiling.xml
blobe4baca4033bd351013d4faa9acb1596cfe4a29f5
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="compiling">
4 <chapterinfo>
5         &author.jelmer;
6         &author.jht;
7         &author.tridge;
8         
9         <pubdate> 22 May 2001 </pubdate>
10         <pubdate> 18 March 2003 </pubdate>
11         <pubdate> June 2005 </pubdate>
12 </chapterinfo>
14 <title>How to Compile Samba</title>
16 <para>
17 You can obtain the Samba source file from the
18 <ulink url="http://samba.org/">Samba Web site</ulink>. To obtain a development version, 
19 you can download Samba from Subversion or using <command>rsync</command>.
20 </para>
22 <sect1>
23 <title>Access Samba Source Code via Subversion</title>
26 <sect2>
27 <title>Introduction</title>
29 <para>
30 <indexterm><primary>Subversion</primary></indexterm>
31 Samba is developed in an open environment. Developers use a
32 Subversion to <quote>checkin</quote> (also known as 
33 <quote>commit</quote>) new source code. Samba's various Subversion branches can
34 be accessed via anonymous Subversion using the instructions
35 detailed in this chapter.
36 </para>
38 <para>
39 This chapter is a modified version of the instructions found at the
40 <ulink noescape="1" url="http://samba.org/samba/subversion.html">Samba</ulink> Web site.
41 </para>
43 </sect2>
45 <sect2>
46 <title>Subversion Access to samba.org</title>
48 <para>
49 The machine samba.org runs a publicly accessible Subversion
50 repository for access to the source code of several packages, 
51 including Samba, rsync, distcc, ccache, and jitterbug. There are two main ways
52 of accessing the Subversion server on this host.
53 </para>
55 <sect3>
56 <title>Access via ViewCVS</title>
59 <para>
60 <indexterm><primary>SVN</primary><secondary>web</secondary></indexterm>
61 You can access the source code via your favorite WWW browser. This allows you to access
62 the contents of individual files in the repository and also to look at the revision 
63 history and commit logs of individual files. You can also ask for a diff 
64 listing between any two versions on the repository.
65 </para>
67 <para>
68 Use the URL
69 <ulink noescape="1" url="http://viewcvs.samba.org/">http://viewcvs.samba.org/</ulink>.
70 </para>
71 </sect3>
73 <sect3>
74 <title>Access via Subversion</title>
76 <para>
77 <indexterm><primary>Subversion</primary></indexterm>
78 You can also access the source code via a normal Subversion client. This gives you much more control over what
79 you can do with the repository and allows you to check out whole source trees and keep them up to date via
80 normal Subversion commands. This is the preferred method of access if you are a developer and not just a
81 casual browser.
82 </para>
84 <para>In order to be able to download the Samba sources off Subversion, you need 
85 a Subversion client. Your distribution might include one, or you can download the 
86 sources from <ulink noescape="1" url="http://subversion.tigris.org/">http://subversion.tigris.org/</ulink>.
87 </para>
89 <para>
90 To gain access via anonymous Subversion, use the following steps. 
91 </para>
93 <procedure>
94         <title>Retrieving Samba using Subversion</title>
96         <step>
97         <para>
98         Install a recent copy of Subversion. All you really need is a 
99         copy of the Subversion client binary. 
100         </para>
101         </step>
103         <step>
104         <para>
105         Run the command 
106         <screen>
107         <userinput>svn co svn://svnanon.samba.org/samba/trunk samba</userinput>.
108         </screen>
109         </para>
110         
111         <para>
112         This will create a directory called <filename>samba</filename> containing the 
113         latest Samba source code (usually the branch that is going to be the next major release). This 
114         currently corresponds to the 3.1 development tree. 
115         </para>
116         
117         <para>
118         Subversion branches other then trunk can be obtained by adding branches/BRANCH_NAME to the URL you check
119         out. A list of branch names can be found on the <quote>Development</quote> page of the Samba Web site. A
120         common request is to obtain the latest 3.0 release code. This could be done by using the following command:
121         <screen>
122         <userinput>svn co svn://svnanon.samba.org/samba/branches/SAMBA_3_0 samba_3</userinput>.
123         </screen>
124         </para>
125         </step>
127         <step>
128         <para>
129         Whenever you want to merge in the latest code changes, use the following command from within the Samba
130         directory:
131         <screen>
132         <userinput>svn update</userinput>
133         </screen>
134         </para>
135         </step>
136 </procedure>
137         
138 </sect3>
139 </sect2>
141 </sect1>
143 <sect1>
144         <title>Accessing the Samba Sources via rsync and ftp</title>
147         <para>
148         <indexterm><primary>rsync</primary></indexterm>
149         <indexterm><primary>ftp</primary></indexterm>
150         <parameter>pserver.samba.org</parameter> also exports unpacked copies of most parts of the Subversion tree
151         at the Samba <ulink noescape="1" url="ftp://pserver.samba.org/pub/unpacked">pserver</ulink> location and also
152         via anonymous rsync at the Samba <ulink noescape="1"
153         url="rsync://pserver.samba.org/ftp/unpacked/">rsync</ulink> server location.  I recommend using rsync rather
154         than ftp, because rsync is capable of compressing data streams, but it is also more useful than FTP because
155         during a partial update it will transfer only the data that is missing plus a small overhead.  See <ulink
156         noescape="1" url="http://rsync.samba.org/">the rsync home page</ulink> for more info on rsync.
157         </para>
159         <para>
160         The disadvantage of the unpacked trees is that they do not support automatic
161         merging of local changes as Subversion does. <command>rsync</command> access is most convenient 
162         for an initial install.                      
163         </para>
164 </sect1>
166 <sect1>
167 <title>Verifying Samba's PGP Signature</title>
169 <para>
170 <indexterm><primary>GPG</primary></indexterm>
171 <indexterm><primary>PGP</primary></indexterm>
172 It is strongly recommended that you verify the PGP signature for any source file before
173 installing it. Even if you're not downloading from a mirror site, verifying PGP signatures
174 should be a standard reflex. Many people today use the GNU GPG tool set in place of PGP.
175 GPG can substitute for PGP.
176 </para>
179 <para>
180 With that said, go ahead and download the following files:
181 </para>
183 <para><screen>
184 &prompt;<userinput>wget http://us1.samba.org/samba/ftp/samba-3.0.20.tar.asc</userinput>
185 &prompt;<userinput>wget http://us1.samba.org/samba/ftp/samba-pubkey.asc</userinput>
186 </screen></para>
189 <para>
190 <indexterm><primary>PGP</primary></indexterm>
191 The first file is the PGP signature for the Samba source file; the other is the Samba public
192 PGP key itself. Import the public PGP key with:
193 <screen>
194 &prompt;<userinput>gpg --import samba-pubkey.asc</userinput>
195 </screen>
196 and verify the Samba source code integrity with:
197 <screen>
198 &prompt;<userinput>gzip -d samba-3.0.20.tar.gz</userinput>
199 &prompt;<userinput>gpg --verify samba-3.0.20.tar.asc</userinput>
200 </screen>
201 </para>
203 <para>
204 If you receive a message like, <quote>Good signature from Samba Distribution Verification Key...,</quote>
205 then all is well. The warnings about trust relationships can be ignored. An
206 example of what you would not want to see would be:
207 <screen>
208 gpg: BAD signature from <quote>Samba Distribution Verification Key</quote>
209 </screen>
210 </para>
212 </sect1>
214 <sect1>
215         <title>Building the Binaries</title>
216         
217         <para>
218         <indexterm><primary>autogen.sh</primary></indexterm>
219 <indexterm><primary>configure</primary></indexterm>
220         After the source tarball has been unpacked, the next step involves
221         configuration to match Samba to your operating system platform.
222         If your source directory does not contain the <command>configure</command> script,
223         it is necessary to build it before you can continue. Building of
224         the configure script requires the correct version of the autoconf
225         tool kit. Where the necessary version of autoconf is present,
226         the configure script can be generated by executing the following
227         (please note that in Samba 3.4.x, the directory is called source3 instead
228         of source):
229 <screen>
230 &rootprompt; cd samba-3.0.20/source
231 &rootprompt; ./autogen.sh
232 </screen>
233         </para>
234         
236         <para>
237         <indexterm><primary>configure</primary></indexterm>
238         To build the binaries, run the program <userinput>./configure
239         </userinput> in the source directory. This should automatically 
240         configure Samba for your operating system. If you have unusual 
241         needs, then you may wish to first run:
242 <screen>
243 &rootprompt;<userinput>./configure --help</userinput>
244 </screen>
245 </para>
246         
247         <para>
248         This will help you to see what special options can be enabled. Now execute
249         <userinput>./configure</userinput> with any arguments it might need:
250 <screen>
251 &rootprompt;<userinput>./configure <replaceable>[... arguments ...]</replaceable></userinput>
252 </screen>
253         </para>
254         
255         <para>
256         <indexterm><primary>make</primary></indexterm>
257         Execute the following create the binaries:
258 <screen>
259 &rootprompt; <userinput>make</userinput>
260 </screen>
261         Once it is successfully compiled, you can execute the command shown here to
262         install the binaries and manual pages:
263 <screen>
264 &rootprompt; <userinput>make install</userinput>
265 </screen>
266         </para>
267         
268         <para>
269         Some people prefer to install binary files and man pages separately. If this is
270         your wish, the binary files can be installed by executing:
271 <screen>
272 &rootprompt; <userinput>make installbin</userinput>
273 </screen>
274         The man pages can be installed using this command:
275 <screen>
276 &rootprompt; <userinput>make installman</userinput>
277 </screen>
278         </para>
280         <para>
281         Note that if you are upgrading from a previous version of Samba the old
282         versions of the binaries will be renamed with an <quote>.old</quote> extension.
283         You can go back to the previous version by executing:
284 <screen>
285 &rootprompt; <userinput>make revert</userinput>
286 </screen>
287         As you can see from this, building and installing Samba does not need to
288         result in disaster!
289         </para>
290         
292         <sect2>
293         <title>Compiling Samba with Active Directory Support</title>
294         
295         <para>
296         In order to compile Samba with ADS support, you need to have installed
297         on your system:
298         </para>
300         <itemizedlist>
301         
302             <listitem><para>
303                 The MIT or Heimdal Kerberos development libraries
304             (either install from the sources or use a package).
305                 </para></listitem>
306         
307             <listitem><para>
308                 The OpenLDAP development libraries.
309                 </para></listitem>
310             
311         </itemizedlist>
313         <para>
314         If your Kerberos libraries are in a nonstandard location, then
315         remember to add the configure option
316         <option>--with-krb5=<replaceable>DIR</replaceable></option>.
317         </para>
319         <para>
320         After you run configure, make sure that the 
321         <filename>include/config.h</filename> it generates contain lines like this:
322 <programlisting>
323 #define HAVE_KRB5 1
324 #define HAVE_LDAP 1
325 </programlisting>
326         </para>
328         <para>
329         If it does not, configure did not find your KRB5 libraries or
330         your LDAP libraries. Look in <filename>config.log</filename> to figure
331         out why and fix it.
332         </para>
334         <sect3>
335         <title>Installing the Required Packages for Debian</title>
337         <para>On Debian, you need to install the following packages:</para>
338         <para>
339                 <itemizedlist>
340                         <listitem><para>libkrb5-dev</para></listitem>
341                         <listitem><para>krb5-user</para></listitem>
342                 </itemizedlist>
343         </para>
344         </sect3>
346         <sect3>
347         <title>Installing the Required Packages for Red Hat Linux</title>
349         <para>On Red Hat Linux, this means you should have at least: </para>
350         <para>
351                 <itemizedlist>
352                         <listitem><para>krb5-workstation (for kinit)</para></listitem>
353                         <listitem><para>krb5-libs (for linking with)</para></listitem>
354                         <listitem><para>krb5-devel (because you are compiling from source)</para></listitem>
355                 </itemizedlist>
356         </para>
358         <para>in addition to the standard development environment.</para>
360         <para>If these files are not installed on your system, you should check the installation
361         CDs to find which has them and install the files using your tool of choice. If in doubt
362         about what tool to use, refer to the Red Hat Linux documentation.</para>
364         </sect3>
366         <sect3>
367         <title>SuSE Linux Package Requirements</title>
369         <para>
370         SuSE Linux installs Heimdal packages that may be required to allow you to build
371         binary packages. You should verify that the development libraries have been installed on
372         your system.
373         </para>
375         <para>
376         SuSE Linux Samba RPMs support Kerberos. Please refer to the documentation for
377         your SuSE Linux system for information regarding SuSE Linux specific configuration.
378         Additionally, SuSE is very active in the maintenance of Samba packages that provide
379         the maximum capabilities that are available. You should consider using SuSE-provided
380         packages where they are available.
381         </para>
383         </sect3>
384         
385         </sect2>
386                           
387 </sect1>
389 <sect1 id="startingSamba">
390         <title>Starting the &smbd; &nmbd; and &winbindd;</title>
393         <para>
394         <indexterm><primary>inetd</primary></indexterm>
395         You must choose to start &smbd;, &winbindd;  and &nmbd; either as daemons or from
396         <application>inetd</application>. Don't try to do both!  Either you can put
397         them in <filename> inetd.conf</filename> and have them started on demand by
398         <application>inetd</application> or <application>xinetd</application>, or you
399         can start them as daemons either from the command-line or in
400         <filename>/etc/rc.local</filename>. See the man pages for details on the
401         command line options. Take particular care to read the bit about what user
402         you need to have to start Samba. In many cases, you must be root.
403         </para>
405         <para>
406         The main advantage of starting &smbd; and &nmbd; using the recommended daemon method
407         is that they will respond slightly more quickly to an initial connection request.
408         </para>
410         <sect2>
411         <title>Starting from inetd.conf</title>
413         <indexterm><primary>inetd</primary></indexterm>
414         
415         <note>
416         <para>The following will be different if 
417         you use NIS, NIS+, or LDAP to distribute services maps.</para>
418         </note>
419         
420         <para>Look at your <filename>/etc/services</filename>. 
421         What is defined at port 139/tcp? If nothing is defined, 
422         then add a line like this:</para>
424         <para><programlisting>netbios-ssn     139/tcp</programlisting></para>
426         <para>Similarly for 137/udp, you should have an entry like:</para>
428         <para><programlisting>netbios-ns        137/udp</programlisting></para>
430         <para>
431         Next, edit your <filename>/etc/inetd.conf</filename> and add two lines like this:
432 <programlisting>
433 netbios-ssn stream tcp nowait root /usr/local/samba/sbin/smbd smbd 
434 netbios-ns dgram udp wait root /usr/local/samba/sbin/nmbd nmbd 
435 </programlisting>
436         </para>
438 <indexterm><primary>/etc/inetd.conf</primary></indexterm>
439         <para>
440         The exact syntax of <filename>/etc/inetd.conf</filename> 
441         varies between UNIXes. Look at the other entries in inetd.conf 
442         for a guide.
443         </para>
445         <para>
446         <indexterm><primary>xinetd</primary></indexterm>
447         Some distributions use xinetd instead of inetd. Consult the 
448         xinetd manual for configuration information.
449         </para>
451         <note><para>Some UNIXes already have entries like netbios_ns 
452         (note the underscore) in <filename>/etc/services</filename>. 
453         You must edit <filename>/etc/services</filename> or
454         <filename>/etc/inetd.conf</filename> to make them consistent.
455         </para></note>
457         <note><para>
458         <indexterm><primary>ifconfig</primary></indexterm>
459         On many systems you may need to use the
460         <smbconfoption name="interfaces"/> option in &smb.conf; to specify
461         the IP address and netmask of your interfaces. Run 
462         <application>ifconfig</application> as root if you do
463         not know what the broadcast is for your net. &nmbd; tries
464         to determine it at runtime, but fails on some UNIXes. 
465         </para></note>
467         <warning><para>
468         Many UNIXes only accept around five parameters on the command
469         line in <filename>inetd.conf</filename>.  This means you shouldn't
470         use spaces between the options and arguments, or you should use
471         a script and start the script from <command>inetd</command>.
472         </para></warning>
474         <para>
475         Restart <application>inetd</application>, perhaps just send it a HUP,
476         like this:
477 <indexterm><primary>killall</primary></indexterm>
478 <screen>
479 &rootprompt;<userinput>killall -HUP inetd</userinput>
480 </screen>
481         </para>
482                 
483         </sect2>
484         
485         <sect2>
486         <title>Alternative: Starting &smbd; as a Daemon</title>
487                 
488         <para>
489         <indexterm><primary>daemon</primary></indexterm>
490 <indexterm><primary>startsmb</primary></indexterm>
491         To start the server as a daemon, you should create a script something
492         like this one, perhaps calling it <filename>startsmb</filename>.
493         </para>
495 <para><programlisting>
496 #!/bin/sh
497 /usr/local/samba/sbin/smbd -D
498 /usr/local/samba/sbin/winbindd -D
499 /usr/local/samba/sbin/nmbd -D
500 </programlisting></para>
502         <para>
503         Make it executable with <command>chmod +x startsmb</command>.
504         </para>
506         <para>
507         You can then run <command>startsmb</command> by hand or execute
508         it from <filename>/etc/rc.local</filename>.
509         </para>
511         <para>
512         To kill it, send a kill signal to the processes &nmbd; and &smbd;.
513         </para>
515         <note><para>
516         If you use the SVR4-style init system, you may like to look at the
517         <filename>examples/svr4-startup</filename> script to make Samba fit
518         into that system.
519         </para></note>
521         <sect3>
522         <title>Starting Samba for Red Hat Linux</title>
524         <para>
525         Red Hat Linux has not always included all Samba components in the standard installation.
526         So versions of Red Hat Linux do not install the winbind utility, even though it is present
527         on the installation CDROM media. Check to see if the <command>winbindd</command> is present
528         on the system:
529 <screen>
530 &rootprompt; ls /usr/sbin/winbindd
531 /usr/sbin/winbindd
532 </screen>
533         This means that the appropriate RPM package was installed. The following response means
534         that it is not installed:
535 <screen>
536 /bin/ls: /usr/sbin/winbind: No such file or directory
537 </screen>
538         In this case, it should be installed if you intend to use <command>winbindd</command>. Search
539         the CDROM installation media for the samba-winbind RPM and install it following Red Hat
540         guidelines.
541         </para>
543         <para>
544         The process for starting Samba will now be outlined. Be sure to configure Samba's &smb.conf;
545         file before starting Samba. When configured, start Samba by executing:
546 <screen>
547 &rootprompt; service smb start
548 &rootprompt; service winbind start
549 </screen>
550         These steps will start &nmbd;, &smbd; and &winbindd;.
551         </para>
553         <para>
554         To ensure that these services will be automatically restarted when the system is rebooted
555         execute:
556 <screen>
557 &rootprompt; chkconfig smb on
558 &rootprompt; chkconfig winbind on
559 </screen>
560         Samba will be started automatically at every system reboot.
561         </para>
563         </sect3>
565         <sect3>
566         <title>Starting Samba for Novell SUSE Linux</title>
568         <para>
569         Novell SUSE Linux products automatically install all essential Samba components in a default installation.
570         Configure your &smb.conf; file, then execute the following to start Samba:
571 <screen>
572 &rootprompt; rcnmb start
573 &rootprompt; rcsmb start
574 &rootprompt; rcwinbind start
575 </screen>
576         Now execute these commands so that Samba will be started automatically following a system
577         reboot:
578 <screen>
579 &rootprompt; chkconfig nmb on
580 &rootprompt; chkconfig smb on
581 &rootprompt; chkconfig winbind on
582 </screen>
583         The Samba services will now be started automatically following a system reboot.
584         </para>
586         </sect3>
588         </sect2>
590 </sect1>
592 </chapter>