e110afaea592f35e301fa93d9d53b32feabef238
[import/samba-docs-svnimport.git] / Samba3-HOWTO / TOSHARG-Compiling.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="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>
13
14 <title>How to Compile Samba</title>
15
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>
21
22 <sect1>
23 <title>Access Samba Source Code via Subversion</title>
24
25
26 <sect2>
27 <title>Introduction</title>
28
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>
37
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>
42
43 </sect2>
44
45 <sect2>
46 <title>Subversion Access to samba.org</title>
47
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>
54
55 <sect3>
56 <title>Access via SVNweb</title>
57
58
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>
66
67 <para>
68 Use the URL
69 <ulink noescape="1" url="http://svnweb.samba.org/">http://svnweb.samba.org/</ulink>.
70 </para>
71 </sect3>
72
73 <sect3>
74 <title>Access via Subversion</title>
75
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>
83
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>
88
89 <para>
90 To gain access via anonymous Subversion, use the following steps. 
91 </para>
92
93 <procedure>
94         <title>Retrieving Samba using Subversion</title>
95
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>
102
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>
126
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>
140
141 </sect1>
142
143 <sect1>
144         <title>Accessing the Samba Sources via rsync and ftp</title>
145
146
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 
151         tree at the Samba <ulink noescape="1" url="ftp://pserver.samba.org/pub/unpacked">pserver</ulink> 
152         location and also via anonymous rsync at the Samba
153         <ulink noescape="1" url="rsync://pserver.samba.org/ftp/unpacked/">rsync</ulink> server location. 
154         I recommend using rsync rather than ftp.
155         See <ulink noescape="1" url="http://rsync.samba.org/">the rsync home page</ulink> for more info on rsync.                      
156         </para>
157
158         <para>
159         The disadvantage of the unpacked trees is that they do not support automatic
160         merging of local changes as Subversion does. <command>rsync</command> access is most convenient 
161         for an initial install.                      
162         </para>
163 </sect1>
164
165 <sect1>
166 <title>Verifying Samba's PGP Signature</title>
167
168 <para>
169 <indexterm><primary>GPG</primary></indexterm>
170 <indexterm><primary>PGP</primary></indexterm>
171 It is strongly recommended that you verify the PGP signature for any source file before
172 installing it. Even if you're not downloading from a mirror site, verifying PGP signatures
173 should be a standard reflex. Many people today use the GNU GPG tool set in place of PGP.
174 GPG can substitute for PGP.
175 </para>
176
177
178 <para>
179 With that said, go ahead and download the following files:
180 </para>
181
182 <para><screen>
183 &prompt;<userinput>wget http://us1.samba.org/samba/ftp/samba-3.0.20.tar.asc</userinput>
184 &prompt;<userinput>wget http://us1.samba.org/samba/ftp/samba-pubkey.asc</userinput>
185 </screen></para>
186
187
188 <para>
189 <indexterm><primary>PGP</primary></indexterm>
190 The first file is the PGP signature for the Samba source file; the other is the Samba public
191 PGP key itself. Import the public PGP key with:
192 <screen>
193 &prompt;<userinput>gpg --import samba-pubkey.asc</userinput>
194 </screen>
195 and verify the Samba source code integrity with:
196 <screen>
197 &prompt;<userinput>gzip -d samba-3.0.20.tar.gz</userinput>
198 &prompt;<userinput>gpg --verify samba-3.0.20.tar.asc</userinput>
199 </screen>
200 </para>
201
202 <para>
203 If you receive a message like, <quote>Good signature from Samba Distribution Verification Key...,</quote>
204 then all is well. The warnings about trust relationships can be ignored. An
205 example of what you would not want to see would be:
206 <screen>
207 gpg: BAD signature from <quote>Samba Distribution Verification Key</quote>
208 </screen>
209 </para>
210
211 </sect1>
212
213 <sect1>
214         <title>Building the Binaries</title>
215         
216         <para>
217         <indexterm><primary>autogen.sh</primary></indexterm>
218 <indexterm><primary>configure</primary></indexterm>
219         After the source tarball has been unpacked, the next step involves
220         configuration to match Samba to your operating system platform.
221         If your source directory does not contain the <command>configure</command> script,
222         it is necessary to build it before you can continue. Building of
223         the configure script requires the correct version of the autoconf
224         tool kit. Where the necessary version of autoconf is present,
225         the configure script can be generated by executing the following:
226 <screen>
227 &rootprompt; cd samba-3.0.20
228 &rootprompt; ./autogen.sh
229 </screen>
230         </para>
231         
232
233         <para>
234         <indexterm><primary>configure</primary></indexterm>
235         To build the binaries, run the program <userinput>./configure
236         </userinput> in the source directory. This should automatically 
237         configure Samba for your operating system. If you have unusual 
238         needs, then you may wish to first run:
239 <screen>
240 &rootprompt;<userinput>./configure --help</userinput>
241 </screen>
242 </para>
243         
244         <para>
245         This will help you to see what special options can be enabled. Now execute
246         <userinput>./configure</userinput> with any arguments it might need:
247 <screen>
248 &rootprompt;<userinput>./configure <replaceable>[... arguments ...]</replaceable></userinput>
249 </screen>
250         </para>
251         
252         <para>
253         <indexterm><primary>make</primary></indexterm>
254         Execute the following create the binaries:
255 <screen>
256 &rootprompt; <userinput>make</userinput>
257 </screen>
258         Once it is successfully compiled, you can execute the command shown here to
259         install the binaries and manual pages:
260 <screen>
261 &rootprompt; <userinput>make install</userinput>
262 </screen>
263         </para>
264         
265         <para>
266         Some people prefer to install binary files and man pages separately. If this is
267         your wish, the binary files can be installed by executing:
268 <screen>
269 &rootprompt; <userinput>make installbin</userinput>
270 </screen>
271         The man pages can be installed using this command:
272 <screen>
273 &rootprompt; <userinput>make installman</userinput>
274 </screen>
275         </para>
276
277         <para>
278         Note that if you are upgrading from a previous version of Samba the old
279         versions of the binaries will be renamed with an <quote>.old</quote> extension.
280         You can go back to the previous version by executing:
281 <screen>
282 &rootprompt; <userinput>make revert</userinput>
283 </screen>
284         As you can see from this, building and installing Samba does not need to
285         result in disaster!
286         </para>
287         
288
289         <sect2>
290         <title>Compiling Samba with Active Directory Support</title>
291         
292         <para>
293         In order to compile Samba with ADS support, you need to have installed
294         on your system:
295         </para>
296
297         <itemizedlist>
298         
299             <listitem><para>
300                 The MIT or Heimdal Kerberos development libraries
301             (either install from the sources or use a package).
302                 </para></listitem>
303         
304             <listitem><para>
305                 The OpenLDAP development libraries.
306                 </para></listitem>
307             
308         </itemizedlist>
309
310         <para>
311         If your Kerberos libraries are in a nonstandard location, then
312         remember to add the configure option
313         <option>--with-krb5=<replaceable>DIR</replaceable></option>.
314         </para>
315
316         <para>
317         After you run configure, make sure that the 
318         <filename>include/config.h</filename> it generates contain lines like this:
319 <programlisting>
320 #define HAVE_KRB5 1
321 #define HAVE_LDAP 1
322 </programlisting>
323         </para>
324
325         <para>
326         If it does not, configure did not find your KRB5 libraries or
327         your LDAP libraries. Look in <filename>config.log</filename> to figure
328         out why and fix it.
329         </para>
330
331         <sect3>
332         <title>Installing the Required Packages for Debian</title>
333
334         <para>On Debian, you need to install the following packages:</para>
335         <para>
336                 <itemizedlist>
337                         <listitem><para>libkrb5-dev</para></listitem>
338                         <listitem><para>krb5-user</para></listitem>
339                 </itemizedlist>
340         </para>
341         </sect3>
342
343         <sect3>
344         <title>Installing the Required Packages for Red Hat Linux</title>
345
346         <para>On Red Hat Linux, this means you should have at least: </para>
347         <para>
348                 <itemizedlist>
349                         <listitem><para>krb5-workstation (for kinit)</para></listitem>
350                         <listitem><para>krb5-libs (for linking with)</para></listitem>
351                         <listitem><para>krb5-devel (because you are compiling from source)</para></listitem>
352                 </itemizedlist>
353         </para>
354
355         <para>in addition to the standard development environment.</para>
356
357         <para>If these files are not installed on your system, you should check the installation
358         CDs to find which has them and install the files using your tool of choice. If in doubt
359         about what tool to use, refer to the Red Hat Linux documentation.</para>
360
361         </sect3>
362
363         <sect3>
364         <title>SuSE Linux Package Requirements</title>
365
366         <para>
367         SuSE Linux installs Heimdal packages that may be required to allow you to build
368         binary packages. You should verify that the development libraries have been installed on
369         your system.
370         </para>
371
372         <para>
373         SuSE Linux Samba RPMs support Kerberos. Please refer to the documentation for
374         your SuSE Linux system for information regarding SuSE Linux specific configuration.
375         Additionally, SuSE is very active in the maintenance of Samba packages that provide
376         the maximum capabilities that are available. You should consider using SuSE-provided
377         packages where they are available.
378         </para>
379
380         </sect3>
381         
382         </sect2>
383                           
384 </sect1>
385
386 <sect1 id="startingSamba">
387         <title>Starting the &smbd; &nmbd; and &winbindd;</title>
388
389
390         <para>
391         <indexterm><primary>inetd</primary></indexterm>
392         You must choose to start &smbd;, &winbindd;  and &nmbd; either as daemons or from
393         <application>inetd</application>. Don't try to do both!  Either you can put
394         them in <filename> inetd.conf</filename> and have them started on demand by
395         <application>inetd</application> or <application>xinetd</application>, or you
396         can start them as daemons either from the command-line or in
397         <filename>/etc/rc.local</filename>. See the man pages for details on the
398         command line options. Take particular care to read the bit about what user
399         you need to have to start Samba. In many cases, you must be root.
400         </para>
401
402         <para>
403         The main advantage of starting &smbd; and &nmbd; using the recommended daemon method
404         is that they will respond slightly more quickly to an initial connection request.
405         </para>
406
407         <sect2>
408         <title>Starting from inetd.conf</title>
409
410         <indexterm><primary>inetd</primary></indexterm>
411         
412         <note>
413         <para>The following will be different if 
414         you use NIS, NIS+, or LDAP to distribute services maps.</para>
415         </note>
416         
417         <para>Look at your <filename>/etc/services</filename>. 
418         What is defined at port 139/tcp? If nothing is defined, 
419         then add a line like this:</para>
420
421         <para><programlisting>netbios-ssn     139/tcp</programlisting></para>
422
423         <para>Similarly for 137/udp, you should have an entry like:</para>
424
425         <para><programlisting>netbios-ns        137/udp</programlisting></para>
426
427         <para>
428         Next, edit your <filename>/etc/inetd.conf</filename> and add two lines like this:
429 <programlisting>
430 netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd 
431 netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbd 
432 </programlisting>
433         </para>
434
435 <indexterm><primary>/etc/inetd.conf</primary></indexterm>
436         <para>
437         The exact syntax of <filename>/etc/inetd.conf</filename> 
438         varies between UNIXes. Look at the other entries in inetd.conf 
439         for a guide.
440         </para>
441
442         <para>
443         <indexterm><primary>xinetd</primary></indexterm>
444         Some distributions use xinetd instead of inetd. Consult the 
445         xinetd manual for configuration information.
446         </para>
447
448         <note><para>Some UNIXes already have entries like netbios_ns 
449         (note the underscore) in <filename>/etc/services</filename>. 
450         You must edit <filename>/etc/services</filename> or
451         <filename>/etc/inetd.conf</filename> to make them consistent.
452         </para></note>
453
454         <note><para>
455         <indexterm><primary>ifconfig</primary></indexterm>
456         On many systems you may need to use the
457         <smbconfoption name="interfaces"/> option in &smb.conf; to specify
458         the IP address and netmask of your interfaces. Run 
459         <application>ifconfig</application> as root if you do
460         not know what the broadcast is for your net. &nmbd; tries
461         to determine it at runtime, but fails on some UNIXes. 
462         </para></note>
463
464         <warning><para>
465         Many UNIXes only accept around five parameters on the command
466         line in <filename>inetd.conf</filename>.  This means you shouldn't
467         use spaces between the options and arguments, or you should use
468         a script and start the script from <command>inetd</command>.
469         </para></warning>
470
471         <para>
472         Restart <application>inetd</application>, perhaps just send it a HUP,
473         like this:
474 <indexterm><primary>killall</primary></indexterm>
475 <screen>
476 &rootprompt;<userinput>killall -HUP inetd</userinput>
477 </screen>
478         </para>
479                 
480         </sect2>
481         
482         <sect2>
483         <title>Alternative: Starting &smbd; as a Daemon</title>
484                 
485         <para>
486         <indexterm><primary>daemon</primary></indexterm>
487 <indexterm><primary>startsmb</primary></indexterm>
488         To start the server as a daemon, you should create a script something
489         like this one, perhaps calling it <filename>startsmb</filename>.
490         </para>
491
492 <para><programlisting>
493 #!/bin/sh
494 /usr/local/samba/bin/smbd -D 
495 /usr/local/samba/bin/winbindd -B
496 /usr/local/samba/bin/nmbd -D 
497 </programlisting></para>
498
499         <para>
500         Make it executable with <command>chmod +x startsmb</command>.
501         </para>
502
503         <para>
504         You can then run <command>startsmb</command> by hand or execute
505         it from <filename>/etc/rc.local</filename>.
506         </para>
507
508         <para>
509         To kill it, send a kill signal to the processes &nmbd; and &smbd;.
510         </para>
511
512         <note><para>
513         If you use the SVR4-style init system, you may like to look at the
514         <filename>examples/svr4-startup</filename> script to make Samba fit
515         into that system.
516         </para></note>
517
518         <sect3>
519         <title>Starting Samba for Red Hat Linux</title>
520
521         <para>
522         Red Hat Linux has not always included all Samba components in the standard installation.
523         So versions of Red Hat Linux do not install the winbind utility, even though it is present
524         on the installation CDROM media. Check to see if the <command>winbindd</command> is present
525         on the system:
526 <screen>
527 &rootprompt; ls /usr/sbin/winbindd
528 /usr/sbin/winbindd
529 </screen>
530         This means that the appropriate RPM package was installed. The following response means
531         that it is not installed:
532 <screen>
533 /bin/ls: /usr/sbin/winbind: No such file or directory
534 </screen>
535         In this case it should be installed if you intend to use <command>winbindd</command>. Search
536         the CDROM installation media for the samba-winbind RPM and install it following Red Hat
537         guidelines.
538         </para>
539
540         <para>
541         The process for starting Samba will now be outlined. Be sure to configure Sambas' &smb.conf;
542         file before starting Samba. When configured, start Samba by executing:
543 <screen>
544 &rootprompt; service smb start
545 &rootprompt; service winbind start
546 </screen>
547         These steps will start &nmbd;, &smbd; and &winbindd;.
548         </para>
549
550         <para>
551         To ensure that these services will be automatically restarted when the system is rebooted
552         execute:
553 <screen>
554 &rootprompt; chkconfig smb on
555 &rootprompt; chkconfig winbind on
556 </screen>
557         Samba will be started automatically at every system reboot.
558         </para>
559
560         </sect3>
561
562         <sect3>
563         <title>Starting Samba for Novell SUSE Linux</title>
564
565         <para>
566         Novell SUSE Linux products automatically install all essential Samba components in a default installation.
567         Configure your &smb.conf; file, then execute the following to start Samba:
568 <screen>
569 &rootprompt; rcnmb start
570 &rootprompt; rcsmb start
571 &rootprompt; rcwinbind start
572 </screen>
573         Now execute these commands so that Samba will be started automatically following a system
574         reboot:
575 <screen>
576 &rootprompt; chkconfig nmb on
577 &rootprompt; chkconfig smb on
578 &rootprompt; chkconfig winbind on
579 </screen>
580         The Samba services will now be started automatically following a system reboot.
581         </para>
582
583         </sect3>
584
585         </sect2>
586
587 </sect1>
588
589 </chapter>