~zulcss/samba/server-dailies-3.4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
<html>
<body bgcolor="#ffffff">

<img src="samba2_xs.gif" border="0" alt=" " height="100" width="76"
hspace="10" align="left" />

<h1 class="head0">Chapter 2. Installing Samba on a Unix System</h1>

<p><a name="INDEX-1"/>Now
that you know what Samba can do for you and your users,
it's time to get your own network set up.
Let's start with the installation of Samba. When
dancing the samba, one learns by taking small steps.
It's just the same when installing Samba; we need to
teach it step by step. This chapter will help you start off on the
right foot.</p>

<p>For illustrative purposes, we will be installing the 2.2.6 version of
the Samba server on a Linux system running Version 2.4 of the kernel.
However, the installation steps are essentially the same for all the
platforms Samba supports.</p>


<div class="sect1"><a name="samba2-CHP-2-SECT-1"/>

<h2 class="head1">Bundled Versions</h2>

<p><a name="INDEX-2"/><a name="INDEX-3"/>Samba is in such
popular use that many Unix distributions come with it already
installed. If you choose to use a bundled version of Samba, you can
breeze through most of this chapter, but you'll be
stuck with the Samba version and compile-time options your vendor
selected for you. That version of Samba can't be any
newer than the operating system release, so you're
likely to be pretty far behind the latest developments. On the other
hand, you can be fairly sure that a bundled version has been
installed properly, and perhaps it will take only a few simple
modifications to your <em class="emphasis">smb.conf</em> file for you to
be off and running. Samba is mature enough that you probably
don't need the latest release to meet your basic
needs, so you might be perfectly happy running a bundled version.</p>

<p>If you choose this option, be aware that your Samba files, including
the very important
<em class="emphasis">smb.conf</em>,<a name="INDEX-4"/> might be in different places
than they would be if you were to install from a binary or source
distribution. For example, with the Red Hat, Debian, and Mandrake
Linux distributions, <em class="emphasis">smb.conf</em> and some other
Samba-related files are in the <em class="emphasis">/etc/samba</em>
directory.</p>

<p>If Samba is already installed on your system, you can check to see
what version you have by using the command:</p>

<blockquote><pre class="code">$ <tt class="userinput"><b>smbd -V</b></tt>
Version 2.2.6</pre></blockquote>

<p>(If this doesn't work, it might be because
<em class="emphasis">smbd</em> is not in your shell's
search path. If you have the <em class="emphasis">locate</em> or
<em class="emphasis">whereis</em> command in your Unix variant, you can
use it to locate the <em class="emphasis">smbd</em> executable.)</p>

<p>You might also be able to use a system-specific tool to query a
software-package maintenance utility. On Red Hat Linux, you can use
the <em class="emphasis">rpm</em><a name="INDEX-5"/> command to query the installed packages
for Samba:</p>

<blockquote><pre class="code">$ <tt class="userinput"><b>rpm -qa | grep samba</b></tt>
samba-client-2.0.8-1.7.1
samba-2.0.8-1.7.1
samba-common-2.0.8-1.7.1</pre></blockquote>

<p>This shows we have Samba 2.0.8, divided into three Red Hat Package
Manager (RPM) packages, bundled with Red Hat 7.1. If your version of
Samba is old, you might at the very least want to check with your
vendor for an update.</p>

<p>Otherwise, if you're sure you are going to install
from a binary or source distribution, you can remove the RPM packages
as follows:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>rpm -e samba</b></tt>
# <tt class="userinput"><b>rpm -e samba-client</b></tt>
# <tt class="userinput"><b>rpm -e samba-common</b></tt></pre></blockquote>

<p>If you are not using Red Hat Linux, consult your
system's documentation to find the method that works
for you.</p>


<div class="sect2"><a name="samba2-CHP-2-SECT-1.1"/>

<h3 class="head2">Binary or Source?</h3>

<p><a name="INDEX-6"/>Precompiled
&quot;binary&quot; packages are also
available for a large number of Unix platforms. These packages
contain binaries for each Samba executable, as well as the standard
Samba documentation. Note that while installing a binary distribution
can save you a fair amount of time and trouble, you should keep a
couple of issues in mind when deciding whether to use the binary or
compile the source yourself:</p>

<ul><li>
<p>The binary packages can lag behind the latest version of the software
by one or two (maybe more) minor releases, especially after a series
of small changes and for less popular platforms. Compare the release
notes for the source and binary packages to make sure there
aren't any new features that you need on your
platform.</p>
</li><li>
<p>If you use a precompiled binary that is dynamically linked, you will
need to ensure that you have the correct libraries required by the
executables. If your system does not already have the required
version of a library, you might have to install a new version. The
<em class="filename">README</em> file or <em class="filename">makefile</em>
that accompanies the binary distribution should list any special
requirements.</p>

<p>Many systems with shared libraries come with a nifty tool called
<em class="emphasis">ldd</em>. This tool will tell you which libraries a
specific binary requires and which libraries on the system satisfy
that requirement. For example, checking the <em class="emphasis">smbd</em>
program on our test machine gave us:</p>

<blockquote><pre class="code">$ <tt class="userinput"><b>ldd smbd</b></tt>
        libdl.so.2 =&gt; /lib/libdl.so.2 (0x40026000)
        libnsl.so.1 =&gt; /lib/libnsl.so.1 (0x4002a000)
        libpam.so.0 =&gt; /lib/libpam.so.0 (0x40041000)
        libc.so.6 =&gt; /lib/libc.so.6 (0x40049000)
        /lib/ld-linux.so.2 =&gt; /lib/ld-linux.so.2 (0x40000000)</pre></blockquote>

<p>If there are any incompatibilities between Samba and specific
libraries on your machine, the distribution-specific documentation
should highlight them.</p>
</li><li>
<p>If your precompiled binary is statically linked, it is still possible
to have problems. There have been cases in which the statically
linked C library calls in Samba programs have been out of sync with
the operating-system kernel, even though this is
&quot;not supposed to happen.&quot;</p>
</li><li>
<p>Keep in mind that each binary distribution carries preset values
about the target platform, such as default directories and
configuration option values. Again, check the documentation and the
makefile included in the source directory to see which directives and
variables were used when the binary was compiled. In some cases,
these will not be appropriate for your situation.</p>

<p>A few configuration items can be reset with command-line options at
runtime rather than at compile time. For example, if your binary
tries to place any log, lock, or status files in the
&quot;wrong&quot; place (for example, in
<em class="filename">/usr/local</em> ), you can override this without
recompiling.</p>
</li></ul>
<p>One point worth mentioning is that the Samba source requires an
<a name="INDEX-7"/><a name="INDEX-8"/><a name="INDEX-9"/>ANSI C
compiler. If you are on a legacy platform with a non-ANSI compiler,
such as the <em class="emphasis">cc</em> compiler on SunOS Version 4,
you'll have to install an ANSI-compliant compiler
such as <em class="emphasis">gcc</em> <a name="INDEX-10"/>before you do anything else.<a name="FNPTR-1"/><a href="#FOOTNOTE-1">[1]</a>
If installing a compiler isn't something you want to
wrestle with, you can start off with a binary package. However, for
the most flexibility and compatibility on your system, we always
recommend compiling from the latest stable or production source.</p>

<p>A typical installation will take about an hour to complete, including
downloading the source files and compiling them, setting up the
configuration files, and testing the server.</p>

<p>Here is an overview of the steps:</p>

<ol><li>
<p><a name="INDEX-11"/>Download the source or binary files.</p>
</li><li>
<p>Read the installation documentation.</p>
</li><li>
<p>Configure a makefile.</p>
</li><li>
<p>Compile the server and utility programs.</p>
</li><li>
<p>Install the server files.</p>
</li><li>
<p>Create a Samba configuration file.</p>
</li><li>
<p>Test the configuration file.</p>
</li><li>
<p>Start the Samba daemons.</p>
</li><li>
<p>Test the Samba daemons. <a name="INDEX-12"/></p>
</li></ol>

</div>


</div>



<div class="sect1"><a name="samba2-CHP-2-SECT-2"/>

<h2 class="head1">Downloading the Samba Distribution</h2>

<p><a name="INDEX-13"/>If
you would like to download the latest version of the Samba software,
the primary web site is <a href="http://www.samba.org">http://www.samba.org</a>. Once connected to this
page, you'll see links to several Samba mirror sites
across the world, both for the standard Samba web pages and for sites
devoted exclusively to downloading Samba. For the best performance,
choose a site that is closest to your own geographic location.</p>

<p>The standard Samba web sites have Samba
<a name="INDEX-14"/>documentation and
<a name="INDEX-15"/>tutorials,
<a name="INDEX-16"/>mailing-list
archives, and the latest Samba <a name="INDEX-17"/>news, as well as source and binary
distributions of Samba. The download sites (sometimes called
<em class="emphasis">F T P sites</em>) have only the source and binary
distributions. Unless you specifically want an older version of the
Samba server or are going to install a binary distribution, download
the latest source distribution from the closest mirror site. This
distribution is always named:</p>

