summaryrefslogtreecommitdiff
path: root/docs-xml/using_samba/ch07.xml
blob: 9ecdae70495ccb810353944c0c59a37aac8dc3d7 (plain)
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
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
<chapter label="7" id="SAMBA-CH-7">
<title>Printing and Name Resolution</title>




<para>
<indexterm id="ch07-idx-956351-0" class="startofrange"><primary>printing</primary></indexterm>This chapter tackles two Samba topics: setting up printers for use with a Samba server and configuring Samba to use or become a Windows Internet Name Service (WINS) server. Samba allows client machines to send documents to printers connected to the Samba server. In addition, Samba can also assist you with printing Unix documents to a printer on a Windows machine. In the first part of this chapter, we will discuss how to get printers configured to work on either side.</para>


<para>In the second half of the chapter, we will introduce the Windows Internet Name Service, Microsoft's implementation of a NetBIOS Name Server (NBNS). As mentioned in <link linkend="ch01-48078">Chapter 1</link>, an NBNS allows machines to perform name resolution on a NetBIOS network without having to rely on broadcasts. Instead, each machine knows exactly where the WINS server is and can query it for the IP addresses of other machines on the network.</para>











<sect1 role="" label="7.1" id="ch07-61388">
<title>Sending Print Jobs to Samba</title>


<para>
<indexterm id="ch07-idx-956360-0" class="startofrange"><primary>printing</primary><secondary sortas="Samba">through Samba</secondary></indexterm>A printer attached to the Samba server shows up in the list of shares offered in the Network Neighborhood. If the printer is registered on the client machine and the client has the correct printer driver installed, the client can effortlessly send print jobs to a printer attached to a Samba server. <link linkend="ch07-35075">Figure 7.1</link> shows a Samba printer as it appears in the Network Neighborhood of a Windows client.</para>


<para>
<indexterm id="ch07-idx-956377-0"><primary>printing</primary><secondary>on a network, steps in</secondary></indexterm>
<indexterm id="ch07-idx-956377-1"><primary>networking</primary><secondary>printing on a network, steps in</secondary></indexterm>To administer printers with Samba, you should understand the basic process by which printing takes place on a network. Sending a print job to a printer on a Samba server involves four steps:</para>


<orderedlist>
<listitem><para>Opening and authenticating a connection to the printer share</para></listitem>
<listitem><para>Copying the file over the network</para></listitem>
<listitem><para>Closing the connection</para></listitem>
<listitem><para>Printing and deleting the copy of the file</para>


<figure label="7.1" id="ch07-35075">
<title>A Samba printer in the Network Neighborhood</title>

<graphic width="502" depth="171" fileref="figs/sam.0701.gif"></graphic>
</figure></listitem>
</orderedlist>

<para>When a print job arrives at a Samba server, the print data is temporarily written to disk in the directory specified by the <literal>path</literal> option of the printer share. Samba then executes a Unix print command to send that data file to the printer. The job is printed as the authenticated user of the share. Note that this may be the guest user, depending on how the share is configured.</para>


<sect2 role="" label="7.1.1" id="ch07-SECT-1.1">
<title>Print Commands</title>


<para>
<indexterm id="ch07-idx-956378-0"><primary>printing</primary><secondary>commands</secondary></indexterm>In order to print the document, you'll need to tell Samba what the command is to print and delete a file. On Linux, such a command is:</para>


<programlisting>lpr -r -P<replaceable>printer</replaceable> <replaceable>file</replaceable></programlisting>


<para>This tells <literal>lpr</literal> to copy the document to a spool area, usually <filename>/var/spool</filename>, retrieve the name of the printer in the system configuration file (<filename>/etc/printcap</filename>), and interpret the rules it finds there to decide how to process the data and which physical device to send it to. Note that because the <literal>-r</literal> option has been listed, the file specified on the command line will be deleted after it has been printed. Of course, the file removed is just a copy stored on the Samba server; the original file on the client is unaffected.</para>


<para>Linux uses a Berkeley (BSD) style of printing. However, the process is similar on System V Unix. Here, printing and deleting becomes a compound command:</para>


<programlisting>lp -d<replaceable>printer</replaceable> -s <replaceable>file</replaceable>; rm <replaceable>file</replaceable></programlisting>


<para>With System V, the <filename>/etc/printcap</filename> file is replaced with different set of configuration files hiding in <filename>/usr/spool/lp</filename>, and there is no option to delete the file. You have to do it yourself, which is why we have added the <literal>rm</literal> command afterward.</para>
</sect2>





<sect2 role="" label="7.1.2" id="ch07-SECT-1.2">
<title>Printing Variables</title>


<para>
<indexterm id="ch07-idx-956380-0"><primary>printing</primary><secondary>variables for</secondary></indexterm>Samba provides four variables specifically for use with <indexterm id="ch07-idx-956450-0" class="startofrange"><primary>printing</primary><secondary>configuration options</secondary></indexterm>printing configuration options. They are shown in <link linkend="ch07-29758">Table 7.1</link>.</para>


<table label="7.1" id="ch07-29758">
<title>Printing Variables </title>

<tgroup cols="2">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<thead>
<row>

<entry colname="col1"><para>Variable</para></entry>

<entry colname="col2"><para>Definition</para></entry>

</row>

</thead>

<tbody>
<row>

<entry colname="col1"><para><literal>%s</literal></para></entry>

<entry colname="col2"><para>The full pathname of the file on the Samba server to be printed</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>%f</literal></para></entry>

<entry colname="col2"><para>The name of the file itself (without the preceding path) on the Samba server to be printed</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>%p</literal></para></entry>

<entry colname="col2"><para>The name of the Unix printer to use</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>%j</literal></para></entry>

<entry colname="col2"><para>The number of the print job (for use with <literal>lprm</literal>, <literal>lppause</literal>, and <literal>lpresume</literal>)</para></entry>

</row>

</tbody>
</tgroup>
</table>
</sect2>





<sect2 role="" label="7.1.3" id="ch07-SECT-1.3">
<title>A Minimal Printing Setup</title>


<para>
<indexterm id="ch07-idx-956382-0" class="startofrange"><primary>printing</primary><secondary>configuration, minimal</secondary></indexterm>Let's start with a simple but illustrative printing share. Assuming that you're on a Linux system and you have a printer called <literal>lp</literal> listed in the printer capabilities file, the following addition to your <filename>smb.conf</filename>
<indexterm id="ch07-idx-956439-0"><primary>smb.conf (Samba configuration) file</primary><secondary>configuring printers</secondary></indexterm> file will make the printer accessible through the network:</para>


<programlisting>[printer1]
	printable = yes
	print command = /usr/bin/lpr -r  %s
	printer = lp
	printing = BSD
	read only = yes
	guest ok = yes</programlisting>


<para>This configuration allows anyone to send data to the printer, something we may want to change later. For the moment, what's important to understand is that the variable <literal>%s</literal> in the <literal>print</literal> <literal>command</literal> option will be replaced with the name of the file to be printed when Samba executes the command. Changing the <literal>print command</literal> to reflect a different style of Unix machine typically involves only replacing the right side of the <literal>print</literal> <literal>command</literal> option with whatever command you need for your system and changing the target of the <literal>printing</literal> option.</para>


<para>Let's look at the commands for a <indexterm id="ch07-idx-956440-0"><primary>System V Unix</primary><secondary>printer configuration for</secondary></indexterm>
<indexterm id="ch07-idx-956440-1"><primary>Unix</primary><secondary>System V</secondary><tertiary>printer configuration for</tertiary></indexterm>System V Unix. With variable substitution, the System V Unix command becomes:</para>


<programlisting>print command = lp -d%p -s %s; rm %s</programlisting>


<para>As mentioned earlier, the <literal>%p</literal> variable resolves to the name of the printer, while the <literal>%s</literal> variable resolves to the name of the file. After that, you can change the <literal>printing</literal> option to reflect that you're using a System V architecture:</para>


<programlisting>printing = SYSV</programlisting>


<para>If you are using <indexterm id="ch07-idx-956441-0"><primary>share-level security</primary><secondary>printing and guest accounts</secondary></indexterm>share-level security, pay special attention to the guest account used by Samba. The typical setting, <literal>nobody</literal>, may not be allowed to print by the operating system. If that's true for your operating system, you should place a <literal>guest</literal> <literal>account</literal> option under the <indexterm id="ch07-idx-956445-0"><primary>print shares</primary></indexterm>printing share (or even perhaps the global share) specifying an account that can. A popular candidate with the Samba authors is the <literal>ftp</literal> account, which is often preconfigured to be safe for untrusted guest users. You can set it with the following command:</para>


<programlisting>guest account = ftp</programlisting>


<para>Another common printing issue is that clients may need to request the status of a <indexterm id="ch07-idx-956443-0"><primary>printing</primary><secondary>print jobs</secondary></indexterm>print job sent to the Samba server. Samba will not reject a document from being sent to an already busy printer share. Consequently, Samba needs the ability to communicate not only the status of the current printing job to the client, but also which documents are currently waiting to be printed on that printer. Samba also has to provide the client the ability to pause print jobs, resume print jobs, and remove print jobs from the printing queue. Samba provides options for each of these tasks. As you might expect, they borrow functionality from existing Unix commands. The options are:</para>


<itemizedlist>
<listitem><para><literal>lpq command</literal></para></listitem>
<listitem><para><literal>lprm command</literal></para></listitem>
<listitem><para><literal>lppause command</literal></para></listitem>
<listitem><para><literal>lpresume command</literal></para></listitem>
</itemizedlist>

<para>We will cover these options in more detail below. For the most part, however, the value of the <literal>printing</literal> configuration option will determine their values, and you should not need to alter the default values of these options.</para>


<para>Here are a few important items to remember about printing shares:</para>


