1 <appendix label="F" id="SAMBA-AP-F">
2 <title>Sample Configuration File</title>
8 <indexterm id="appf-idx-993481-0" class="startofrange"><primary>configuration files</primary><secondary>sample of</secondary></indexterm>This appendix gives an example of a production <filename>smb.conf</filename> file and looks at how many of the options are used in practice. The following is a slightly disguised version of one we used at a corporation with five Linux servers, five Windows for Workgroups clients and three NT Workstation clients:</para>
11 <programlisting># smb.conf -- File Server System for: 1 Example.COM BSC & Management Office
14 interfaces = 10.10.1.14/24</programlisting>
17 <para>We provide this service on only one of the machine's interfaces. The <literal>interfaces</literal> option sets its address and netmask, where <literal>/24</literal> is the same as using the netmask 255.255.255.0:</para>
20 <programlisting>comment = Samba ver. %v
21 preexec = csh -c `echo /usr/samba/bin/smbclient \
22 -M %m -I %I` &</programlisting>
25 <para>We use the <command>preexec</command> command to log information about all connections by machine name (<literal>%m</literal>) and IP address (<literal>%I)</literal>:</para>
28 <programlisting># smbstatus will output various info on current status
33 # the username that will be used for access to services
34 # specified with 'guest = ok'
35 guest account = samba</programlisting>
38 <para>The default guest account was <literal>nobody</literal>, uid -1, which produced log messages on one of our machines saying "your server is being unfriendly," so we created a specific Samba guest account for browsing and printing:</para>
41 <programlisting># superuser account - admin privileges to shares, with no
43 # WARNING - use this with care: files can be modified,
44 # regardless of file permissions
47 # who is NOT allowed to connect to ANY service
48 invalid users = @wheel, mail, deamon, adt</programlisting>
51 <para>Daemons can't use Samba, only people. The <literal>invalid</literal> <literal>users</literal> option closes a security hole; it prevents intruders from breaking in by pretending to be a daemon process.</para>
54 <programlisting># hosts that are ALLOWED or DENIED from connecting to ANY service
55 hosts allow = 10.10.1.
56 hosts deny = 10.10.1.6
58 # where the lock files will be located
59 lock directory = /var/lock/samba/locks
62 # %m = separate log for each NetBIOS name (each machine)
63 log file = /var/log/samba/log.%m
65 # We send priority 0, 1 and 2 messages to the system logs
68 # If a WinPopup message is sent to the server,
69 # redirect it to a user via e-mail
71 message command = /bin/mail -s 'message from #% on %m' \
74 # ---------------------------------------------------
75 # [globals] Performance Tuning
76 # ---------------------------------------------------
78 # caching algorithm to reduce time doing getwd() calls.
81 socket options = TCP_NODELAY
83 # tell the server whether the client is present and
84 # responding in seconds
87 # num minutes of inactivity before a connection is
93 read size = 512</programlisting>
96 <para>The <literal>share</literal> <literal>modes</literal>, <literal>max</literal>, <literal>xinit</literal>, and <literal>read</literal> <literal>size</literal> options are machine-specific (see <link linkend="SAMBA-AP-B">Appendix B</link>):</para>
99 <programlisting># locking is done by the server
102 # control whether dos style attributes should be mapped
103 # to unix execute bits
106 map system = yes</programlisting>
109 <para>The three <literal>map</literal> options will work only on shares with a create mode that includes the execute bits (0111). Our <literal>homes</literal> and <literal>printers</literal> shares won't honor them, but the [<literal>www]</literal> share will:</para>
112 <programlisting># ---------------------------------------------------------
113 # [globals] Security and Domain Logon Services
114 # ---------------------------------------------------------
115 # connections are made with UID and GID, not as shares
118 # boolean variable that controls whether passwords
120 encrypt passwords = yes
121 passwd chat = "*New password:*" %n\r "*New password (again):*" %n\r \ "*Password changed*"
122 passwd program = /usr/bin/passwd %u
124 # Always become the local master browser
126 preferred master = yes
129 # For domain logons to work correctly. Samba acts as a
130 # primary domain controller.
133 # Logon script to run for user off the server each time
134 # username (%U) logs in. Set the time, connect to shares,
136 logon script = scripts\%U.bat
139 comment = "Domain Logon Services"
144 volume = "Network"</programlisting>
147 <para>This share, discussed in <link linkend="SAMBA-CH-6">Chapter 6</link>, is required for Samba to work smoothly in a Windows NT domain:</para>
150 <programlisting># -----------------------------------------------------------
151 # [homes] User Home Directories
152 # -----------------------------------------------------------
154 comment = "Home Directory for : %u "
155 path = /u/users/%u</programlisting>
158 <para>The password file of the Samba server specifies each person's home directory as <emphasis>/home/</emphasis><replaceable>machine_name</replaceable><emphasis>/</emphasis><replaceable>person</replaceable>, which NFS converts to point to the actual physicl location under <emphasis>/u/users</emphasis>. The <literal>path</literal> option in the <literal>[homes]</literal> share tells Samba the actual (non-NFS) location:</para>
161 <programlisting>guest ok = no
167 # -----------------------------------------------------------
168 # [printers] System Printers
169 # -----------------------------------------------------------
172 path = /var/spool/lpd/samba
173 printcap name = /etc/printcap
178 lpq command = /usr/bin/lpq -P%p
179 lprm command = /usr/bin/lprm -P%p %j
180 lppause command = /usr/sbin/lpc stop %p
181 lpresume command = /usr/sbin/lpc start %p
188 # -----------------------------------------------------------
189 # Specific Descriptions: [programs] [data] [retail]
190 # -----------------------------------------------------------
192 comment = "Shared Programs %T"
193 volume = "programs"</programlisting>
196 <para>Shared Programs shows up in the Network Neighborhood, and <literal>programs</literal> is the volume name you specify when an installation program wants to know the label of the CD-ROM from which it thinks it's loading:</para>
199 <programlisting>path = /u/programs
205 comment = "Unix CDROM"
213 comment = "Data Directories %T"
221 comment = "NT4 Server"
222 path = /u/systems/nt4
226 volume = "nt4_server"
229 comment = "WWW System"
234 volume = "www_system"</programlisting>
237 <para>The <literal>[www]</literal> share is the directory used on the Unix server to serve web pages. Samba makes the directory available to local PC users so the art department can update web pages.</para>