<blockquote><pre class="code">samba-latest.tar.gz</pre></blockquote>

<p>which for the 2.2.6 release is an approximately 5MB file.</p>

<p>The source distribution has been archived with
<em class="emphasis">tar</em> and then compressed with the GNU
<em class="emphasis">gzip</em> program. To unpack it, move the file to the
directory in which you want the Samba source directory to be located,
then <em class="emphasis">cd</em> to that directory and run the command:</p>

<blockquote><pre class="code">$ <tt class="userinput"><b>tar xvfz samba-latest.tar.gz</b></tt></pre></blockquote>

<p>Or, if you do not have the GNU <em class="emphasis">tar</em> program
(which also handles the unzipping):</p>

<blockquote><pre class="code">$ <tt class="userinput"><b>gunzip samba-latest.tar.gz</b></tt>
$ <tt class="userinput"><b>tar xvf samba-latest.tar</b></tt></pre></blockquote>

<p>In that latter case, you might need to install the GNU
<em class="emphasis">gunzip</em> program first. While the
<em class="emphasis">tar</em> command runs, it will print out a list of
the files it installs.</p>


<div class="sect2"><a name="samba2-CHP-2-SECT-2.1"/>

<h3 class="head2">Read the Documentation</h3>

<p><a name="INDEX-18"/>This
part might seem obvious, but at one time or other you probably
uncompressed a package, blindly typed:</p>

<blockquote><pre class="code">$ <tt class="userinput"><b>configure; make; make install</b></tt></pre></blockquote>

<p>and walked away to get another cup of coffee. Do yourself a favor and
be a little more careful this time.</p>

<p>In the top-level directory that you just installed, there is a file
named <em class="filename">WHATSNEW.txt</em>, which contains the latest
news about the release. If you are upgrading, you can find important
information about bug fixes or configuration parameters that have
been added or are no longer supported.</p>

<p>With both source and binary packages you'll find a
large number of documents in the <em class="filename">docs</em> directory,
in a variety of formats. One file is especially important:</p>

<blockquote><pre class="code">docs/htmldocs/UNIX_INSTALL.html</pre></blockquote>

<p>This is the Samba Team's official instructions on
installing Samba on a Unix system, which you might like to use as
another perspective besides what we are telling you here.</p>

<p>In general, we expect you'll find to be most useful
the files in the following directories:</p>

<dl>
<dt><b>docs/faq</b></dt>
<dd>
<p>This is the Samba Frequently Asked Questions (FAQ) files.</p>
</dd>



<dt><b>docs/htmldocs</b></dt>
<dd>
<p>This is the miscellaneous documentation in HTML format.</p>
</dd>



<dt><b>docs/textdocs</b></dt>
<dd>
<p>Here is more documentation, in simple text format.</p>
</dd>



<dt><b>docs/manpages</b></dt>
<dd>
<p>You don't need to worry about these yet; during the
installation, the files will be installed so that you can use the
<em class="emphasis">man</em> command to read them. But you can take a
look in the directory to see which manpages are available.</p>
</dd>

</dl>


</div>


</div>



<div class="sect1"><a name="samba2-CHP-2-SECT-3"/>

<h2 class="head1">Configuring Samba</h2>

<p><a name="INDEX-19"/><a name="INDEX-20"/>Samba automatically configures itself
prior to compilation. This reduces the likelihood of a
machine-specific problem, but you might end up wishing for an option
after Samba has been installed.</p>

<p>The source distribution of Samba 2.2 and above
doesn't initially have a
<a name="INDEX-21"/>makefile. Instead, one is
generated through a <a name="INDEX-22"/><a name="INDEX-23"/>GNU <em class="filename">configure</em>
script, which is located in the <em class="filename">samba-2.2.x
/source/</em> directory. The <em class="firstterm">configure</em>
script takes care of the machine-specific issues of building Samba.</p>

<a name="samba2-CHP-2-NOTE-88"/><blockquote class="note"><h4 class="objtitle">NOTE</h4>



<p>Before running the <em class="filename">configure</em> script, it is
important that you become the root user on the system. Otherwise, you
might get a warning such as:</p>


<blockquote><pre class="code">configure: warning: running as non-root will disable some tests</pre></blockquote>


<p>You don't want any test to be disabled when the
Samba makefile is being created; it would leave the potential for
errors down the road when compiling or running Samba on your system.</p>
</blockquote>

<p>When the <em class="filename">configure </em>script is run, it prints out
messages telling what it is doing, and error messages might be mixed
in. To make sure you see those very important error messages, we
suggest you run <em class="filename">configure </em>with its standard
output passed through some filter to capture the output and keep it
from scrolling out of sight. One method is using the
<em class="filename">more</em> command:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>./configure | more</b></tt></pre></blockquote>

<p>We will show you another in a moment.</p>

<p>Although you can run <em class="filename">configure </em>as previously
with no options, you might want to add support for extra features by
passing options on the command line. For example:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>./configure --with-winbind</b></tt></pre></blockquote>

<p>will configure the Samba makefile with support for winbind
authentication. If you would like a complete list of options, type
the following:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>./configure --help</b></tt></pre></blockquote>

<p>Each option enables or disables various features. You typically
enable a feature by specifying the
<tt class="literal">--</tt><a name="INDEX-24"/><a name="INDEX-25"/><a name="INDEX-26"/><a name="INDEX-27"/><tt class="literal">with-</tt><em class="replaceable">feature</em>
option, which will cause the feature to be compiled and installed.
Likewise, if you specify a
<tt class="literal">--without-</tt><em class="replaceable">feature</em>
option, the feature will be disabled. A full list of configuration
options is provided in <a href="appe.html">Appendix E</a>, but for now we
want to point out three of them, which are features we cover later in
this book:</p>

<dl>
<dt><b><tt class="literal">--with-msdfs</tt><a name="INDEX-28"/><a name="INDEX-29"/></b></dt>
<dd>
<p>Include support for Microsoft Distributed filesystem (Dfs), which
allows dispersed network resources to be clumped together into one
easy-to-navigate directory tree. See <a href="ch08.html">Chapter 8</a>.</p>
</dd>



<dt><b><tt class="literal">--with-smbwrapper</tt><a name="INDEX-30"/><a name="INDEX-31"/></b></dt>
<dd>
<p>Include SMB wrapper support, which allows programs running on the
Unix host to access SMB shared folders as if they were Unix
filesystems. We recommend using this option. See <a href="ch05.html">Chapter 5</a>.</p>
</dd>



<dt><b><tt class="literal">--with-smbmount</tt><a name="INDEX-32"/><a name="INDEX-33"/></b></dt>
<dd>
<p>Include <em class="emphasis">smbmount</em> support, which allows SMB
shared folders to be mounted in the Unix filesystem. At the time of
this writing, support for this feature exists only for Linux. This is
also covered in <a href="ch05.html">Chapter 5</a>.</p>
</dd>

</dl>

<p>Each option is disabled by default, and none of the features is
essential to Samba. However, you may want to include them in your
configuration (as we will in our example) at least to be able to try
out the options in later chapters.</p>

<p>In addition, <a href="ch02.html#samba2-CHP-2-TABLE-1">Table 2-1</a> shows some other parameters
that you can give the <em class="filename">configure</em> script if you
wish to store parts of the Samba distribution in different places,
perhaps to make use of multiple disks or partitions. Note that the
defaults sometimes refer to a prefix specified earlier in the table.</p>

<a name="samba2-CHP-2-TABLE-1"/><h4 class="head4">Table 2-1. Additional configure options</h4><table border="1">




<tr>
<th>
<p>Option</p>
</th>
<th>
<p>Meaning</p>
</th>
<th>
<p>Default</p>
</th>
</tr>


<tr>
<td>
<p><tt class="literal">--prefix</tt><a name="INDEX-34"/><a name="INDEX-35"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install architecture-independent files at the base directory
specified.</p>
</td>
<td>
<p><em class="filename">/usr/local/samba</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--eprefix</tt><a name="INDEX-36"/><a name="INDEX-37"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install architecture-dependent files at the base directory specified.</p>
</td>
<td>
<p><em class="filename">/usr/local/samba</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--bindir</tt><a name="INDEX-38"/><a name="INDEX-39"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install user executables in the directory specified.</p>
</td>
<td>
<p><em class="replaceable">eprefix</em><em class="filename">/bin</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--sbindir</tt><a name="INDEX-40"/><a name="INDEX-41"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install administrator executables in the directory specified.</p>
</td>
<td>
<p><em class="replaceable">eprefix</em><em class="filename">/bin</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--libexecdir</tt><a name="INDEX-42"/><a name="INDEX-43"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install program executables in the directory specified.</p>
</td>
<td>
<p><em class="replaceable">eprefix</em><em class="filename">/libexec</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--datadir</tt><a name="INDEX-44"/><a name="INDEX-45"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install read-only architecture-independent data in the directory
specified.</p>
</td>
<td>
<p><em class="replaceable">prefix</em><em class="filename">/share</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--libdir</tt><a name="INDEX-46"/><a name="INDEX-47"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install program libraries in the directory specified.</p>
</td>
<td>
<p><em class="replaceable">eprefix</em><em class="filename">/lib</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--includedir</tt><a name="INDEX-48"/><a name="INDEX-49"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install package-include files in the directory specified.</p>
</td>
<td>
<p><em class="replaceable">prefix</em><em class="filename">/include</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--infodir</tt><a name="INDEX-50"/><a name="INDEX-51"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install additional information files in the directory specified.</p>
</td>
<td>
<p><em class="replaceable">prefix</em><em class="filename">/info</em></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">--mandir</tt><a name="INDEX-52"/><a name="INDEX-53"/>=<em class="replaceable">directory</em></p>
</td>
<td>
<p>Install manual pages in the directory specified.</p>
</td>
<td>
<p><em class="replaceable">prefix</em><em class="filename">/man</em></p>
</td>
</tr>

</table>

<p>Here is a sample execution of the
<em class="filename">configure</em><a name="INDEX-54"/>
script, which creates a Samba 2.2.6 makefile for the Linux platform.
Note that you must run the configure script in the
<em class="emphasis">source</em> directory and that we are showing you yet
another way to capture the output of the script:</p>

<blockquote><pre class="code">$ <tt class="userinput"><b>cd samba-2.2.6/source/</b></tt>
$ <tt class="userinput"><b>su</b></tt>
Password:
# <tt class="userinput"><b>./configure --with-smbwrapper --with-smbmount \</b></tt>
<tt class="userinput"><b>--with-msdfs --with-syslog --with-utmp 2&gt;&amp;1 | tee config.my.log</b></tt>
loading cache ./config.cache
checking for gcc... (cached) gcc
checking whether the C compiler (gcc -O ) works... yes
checking whether the C compiler (gcc -O ) is a cross-compiler... no
checking whether we are using GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for a BSD-compatible install... (cached) /usr/bin/install -c

<i class="lineannotation">...(content omitted)...</i>

checking configure summary
configure OK
creating ./config.status
creating include/stamp-h
creating Makefile
creating include/config.h</pre></blockquote>

<p>In general, any message from <em class="filename">configure</em> that
doesn't begin with the words
<tt class="literal">checking</tt><a name="INDEX-55"/> or
<tt class="literal">creating</tt><a name="INDEX-56"/> is an
<a name="INDEX-57"/>error; it often helps to redirect the
output of the configure script to a file so that you can quickly
search for errors, as we did with the <em class="filename">tee</em>
command earlier. If there was an error during configuration, more
detailed information about it can be found in the
<em class="filename">config.log</em><a name="INDEX-58"/> file, which is written to the local
directory by the <em class="filename">configure</em> script, as well as in
the <em class="filename">config.my.log</em> file, which we created by
piping through the <em class="filename">tee</em> command. These files are
very similar in both name and content, but be careful to check both
of them for error messages before continuing!</p>

<p>If the configuration works, you'll see a
<tt class="literal">checking</tt> <tt class="literal">configure</tt>
<tt class="literal">summary</tt> message followed by a
<tt class="literal">configure</tt> <tt class="literal">OK</tt> message and four
or five file-creation messages. So far, so good. <a name="INDEX-59"/></p>


</div>



<div class="sect1"><a name="samba2-CHP-2-SECT-4"/>

<h2 class="head1">Compiling and Installing Samba</h2>

<p><a name="INDEX-60"/><a name="INDEX-61"/><a name="INDEX-62"/><a name="INDEX-63"/>At this point you should be ready to build
the Samba executables. Compiling is also easy: in the
<em class="filename">source</em> directory, type <tt class="literal">make</tt>
on the command line. The
<em class="filename">make</em><a name="INDEX-64"/> utility will produce a stream of
explanatory and success messages, beginning with:</p>

<blockquote><pre class="code">Using FLAGS = -O -Iinclude ...</pre></blockquote>

<p>This build includes compiles for both <em class="emphasis">smbd</em> and
<em class="emphasis">nmbd</em> and ends in a linking command for
<em class="filename">bin/nmblookup</em>. For example, here is a sample
make of Samba Version 2.2.6 on a Linux server:</p>

<blockquote><pre class="code"># make 2&gt;&amp;1 | tee make.log
Using FLAGS =  -O  -Iinclude -I./include -I./ubiqx -I./smbwrapper -D_LARGEFILE64
_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE  -DLOGFILEBASE=&quot;/usr/local/samba/va
r&quot; -DCONFIGFILE=&quot;/usr/local/samba/lib/smb.conf&quot; -DLMHOSTSFILE=&quot;/usr/local/samba/
lib/lmhosts&quot;   -DSWATDIR=&quot;/usr/local/samba/swat&quot; -DSBINDIR=&quot;/usr/local/samba/bin
&quot; -DLOCKDIR=&quot;/usr/local/samba/var/locks&quot; -DCODEPAGEDIR=&quot;/usr/local/samba/lib/cod
epages&quot; -DDRIVERFILE=&quot;/usr/local/samba/lib/printers.def&quot; -DBINDIR=&quot;/usr/local/sa
mba/bin&quot;  -DHAVE_INCLUDES_H -DPASSWD_PROGRAM=&quot;/bin/passwd&quot; -DSMB_PASSWD_FILE=&quot;/u
sr/local/samba/private/smbpasswd&quot; -DTDB_PASSWD_FILE=&quot;/usr/local/samba/private/sm
bpasswd.tdb&quot;
Using FLAGS32 =  -O  -Iinclude -I./include -I./ubiqx -I./smbwrapper -D_LARGEFILE
64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE  -DLOGFILEBASE=&quot;/usr/local/samba/
var&quot; -DCONFIGFILE=&quot;/usr/local/samba/lib/smb.conf&quot; -DLMHOSTSFILE=&quot;/usr/local/samb
a/lib/lmhosts&quot;   -DSWATDIR=&quot;/usr/local/samba/swat&quot; -DSBINDIR=&quot;/usr/local/samba/b
in&quot; -DLOCKDIR=&quot;/usr/local/samba/var/locks&quot; -DCODEPAGEDIR=&quot;/usr/local/samba/lib/c
odepages&quot; -DDRIVERFILE=&quot;/usr/local/samba/lib/printers.def&quot; -DBINDIR=&quot;/usr/local/
samba/bin&quot;  -DHAVE_INCLUDES_H -DPASSWD_PROGRAM=&quot;/bin/passwd&quot; -DSMB_PASSWD_FILE=&quot;
/usr/local/samba/private/smbpasswd&quot; -DTDB_PASSWD_FILE=&quot;/usr/local/samba/private/
smbpasswd.tdb&quot;
Using LIBS = -ldl -lnsl -lpam
Compiling smbd/server.c
Compiling smbd/files.c
Compiling smbd/chgpasswd.c
Compiling smbd/connection.c
Compiling smbd/utmp.c
Compiling smbd/session.c
Compiling smbd/dfree.c
Compiling smbd/dir.c

<i class="lineannotation">...(content omitted)...</i>

Compiling rpc_server/srv_srvsvc.c
Compiling rpc_server/srv_srvsvc_nt.c
Compiling rpc_server/srv_util.c
Compiling rpc_server/srv_wkssvc.c
Compiling rpc_server/srv_wkssvc_nt.c
Compiling rpc_server/srv_pipe.c
Compiling rpc_server/srv_dfs.c
Compiling rpc_server/srv_dfs_nt.c
Compiling rpc_server/srv_spoolss.c
Compiling rpc_server/srv_spoolss_nt.c
Compiling lib/util_getent.c
Compiling rpc_parse/parse_lsa.c
Compiling rpc_parse/parse_net.c
Compiling rpc_parse/parsen/smbmount
Compiling client/smbmnt.c
Linking bin/smbmnt
Compiling client/smbumount.c
Linking bin/smbumount
Compiling utils/nmblookup.c
Linking bin/nmblookup</pre></blockquote>

<p>If you encounter a problem when compiling, first check the Samba
documentation to see if it is easily fixable. Another possibility is
to search or post to the Samba mailing lists, which are given at the
end of <a href="ch12.html">Chapter 12</a> and on the Samba home page. Most
compilation issues are system-specific and almost always easy to
overcome.</p>

<p>Now that the files have been compiled, you can install them into the
directories you identified with the command:</p>

<blockquote><pre class="code">#<tt class="userinput"><b> make install</b></tt></pre></blockquote>

<p>If you happen to be <a name="INDEX-65"/>upgrading, your old Samba files will be
saved with the extension
<em class="emphasis">.old</em>,<a name="INDEX-66"/> and you can go back to that previous
version with the command
<tt class="literal">make</tt><a name="INDEX-67"/> <tt class="literal">revert</tt>. After doing a
<tt class="literal">make</tt><a name="INDEX-68"/> <tt class="literal">install</tt>, you should
copy the <em class="emphasis">.old</em> files (if they exist) to a new
location or name. Otherwise, the next time you install Samba, the
original <em class="emphasis">.old</em> will be overwritten without
warning and you could lose your earlier version. If you configured
Samba to use the default locations for files, the new files will be
installed in the directories listed in <a href="ch02.html#samba2-CHP-2-TABLE-2">Table 2-2</a>.
Remember that you need to perform the installation from an account
that has write privileges on these target directories; this is
typically the root account.</p>

<a name="samba2-CHP-2-TABLE-2"/><h4 class="head4">Table 2-2. Samba installation directories</h4><table border="1">



<tr>
<th>
<p>Directory</p>
</th>
<th>
<p>Description</p>
</th>
</tr>


<tr>
<td>
<p><em class="emphasis">/usr/local/samba</em></p>
</td>
<td>
<p>Main tree</p>
</td>
</tr>
<tr>
<td>
<p><em class="emphasis">/usr/local/samba/bin</em></p>
</td>
<td>
<p>Binaries</p>
</td>
</tr>
<tr>
<td>
<p><em class="emphasis">/usr/local/samba/lib</em></p>
</td>
<td>
<p><em class="emphasis">smb.conf</em>, <em class="emphasis">lmhosts</em>,
configuration files, etc.</p>
</td>
</tr>
<tr>
<td>
<p><em class="emphasis">/usr/local/samba/man</em></p>
</td>
<td>
<p>Samba documentation</p>
</td>
</tr>
<tr>
<td>
<p><em class="emphasis">/usr/local/samba/private</em></p>
</td>
<td>
<p>Samba-encrypted password file</p>
</td>
</tr>
<tr>
<td>
<p><em class="emphasis">/usr/local/samba/swat</em></p>
</td>
<td>
<p>SWAT files</p>
</td>
</tr>
<tr>
<td>
<p><em class="emphasis">/usr/local/samba/var</em></p>
</td>
<td>
<p>Samba log files, lock files, browse list info, shared memory files,
process ID files</p>
</td>
</tr>

</table>

<p>Throughout the remainder of the book, we occasionally refer to the
location of the main tree as <em class="filename">/usr/local/samba</em>.
In most configurations, this is the base directory of the installed
Samba package; however, it can vary from system to system<em class="filename">
</em>.</p>

<a name="samba2-CHP-2-NOTE-90"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
<p>Watch out if you've made <em class="filename">/usr</em> a
read-only partition. You will want to put the logs, locks, and
password files somewhere else.</p>
</blockquote>

<p>Here is the installation that we performed on our machine. You can
see that we used <em class="filename">/usr/local/samba</em> as the base
directory for the distribution:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>make install 2&gt;&amp;1 | tee make-install.log</b></tt>
Using FLAGS =  -O  -Iinclude -I./include -I./ubiqx -I./smbwrapper -D_LARGEFILE64
_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE  -DLOGFILEBASE=&quot;/usr/local/samba/va
r&quot; -DCONFIGFILE=&quot;/usr/local/samba/lib/smb.conf&quot;

<i class="lineannotation">...(content omitted)...</i>

The binaries are installed. You can restore the old binaries (if there
were any) using the command &quot;make revert&quot;. You can uninstall the binaries
using the command &quot;make uninstallbin&quot; or &quot;make uninstall&quot; to uninstall
binaries, manpages and shell scripts.

<i class="lineannotation">...(content omitted)...</i>

======================================================================
The SWAT files have been installed. Remember to read the swat/README
for information on enabling and using SWAT.
======================================================================</pre></blockquote>

<p>If the last message is about SWAT, you've
successfully installed all the files. Congratulations! You now have
Samba on your system!</p>


<div class="sect2"><a name="samba2-CHP-2-SECT-4.1"/>

<h3 class="head2">Upgrading Your Installation</h3>

<p><a name="INDEX-70"/><a name="INDEX-71"/>Eventually a new version of
Samba will be released, and you will want to upgrade. This is simple;
just repeat the same steps you used to install your current version.
Download the source distribution from the Samba web site and install
it, then run the <tt class="literal">./configure</tt>,
<tt class="literal">make</tt>, and <tt class="literal">make</tt>
<tt class="literal">install</tt> commands as before. If
you've forgotten which options you used with the
<a name="INDEX-72"/><a name="INDEX-73"/><a name="INDEX-74"/><a name="INDEX-75"/><em class="emphasis">configure</em>
script, take a look at the
<em class="filename">source/config.status</em><a name="INDEX-76"/><a name="INDEX-77"/> file in your previous
version's source distribution. The first few lines
of this file show the options used the last time
<em class="emphasis">configure</em> was run.</p>

<p>When you run the <tt class="literal">make
install</tt><a name="INDEX-78"/> command to install your new
version, the files of the previous version are replaced with the new
ones, and then all you have to do is restart the Samba daemons to get
your new version running. See <a href="ch02.html#samba2-CHP-2-SECT-8">Section 2.8</a> later in this chapter for directions on how to do this.</p>


</div>


<div class="sect2"><a name="samba2-CHP-2-SECT-4.2"/>

<h3 class="head2">Reconfiguring Samba</h3>

<p><a name="INDEX-79"/>If you
have already compiled Samba and wish to recompile the same source
code with different <em class="emphasis">configure</em> options, you
should run the following three commands in the
<em class="emphasis">source</em> directory before rerunning the
<em class="emphasis">configure</em> script:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>autoconf</b></tt>
# <tt class="userinput"><b>make clean</b></tt>
# <tt class="userinput"><b>rm config.cache</b></tt></pre></blockquote>

<p>This ensures that you are starting with a clean slate and that your
previous <em class="emphasis">configure</em> command does not leave any
data around that can affect your new build. From here, you can rerun
<tt class="literal">./configure</tt> and then <tt class="literal">make</tt> and
<tt class="literal">make install</tt>.</p>


</div>


<div class="sect2"><a name="samba2-CHP-2-SECT-4.3"/>

<h3 class="head2">Setting Search Paths</h3>

<p><a name="INDEX-80"/>You
will probably want to run commands included in the Samba distribution
without having to specify their full directory paths. For that to
work, the directory in which the Samba executables are located,
<em class="filename">/usr/local/samba/bin</em> by default, must be added
to your shell's <a name="INDEX-81"/>PATH environment variable. This
environment variable is usually set in one or more of the
shell's startup files, which in the case of
<em class="emphasis">bash</em> are <em class="filename">/etc/profile</em>
(systemwide) and the <em class="filename">.bash_profile</em> and
<em class="filename">.bashrc</em> files in each user's
home directory.</p>

<p>To be able to read the <a name="INDEX-82"/><a name="INDEX-83"/><a name="INDEX-84"/>Samba manual pages using the
<em class="emphasis">man</em> command, the directory where
Samba's manual pages reside,
<em class="filename">/usr/local/samba/man</em> by default, must be in your
<a name="INDEX-85"/>MANPATH environment variable. On Red
Hat Linux, this can be accomplished by adding the following two lines
to <em class="filename">/etc/man.config</em>:</p>

<a name="INDEX-86"/><a name="INDEX-87"/><blockquote><pre class="code">
MANPATH            /usr/local/samba/man
MANPATH_MAP        /usr/local/samba/bin     /usr/local/samba/man</pre></blockquote>


</div>


</div>



<div class="sect1"><a name="samba2-CHP-2-SECT-5"/>

<h2 class="head1">Enabling SWAT</h2>

<p>The <a name="INDEX-88"/><a name="INDEX-89"/>Samba
Web Administration Tool (SWAT) runs as a daemon under
<em class="emphasis">inetd</em> or <em class="filename">xinetd </em>and
provides a forms-based editor in your web browser for creating and
modifying <a name="INDEX-90"/>Samba's
configuration file. For SWAT to work, entries must be added for it in
the <em class="filename">/etc/services</em> and
<em class="filename">/etc/inetd.conf</em> (or
<em class="filename">/etc/xinetd.d/swat) </em>configuration files. To add
the entries, follow these two steps:</p>

<ol><li>
<p>Check your <em class="filename">/etc/services</em> file, and if it does
not contain the following line, add it to the end of the file:</p>

<blockquote><pre class="code">swat   901/tcp</pre></blockquote>
</li>
<li>
<p>Now for <em class="filename">inetd </em><a name="INDEX-91"/>or <em class="filename">xinetd.
</em><a name="INDEX-92"/>These are &quot;Internet
super daemons&quot; that handle starting daemons on
demand, instead of letting them sit around in memory consuming system
resources. Most systems use <em class="filename">inetd, </em>but
<em class="filename">xinetd </em>is also used in some versions of Unix,
notably the Red Hat Linux (Versions 7 and newer) that we use in our
examples. You can use the <em class="emphasis">ps</em> command to see
which of the two your system is running.</p>
</li></ol>
<p>For <em class="filename">inetd, </em>add a line to the
<em class="emphasis">/etc/</em><em class="filename">inetd.conf </em>file.
(Check your <em class="filename">inetd.conf</em> manual page to see the
exact format of the<em class="filename"> inetd.conf</em> file if it
differs from the following example.) Don't forget to
change the path to the SWAT binary if you installed it in a different
location from the default <em class="filename">/usr/local/samba</em>:</p>

<blockquote><pre class="code">swat   stream  tcp  nowait  root  /usr/local/samba/bin/swat  swat</pre></blockquote>

<p>Then force <em class="filename">inetd</em> to reread its configuration
file by sending it a SIGHUP (hangup) signal:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>/bin/kill -HUP -a inetd</b></tt></pre></blockquote>

<p>Notice that we are using a version of the <em class="emphasis">kill</em>
command that supports the <em class="emphasis">-a</em> option, so as to
allow us to specify the process by name. On FreeBSD and Linux, you
can use the <em class="emphasis">killall</em> command<a name="FNPTR-2"/><a href="#FOOTNOTE-2">[2]</a> as follows:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>killall -HUP inetd</b></tt></pre></blockquote>

<p>If you are not running Linux or FreeBSD and your version of
<em class="emphasis">kill</em> doesn't have the
<em class="emphasis">-a</em> option, you will need to use the
<em class="emphasis">ps</em> command to find the process ID and then
supply that to <em class="emphasis">kill</em>:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>ps ax | grep inetd</b></tt>
  780 ?        S      0:00 inetd
 1981 pts/4    S      0:00 grep inetd                                         
# <tt class="userinput"><b>kill -HUP 780</b></tt></pre></blockquote>

<p>If your system is using <em class="filename">xinet, </em>add a file named
<em class="emphasis">swat</em> in your <em class="filename">/etc/xinetd.d
</em>directory, containing the following:</p>

<blockquote><pre class="code"># description: swat is the Samba Web Administration Tool, which
#       allows an administrator to configure Samba using a web
#       browser interface, with the URL http://localhost:901
service swat.
{
        socket_type             = stream
        wait                    = no
        protocol                = tcp
        only_from               = localhost
        user                    = root
        log_on_failure          += USERID
        server                  = /usr/local/samba/bin/swat
        port                    = 901
        disable                 = no
}</pre></blockquote>

<p>Then <em class="emphasis">xinetd</em> needs to be sent a signal<a name="FNPTR-3"/><a href="#FOOTNOTE-3">[3]</a> to make it reread its configuration files:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>/bin/kill -HUP -a xinetd</b></tt></pre></blockquote>

<p>And that's pretty much it for the installation.
Before you can start up Samba, however, you need to create a
configuration file for it.</p>


</div>



<div class="sect1"><a name="samba2-CHP-2-SECT-6"/>

<h2 class="head1">A Basic Samba Configuration File</h2>

<p><a name="INDEX-93"/>The
key to configuring Samba is its configuration file,
<em class="filename">smb.conf</em>. This configuration file can be very
simple or extremely complex, and the rest of this book is devoted to
helping you get deeply personal with this file. For now, however,
we'll show you how to set up a single file service,
which will allow you to fire up the Samba daemons and see that
everything is running as it should be. In later chapters, you will
see how to configure Samba for more complicated and interesting
tasks.</p>

<p>The installation process does not automatically create an
<em class="filename">smb.conf</em> configuration file, although several
example files are included in the Samba distribution. To test the
server software, though, we'll use the following
file, which you can create in a text editor. It should be named
<em class="filename">smb.conf</em> and placed in the
<em class="emphasis">/usr/local/samba/lib</em> directory:<a name="FNPTR-4"/><a href="#FOOTNOTE-4">[4]</a></p>

<blockquote><pre class="code">[global]
    workgroup = METRAN 
[test] 
    comment = For testing only, please
    path = /usr/local/samba/tmp
    read only = no
    guest ok = yes</pre></blockquote>

<p>This brief configuration file tells the Samba server to offer the
<em class="filename">/usr/local/samba/tmp</em> directory on the server as
an SMB share called <em class="emphasis">test</em>. The server also
becomes part of the METRAN workgroup, of which each client must also
be a part. If you have already chosen a name for your own workgroup,
use the name of your workgroup instead of METRAN in the previous
example. In case you are connecting your Samba system into an
existing network and need to know the workgroup name, you can ask
another system administrator or go to a Windows system in the
workgroup and follow these instructions:</p>

<ul><li>
<p>Windows 95/98/Me/NT: open the Control Panel, then double-click the
Network icon. Click the Identification tab, and look for the
&quot;Workgroup:&quot; label.</p>
</li><li>
<p>Windows 2000: open the Control Panel and double-click the System
icon. Click the Network Identification tab. The workgroup name will
appear below the computer name.</p>
</li><li>
<p>Windows XP: open the Control Panel in Classic View mode and
double-click the System icon. Then click the Computer Name tab.</p>
</li></ul>
<p>We'll use the <tt class="literal">[test]</tt> share in the
next chapter to set up the Windows clients. For now, you can complete
the setup by performing the following commands as root on your Unix
server:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>mkdir /usr/local/samba/tmp</b></tt>
# <tt class="userinput"><b>chmod 777 /usr/local/samba/tmp</b></tt></pre></blockquote>

<p>You might also want to put a file or two in the
<em class="filename">/usr/local/samba/tmp</em> directory so that after
your Windows systems are initially configured, you will have
something to use to check that everything works.</p>

<p>We should point out that in terms of system security, this is the
worst setup possible. For the moment, however, we only wish to test
Samba, so we'll leave security out of the picture.
In addition, we will encounter some encrypted password issues with
Windows clients later on, so this setup will afford us the least
amount of headaches.</p>


<div class="sect2"><a name="samba2-CHP-2-SECT-6.1"/>

<h3 class="head2">Encrypted Passwords</h3>

<p><a name="INDEX-94"/><a name="INDEX-95"/><a name="INDEX-96"/>If your Windows clients are using Windows
98 or Windows NT 4 Service Pack 3 or above (including Windows 2000
and Windows XP) and you are using a version of Samba earlier than
3.0, you must add the following entry to the
<tt class="literal">[global]</tt> section of the Samba configuration file:</p>

<blockquote><pre class="code">[global]
    encrypt passwords = yes</pre></blockquote>

<p>In addition, you must use the
<em class="filename">smbpasswd</em><a name="INDEX-97"/> program (typically located in the
directory <em class="filename">/usr/local/samba/bin/ </em>) to enter the
username/password combinations of the Samba users into
Samba's encrypted password database. For example, if
you wanted to allow Unix user <tt class="literal">steve</tt> to access
shares from a client system, you would use this command:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>smbpasswd -a steve</b></tt>
New SMB password:
Retype new SMB password:
Added user steve.</pre></blockquote>

<p>When the first user is added, the program will output a message
saying that the encrypted password database does not exist.
Don't worry: it will then create the database for
you. Make sure that the username/password combinations you add to the
encrypted database match the usernames and passwords you intend to
use on the Windows client side. You must run
<em class="emphasis">smbpasswd</em> for each client user.</p>

<p>In Samba 3.0, passwords are encrypted by default, so the
<tt class="literal">encrypt</tt> <tt class="literal">passwords</tt>
<tt class="literal">=</tt> <tt class="literal">yes</tt> parameter in the
configuration file is optional. However, you will still need to run
the <em class="emphasis">smbpasswd</em> command to add users to the
encrypted password file.</p>


</div>


<div class="sect2"><a name="samba2-CHP-2-SECT-6.2"/>

<h3 class="head2">Using SWAT</h3>

<p><a name="INDEX-98"/>Creating
a configuration file with SWAT is even easier than writing a
configuration file by hand. To invoke SWAT, use your web browser to
connect to <em class="emphasis">http://localhost:901</em>, and log on as
root with the root password, as shown in <a href="ch02.html#samba2-CHP-2-FIG-1">Figure 2-1</a>.</p>

<div class="figure"><a name="samba2-CHP-2-FIG-1"/><a name="INDEX-99"/><img src="figs/sam2_0201.gif"/></div><h4 class="head4">Figure 2-1. SWAT login</h4>

<p>After logging in, click the GLOBALS button at the top of the screen.
You should see the Global Variables page shown in <a href="ch02.html#samba2-CHP-2-FIG-2">Figure 2-2</a>.</p>

<div class="figure"><a name="samba2-CHP-2-FIG-2"/><img src="figs/sam2_0202.gif"/></div><h4 class="head4">Figure 2-2. SWAT Global Variables page</h4>