<itemizedlist>
<listitem><para>You must put <literal>printable</literal> <literal>=</literal> <literal>yes</literal> in all printer shares (even <literal>[printers]</literal>), so that Samba will know that they are printer shares. If you forget, the shares will not be usable for printing and will instead be treated as disk shares.</para></listitem>
<listitem><para>If you set the <literal>path</literal> configuration option in the printer section, any files sent to the printer(s) will be copied to the directory you specify instead of to the default location of <filename>/tmp</filename>. As the amount of disk space allocated to <filename>/tmp</filename> can be relatively small in some Unix operating systems, many administrators opt to use <filename>/var/spool</filename> or some other directory instead.</para></listitem>
<listitem><para>The <literal>read only</literal> option is ignored for printer shares.</para></listitem>
<listitem><para>If you set <literal>guest</literal> <literal>ok</literal> <literal>=</literal> <literal>yes</literal> in a printer share and Samba is configured for share-level security, it will allow anyone to send data to the printer as the <literal>guest</literal> <literal>account</literal> user.</para></listitem>
</itemizedlist>

<para>Using one or more Samba machines as a print server gives you a great deal of flexibility on your LAN. You can easily partition your available printers, restricting some to members of one department, or you can maintain a bank of printers available to all. In addition, you can restrict a printer to a selected few by adding the trusty <literal>valid</literal> <literal>users</literal> option to its share definition:</para>


<programlisting>[deskjet]
	printable = yes
	path = /var/spool/samba/print
	valid users = gail sam</programlisting>


<para>All of the other share accessibility options defined in the previous chapter should work for printing shares as well. Since the printers themselves are accessed through Samba by name, it's also simple to delegate print services among several servers using familiar Unix commands for tasks such as load balancing or maintenance.<indexterm id="ch07-idx-956385-0" class="endofrange" startref="ch07-idx-956382-0"/></para>
</sect2>





<sect2 role="" label="7.1.4" id="ch07-SECT-1.4">
<title>The [printers] Share</title>


<para>
<indexterm id="ch07-idx-956390-0"><primary>print shares</primary></indexterm><link linkend="ch04-21486">Chapter 4</link>, briefly introduced <literal>[printers]</literal>, a special share for automatically creating printing services. Let's review how it works: if you create a share named <literal>[printers]</literal> in the configuration file, Samba will automatically read in your printer capabilities file and create a printing share for each printer that appears in the file. For example, if the Samba server had <literal>lp</literal>, <literal>pcl</literal> and <literal>ps</literal> printers in its printer capabilities file, Samba would provide three printer shares with those names, each configured with the options in the <literal>[printers]</literal> share.</para>


<para>
<indexterm id="ch07-idx-956509-0"><primary>print shares</primary><secondary>created by Samba</secondary></indexterm>Recall that Samba obeys following rules when a client requests a share that has not been created through the <filename>smb.conf</filename> file:</para>


<itemizedlist>
<listitem><para>If the share name matches a username in the system password file and a <literal>[homes]</literal> share exists, a new share is created with the name of the user and is initialized using the values given in the <literal>[homes]</literal> and <literal>[global]</literal> sections.</para></listitem>
<listitem><para>Otherwise, if the name matches a printer in the system printer capabilities file, and a <literal>[printers]</literal> share exists, a new share is created with the name of the printer and initialized using the values given in the <literal>[printers]</literal> section. (Variables in the <literal>[global]</literal> section do not apply here.)</para></listitem>
<listitem><para>If neither of those succeed, Samba looks for a <literal>default</literal> <literal>service</literal> share. If none is found, it returns an error.</para></listitem>
</itemizedlist>

<para>This brings to light an important point: be careful that you do not give a <indexterm id="ch07-idx-956508-0"><primary>printers</primary><secondary>names</secondary><tertiary>caution with</tertiary></indexterm>printer the same name as a user. Otherwise, you will end up connecting to a disk share when you may have wanted a printer share instead.</para>


<para>Here is an example <literal>[printers]</literal> share for a Linux (BSD) system. Some of these options are already defaults; however, we have listed them anyway for illustrative purposes:</para>


<programlisting>[global]
	printing = BSD
	print command = /usr/bin/lpr -P%p -r %s
	printcap file = /etc/printcap
	min print space = 2000

[printers]
	path = /usr/spool/public
	printable = true
	guest ok = true
	guest account = pcguest</programlisting>


<para>Here, we've given Samba global options that specify the printing type (BSD), a print command to send data to the printer and remove a temporary file, our default printer capabilities file, and a minimum printing space of 2 megabytes.</para>


<para>In addition, we've created a <literal>[printers]</literal> share for each of the system printers. Our temporary spooling directory is specified by the <literal>path</literal> option: <filename>/usr/spool/public</filename>. Each of the shares is marked as printable&mdash;this is necessary, even in the <literal>[printers]</literal> section. The two <literal>guest</literal> options are useful in the event that Samba is using share-level security: we allow guest access to the printer and we specify the guest user that Samba should use to execute print commands.</para>
</sect2>





<sect2 role="" label="7.1.5" id="ch07-SECT-1.5">
<title>Test Printing</title>


<para>
<indexterm id="ch07-idx-956391-0"><primary>printing</primary><secondary>test for</secondary></indexterm>Here is how you can test printing from the Samba server. Let's assume the most complex case and use a guest account. First, run the Samba <emphasis>testparm</emphasis> command on your configuration file that contains the print shares, as we did in <link linkend="SAMBA-CH-2">Chapter 2</link>. This will tell you if there are any syntactical problems with the configuration file. For example, here is what you would see if you left out the <literal>path</literal> configuration option in the previous example:</para>


<programlisting># testparm
Load smb config files from /usr/local/samba/lib/smb.conf
Processing configuration file "/usr/local/samba/lib/smb.conf"
Processing section "[global]"
Processing section "[homes]"
Processing section "[data]"
Processing section "[printers]"
No path in service printers - using /tmp
Loaded services file OK.
Press enter to see a dump of your service definitions
Global parameters:
	load printers: Yes
	printcap name: /etc/printcap
Default service parameters:
	guest account: ftp
	min print space: 0
	print command: lpr -r -P%p %s
	lpq command: lpq -P%p
	lprm command: lprm -P%p %j
lppause command:
	lpresume command:
 Service parameters [printers]:
	path: /tmp
	print ok: Yes
	read only: true
	public: true</programlisting>


<para>Second, try the command <literal>testprns</literal> <replaceable>printername</replaceable>. This is a simple program that verifies that the specified printer is available in your <emphasis>printcap</emphasis> file. If your <emphasis>printcap</emphasis> file is not in the usual place, you can specify its full pathname as the second argument to the <emphasis>testprns</emphasis> command:</para>


<programlisting># testprns lp /etc/printcap
Looking for printer lp in printcap file /etc/printcap
Printer name lp is valid.</programlisting>


<para>Next, log on as the guest user, go to the spooling directory, and ensure that you can print using the same command that <emphasis>testparm</emphasis> says Samba will use. As mentioned before, this will tell you if you need to change the guest account, as the default account may not be allowed to print.</para>


<para>Finally, print something to the Samba server via <literal>smbclient</literal>, and see if the following actions occur:</para>


<itemizedlist>
<listitem><para>The job appears (briefly) in the Samba spool directory specified by the path.</para></listitem>
<listitem><para>The job shows up in your print systems spool directory.</para></listitem>
<listitem><para>The job disappears from the spool directory that Samba used.</para></listitem>
</itemizedlist>

<para>If <emphasis>smbclient</emphasis> cannot print, you can reset the <literal>print</literal> <literal>command</literal> option to collect debugging information:</para>


<programlisting>print command = /bin/cat %s &gt;&gt;/tmp/printlog; rm %s</programlisting>


<para>or:</para>


<programlisting>print command = echo "printed %s on %p" &gt;&gt;/tmp/printlog</programlisting>


<para>A common problem with Samba printer configuration is forgetting to use the full <indexterm id="ch07-idx-956511-0"><primary>pathnames</primary><secondary>printer configuration and</secondary></indexterm>
<indexterm id="ch07-idx-956511-1"><primary>printing</primary><secondary>pathnames used in comands for</secondary></indexterm>pathnames for commands; simple commands often don't work because the guest account's PATH doesn't include them. Another frequent problem is not having the correct <indexterm id="ch07-idx-956512-0"><primary>permissions</primary><secondary sortas="printing">for printing</secondary></indexterm>
<indexterm id="ch07-idx-956512-1"><primary>printing</primary><secondary>permissions for</secondary></indexterm>permissions on the spooling directory.<indexterm id="ch07-idx-956494-0" class="endofrange" startref="ch07-idx-956450-0"/></para>


<tip role="ora">
<para>
<indexterm id="ch07-idx-956514-0"><primary>resources for further information</primary><secondary>printers, debuggiing</secondary></indexterm>
<indexterm id="ch07-idx-956514-1"><primary>printing</primary><secondary>resources for information on debugging</secondary></indexterm>There is more information on debugging printers in the Samba documentation (<filename>Printing.txt</filename>). In addition, the Unix print systems are covered in detail in AEleen Frisch's <emphasis>Essential Systems Administration</emphasis> (published by O'Reilly).</para>

</tip>
</sect2>





<sect2 role="" label="7.1.6" id="ch07-SECT-1.6">
<title>Setting Up and Testing a Windows Client</title>


<para>
<indexterm id="ch07-idx-956392-0"><primary>printing</primary><secondary>Windows client printers</secondary><tertiary>setting up and testing</tertiary></indexterm>
<indexterm id="ch07-idx-956392-1"><primary>Windows clients</primary><secondary>printers for, setting up and testing</secondary></indexterm>Now that Samba is offering a workable printer, you need to set it up on a Windows client. Look at the Samba server in the Network Neighborhood. It should now show each of the printers that are available. For example, in <link linkend="ch07-35075">Figure 7.1</link>, we saw a printer called <literal>lp</literal>.</para>


<para>Next, you need to have the Windows client recognize the printer. Double-click on the printer icon to get started. If you try to select an uninstalled printer (as you just did), Windows will ask you if it should help configure it for the Windows system. Respond "Yes," which will open the Printer Wizard.</para>


<para>The first thing the wizard will ask is whether you need to print from DOS.  Let's assume you don't, so choose No and press the Next button to get to the manufacturer/model window as shown in <link linkend="ch07-60084">Figure 7.2</link>.</para>


<figure label="7.2" id="ch07-60084">
<title>A printer in the Network Neighborhood</title>

