11.2. Compiling Samba from Source Code

Your Linux distribution did not compile support for all the options you need into Samba (see the previous recipe), so you need to rebuild it from scratch and ensure that it has everything you need built-in. Or, you just prefer source installations.

Follow these steps.

First, make sure you have the necessary development tools installed on your system. Debian users need:

Fedora users need:

The command yum groupinstall 'Development Tools' installs all of the basic Linux development tools that you need for a source build on Fedora.

Obtain the Samba source code tarball from samba.org, the signature file, and the GPG key. Verify the filenames before downloading, making sure you have the latest stable versions:

	$ wget http://us1.samba.org/samba/ftp/samba-3.0.25a.tar.asc
	$ wget http://us1.samba.org/samba/ftp/samba-pubkey.asc
	$ wget http://us1.samba.org/samba/ftp/samba-3.0.25a.tar.gz

Uncompress the tarball into a directory where you have write permissions, like in your home directory:

	$ gunzip -d samba-3.0.25a.tar.gz

Import the GPG key into your GPG keyring:

	$ gpg --import samba-pubkey.asc
	gpg: key F17F9772: public key "Samba Distribution Verification Key <samba-bugs@samba.
	org>" imported
	gpg: Total number processed: 1
	gpg:               imported: 1

Then, verify the uncompressed tarball:

	$ gpg --verify samba-3.0.25a.tar.asc
	gpg: Signature made Wed Oct 12 19:20:25 2005 PDT using DSA key ID F17F9772
	gpg: Good signature from "Samba Distribution Verification Key
	<samba-bugs@samba.org>"
	Primary key fingerprint: 2FD9 BC31 99F3 AEB0 8D30  2233 A037 FC69 F17F 9772

Now, you can unpack the tarball:

	$ tar xvf samba-3.0.25a.tar

Next, change to the directory in the Samba source tree that contains the autogen.sh script, and run the script:

	$ cd samba-3.0.25b/source
	$ ./autogen.sh
	./autogen.sh: running script/mkversion.sh
	./script/mkversion.sh: 'include/version.h' created for Samba("3.0.25a")
	./autogen.sh: running autoheader
	./autogen.sh: running autoconf

To see a complete list of build options, run:

	$ ./configure --help

Select these options to support Active Directory, Kerberos, Winbind, and LDAP:

	$ ./configure --with-ldap --with-ads --with-krb5=/usr --with-winbind

Make sure that --with-krb5 points to the directory containing your Kerberos librar-ies. Additionally, these build options are also useful:

	--with-automount -with-smbmount --with-pam --with-pam_smbpass \
	 --with-ldapsam --with-syslog --with-quotas --with-sys-quotas

Then su to root, build, and install Samba:

	$ su
	# make
	# make install

The final steps are configuring Samba to start automatically at boot. See Recipe 11.3.

There are all manner of build options, as ./configure--help shows. You can control installation directories, fine-tune debugging output, and make platform-specific tweaks. The default installation directory is /usr/local/samba/, which makes it easy to wipe out a troublesome installation and start over.

The Samba tarball includes files and instructions for building packages for Debian, Red Hat, Solaris, and many others; see the packaging/ directory in the Samba tarball.

You'll need a build environment for compiling programs from source code. The tools you need are standard on all Linux distributions, though they may not be installed, depending on what sort of installation you choose:

  • Chapter 4, "Installing Programs from Source Code," in Linux Cookbook by Carla Schroder (O'Reilly)