<p>In this example, notice that SWAT retrieved the workgroup name from
the <em class="emphasis">smb.conf</em> file that you created. (If it
didn't, go back and perform that step correctly.)
Make sure that the <tt class="literal">security</tt> field is set to
<tt class="literal">USER</tt>.</p>

<p>If you are running Samba 2.2 and your Windows clients are at least
Windows 98 or Windows NT 4 SP 3 or later versions, find
<tt class="literal">encrypt</tt> <tt class="literal">passwords</tt> in the
Security Options section and select <tt class="literal">yes</tt>.</p>

<p>The only other option you need to change from the menu is one
determining which system on the LAN resolves NetBIOS addresses; this
system is called the <em class="emphasis">WINS server</em>. At the very
bottom of the page, set the <tt class="literal">wins</tt>
<tt class="literal">support</tt> field to <tt class="literal">Yes</tt>, unless
you already have a WINS server on your network. If you do, put the
WINS server's IP address in the
<tt class="literal">wins</tt> <tt class="literal">server</tt> field instead. Then
return to the top of the screen, and press the Commit Changes button
to write the changes out to the <em class="emphasis">smb.conf</em> file.</p>

<p>Next, click the SHARES icon. You should see a page similar to <a href="ch02.html#samba2-CHP-2-FIG-3">Figure 2-3</a>. Select <tt class="literal">test</tt> (to the right
of the Choose Share button), and click the Choose Share button. You
will see the Share Parameters screen, as shown in <a href="ch02.html#samba2-CHP-2-FIG-3">Figure 2-3</a>, with the <tt class="literal">comment</tt> and
<tt class="literal">path</tt> fields filled in from your
<em class="emphasis">smb.conf</em> file.</p>

<div class="figure"><a name="samba2-CHP-2-FIG-3"/><img src="figs/sam2_0203.gif"/></div><h4 class="head4">Figure 2-3. SWAT Share Parameters screen</h4>

<p>If you specified that you want to use encrypted passwords on the
GLOBALS page, click the PASSWORD button. Near the top of the screen,
you will see the Server Password Management section. Enter your Unix
username and password in the spaces, and click the Add New User
button. This functions the same as the <em class="emphasis">smbpasswd</em>
utility and creates an entry in the
<em class="emphasis">/usr/local/samba/private/smbpasswd</em> file to allow
you to authenticate from a Windows client.</p>

<p>Now click the VIEW button at the top, and SWAT shows you the
following <em class="filename">smb.conf</em> file:</p>

<blockquote><pre class="code"># Samba config file created using SWAT
# from localhost (127.0.0.1)
# Date: 2002/09/05 04:56:43

# Global parameters
        workgroup = METRAN
        encrypt passwords = Yes
        wins support = Yes

[test]
        comment = For testing only!
        path = /usr/local/samba/tmp
        read only = No</pre></blockquote>

<p>Once this configuration file is completed, you can skip the next step
because the output of SWAT is guaranteed to be syntactically correct.
<a name="INDEX-100"/></p>


</div>


<div class="sect2"><a name="samba2-CHP-2-SECT-6.3"/>

<h3 class="head2">Disabling Oplocks</h3>

<p>The <em class="filename">smb.conf</em><a name="INDEX-101"/><a name="INDEX-102"/>
file you have just created is certainly good enough for the purpose
of initial setup and testing, and you can use it as a starting point
from which to develop the configuration of your production Samba
server. But before you get too far with that, we want to bring one
thing to your attention.</p>

<p>If you are the type of administrator who is highly concerned about
data integrity, you might want to make the following modification to
your <em class="filename">smb.conf</em> file before continuing:</p>

<blockquote><pre class="code">[global]
    oplocks = no</pre></blockquote>

<p>That is, use a text editor to add the line <tt class="literal">oplocks</tt>
<tt class="literal">=</tt> <tt class="literal">no</tt> to the
<tt class="literal">[global]</tt> section of your
<em class="filename">smb.conf</em> file. With this example, as with other
examples we will present throughout this book, you do not need to
enter the <tt class="literal">[global]</tt> line again in your
configuration file. We include it only to indicate in which section
the parameter belongs.</p>

<p>The <tt class="literal">oplocks</tt> <tt class="literal">=</tt>
<tt class="literal">no</tt> parameter disables opportunistic locking by
clients. This will result in significantly poorer performance, but
will help ensure that flaky Windows clients and/or unreliable network
hardware will not lead to corrupted files on the Samba server.</p>

<p>We will cover opportunistic locking (oplocks) in more detail in the
section &quot;Locks and Oplocks&quot; in
<a href="ch08.html">Chapter 8</a>, and recommend that you understand the
ideas presented there before implementing a production Samba server
that serves database files or other valuable data.</p>


</div>


<div class="sect2"><a name="samba2-CHP-2-SECT-6.4"/>

<h3 class="head2">Testing the Configuration File</h3>

<p><a name="INDEX-103"/>If you
didn't use SWAT to create your configuration file,
you should probably test it to ensure that it is syntactically
correct. It might seem silly to run a test program against an
eight-line configuration file, but it's good
practice for the real ones that we'll be writing
later on.</p>

<p>The test parser,
<em class="filename">testparm</em><a name="INDEX-104"/>, examines an
<em class="filename">smb.conf</em> file for syntax errors and reports any
it finds along with a list of the services enabled on your machine.
An example follows; you'll notice that in our haste
to get the server running we mistyped <tt class="literal">workgroup</tt> as
<tt class="literal">workgrp</tt> (the output is often lengthy, so we
recommend capturing it with the <em class="emphasis">tee</em> command):</p>

<blockquote><pre class="code">Load smb config files from smb.conf
Unknown parameter encountered: &quot;workgrp&quot;
Ignoring unknown parameter &quot;workgrp&quot;
Processing section &quot;[test]&quot;
Loaded services file OK.
Press Enter to see a dump of your service definitions
# Global parameters
[global]
    workgroup = WORKGROUP
    netbios name = 
    netbios aliases = 
    server string = Samba 2.2.6
    interfaces = 
    bind interfaces only = No

<i class="lineannotation">...(content omitted)...</i>

[test]
    comment = For testing only!
    path = /usr/local/samba/tmp
    read only = No</pre></blockquote>

<p>The interesting parts are at the top and bottom. The top of the
output will flag any syntax errors that you might have made, and the
bottom lists the services that the server thinks it should offer. A
word of advice: make sure you and the server have the same
expectations. <a name="INDEX-105"/></p>


</div>


</div>



<div class="sect1"><a name="samba2-CHP-2-SECT-7"/>

<h2 class="head1">Firewall Configuration</h2>

<p><a name="INDEX-106"/>As
with any services that run on TCP/IP, the SMB networking services
offered by Samba can be accessed from across the Internet unless your
organization's firewall is properly configured. The
following ports are used by Samba for SMB networking and SWAT:</p>

<dl>
<dt><b>Port 137</b></dt>
<dd>
<p>Used for NetBIOS network browsing</p>
</dd>



<dt><b>Port 138</b></dt>
<dd>
<p>Used for NetBIOS name service</p>
</dd>



<dt><b>Port 139</b></dt>
<dd>
<p>Used for file and printer sharing and other operations</p>
</dd>



<dt><b>Port 445</b></dt>
<dd>
<p>Used by Windows 2000/XP when NetBIOS over TCP/IP is disabled</p>
</dd>



<dt><b>Port 901</b></dt>
<dd>
<p>Used by SWAT</p>
</dd>

</dl>

<p>At the minimum, your organization's Internet
firewall should shut down all the ports in the list to traffic in
both directions. Do not assume that preventing incoming connections
is sufficient; there are cracks that trick Windows clients into
sending data out of the local area network and into the Internet by
SMB protocol, even from a local network that uses private IP
addresses not forwarded by routers. If you want SMB traffic to travel
across the Internet to remote sites, the best way is to use a virtual
private network (VPN). See the O'Reilly book,
<em class="citetitle">Virtual Private Networks</em>, for more information
on this subject.</p>

<p>In addition, you might wish to configure a firewall on the Samba host
system to keep SMB packets from traveling further than necessary
within your organization's network. For example,
port 901 can be shut down for remote accesses so that SWAT can be run
only on the Samba host system. If you are using Samba to serve only a
fraction of the client systems within your organization, consider
allowing SMB packets (i.e., packets on ports 137-139 and 445) to go
to or come from only those clients.</p>

<p>For more information on configuring firewalls, see the
O'Reilly book <em class="citetitle">Building Internet
Firewalls</em>.</p>


</div>



<div class="sect1"><a name="samba2-CHP-2-SECT-8"/>

<h2 class="head1">Starting the Samba Daemons</h2>

<p>Two Samba processes,
<em class="emphasis">smbd</em><a name="INDEX-107"/> and
<em class="emphasis">nmbd</em><a name="INDEX-108"/>, need to be running for Samba to work
correctly. There are three ways to start them:</p>

<ul><li>
<p>Manually</p>
</li><li>
<p>Automatically, during system boot</p>
</li><li>
<p>From <em class="emphasis">inetd or xinetd</em></p>
</li></ul>

<div class="sect2"><a name="samba2-CHP-2-SECT-8.1"/>

<h3 class="head2">Starting the Daemons Manually</h3>

<p><a name="INDEX-109"/><a name="INDEX-110"/>If you're in a
hurry, you can start the Samba daemons by hand. As root, simply enter
the following commands:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>/usr/local/samba/bin/smbd -D</b></tt>
# <tt class="userinput"><b>/usr/local/samba/bin/nmbd -D</b></tt></pre></blockquote>

<p>Samba will now be running on your system and is ready to accept
connections. However, keep in mind that if either of the daemons exit
for any reason (including system reboots), they will need to be
restarted manually.</p>


</div>


<div class="sect2"><a name="samba2-CHP-2-SECT-8.2"/>

<h3 class="head2">Automatic Startup</h3>

<p><a name="INDEX-111"/><a name="INDEX-112"/>To have the Samba daemons
started automatically when the system boots, you need to add the
commands listed in the previous section to your standard Unix startup
scripts. The exact method varies depending on the flavor of Unix
you're using.</p>


<div class="sect3"><a name="samba2-CHP-2-SECT-8.2.1"/>

<h3 class="head3">BSD Unix</h3>

<p><a name="INDEX-113"/><a name="INDEX-114"/><a name="INDEX-115"/>With a BSD-style Unix, you need to append
the following code to the <em class="filename">rc.local </em>file, which
is typically found in the <em class="filename">/etc</em> or
<em class="filename">/etc/rc.d</em> directories:</p>

<blockquote><pre class="code">if [ -x /usr/local/samba/bin/smbd]; then
    echo &quot;Starting smbd...&quot;
    /usr/local/samba/bin/smbd -D
    echo &quot;Starting nmbd...&quot;
    /usr/local/samba/bin/nmbd -D
fi</pre></blockquote>

<p>This code is very simple: it checks to see if the
<em class="filename">smbd</em> file exists and has execute permissions,
and if it does, it starts up both of the Samba daemons on system
boot.</p>


</div>



<div class="sect3"><a name="samba2-CHP-2-SECT-8.2.2"/>

<h3 class="head3">System V Unix</h3>

<p><a name="INDEX-116"/><a name="INDEX-117"/><a name="INDEX-118"/>With System V, things can get a little
more complex. Depending on your Unix version, you might be able to
get away with making a simple change to an
<em class="filename">rc.local</em> file as with BSD Unix, but System V
typically uses directories containing links to scripts that control
daemons on the system. Hence, you need to instruct the system how to
start and stop the Samba daemons. The first step to implement this is
to modify the contents of the <em class="filename">/etc/rc.d/init.d</em>
directory by adding something similar to the following shell script,
which for this example we will name <em class="filename">smb </em>:</p>

<blockquote><pre class="code">#!/bin/sh

# Check that the Samba configuration file exists
[ -f /usr/local/samba/lib/smb.conf ] || exit 0

start(  )
{
        echo -n &quot;Starting SMB services: &quot;
        /usr/local/samba/bin/smbd -D
        ERROR=$?
        echo

        echo -n &quot;Starting NMB services: &quot;
        /usr/local/samba/bin/nmbd -D
        ERROR2=$?
        if [ $ERROR2 -ne 0 ]
        then
                ERROR=1
        fi
        echo

        return $ERROR
}

stop(  )
{
        echo -n &quot;Shutting down SMB services: &quot;
        /bin/kill -TERM -a smbd
        ERROR=$?
        echo

        echo -n &quot;Shutting down NMB services: &quot;
        /bin/kill -TERM -a nmbd
        ERROR2=$?
        if [ $ERROR2 -ne 0 ]
        then
                ERROR=1
        fi
        echo

        return $ERROR
}

case &quot;$1&quot; in
  start)
        start
        ;;
  stop)
        stop
        ;;
  *)
        echo &quot;Usage: $0 {start|stop}&quot;
        exit 1
