Sams Teach Yourself Samba in 24 Hours

ContentsIndex

Hour 3: Obtaining the Latest Source

Previous HourNext Hour

Sections in this Chapter:

 

Compiling Samba

Pre-2.0

2.0's autoconf Support

After you have the source code distribution of Samba, the next actions for compiling depend on what version of Samba you are installing. Things are done very differently in versions prior to 2.0 as compared to 2.0 and above. The reason is that 2.0 was reworked to use the GNU autoconf tests.

Pre-2.0

For some reason, you might not be able to upgrade to the latest version. Perhaps you have to support an inherited system and need to change one of the compile-time defaults. As I said before, the compiling versions prior to 2.0 are very different than the current method. To give you a frame of reference, the last version released prior to 2.0 was 1.9.18p10.

In the pre-2.0 code tree, all the source files are located in one directory with a make file that you have to slightly modify before compiling:

# The base directory for all samba files
BASEDIR = /usr/local/samba

One of the most common options to change is the base directory for the Samba binary tree after it's installed. The contents of this directory are discussed later in this hour. For now, think of it as the default location where Samba looks for and writes information. Most of these locations can be overridden using smb.conf options or command-line parameters. I prefer to explicitly tell Samba where things are at run time and not make assumptions, but that is my personal preference:

# The directories to put things in. If you use multiple
# architectures or share the samba binaries across NFS 
# you will probably want to change this layout.
# Note: The SBINDIR is for files you do not want users to access
#       normally applies only to nmbd and smbd
#       SBINDIR implies a secure binary directory
BINDIR = $(BASEDIR)/bin
SBINDIR = $(BASEDIR)/bin
LIBDIR = $(BASEDIR)/lib
VARDIR = $(BASEDIR)/var

If you want to distribute the individual Samba directories outside of one tree, you can change the values of ${BINDIR}, ${SBINDIR}$, ${LIBDIR}, and {VARDIR}.

You can also override the default locations of individual files by changing any of the following make file variables. If you are unsure of exactly what the various files are, you can safely leave the defaults.

# set these to where to find various files
# These can be overridden by command line switches (see smbd(8))
# or in smb.conf (see smb.conf(5))
SMBLOGFILE = $(VARDIR)/log.smb
NMBLOGFILE = $(VARDIR)/log.nmb

Before continuing, I want to point out the convention of defining the section of the man pages where an entry occurs by adding (number). In the make file excerpt listed here, the smbd(8) reference means that the smbd man page is located in section 8. Assuming the default install directories, the smbd man page is physically located in /usr/local/samba/mab/man8.

The log files are where the smbd and nmbd daemons write their logging information:

CONFIGFILE = $(LIBDIR)/smb.conf
LMHOSTSFILE = $(LIBDIR)/lmhosts

The smb.conf file has been mentioned already. The lmhosts file is the NetBIOS equivalent of an /etc/hosts file:

DRIVERFILE = $(LIBDIR)/printers.def

The printer.def file contains information about printer drivers which can be downloaded and installed by Windows 95 and 98 clients on-the-fly when connecting to the printers:

SMB_PASSWD = $(BINDIR)/smbpasswd
SMB_PASSWD_FILE = $(BASEDIR)/private/smbpasswd

These files are the Samba passwd utility and the passwd file respectively. They are discussed more in Hour 6, "Security Levels and Passwords."

# the directory where lock files go
LOCKDIR = $(VARDIR)/locks

The lock directory is where Samba places things such as its current browse list (see Hours 19, "Local Subnet Browsing," and 20, "Routed Networks and Browsing"), file lock information, and WINS database (see Hour 18, "Resolving NetBIOS Names Without Using Broadcasts").

One of the major advantages of the autoconf support is that it insulates you from having to specify many details about your operating system. In a pre-2.0 make file, you need to uncomment the flags in the section of the make file which refers to your OS. For example, the following section is for Linux installations that use shadow password but not PAM. The FLAGSM and LIBSM variables were previously commented out by a preceding # as are all the OS-specific sections:

# Use this for Linux with shadow passwords but not using PAM!
# contributed by Andrew.Tridgell@anu.edu.au
# add -DLINUX_BIGCRYPT is you have shadow passwords but don't have
# the right libraries and includes
FLAGSM = -DLINUX -DSHADOW_PWD -DFAST_SHARE_MODES
LIBSM = -lshadow

One last flag that is often useful to set is the CC variable. The default value for CC is to use the cc compiler. If you want to use the gcc compiler instead, you must uncomment the line that says CC = gcc.