<graphic width="502" depth="128" fileref="figs/sam.0702.gif"></graphic>
</figure>

<para>In this dialog box, you should see a large list of manufacturers and models for almost every printer imaginable. If you don't see your printer on the list, but you know it's a PostScript printer, select Apple as the manufacturer and Apple LaserWriter as the model. This will give you the most basic Postscript printer setup, and arguably one of the most reliable. If you already have any Postscript printers attached, you will be asked about replacing or reusing the existing driver. Be aware that if you replace it with a new one, you may make your other printers fail. Therefore, we recommend you keep using your existing printer drivers as long as they're working properly.</para>


<para>Following that, the Printer Wizard will ask you to name the printer. <link linkend="ch07-69466">Figure 7.3</link> shows this example, where the name has defaulted to our second laserwriter. Here, you rename it from Apple Laserwriter (Copy 2) to "ps on Samba server," so you know where to look for the printouts. In reality, you can name the printer anything you want.</para>


<figure label="7.3" id="ch07-69466">
<title>Printer manufacturers and models</title>

<graphic width="502" depth="296" fileref="figs/sam.0703.gif"></graphic>
</figure>

<para>Finally, the Printing Wizard asks if it should print a test page. Click on Yes, and you should be presented with the dialog in <link linkend="ch07-43374">Figure 7.4</link>.</para>


<figure label="7.4" id="ch07-43374">
<title>Printing successfully completed</title>

<graphic width="502" depth="232" fileref="figs/sam.0704.gif"></graphic>
</figure>

<para>If the test printing was unsuccessful, press the No button in <link linkend="ch07-43374">Figure 7.4</link> and the Printing Wizard will walk you through some debugging steps for the client side of the process. If the test printing does work, congratulations! The remote printer will now be available to all your PC applications through the File and Print menu items.</para>
</sect2>





<sect2 role="" label="7.1.7" id="ch07-30008">
<title>Automatically Setting Up Printer Drivers</title>


<para>
<indexterm id="ch07-idx-956393-0" class="startofrange"><primary>printing</primary><secondary>drivers for, setting up</secondary></indexterm>The previous section described how to manually configure a printer driver for your Windows system. As a system administrator, however, you can't always guarantee that users can perform such a process without making mistakes. Luckily, however, you can ask Samba to automatically set up the printer drivers for a specific printer.</para>


<para>Samba has three options that can be used to automatically set up printer drivers for clients who are connecting for the first time. These options are <literal>printer</literal> <literal>driver</literal>, <literal>printer</literal> <literal>driver</literal> <literal>file</literal>, and <literal>printer</literal> <literal>driver</literal> <literal>location</literal>. This section explains how to use these options to allow users to skip over the Manufacturer dialog in the Add Printer Wizard above.</para>


<tip role="ora">
<para>For more information on how to do this, see the <filename>PRINTER_DRIVER.TXT</filename> file in the Samba distribution documentation.</para>

</tip>

<para>There are four major steps:</para>


<orderedlist>
<listitem><para>Install the drivers for the printer on a Windows client (the printer need not be attached).</para></listitem>
<listitem><para>Create a printer definition file from the information on a Windows machine.</para></listitem>
<listitem><para>Create a <literal>PRINTER$</literal> share where the resulting driver files can be placed.</para></listitem>
<listitem><para>Modify the Samba configuration file accordingly.</para></listitem>
</orderedlist>

<para>Let's go over each of the four steps in greater detail.</para>


<sect3 role="" label="7.1.7.1" id="ch07-SECT-1.7.1">
<title>Install the drivers on a windows client</title>


<para>Use <indexterm id="ch07-idx-956517-0"><primary>Windows 95/98</primary><secondary>printer drivers, installing</secondary></indexterm>Windows 95/98 for this step. It doesn't matter which client you choose, as long as it has the ability to load the appropriate drivers for the printer. In fact, you don't even need to have the printer attached to the machine. All you're interested in here is getting the appropriate driver files into the Windows directory. First, go to the Printers window of My Computer and double-click on the Add Printer icon, as shown in <link linkend="ch07-52397">Figure 7.5</link>.</para>


<figure label="7.5" id="ch07-52397">
<title>The Printers window</title>

<graphic width="502" depth="223" fileref="figs/sam.0705.gif"></graphic>
</figure>

<para>At this point, you can follow the Add Printer Wizard dialogs through to select the manufacturer and model of the printer in question. If it asks you if you want to print from MS-DOS, answer No. Windows should load the appropriate driver resources from its CD-ROM and ask you if you want to print a test page. Again, respond No and close the Add Printer Wizard dialog.</para>
</sect3>



<sect3 role="" label="7.1.7.2" id="ch07-SECT-1.7.2">
<title>Create a printer definition file</title>


<para>You can create a <indexterm id="ch07-idx-956518-0"><primary>printing</primary><secondary>printer definition file</secondary></indexterm>printer definition file by using the <filename>make_ printerdef</filename> script in the <filename>/usr/local/samba/bin</filename> directory. In order to use this script, you need to copy over the following four files from a Windows client:<footnote label="1" id="ch07-pgfId-951615">


<para>Older Windows 95 clients may have only the first two files.</para>


</footnote></para>


<simplelist>

<member><emphasis>C:\WINDOWS\INF\MSPRINT.INF</emphasis></member>

<member><emphasis>C:\WINDOWS\INF\MSPRINT2.INF</emphasis></member>

<member><emphasis>C:\WINDOWS\INF\MSPRINT3.INF</emphasis></member>

<member><emphasis>C:\WINDOWS\INF\MSPRINT4.INF</emphasis></member>

</simplelist>


<para>Once you have the four files, you can create a printer definition file using the appropriate printer driver and its .INF file. If the printer driver starts with the letters A-K, use either the <emphasis>MSPRINT.INF</emphasis> file or the <emphasis>MSPRINT3.INF</emphasis> file. If it begins with the letters L-Z, use the <emphasis>MSPRINT2.INF</emphasis> file or the <emphasis>MSPRINT4.INF</emphasis> file. You may need to <emphasis>grep</emphasis> through each of the files to see where your specific driver is. For the following example, we have located our driver in <emphasis>MSPRINT3.INF</emphasis> and created a printer definition file for a HP DeskJet 560C printer:</para>


<programlisting>$grep "HP DeskJet 560C Printer" MSPRINT.INF MSPRINT3.INF
MSPRINT3.INF: "HP DeskJet 560C Printer"=DESKJETC.DRV,HP_DeskJet_ ...

$make_printerdef MSPRINT3.INF "HP DeskJet 560C Printer" &gt;printers.def
FOUND:DESKJETC.DRV
End of section found
CopyFiles: DESKJETC,COLOR_DESKJETC
Datasection: (null)
Datafile: DESKJETC.DRV
Driverfile: DESKJETC.DRV
Helpfile: HPVDJC.HLP
LanguageMonitor: (null)

Copy the following files to your printer$ share location:
DESKJETC.DRV
HPVCM.HPM
HPVIOL.DLL
HPVMON.DLL
HPVRES.DLL
HPCOLOR.DLL
HPVUI.DLL
HPVDJCC.HLP
color\HPDESK.ICM</programlisting>


<para>Note the files that the script asks you to copy. You'll need those for the next step.</para>
</sect3>



<sect3 role="" label="7.1.7.3" id="ch07-SECT-1.7.3">
<title>Create a PRINTER$ share</title>


<para>
<indexterm id="ch07-idx-956525-0"><primary>PRINTER$ share, creating</primary></indexterm>This part is relatively easy. Create a share called <literal>[PRINTER$]</literal> in your <filename>smb.conf</filename> that points to an empty directory on the Samba server. Once that is done, copy over the files that the <filename>make_ printerdef</filename> script requested of you into the location of the <literal>path</literal> configuration option for the <literal>[PRINTER$]</literal> share. For example, you can put the following in your configuration file:</para>


<programlisting>[PRINTER$]
	path = /usr/local/samba/print
	read only = yes
	browsable = no
	guest ok = yes</programlisting>


<para>The files requested by the <filename>make_ printerdef</filename> script are typically located in the <emphasis>C:\WINDOWS\SYSTEM</emphasis> directory, although you can use the following commands to find out exactly where they are:</para>


<programlisting>cd C:\WINDOWS
dir <replaceable>filename</replaceable> /s</programlisting>


<para>In this case, each of the files needs to be copied to the <filename>/usr/local/samba/print</filename> directory on the Samba server. In addition, copy the <filename>printers.def</filename> file that you created over to that share as well. Once you've done that, you're almost ready to go.</para>
</sect3>



<sect3 role="" label="7.1.7.4" id="ch07-SECT-1.7.4">
<title>Modify the Samba configuration file</title>


<para><filename></filename>
<indexterm id="ch07-idx-956532-0"><primary>smb.conf (Samba configuration) file</primary><secondary>modifying for printer drivers</secondary></indexterm>The last step is to modify the Samba configuration file by adding the following three options:</para>


<itemizedlist>
<listitem><para><literal>printer</literal> <literal>driver</literal></para></listitem>
<listitem><para><literal>printer</literal> <literal>driver</literal> <literal>file</literal></para></listitem>
<listitem><para><literal>printer</literal> <literal>driver</literal> <literal>location</literal></para></listitem>
</itemizedlist>

<para>The <literal>printer</literal> <literal>driver</literal> <literal>file</literal> is a global option that points to the <filename>printers.def</filename> file; place that option in your <literal>[global]</literal> section. The other options should be set in the printer share for which you wish to automatically configure the drivers. The value for <literal>printer</literal> <literal>driver</literal> should match the string that shows up in the Printer Wizard on the Windows system. The value of the <literal>printer</literal> <literal>driver</literal> <literal>location</literal> is the pathname of the PRINTER$ share you set up, not the Unix pathname on the server. Thus, you could use the following:</para>


<programlisting>[global]
	printer driver file = /usr/local/samba/print/printers.def
[hpdeskjet]
	path = /var/spool/samba/printers
	printable = yes

	printer driver = HP DeskJet 560C Printer
	printer driver location = \\%L\PRINTER$</programlisting>


<para>Now you're ready to test it out. At this point, remove the Windows printer that you "set up" in the first step from the list of printers in the Printers window of My Computer. If Samba asks you to delete unneeded files, do so. These files will be replaced shortly on the client, as they now exist on the Samba server.</para>
</sect3>



<sect3 role="" label="7.1.7.5" id="ch07-SECT-1.7.5">
<title>Testing the configuration</title>


<para>Restart the Samba daemons and look for the <literal>[hpdeskjet]</literal> share under the machine name in the Network Neighborhood. At this point, if you click on the printer icon, you should begin the printer setup process and come to the dialog shown in <link linkend="ch07-60108">Figure 7.6</link>.</para>


<para>This is different from the dialog you saw earlier when setting up a printer. Essentially, the dialog is asking if you wish to accept the driver that is "already installed"&mdash;in other words, offered by Samba. Go ahead and keep the existing driver, and press the Next button. At this point, you can give the printer a name and print out a test page. If it works, the setup should be complete. You should be able to repeat the process now from any Windows<indexterm id="ch07-idx-956413-0" class="endofrange" startref="ch07-idx-956393-0"/> client. <indexterm id="ch07-idx-956407-0" class="endofrange" startref="ch07-idx-956360-0"/></para>


<figure label="7.6" id="ch07-60108">
<title>Automatically configuring the printer driver</title>

<graphic width="502" depth="296" fileref="figs/sam.0706.gif"></graphic>
</figure>
</sect3>
</sect2>
</sect1>









<sect1 role="" label="7.2" id="ch07-31526">
<title>Printing to Windows Client Printers</title>


<para>
<indexterm id="ch07-idx-956368-0" class="startofrange"><primary>printing</primary><secondary>Windows client printers</secondary><tertiary>printing to</tertiary></indexterm>If you have printers connected to clients running Windows 95/98 or NT 4.0, those printers can also be accessed from Samba. Samba comes equipped with a tool called <emphasis>smbprint</emphasis>
<indexterm id="ch07-idx-956539-0"><primary>smbprint tool, spooling print jobs</primary></indexterm>
<indexterm id="ch07-idx-956539-1"><primary>printing</primary><secondary>print jobs</secondary><tertiary>spooling with smbprint tool</tertiary></indexterm> that can be used to spool print jobs to Windows-based printers. In order to use this, however, you need to set up the printer as a shared resource on the client machine. If you haven't already done this, you can reset this from the Printers window, reached from the Start button, as shown in <link linkend="ch07-32814">Figure 7.7</link>.</para>


<figure label="7.7" id="ch07-32814">
<title>The Printers window</title>

<graphic width="502" depth="273" fileref="figs/sam.0707.gif"></graphic>
</figure>

<para>Select a printer that's locally connected (for example, ours is the Canon printer), press the right mouse button to bring up a menu, and select Sharing. This will give you the Sharing tab of the Printer Properties frame, as shown in <link linkend="ch07-92021">Figure 7.8</link>. If you want it available to everybody on your LAN as the Windows guest user, enter a blank password.</para>


<figure label="7.8" id="ch07-92021">
<title>The Sharing tab of the printer</title>

<graphic width="502" depth="273" fileref="figs/sam.0708.gif"></graphic>
</figure>

<para>Once you've got this working, you can add your printer to the list of standard printers and Samba can make it available to all the other PCs in the workgroup. To make installation on Unix easier, the Samba distribution provides two sample scripts: <filename>smbprint</filename> and <filename>smbprint.sysv</filename>. The first works with BSD-style printers; the second is designed for System V printers.</para>


<sect2 role="" label="7.2.1" id="ch07-SECT-2.0.1">
<title>BSD printers</title>


<para>
<indexterm id="ch07-idx-956540-0"><primary>printers</primary><secondary>BSD</secondary></indexterm>There are two steps you need to have a BSD Unix recognize a remote printer:</para>


<orderedlist>
<listitem><para>Place an entry for the printer in the <filename>/etc/printcap</filename> file (or equivalent).</para></listitem>
<listitem><para>Place a configuration file in the <filename>/var/spool</filename> directory for the printer.</para></listitem>
</orderedlist>

<para>First, edit your <filename>/etc/printcap</filename> file and add an entry for the remote printer. Note that the input filter (<literal>if</literal>) entry needs to point to the <emphasis>smbprint</emphasis> program if the machine is on Windows 95/98. The following set of lines will accomplish on a Linux machine, for example:</para>


<programlisting>laserjet:\
  :sd=/var/spool/lpd/laser:\         <replaceable># spool directory</replaceable>
  :mx#0:\                            <replaceable># maximum file size (none)</replaceable>
  :sh:\                              <replaceable># surpress burst header (no)</replaceable>
  :if=/usr/local/samba/bin/smbprint: <replaceable># text filter</replaceable></programlisting>


<para>After that, you need to create a configuration file in the spool directory that you specified with the <literal>sd</literal> parameter above. (You may need to create that directory.) The file must have the name <emphasis>.config</emphasis> and should contain the following information:</para>


<itemizedlist>
<listitem><para>The NetBIOS name of the Windows machine with the printer</para></listitem>
<listitem><para>The service name that represents the printer</para></listitem>
<listitem><para>The password used to access that service</para></listitem>
</itemizedlist>

<para>The last two parameters were set up in the Sharing dialog for the requested resource on the Windows machine. In this case, the <emphasis>.config</emphasis> file would have three lines:</para>


<programlisting>server = phoenix
service = CANON
password = ""</programlisting>


<para>After you've done that, reset the Samba server machine and try printing to it using any standard Unix program.</para>
</sect2>





<sect2 role="" label="7.2.2" id="ch07-SECT-2.0.2">
<title>System V printers</title>


<para>
<indexterm id="ch07-idx-956541-0"><primary>printers</primary><secondary>System V</secondary></indexterm>Sending print jobs from a System V Unix system is a little easier. Here, you need to get obtain the <filename>smbprint.sysv</filename> script in the <filename>/usr/local/samba/examples/printing</filename> directory and do the following:</para>


<orderedlist>
<listitem><para>Change the <literal>server</literal>, <literal>service</literal>, and <literal>password</literal> parameters in the script to match the NetBIOS machine, its shared printer service, and its password, respectively. For example, the following entries would be correct for the service in the previous example:</para>


<programlisting>server = phoenix
service = CANON
password = ""</programlisting></listitem>

<listitem><para>Run the following commands, which create a reference for the printer in the printer capabilities file. Note that the new Unix printer entry <literal>canon_  printer</literal> is named:</para>


<programlisting># lpadmin -p canon_printer -v /dev/null -i./smbprint.sysv
# enable canon_printer
# accept canon_printer</programlisting></listitem>
</orderedlist>

<para>After you've done that, restart the Samba daemons and try printing to it using any standard Unix program. You should now be able to send data to a printer on a Windows client across the network.</para>
</sect2>




<sect2 role="" label="7.2.3" id="ch07-SECT-2.1">
<title>Samba Printing Options</title>


<para>
<indexterm id="ch07-idx-956419-0" class="startofrange"><primary>printing</primary><secondary>options for</secondary></indexterm><link linkend="ch07-19361">Table 7.2</link> summarizes the Samba printing options.</para>


<table label="7.2" id="ch07-19361">
<title>Printing Configuration Options </title>

<tgroup cols="5">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
<colspec colnum="4" colname="col4"/>
<colspec colnum="5" colname="col5"/>
<thead>
<row>

<entry colname="col1"><para>Option</para></entry>

<entry colname="col2"><para>Parameters</para></entry>

<entry colname="col3"><para>Function</para></entry>

<entry colname="col4"><para>Default</para></entry>

<entry colname="col5"><para>Scope</para></entry>

</row>

</thead>

<tbody>
<row>

<entry colname="col1"><para><literal>printing</literal></para></entry>

<entry colname="col2"><para><literal>bsd</literal>, <literal>sysv</literal>, <literal>hpux</literal>, <literal>aix</literal>, <literal>qnx</literal>, <literal>plp</literal>, <literal>softq</literal>, or <literal>lprng</literal></para></entry>

<entry colname="col3"><para>Sets the print system type for your Unix system.</para></entry>

<entry colname="col4"><para>System dependent</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>printable (print ok)</literal></para></entry>

<entry colname="col2"><para>boolean</para></entry>

<entry colname="col3"><para>Marks a share as a printing share.</para></entry>

<entry colname="col4"><para><literal>no</literal></para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>printer (printer name)</literal></para></entry>

<entry colname="col2"><para>string (Unix printer name)</para></entry>

<entry colname="col3"><para>Sets the name of the printer to be shown to clients.</para></entry>

<entry colname="col4"><para>System dependent</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>printer driver</literal></para></entry>

<entry colname="col2"><para>string (printer driver name)</para></entry>

<entry colname="col3"><para>Sets the driver name that should be used by the client to send data to the printer.</para></entry>

<entry colname="col4"><para>None</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>printer driver file</literal></para></entry>

<entry colname="col2"><para>string (fully-qualified pathname)</para></entry>

<entry colname="col3"><para>Sets the name of the printer driver file.</para></entry>

<entry colname="col4"><para>None</para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>printer driver location</literal></para></entry>

<entry colname="col2"><para>string (network pathname)</para></entry>

<entry colname="col3"><para>Specifies the pathname of the share for the printer driver file.</para></entry>

<entry colname="col4"><para>None</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lpq cache time</literal></para></entry>

<entry colname="col2"><para>numeric (time in seconds)</para></entry>

<entry colname="col3"><para>Sets the amount of time in seconds that Samba will cache the lpq status.</para></entry>

<entry colname="col4"><para><literal>10</literal></para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>postscript</literal></para></entry>

<entry colname="col2"><para>boolean</para></entry>

<entry colname="col3"><para>Treats all print jobs sent as postscript by prepending <literal>%!</literal> at the beginning of each file.</para></entry>

<entry colname="col4"><para><literal>no</literal></para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>load printers</literal></para></entry>

<entry colname="col2"><para>boolean</para></entry>

<entry colname="col3"><para>Automatically loads each of the printers in the <emphasis>printcap</emphasis> file as printing shares.</para></entry>

<entry colname="col4"><para><literal>no</literal></para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>print command</literal></para></entry>

<entry colname="col2"><para>string (shell command)</para></entry>

<entry colname="col3"><para>Sets the Unix command to perform printing.</para></entry>

<entry colname="col4"><para>See below</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lpq command</literal></para></entry>

<entry colname="col2"><para>string (shell command)</para></entry>

<entry colname="col3"><para>Sets the Unix command to return the status of the printing queue.</para></entry>

<entry colname="col4"><para>See below</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lprm command</literal></para></entry>

<entry colname="col2"><para>string (shell command)</para></entry>

<entry colname="col3"><para>Sets the Unix command to remove a job from the printing queue.</para></entry>

<entry colname="col4"><para>See below</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lppause command</literal></para></entry>

<entry colname="col2"><para>string (shell command)</para></entry>

<entry colname="col3"><para>Sets the Unix command to pause a job on the printing queue.</para></entry>

<entry colname="col4"><para>See below</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lpresume command</literal></para></entry>

<entry colname="col2"><para>string (shell command)</para></entry>

<entry colname="col3"><para>Sets the Unix command to resume a paused job on the printing queue.</para></entry>

<entry colname="col4"><para>See below</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>printcap name</literal></para>

<para><literal>(printcap)</literal></para></entry>

<entry colname="col2"><para>string (fully-qualified pathname)</para></entry>

<entry colname="col3"><para>Specifies the location of the printer capabilities file.</para></entry>

<entry colname="col4"><para>System dependent</para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>min print space</literal></para></entry>

<entry colname="col2"><para>numeric (size in kilobytes)</para></entry>

<entry colname="col3"><para>Sets the minimum amount of disk free space that must be present to print.</para></entry>

<entry colname="col4"><para><literal>0</literal></para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>queuepause command</literal></para></entry>

<entry colname="col2"><para>string (shell command)</para></entry>

<entry colname="col3"><para>Sets the Unix command to pause a queue.</para></entry>

<entry colname="col4"><para>See below</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>queueresume command</literal></para></entry>

<entry colname="col2"><para>string (shell command)</para></entry>

<entry colname="col3"><para>Sets the Unix command to resume a queue.</para></entry>

<entry colname="col4"><para>See below</para></entry>

<entry colname="col5"><para>Share</para></entry>

</row>

</tbody>
</tgroup>
</table>


<sect3 role="" label="7.2.3.1" id="ch07-SECT-2.1.1">
<title>printing</title>


<para>The <literal>printing</literal>
<indexterm id="ch07-idx-958423-0"><primary>printing configuration option</primary></indexterm> configuration option tells Samba a little about your Unix printing system, in this case which printing parser to use. With Unix, there are several different families of commands to control printing and print statusing. Samba supports seven different types, as shown in <link linkend="ch07-28758">Table 7.3</link>.</para>


<table label="7.3" id="ch07-28758">
<title>Printing Types </title>

<tgroup cols="2">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<thead>
<row>

<entry colname="col1"><para>Variable</para></entry>

<entry colname="col2"><para>Definition</para></entry>

</row>

</thead>

<tbody>
<row>

<entry colname="col1"><para>BSD</para></entry>

<entry colname="col2"><para>
<indexterm id="ch07-idx-956545-0"><primary>printing</primary><secondary>types</secondary></indexterm>Berkeley Unix system</para></entry>

</row>

<row>

<entry colname="col1"><para>SYSV</para></entry>

<entry colname="col2"><para>System V</para></entry>

</row>

<row>

<entry colname="col1"><para>AIX</para></entry>

<entry colname="col2"><para>AIX Operating System (IBM)</para></entry>

</row>

<row>

<entry colname="col1"><para>HPUX</para></entry>

<entry colname="col2"><para>Hewlett-Packard Unix</para></entry>

</row>

<row>

<entry colname="col1"><para>QNX</para></entry>

<entry colname="col2"><para>QNX Realtime Operating System (QNX)</para></entry>

</row>

<row>

<entry colname="col1"><para>LPRNG</para></entry>

<entry colname="col2"><para>LPR Next Generation (Powell)</para></entry>

</row>

<row>

<entry colname="col1"><para>SOFTQ</para></entry>

<entry colname="col2"><para>SOFTQ system</para></entry>

</row>

<row>

<entry colname="col1"><para>PLP</para></entry>

<entry colname="col2"><para>Portable Line Printer (Powell)</para></entry>

</row>

</tbody>
</tgroup>
</table>


<para>The value for this optio.n will be one of these seven options. For example:</para>


<programlisting>printing = SYSV</programlisting>


<para>The default value of this option is system dependent and is configured when Samba is first compiled. For most systems, the <filename>configure</filename> script will automatically detect the printing system to be used and configure it properly in the Samba makefile. However, if your system is a PLP, LPRNG, or QNX printing system, you will need to explicitly specify this in the makefile or the printing share.</para>


<para>The most common system types are BSD and SYSV. Each of the printers on a BSD Unix server are described in the printer capabilities file&mdash;normally <filename>/etc/printcap</filename>.</para>


<para>Setting the <literal>printing</literal> configuration option automatically sets at least three other printing options for the service in question: <literal>print</literal> <literal>command</literal>, <literal>lpq</literal> <literal>command</literal>, and <literal>lprm</literal> <literal>command</literal>. If you are running Samba on a system that doesn't support any of these printing styles, simply set the commands for each of these manually.</para>
</sect3>



<sect3 role="" label="7.2.3.2" id="ch07-SECT-2.1.2">
<title>printable</title>


<para>The <indexterm id="ch07-idx-958426-0"><primary>printable option</primary></indexterm>printable option must be set to <literal>yes</literal> in order to flag a share as a printing service. If this option is not set, the share will be treated as a disk share instead. You can set the option as follows:</para>


<programlisting>[printer1]
	printable = yes</programlisting>
</sect3>



<sect3 role="" label="7.2.3.3" id="ch07-SECT-2.1.3">
<title>printer</title>


<para>
<indexterm id="ch07-idx-957248-0" class="startofrange"><primary>printers</primary><secondary>option for</secondary></indexterm>The <indexterm id="ch07-idx-958427-0"><primary>printer option</primary></indexterm>option, sometimes called <literal>printer</literal> <literal>name</literal>, specifies the name of the printer on the server to which the share points. This option has no default and should be set explicitly in the configuration file, even though Unix systems themselves often recognize a default name such as <literal>lp</literal> for a printer. For example:</para>


<programlisting>[deskjet]
	printer = hpdkjet1</programlisting>
</sect3>



<sect3 role="" label="7.2.3.4" id="ch07-SECT-2.1.4">
<title>printer driver</title>


<para>The <literal>printer</literal>
<indexterm id="ch07-idx-958428-0"><primary>printer driver option</primary></indexterm> <literal>driver</literal> option sets the string that Samba uses to tell Windows what the printer is. If this option is set correctly, the Windows Printer Wizard will already know what the printer is, making installation easier for end users by giving them one less dialog to worry about. The string given should match the string that shows up in the Printer Wizard, as shown in <link linkend="ch07-46183">Figure 7.9</link>. For example, an Apple LaserWriter typically uses <literal>Apple</literal> <literal>LaserWriter</literal>; a Hewlett Packard Deskjet 560C uses <literal>HP</literal> <literal>DeskJet</literal> <literal>560C</literal> <literal>Printer</literal>.</para>


<figure label="7.9" id="ch07-46183">
<title>The Add Printer Wizard dialog box in Windows 98</title>

<graphic width="502" depth="296" fileref="figs/sam.0709.gif"></graphic>
</figure>

<para>Automatically configuring printer drivers with Samba is explained in greater detail in <link linkend="ch07-30008">Section 7.1.7</link> earlier in this chapter.</para>
</sect3>



<sect3 role="" label="7.2.3.5" id="ch07-SECT-2.1.5">
<indexterm id="ch07-idx-958429-0"><primary>printer driver file option</primary></indexterm>
<title>
printer driver file</title>


<para>This global option gives the location of the Windows 95/98 printer driver definition file, which is needed to give printer drivers to clients using a Samba printer. The default value of this option is <filename>/usr/local/samba/lib/printers.def</filename>. You can override this default as shown below:</para>


<programlisting>[deskjet]
	printer driver file = /var/printers/printers.def</programlisting>


<para>This option is explained in greater detail in <link linkend="ch07-30008">Section 7.1.7</link> earlier in this chapter.</para>
</sect3>



<sect3 role="" label="7.2.3.6" id="ch07-SECT-2.1.6">
<indexterm id="ch07-idx-958432-0"><primary>printer driver location option</primary></indexterm>
<title>
printer driver location</title>


<para>This option specifies a specific share that contains Windows 95 and 98 printer driver and definition files. There is no default parameter for this value. You can specify the location as a network pathname. A frequent approach is to use a share on your own machine, as shown here:</para>


<programlisting>[deskjet]
	printer driver location = \\%L\PRINTER$</programlisting>


<para>This option is also explained in greater detail in <link linkend="ch07-30008">Section 7.1.7</link> earlier in this chapter.</para>
</sect3>



<sect3 role="" label="7.2.3.7" id="ch07-SECT-2.1.7">
<indexterm id="ch07-idx-958433-0"><primary>lpq cache time option</primary></indexterm>
<title>
lpq cache time</title>


<para>
<indexterm id="ch07-idx-956564-0"><primary>cache time (printers), option for</primary></indexterm>The global <literal>lpq</literal> <literal>cache</literal> <literal>time</literal> option allows you to set the number of seconds that Samba will remember the current printer status. After this time elapses, Samba will issue an <emphasis>lpq</emphasis> command (or whatever command you specify with the <literal>lpq</literal> <literal>command</literal> option) to get a more up-to-date status. This defaults to 10 seconds, but can be increased if your <literal>lpq</literal> <literal>command</literal> takes an unusually long time to run or you have lots of clients. The following example resets the time to 30 seconds:</para>


<programlisting>[deskjet]
	lpq cache time = 30</programlisting>
</sect3>



<sect3 role="" label="7.2.3.8" id="ch07-SECT-2.1.8">
<title>postscript</title>


<para>The<indexterm id="ch07-idx-958438-0"><primary>postscript option</primary></indexterm> <literal>postscript</literal> option forces the printer to treat all data sent to it as Postscript. It does this by prepending the characters <literal>%!</literal> at the beginning of the first line of each job. It is normally used with PCs that insert a <literal>^D</literal> (control-D or "end-of-file mark) in front of the first line of a PostScript file. It will not, obviously, turn a non-PostScript printer into a PostScript one. The default value of this options is <literal>no</literal>. You can override it as follows:<indexterm id="ch07-idx-957258-0" class="endofrange" startref="ch07-idx-957248-0"/></para>


<programlisting>[deskjet]
	postscript = yes</programlisting>
</sect3>



<sect3 role="" label="7.2.3.9" id="ch07-SECT-2.1.9">
<indexterm id="ch07-idx-958439-0"><primary>print command option</primary></indexterm>
<indexterm id="ch07-idx-958439-1"><primary>lpq command option</primary></indexterm>
<indexterm id="ch07-idx-958439-2"><primary>lprm command option</primary></indexterm>
<indexterm id="ch07-idx-958439-3"><primary>lppause command option</primary></indexterm>
<indexterm id="ch07-idx-958439-4"><primary>lpresume command option</primary></indexterm>
<title>




print command, lpq command, lprm command, lppause command, lpresume command</title>


<para>
<indexterm id="ch07-idx-956566-0"><primary>Unix</primary><secondary>options</secondary><tertiary sortas="print commands">for print commands</tertiary></indexterm>These options tell Samba which Unix commands used to control and send data to the printer. The Unix commands involved are: <emphasis>lpr</emphasis> (send to Line PRinter), <emphasis>lpq</emphasis> (List Printer Queue), <emphasis>lprm</emphasis> (Line printer ReMove), and optionally <emphasis>lppause</emphasis> and <emphasis>lpresume</emphasis>. Samba provides an option named after each of these commands, in case you need to override any of the system defaults. For example, consider:</para>


<programlisting>lpq command = /usr/ucb/lpq %p</programlisting>


<para>This would set the <literal>lpq command</literal> to use <filename>/usr/ucb/lpq</filename>. Similarly:</para>


<programlisting>lprm command = /usr/local/lprm -P%p %j</programlisting>


<para>would set the Samba printer remove command to <filename>/usr/local/lprm</filename>, and provide it the print job number using the <literal>%j</literal> variable.</para>


<para>The default values for each of these options are dependent on the value of the <literal>printing</literal> option. <link linkend="ch07-82964">Table 7.4</link> shows the default commands for each of the printing options. The most popular printing system is BSD.</para>


<table label="7.4" id="ch07-82964">
<title>Default Commands for Various Printing Commands </title>

<tgroup cols="5">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
<colspec colnum="4" colname="col4"/>
<colspec colnum="5" colname="col5"/>
<thead>
<row>

<entry colname="col1"><para>Option</para></entry>

<entry colname="col2"><para>BSD, AIX, PLP, LPRNG</para></entry>

<entry colname="col3"><para>SYSV, HPUX</para></entry>

<entry colname="col4"><para>QNX</para></entry>

<entry colname="col5"><para>SOFTQ</para></entry>

</row>

</thead>

<tbody>
<row>

<entry colname="col1"><para><literal>print command</literal></para></entry>

<entry colname="col2"><para><literal>lpr -r -P%p %s</literal>
<indexterm id="ch07-idx-958518-0"><primary>printing</primary><secondary>commands</secondary><tertiary>default commands for</tertiary></indexterm></para></entry>

<entry colname="col3"><para><literal>lp -c -d%p %s; rm %s</literal></para></entry>

<entry colname="col4"><para><literal>lp -r -P%p %s</literal></para></entry>

<entry colname="col5"><para><literal>lp -d%p -s %s; rm %s</literal></para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lpq command</literal></para></entry>

<entry colname="col2"><para><literal>lpq -P%p</literal></para></entry>

<entry colname="col3"><para><literal>lpstat -o%p</literal></para></entry>

<entry colname="col4"><para><literal>lpq -P%p</literal></para></entry>

<entry colname="col5"><para><literal>lpstat -o%p</literal></para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lprm command</literal></para></entry>

<entry colname="col2"><para><literal>lprm -P%p %j</literal></para></entry>

<entry colname="col3"><para><literal>cancel %p-%j</literal></para></entry>

<entry colname="col4"><para><literal>cancel %p-%j</literal></para></entry>

<entry colname="col5"><para><literal>cancel %p-%j</literal></para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lppause command</literal></para></entry>

<entry colname="col2"><para><literal>lp -i %p-%j -H hold </literal></para>

<para>(SYSV only)</para></entry>

<entry colname="col3"><para>None</para></entry>

<entry colname="col4"><para>None</para></entry>

<entry colname="col5"><para>None</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>lpresume command</literal></para></entry>

<entry colname="col2"><para><literal>lp -i %p-%j -H resume</literal></para>

<para>(SYSV only)</para></entry>

<entry colname="col3"><para>None</para></entry>

<entry colname="col4"><para>None</para></entry>

<entry colname="col5"><para><literal>qstat -s -j%j -r</literal></para></entry>

</row>

</tbody>
</tgroup>
</table>


<para>It is typically not necessary to reset these options in Samba, with the possible exception of <literal>print</literal> <literal>command</literal>. This option may need to be explicitly set if your printing system doesn't have a <literal>-r</literal> (remove after printing) option on the printing command. For example:</para>


<programlisting>/usr/local/lpr -P%p %s; /bin/rm %s</programlisting>


<para>With a bit of judicious programming, these <filename>smb.conf</filename> options can also used for debugging:</para>


<programlisting>print command = cat %s &gt;&gt;/tmp/printlog; lpr -r -P%p %s</programlisting>


<para>For example, this configuration can verify that files are actually being delivered to the Samba server. If they are, their contents will show up in the <filename>/tmp/printlog</filename> file.</para>


<para>After BSD, the next most popular kind of printing system is SYSV (or System V) printing, plus some SYSV variants for IBM's AIX and Hewlett-Packard's HP-UX. These system do not have an <filename>/etc/printcap</filename> file. Instead, the <literal>printcap</literal> <literal>file</literal> option can be set to an appropriate <emphasis>lpstat</emphasis> command for the system. This tells Samba to get a list of printers from the <emphasis>lpstat</emphasis> command. Alternatively, you can set the global configuration option <literal>printcap</literal> <literal>name</literal> to the name of a dummy <filename>printcap</filename> file you provide. In the latter case, the file must contain a series of lines such as:</para>


<programlisting>lp|print1|My Printer 1
print2|My Printer 2
print3|My Printer 3</programlisting>


<para>Each line names a printer, and provides aliases for it. In this example, the first printer is called <literal>lp</literal>, <literal>print1</literal>, or <literal>My</literal> <literal>Printer</literal> <literal>1</literal>, whichever the user prefers to use. The first name will be used in place of <literal>%p</literal> in any command Samba executes for that printer.</para>


<para>Two additional printer types are also supported by Samba: LPRNG (LPR New Generation) and PLP (Public Line Printer). These are public domain and Open Source printing systems, and are used by many sites to overcome problems with vendor-supplied software. In addition, the SOFTQ and QNX realtime operating systems are supported by Samba.</para>
</sect3>



<sect3 role="" label="7.2.3.10" id="ch07-SECT-2.1.10">
<title>load printers</title>


<para>
<indexterm id="ch07-idx-956568-0"><primary>print shares</primary><secondary>options for</secondary></indexterm>The <literal>load</literal>
<indexterm id="ch07-idx-958440-0"><primary>load printers option</primary></indexterm> <literal>printers</literal> option tells Samba to create shares for all known printer names and load those shares into the browse list. Samba will create and list a printer share for each printer name in <filename>/etc/printcap</filename> (or system equivalent). For example, if your <filename>printcap</filename> file looks like this:<footnote label="2" id="ch07-pgfId-950654">


<para>We have placed annotated comments off to the side in case you've never dealt with this file before.</para>


</footnote></para>


<programlisting>lp:\
  :sd=/var/spool/lpd/lp:\            <replaceable># spool directory</replaceable>
  :mx#0:\                            <replaceable># maximum file size (none)</replaceable>
  :sh:\                              <replaceable># surpress burst header (no)</replaceable>
  :lp=/dev/lp1:\                     <replaceable># device name for output</replaceable>
  :if=/var/spool/lpd/lp/filter:      <replaceable># text filter</replaceable>

laser:\
  :sd=/var/spool/lpd/laser:\         <replaceable># spool directory</replaceable>
  :mx#0:\                            <replaceable># maximum file size (none)</replaceable>
  :sh:\                              <replaceable># surpress burst header (no)</replaceable>
  :lp=/dev/laser:\                   <replaceable># device name for output</replaceable>
  :if=/var/spool/lpd/lp/filter:      <replaceable># text filter</replaceable></programlisting>


<para>and you specify:</para>


<programlisting>load printers = yes</programlisting>


<para>the shares <literal>[lp]</literal> and <literal>[laser]</literal> will automatically be created as valid print shares when Samba is started. Both shares will borrow the configuration options specified in the <literal>[printers]</literal> section to configure themselves, and will be available in the browse list for the Samba server.</para>
</sect3>



<sect3 role="" label="7.2.3.11" id="ch07-SECT-2.1.11">
<title>printcap name</title>


<para>If the <literal>printcap</literal>
<indexterm id="ch07-idx-958442-0"><primary>printcap name option</primary></indexterm> <literal>name</literal> option (also called <literal>printcap</literal>) appears in a printing share, Samba will use the file specified as the system printer capabilities file. This is normally <filename>/etc/printcap</filename>. However, you can reset it to a file consisting of only the printers you want to share over the network. The value must be a fully-qualified filename of a printer capabilities file on the server:</para>


<programlisting>[deskjet]
	printcap name = /usr/local/printcap</programlisting>
</sect3>



<sect3 role="" label="7.2.3.12" id="ch07-SECT-2.1.12">
<title>min print space</title>


<para>The <literal>min</literal>
<indexterm id="ch07-idx-958443-0"><primary>min print space option</primary></indexterm> <literal>print</literal> <literal>space</literal> option sets the amount of <indexterm id="ch07-idx-956570-0"><primary>spool space, options for</primary></indexterm>spool space that must be available on the disk before printing is allowed. Setting it to zero (the default) turns the check off; setting it to any other number sets the amount of free space in kilobytes required. This option helps avoid having print jobs fill up the remaining disk space on the server, which may cause other processes to fail:</para>


<programlisting>[deskjet]
	min print space = 4000</programlisting>
</sect3>



<sect3 role="" label="7.2.3.13" id="ch07-SECT-2.1.13">
<indexterm id="ch07-idx-958444-0"><primary>queuepause command option</primary></indexterm>
<title>
queuepause command</title>


<para>This configuration option specifies a command that tells Samba how to pause a <indexterm id="ch07-idx-956571-0"><primary>print queue, options for</primary></indexterm>print queue entirely, as opposed to a single job on the queue. The default value depends on the printing type chosen. You should not need to alter this option.</para>
</sect3>



<sect3 role="" label="7.2.3.14" id="ch07-SECT-2.1.14">
<indexterm id="ch07-idx-958445-0"><primary>queueresume command option</primary></indexterm>
<title>
queueresume command</title>


<para>This configuration option specifies a command that tells Samba how to resume a paused print queue, as opposed to resuming a single job on the print queue. The default value depends on the printing type chosen. You should not need to alter<indexterm id="ch07-idx-956423-0" class="endofrange" startref="ch07-idx-956419-0"/> this<indexterm id="ch07-idx-956372-0" class="endofrange" startref="ch07-idx-956368-0"/> option.<indexterm id="ch07-idx-956352-0" class="endofrange" startref="ch07-idx-956351-0"/></para>
</sect3>
</sect2>
</sect1>









<sect1 role="" label="7.3" id="ch07-12219">
<title>Name Resolution with Samba</title>


<para>
<indexterm id="ch07-idx-956353-0" class="startofrange"><primary>name resolution</primary></indexterm>Before NetBIOS Name Servers (NBNS) came about, name resolution worked entirely by broadcast. If you needed a machine's address, you simply <indexterm id="ch07-idx-956574-0"><primary>broadcasting</primary><seealso>browsing; name resolution</seealso></indexterm>broadcast its name across the network and, in theory, the machine itself would reply. This approach is still possible: anyone looking for a machine named <literal>fred</literal> can still broadcast a query and find out if it exists and what its IP address is. (We use this capability to troubleshoot Samba name services with the <literal>nmblookup</literal> command in <link linkend="SAMBA-CH-9">Chapter 9</link>.)</para>


<para>As you saw in the first chapter, however, broadcasting&mdash;whether it be browsing or name registration and resolution&mdash;does not pass easily across multiple subnets. In addition, many broadcasts tend to bog down networks. To solve this problem, Microsoft now provides the <indexterm id="ch07-idx-956577-0"><primary>WINS (Windows Internet Name Service)</primary><secondary>name resolution and</secondary></indexterm>Windows Internet Naming Service (WINS), a cross-subnet NBNS, which Samba supports. With it, an administrator can designate a single machine to act as a WINS server, and can then provide each client that requires name resolution the address of the WINS server. Consequently, name registration and resolution requests can be directed to a single machine from any point on the network, instead of broadcast.</para>


<para>WINS and broadcasting are not the only means of name resolution, however. There are actually four mechanisms that can be used with Samba:</para>


<itemizedlist>
<listitem><para>WINS</para></listitem>
<listitem><para>Broadcasting</para></listitem>
<listitem><para>Unix <filename>/etc/hosts</filename> or NIS/NIS+ matches</para></listitem>
<listitem><para><emphasis>LMHOSTS</emphasis> file</para></listitem>
</itemizedlist>

<para>Samba can use any or all of these name resolution methods in the order that you specify in the Samba configuration file using the <literal>name</literal> <literal>resolve</literal> <literal>order</literal> parameter. However, before delving into configuration options, let's discuss the one that you've probably not encountered before: the <filename>LMHOSTS</filename> file.</para>


<sect2 role="" label="7.3.1" id="ch07-SECT-3.1">
<title>The LMHOSTS File</title>


<para><filename>LMHOSTS</filename>
<indexterm id="ch07-idx-956428-0"><primary>LMHOSTS file</primary></indexterm> is the standard LAN Manager <emphasis>hosts</emphasis> file used to resolve names into IP addresses on the system. It is the NBT equivalent of the <filename>/etc/hosts</filename> file that is standard on all Unix systems. By default, the file is usually stored as <filename>/usr/local/samba/lib/LMHOSTS</filename> and shares a format similar to <filename>/etc/hosts</filename>. For example:</para>


<programlisting>192.168.220.100    hydra
192.168.220.101    phoenix</programlisting>


<para>The only difference is that the names on the right side of the entries are NetBIOS names instead of DNS names. Because they are NetBIOS names, you can assign resource types to them as well:</para>


<programlisting>192.168.220.100    hydra#20
192.168.220.100    simple#1b
192.168.220.101    phoenix#20</programlisting>


<para>Here, we've assigned the <literal>hydra</literal> machine to be the primary domain controller of the <literal>SIMPLE</literal> domain, as indicated by the resource type &lt;1B&gt; assigned to the name after <literal>hydra</literal>'s IP address in the second line. The other two are standard workstations.</para>


<para>If you wish to place an <emphasis>LMHOSTS</emphasis> file somewhere other than the default location, you will need to notify the <emphasis>nmbd</emphasis> process upon start up, as follows:</para>


<programlisting>nmbd -H /etc/samba/lmhosts -D</programlisting>
</sect2>





<sect2 role="" label="7.3.2" id="ch07-SECT-3.2">
<title>Setting Up Samba to Use Another WINS Server</title>


<para>
<indexterm id="ch07-idx-956595-0"><primary>Samba</primary><secondary>WINS server and</secondary></indexterm>
<indexterm id="ch07-idx-956595-1"><primary>WINS (Windows Internet Name Service) server</primary><secondary>setting up Sambato use</secondary></indexterm>You can set up Samba to use a WINS server somewhere else on the network by simply pointing it to the IP address of the WINS server. This is done with the global <literal>wins</literal> <literal>server</literal> configuration option, as shown here:</para>


<programlisting>[global]
	wins server = 192.168.200.122</programlisting>


<para>With this option enabled, Samba will direct all WINS requests to the server at 192.168.200.122. Note that because the request is directed at a single machine, we don't have to worry about any of the problems inherent to broadcasting. However, though you have specified an IP address for a WINS server in the configuration file, Samba will not necessarily use the WINS server before other forms of name resolution. The order in which Samba attempts various name-resolution techniques is given with the <literal>name</literal> <literal>resolve</literal> <literal>order</literal> configuration option, which we will discuss shortly.</para>


<para>If you have a Samba server on a subnet that still uses broadcasting and the Samba server knows the correct location of a WINS server on another subnet, you can configure the Samba server to forward any name resolution requests with the <literal>wins</literal> <literal>proxy</literal> option:</para>


<programlisting>[global]
	wins server = 192.168.200.12
	wins proxy = yes</programlisting>


<para>Use this only in situations where the WINS server resides on another subnet. Otherwise, the broadcast will reach the WINS server regardless of any proxying.</para>
</sect2>





<sect2 role="" label="7.3.3" id="ch07-83429">
<title>Setting Up Samba as a WINS Server</title>


<para>
<indexterm id="ch07-idx-956600-0"><primary>WINS (Windows Internet Name Service) server</primary><secondary>setting up Samba as</secondary></indexterm>You can set up Samba as a WINS server by setting two global options in the configuration file, as shown below:</para>


<programlisting>[global]
	wins support = yes
	name resolve order = wins lmhosts hosts bcast</programlisting>


<para>The <literal>wins</literal> <literal>support</literal> option turns Samba into a WINS server. Believe it or not, that's all you need to do! Samba handles the rest of the details behind the scenes, leaving you a relaxed administrator. The <literal>wins</literal> <literal>support=yes</literal> and the <literal>wins</literal> <literal>server</literal> option are mutually exclusive; you cannot simultaneously offer Samba as the WINS server and point to another system as the server.</para>


<para>If Samba is acting as a WINS server, you should probably get familiar with the <literal>name</literal> <literal>resolve</literal> <literal>order</literal> option mentioned earlier. This option tells Samba the order of methods in which it tries to resolve a NetBIOS name. It can take up to four values:</para>


<variablelist>
<varlistentry><term>lmhosts</term>
<listitem><para>Uses a LAN Manager <emphasis>LMHOSTS</emphasis> file</para></listitem>
</varlistentry>


<varlistentry><term>hosts</term>
<listitem><para>Uses the standard name resolution methods of the Unix system, <emphasis>/etc/hosts</emphasis>, DNS, NIS, or a combination (as configured for the system)</para></listitem>
</varlistentry>


<varlistentry><term>wins</term>
<listitem><para>Uses the WINS server</para></listitem>
</varlistentry>


<varlistentry><term>bcast</term>
<listitem><para>Uses a broadcast method</para></listitem>
</varlistentry>
</variablelist>


<para>The order in which you specify them in the value is the order in which Samba will attempt name resolution when acting as a WINS server. For example, let's look at the value specified previously:</para>


<programlisting>name resolve order = wins lmhosts hosts bcast</programlisting>


<para>This means that Samba will attempt to use its WINS entries first for name resolution, followed by the LAN Manager <emphasis>LMHOSTS</emphasis> file on its system. Next, the hosts value causes it to use Unix name resolution methods. The word <literal>hosts</literal> may be misleading; it covers not only the <filename>/etc/hosts</filename> file, but also the use of DNS or NIS (as configured on the Unix host). Finally, if those three do not work, it will use a broadcast to try to locate the correct machine.</para>


<para>Finally, you can instruct a Samba server that is acting as a WINS server to check with the system's DNS server if a requested host cannot be found in its WINS database. With a typical Linux system, for example, you can find the IP address of the DNS server by searching the <filename>/etc/resolv.conf</filename> file. In it, you might see an entry such as the following:</para>


<programlisting>nameserver 127.0.0.1
nameserver 192.168.200.192</programlisting>


<para>This tells us that a DNS server is located at 192.168.220.192. (The 127.0.0.1 is the localhost address and is never a valid DNS server address.)</para>


<para>Use the global <literal>dns</literal> <literal>proxy</literal> option to alert Samba to use the configured DNS server:</para>


<programlisting>[global]
	wins support = yes
	name resolve order = wins lmhosts hosts bcast
	dns proxy = yes</programlisting>
</sect2>





<sect2 role="" label="7.3.4" id="ch07-SECT-3.4">
<title>Name Resolution Configuration Options</title>


<para>
<indexterm id="ch07-idx-956430-0" class="startofrange"><primary>name resolution</primary><secondary>options for</secondary></indexterm>Samba's WINS options are shown in <link linkend="ch07-82331">Table 7.5</link>.</para>


<table label="7.5" id="ch07-82331">
<title>WINS Options </title>

<tgroup cols="5">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
<colspec colnum="4" colname="col4"/>
<colspec colnum="5" colname="col5"/>
<thead>
<row>

<entry colname="col1"><para>Option</para></entry>

<entry colname="col2"><para>Parameters</para></entry>

<entry colname="col3"><para>Function</para></entry>

<entry colname="col4"><para>Default</para></entry>

<entry colname="col5"><para>Scope</para></entry>

</row>

</thead>

<tbody>
<row>

<entry colname="col1"><para><literal>wins support</literal></para></entry>

<entry colname="col2"><para>boolean</para></entry>

<entry colname="col3"><para>If set to <literal>yes</literal>, Samba will act as a WINS server.</para></entry>

<entry colname="col4"><para><literal>no</literal></para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>wins server</literal></para></entry>

<entry colname="col2"><para>string (IP address or DNS name)</para></entry>

<entry colname="col3"><para>Identifies a WINS server for Samba to use for name registration and resolution.</para></entry>

<entry colname="col4"><para>None</para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>wins proxy</literal></para></entry>

<entry colname="col2"><para>boolean</para></entry>

<entry colname="col3"><para>Allows Samba to act as a proxy to a WINS server on another subnet.</para></entry>

<entry colname="col4"><para><literal>no</literal></para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>dns proxy</literal></para></entry>

<entry colname="col2"><para>boolean</para></entry>

<entry colname="col3"><para>If set to <literal>yes</literal>, a Samba WINS server will search DNS if it cannot find a name in WINS.</para></entry>

<entry colname="col4"><para><literal>no</literal></para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>name resolve order</literal></para></entry>

<entry colname="col2"><para><literal>lmhosts</literal>, <literal>hosts</literal>, <literal>wins</literal>, or <literal>bcast</literal></para></entry>

<entry colname="col3"><para>Specifies an order of the methods used to resolve NetBIOS names.</para></entry>

<entry colname="col4"><para><literal>lmhosts hosts wins bcast</literal></para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>max ttl</literal></para></entry>

<entry colname="col2"><para>numerical</para></entry>

<entry colname="col3"><para>Specifies the maximum time-to-live in seconds for a requested NetBIOS names.</para></entry>

<entry colname="col4"><para><literal>259200</literal>( 3 days)</para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>max wins ttl</literal></para></entry>

<entry colname="col2"><para>numerical</para></entry>

<entry colname="col3"><para>Specifies the maximum time-to-live in seconds for NetBIOS names given out by Samba as a WINS server.</para></entry>

<entry colname="col4"><para><literal>518400</literal>(6 days)</para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

<row>

<entry colname="col1"><para><literal>min wins ttl</literal></para></entry>

<entry colname="col2"><para>numerical</para></entry>

<entry colname="col3"><para>Specifies the minimum time-to-live in seconds for NetBIOS names given out by Samba as a WINS server.</para></entry>

<entry colname="col4"><para><literal>21600</literal>(6 hours)</para></entry>

<entry colname="col5"><para>Global</para></entry>

</row>

</tbody>
</tgroup>
</table>


<sect3 role="" label="7.3.4.1" id="ch07-SECT-3.4.1">
<indexterm id="ch07-idx-958447-0"><primary>wins support option</primary></indexterm>
<title>
wins support</title>


<para>Samba will provide <indexterm id="ch07-idx-956607-0"><primary>WINS (Windows Internet Name Service)</primary><secondary>options for</secondary></indexterm>WINS name service to all machines in the network if you set the following in the <literal>[global]</literal> section of the <filename>smb.conf</filename> file:</para>


<programlisting>[global]
    wins support = yes</programlisting>


<para>The default value is <literal>no</literal>, which is typically used to allow another Windows NT server to become a WINS server. If you do enable this option, remember that a Samba WINS server currently cannot exchange data with any backup WINS servers. If activated, this option is mutually exclusive with the <literal>wins</literal> <literal>server</literal> parameter; you cannot set both to <literal>yes</literal> at the same time or Samba will flag an error.</para>
</sect3>



<sect3 role="" label="7.3.4.2" id="ch07-SECT-3.4.2">
<indexterm id="ch07-idx-958448-0"><primary>wins server option</primary></indexterm>
<title>
wins server</title>


<para>Samba will use an existing WINS server on the network if you specify the <literal>wins</literal> <literal>server</literal> global option in your configuration file. The value of this option is either the IP address or DNS name (not NetBIOS name) of the WINS server. For example:</para>


<programlisting>[global]
    wins server = 192.168.220.110</programlisting>


<para>or:</para>


<programlisting>[global]
    wins server = wins.example.com</programlisting>


<para>In order for this option to work, the <literal>wins</literal> <literal>support</literal> option must be set to <literal>no</literal> (the default). Otherwise, Samba will report an error. You can specify only one WINS server using this option.</para>
</sect3>



<sect3 role="" label="7.3.4.3" id="ch07-SECT-3.4.3">
<indexterm id="ch07-idx-958449-0"><primary>wins proxy option</primary></indexterm>
<title>
wins proxy</title>


<para>This option allows Samba to act as a proxy to another WINS server, and thus relay name registration and resolution requests from itself to the real WINS server, often outside the current subnet. The WINS server can be indicated through the <literal>wins</literal> <literal>server</literal> option. The proxy will then return the WINS response back to the client. You can enable this option by specifying the following in the <literal>[global]</literal> section:</para>


<programlisting>[global]
    wins proxy = yes</programlisting>
</sect3>



<sect3 role="" label="7.3.4.4" id="ch07-SECT-3.4.4">
<indexterm id="ch07-idx-958450-0"><primary>dns proxy option</primary></indexterm>
<title>
dns proxy</title>


<para>If you want the <indexterm id="ch07-idx-956608-0"><primary>DNS (Domain Name System)</primary><secondary>option for</secondary></indexterm>domain name service (DNS) to be used if a name isn't found in WINS, you can set the following option:</para>


<programlisting>[global]
    dns proxy = yes</programlisting>


<para>This will cause <filename>nmbd</filename> to query for machine names using the server's standard domain name service. You may wish to deactivate this option if you do not have a permanent connection to your DNS server. Despite this option, we recommend using a WINS server. If you don't already have any WINS servers on your network, make one Samba machine a WINS server. Do not, however, make two Samba machines WINS servers (one primary and one backup) as they currently cannot exchange WINS databases.</para>
</sect3>



<sect3 role="" label="7.3.4.5" id="ch07-SECT-3.4.5">
<indexterm id="ch07-idx-958451-0"><primary>name resolve order option</primary></indexterm>
<title>
name resolve order</title>


<para>The global <literal>name</literal> <literal>resolve</literal> <literal>order</literal> option specifies the order of services that Samba will use in attempting name resolution. The default order is to use the <emphasis>LMHOSTS</emphasis> file, followed by standard Unix name resolution methods (some combination of    <filename>/etc/hosts</filename>, DNS, and NIS), then query a WINS server, and finally use broadcasting to determine the address of a NetBIOS name. You can override this option by specifying something like the following:</para>


<programlisting>[global]
    name resolve order = lmhosts wins hosts bcast</programlisting>


<para>This causes resolution to use the <emphasis>LMHOSTS</emphasis> file first, followed by a query to a WINS server, the system password file, and finally broadcasting. You need not use all four options if you don't want to. This option is covered in more detail in <link linkend="ch07-83429">Section 7.3.3</link> earlier in this chapter.</para>
</sect3>



<sect3 role="" label="7.3.4.6" id="ch07-SECT-3.4.6">
<indexterm id="ch07-idx-958452-0"><primary>max ttl option</primary></indexterm>
<title>
max ttl</title>


<para>This option gives the maximum t<indexterm id="ch07-idx-956610-0"><primary>TTL (time to live), options for</primary></indexterm>
<indexterm id="ch07-idx-956610-1"><primary>time to live (TTL), options for</primary></indexterm>ime to live (T T L) during which a NetBIOS name registered with the Samba server will remain active. You should never need to alter this value.</para>
</sect3>



<sect3 role="" label="7.3.4.7" id="ch07-SECT-3.4.7">
<indexterm id="ch07-idx-958453-0"><primary>max wins ttl option</primary></indexterm>
<title>
max wins ttl</title>


<para>This option give the maximum time to live (T T L) during which a NetBIOS name resolved from a WINS server will remain active. You should never need to change this value from its default.</para>
</sect3>



<sect3 role="" label="7.3.4.8" id="ch07-SECT-3.4.8">
<indexterm id="ch07-idx-958454-0"><primary>min wins ttl option</primary></indexterm>
<title>
min wins ttl</title>


<para>This option give the minimum time to live (T T L) during which a NetBIOS name resolved from a WINS server will remain active. You should never need to alter this value from its<indexterm id="ch07-idx-956431-0" class="endofrange" startref="ch07-idx-956430-0"/> default.<indexterm id="ch07-idx-956354-0" class="endofrange" startref="ch07-idx-956353-0"/></para>
</sect3>
</sect2>
</sect1>
</chapter>