esac

exit $?</pre></blockquote>

<p>With this script, you can start and stop <em class="emphasis">smbd</em>
and <em class="emphasis">nmbd</em> like this:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>/etc/rc.d/init.d/smb start</b></tt>
Starting SMB services:
Starting NMB services:
# <tt class="userinput"><b>ps ax | grep mbd</b></tt>
 1268 ?        S      0:00 /usr/local/samba/bin/smbd -D
 1270 ?        S      0:00 /usr/local/samba/bin/nmbd -D
 1465 pts/2    S      0:00 grep mbd
# <tt class="userinput"><b>/etc/rc.d/init.d/smb stop</b></tt>
Shutting down SMB services:
Shutting down NMB services:</pre></blockquote>

<p>If you are having trouble writing a startup script for your system,
check to see if there is a packaged release of Samba (available from
your Unix vendor or the Samba FTP site). If so, you might be able to
extract a startup script from it to use as a starting point.
Typically, this script doesn't change much (if at
all) from release to release, so using a script from an older Samba
version should not be a problem. Another possibility is to check the
<em class="filename">packaging</em> directory in the Samba source
distribution. In that directory, there are subdirectories for many
Unix versions in which you can find a startup script for those
versions. Even if your version isn't included, you
can probably find a startup script for a similar version to use as a
starting point.</p>

<p>Finally, we need to add symbolic links to the
<em class="filename">smb</em> script in the
<em class="emphasis">/etc/rc.d/rcX.d</em> directories:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc3.d/S35smb</b></tt>
# <tt class="userinput"><b>ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc5.d/S35smb</b></tt>

# <tt class="userinput"><b>ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc0.d/K35smb</b></tt>
# <tt class="userinput"><b>ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc1.d/K35smb</b></tt>
# <tt class="userinput"><b>ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc2.d/K35smb</b></tt>
# <tt class="userinput"><b>ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc4.d/K35smb</b></tt>
# <tt class="userinput"><b>ln -s /etc/rc.d/init.d/smb /etc/rc.d/rc6.d/K35smb</b></tt></pre></blockquote>

<p>The first two commands, with link names starting with an
&quot;S&quot;, cause Samba to be started when
entering runlevels 3 or 5, which are the runlevels in which network
file sharing (NFS) is normally enabled. The second group of commands,
with link names starting with a
&quot;K&quot;, cause Samba to be shut down
when entering any of the other runlevels (0, 1, 2, 4, or 6).</p>

<p>The links starting with &quot;S&quot; are
used to start the daemons, and the links starting with
&quot;K&quot; are used for killing them. When
the runlevel is changed, the links starting with
&quot;K&quot; in the corresponding directory
(e.g., the <em class="filename">rc3.d</em> directory for runlevel 3) are
executed, followed by the links starting with
&quot;S&quot;. If we wanted, we could have
Samba restarted when switching between runlevels 3 and 5 by adding a
<em class="filename">K35smb</em> link to each <em class="filename">rc3.d</em>
and <em class="filename">rc5.d </em>directory.</p>

<p>The number after the K or S in the link names is used to set the
order in which all the daemons with links in the directory are
started or killed off. Get a long listing of the
<em class="emphasis">rc3.d</em> or <em class="emphasis">rc5.d</em> directories
to see how this is set up on your system. We use 35 to match the
behavior of Red Hat's Samba RPM package. The
important thing is to make sure when starting Samba that all services
it requires are started before it. When shutting down, it is a good
idea to shut down Samba before services it requires to avoid excess
error messages in the log files, but the order is not as crucial.</p>


</div>



<div class="sect3"><a name="samba2-CHP-2-SECT-8.2.3"/>

<h3 class="head3">Darwin and Mac OS X</h3>

<p><a name="INDEX-119"/><a name="INDEX-120"/><a name="INDEX-121"/><a name="INDEX-122"/>An installation of Samba is bundled with the
Darwin distribution, which is included in Mac OS X.<a name="FNPTR-5"/><a href="#FOOTNOTE-5">[5]</a> </p>

<p>The Samba daemons are started during system
boot by the script
<em class="filename">/System/Library/StartupItems/Samba/Samba</em>. To
trigger the execution of this script, edit the file
<em class="filename">/etc/hostconfig</em> and change the SMBSERVER
parameter to look like this:</p>

<blockquote><pre class="code">SMBSERVER=-YES-</pre></blockquote>

<p>On Mac OS X, the graphical user interface (GUI) provides an
alternative to using the command line. Launch the System Preferences
application, and select Sharing (see <a href="ch02.html#samba2-CHP-2-FIG-4">Figure 2-4</a>).
Under the Services tab, turn on Windows File Sharing. This will make
the aforementioned change to <em class="filename">/etc/hostconfig</em> and
immediately execute the startup item.</p>

<div class="figure"><a name="samba2-CHP-2-FIG-4"/><img src="figs/sam2_0204.gif"/></div><h4 class="head4">Figure 2-4. Mac OS X sharing preferences</h4>

<p>If you decide to install Samba yourself on Mac OS X,
it's best not to stomp on the installation provided
with the OS. Use the procedures detailed earlier in this chapter to
install the software into <em class="filename">/usr/local/samba</em> or
some other area unaffected by OS upgrades. (Remember to set up users
with <em class="emphasis">smbpasswd</em> if you're using
encrypted passwords, as described earlier in this chapter. This step
is handled automatically with entries in
<em class="filename">/var/db/samba/hash</em> if you're
using the built-in server on Mac OS X.) Once you've
got that working, you can edit the Samba startup item script to refer
to your installation, like this:</p>

<blockquote><pre class="code">    #!/bin/sh
    # Start Samba

    . /etc/rc.common

    if [ &quot;${SMBSERVER:=-NO-}&quot; = &quot;-YES-&quot; ]; then
        ConsoleMessage &quot;Starting SMB server&quot;

        if [ -f /usr/local/samba/lib/smb.conf ]; then
            /usr/local/samba/bin/smbd -D
            /usr/local/samba/bin/nmbd -D
        fi
    fi</pre></blockquote>

<p>However, beware of OS updates, which can wipe out your changes. One
solution is to make the script immutable, like this:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>chflags uchg /System/Library/StartupItems/Samba/Samba</b></tt></pre></blockquote>


</div>



<div class="sect3"><a name="samba2-CHP-2-SECT-8.2.4"/>

<h3 class="head3">Testing automatic startup</h3>

<p><a name="INDEX-123"/><a name="INDEX-124"/>If you can afford a few minutes of
downtime, reboot your system and again use the
<em class="emphasis">ps</em> command to check that the
<em class="emphasis">smbd</em> and <em class="emphasis">nmbd</em> daemons are
running. And if you are managing a 24/7 server, we highly recommend
that you find some downtime in which to reboot and perform this
check. Otherwise, your next unscheduled downtime might surprise you
with a mysterious absence of SMB networking services when the system
comes up again! <a name="INDEX-125"/><a name="INDEX-126"/></p>


</div>


</div>


<div class="sect2"><a name="samba2-CHP-2-SECT-8.3"/>

<h3 class="head2">Starting from inetd</h3>

<p><a name="INDEX-127"/><a name="INDEX-128"/><a name="INDEX-129"/>The <em class="emphasis">inetd</em>
<em class="emphasis"><a name="FNPTR-6"/><a href="#FOOTNOTE-6">[6]</a></em> daemon is a Unix
system's Internet &quot;super
daemon.&quot; It listens on ports defined in
<em class="filename">/etc/services</em> and executes the appropriate
program for each port, which is defined in
<em class="filename">/etc/inetd.conf</em>. The advantage of this scheme is
that you can have a large number of daemons ready to answer queries,
but they don't all have to be running all the time.
Instead, <em class="emphasis">inetd</em> listens for connection requests
and starts the appropriate daemon when it is needed. The penalty is a
small overhead cost of creating a new daemon process, as well as the
fact that you need to edit two files rather than one to set things
up. The <em class="emphasis">inetd</em> daemon is handy if you have only
one or two Samba users or your machine is running too many daemons
already. It's also easier to perform an upgrade
without disturbing an existing connection.</p>

<p>If you wish to start from <em class="filename">inetd</em>, first open
<em class="filename">/etc/services</em> in your text editor. If you
don't already have them defined, add the following
two lines:</p>

<blockquote><pre class="code">netbios-ssn     139/tcp
netbios-ns      137/udp</pre></blockquote>

<p>Next, edit <em class="filename">/etc/inetd.conf</em>. Look for the
following two lines and add them if they don't
exist. If you already have <tt class="literal">smbd</tt> and
<tt class="literal">nmbd</tt> lines in the file, edit them to point at the
new <em class="emphasis">smbd</em> and <em class="emphasis">nmbd</em>
you've installed. Your brand of Unix might use a
slightly different syntax in this file; use the existing entries and
the <em class="filename">inetd.conf </em> manual
page as a guide:</p>

<blockquote><pre class="code">netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd 
netbios-ns  dgram  udp wait   root /usr/local/samba/bin/nmbd nmbd</pre></blockquote>

<p>Finally, kill any <em class="emphasis">smbd</em> or
<em class="emphasis">nmbd</em> processes and send the
<em class="emphasis">inetd</em> process a hangup (HUP) signal to tell it
to reread its configuration file:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>/bin/kill -TERM -a smbd</b></tt>
# <tt class="userinput"><b>/bin/kill -TERM -a nmbd</b></tt>
# <tt class="userinput"><b>/bin/kill -HUP -a inetd</b></tt></pre></blockquote>

<p>After that, Samba should be up and running.</p>

<p>As we've pointed out before, Red Hat and perhaps
other Unix vendors supply <em class="emphasis">xinetd</em> rather than
<em class="emphasis">inetd</em>. If you need to use
<em class="emphasis">xinetd</em>, you will need to supply a configuration
file in the <em class="emphasis">/etc/xinetd.d</em> directory.
<a name="INDEX-130"/></p>


</div>


</div>



<div class="sect1"><a name="samba2-CHP-2-SECT-9"/>

<h2 class="head1">Testing the Samba Daemons</h2>

<p><a name="INDEX-131"/><a name="INDEX-132"/>We're
nearly done with the Samba server setup. All that's
left to do is to make sure everything is working as we think it
should. A convenient way to do this is to use the
<em class="filename">smbclient</em><a name="INDEX-133"/> program to examine what the server is
offering to the network. If everything is set up properly, you should
be able to do the following:</p>

<blockquote><pre class="code"># <tt class="userinput"><b>/usr/local/samba/bin/smbclient -U% -L localhost</b></tt>
added interface ip=172.16.1.1 bcast=172.16.1.255 nmask=255.255.255.0
Domain=[METRAN] OS=[Unix] Server=[Samba 2.2.6]

        Sharename      Type      Comment
        ---------      ----      -------
        test           Disk      For testing only, please
        IPC$           IPC       IPC Service (Samba 2.2.6)
        ADMIN$         Disk      IPC Service (Samba 2.2.6)
        
        Server               Comment
        ---------            -------
        TOLTEC               Samba 2.2.6 on toltec

        Workgroup            Master
        ---------            -------
        METRAN               TOLTEC</pre></blockquote>

<p>If there is a problem, don't panic! Try to start the
daemons manually, and check the system output or the debug files at
<em class="filename">/usr/local/samba/var/log.smb</em><a name="INDEX-134"/><a name="INDEX-135"/><a name="INDEX-136"/> to see if you can determine what happened.
If you think it might be a more serious problem, skip to <a href="ch12.html">Chapter 12</a> for help on troubleshooting the Samba daemons.</p>

<p>If it worked, congratulations! You now have successfully set up the
Samba server with a disk share. It's a simple one,
but we can use it to set up and test the Windows 95/98/Me and
NT/2000/XP clients in the next chapter. Then we will start making it
more interesting by adding services such as home directories,
printers, and security, and by seeing how to integrate the server
into a larger Windows domain. <a name="INDEX-137"/></p>


</div>

<hr/><h4 class="head4">Footnotes</h4><blockquote><a name="FOOTNOTE-1"/>
<p><a href="#FNPTR-1">[1]</a> <em class="emphasis">gcc</em> binaries are available for almost
every modern machine. See <a href="http://www.gnu.org/">http://www.gnu.org/</a> for a list of sites with
<em class="emphasis">gcc</em> and other GNU software.</p> <a name="FOOTNOTE-2"/> <p><a href="#FNPTR-2">[2]</a> Do
not confuse this with the Solaris <em class="emphasis">killall</em>
command, which performs part of the system shutdown sequence!</p>
<a name="FOOTNOTE-3"/>
<p><a href="#FNPTR-3">[3]</a> Depending on the version of <em class="emphasis">xinetd</em> you
have and how it was compiled, you might need to send a USR1 or some
other signal rather than the HUP signal. Check the manual page for
<em class="emphasis">xinetd (8)</em> on your system for details.</p>
<a name="FOOTNOTE-4"/>
<p><a href="#FNPTR-4">[4]</a> If you did not compile Samba, but instead downloaded a binary,
check with the documentation for the package to find out where it
expects the <em class="filename">smb.conf</em> file to be. Or, try running
the <em class="emphasis">testparm</em> program and look for the location
of <em class="filename">smb.conf</em> in the first line of output. If
Samba came preinstalled with your Unix system, an
<em class="filename">smb.conf</em> file is probably already somewhere on
your system.</p> <a name="FOOTNOTE-5"/>
<p><a href="#FNPTR-5">[5]</a> In this book, we cover Darwin Version 6.0 and OS X Version
10.2.</p> <a name="FOOTNOTE-6"/> <p><a href="#FNPTR-6">[6]</a> With early releases of Samba 2.2, there were reports
of intermittent errors when starting from <em class="emphasis">inetd</em>.
We provide this information so that it will be available for later
releases when the problem will hopefully have been identified and
corrected.</p> </blockquote>


<hr/><h4 class="head4"><a href="toc.html">TOC</a></h4>
</body></html>