Besides setting the make file variables, you might need to set some site-specific values in the local.h header, which is located in the source/ directory. The file itself and the macros are fairly self explanatory. Unless you are sure you need to change something in this file, it is generally better to leave it alone.

However, one macro that I have regularly had to change was MAX_OPEN_FILES. The default value for this in pre-2.0 releases is 100. Due to some code writes, the new Samba code has been made immensely more efficient with respect to file handles. The default in the 2.0 release is 10,000.
One office I had to support used a shared database and the front end needed to open about 150 files simultaneously. Increasing the maximum to around 200 fixed my problem. Obviously this problem does not plague me with 2.0! Also a note of difference is that, in the 2.0 source code, this setting can also be set using a run time parameter in the smb.conf file.
After you have made the necessary changes to the make file and local.h (if any), you can create the binaries by typing make. If all goes well, the smbd, nmbd, and other utilities should be located in the same directory as the source files.

2.0's autoconf Support

In contrast to pre-2.0 makes, Samba 2.0 is very simple. There is a configure script located in the source/ directory. To enable support for your operating system, simply change to the source directory and run the following command:

./configure

The script runs and creates the appropriate make file for you.

Although it is possible to edit the created make file manually and set variables, it is easier to simply specify some of the options as command-line parameters. To find out information about what options are available, type ./configure --help.

I've included portions of the output in Listing 3.1. Where I've deleted lines for brevity, the change is noted by braces ({}).

Listing 3.1  Sample Output from ./configure --help

01: Usage: configure [options] [host]
02: Options: [defaults in brackets after descriptions]
03: Configuration:
04: {lines deletd}
05: Directory and file names:
06:   --prefix=PREFIX         install architecture-independent files in PREFIX
07:                           [/usr/local/samba]
08:   --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
09:                           [same as prefix]
10: {lines deletd}
11: Host type:{lines
12:  deletd}
13: Features and packages:
14: {lines deletd}
15: --enable and --with options recognized:
16:   --enable-maintainer-mode enable some make rules for maintainers
17:   --with-smbwrapper     Include SMB wrapper support
18:   --without-smbwrapper  Don't include SMB wrapper support (default)
19:   --with-afs     Include AFS support
20:   --without-afs  Don't include AFS support (default)
21:   --with-dfs     Include DFS support
22:   --without-dfs  Don't include DFS support (default)
23:   --with-krb4=base-dir     Include Kerberos IV support
24:   --whithout-krb4          Don't include Kerbers IV support (default)
25:   --with-automount     Include AUTOMOUNT support
26:   --without-automount  Don't include AUTOMOUNT support (default)
27:   --with-smbmount     Include SMBMOUNT (Linux only) support
28:   --without-smbmount  Don't include SMBMOUNT support (default)
29:   --with-ldap     Include LDAP support
30:   --without-ldap  Don't include LDAP support (default)
31:   --with-nisplus     Include NISPLUS password database support
32:   --without-nisplus  Don't include NISPLUS password database support (default)
33:   --with-nisplus-home     Include NISPLUS_HOME support
34:   --without-nisplus-home  Don't include NISPLUS_HOME support (default)
35:   --with-ssl     Include SSL support
36:   --without-ssl  Don't include SSL support (default)
37:   --with-mmap     Include experimental MMAP support
38:   --without-mmap  Don't include MMAP support (default)
39:   --with-syslog     Include experimental SYSLOG support
40:   --without-syslog  Don't include SYSLOG support (default)
41:   --with-netatalk     Include experimental Netatalk support
42:   --without-netatalk  Don't include experimental Netatalk support (default)
43:   --with-quotas     Include experimental disk-quota support
44:   --without-quotas  Don't include experimental disk-quota support (default)
45:   --with-privatedir=DIR     Where to put smbpasswd (/usr/local/samba/private)
46:   --with-swatdir=DIR     Where to put SWAT files (/usr/local/samba/swat)

The list of options is quite long, but in reality, many of them come in pairs: one to enable the option and one to disable it. For example, look at the options in lines 25 and 26. The first enables automount support and the second disables it. You should also notice that Listing 3.1 indicates which options are enabled and disabled by default.

If you want to override the default location of the top-level install directory (/usr/local/samba by default) and use /usr/samba instead, pass

--prefix=/usr/samba 

as a parameter when you execute the configure command. To create the make file accepting all the default options (which is usually fine), simply run

./configure 

The configure script creates a make file in the source/ directory. All that remains in order to build the Samba binaries is to type make.

Sams Teach Yourself Samba in 24 Hours

ContentsIndex

Hour 3: Obtaining the Latest Source

Previous HourNext Hour

Sections in this Chapter: