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
|
<html>
<body bgcolor="#ffffff">
<img src="samba2_xs.gif" border="0" alt=" " height="100" width="76"
hspace="10" align="left" />
<h1 class="head0">Chapter 10. Printing</h1>
<p><a name="INDEX-1"/>This
chapter tackles the topic of setting up printers for use with Samba.
Aside from the "coolness factor" of
seeing documents from Windows word processing and graphics
applications appearing in the output tray of the Unix printer, this
facility can greatly increase the usefulness of your Samba server. In
many organizations, using a Unix system as the print server has led
to happier system administrators and users alike, due to the reduced
frequency of problems.</p>
<p>Samba allows client machines to share printers connected to the Samba
host system, and Samba can also send Unix documents to printers
shared by Windows systems. In this chapter, we discuss how to get
printers configured to work in either direction.</p>
<p>We focus in this chapter on getting Samba to serve up printers that
are already functioning on the Unix host. We include just a few
basics about setting up printers on Unix. Good references for this
topic include <em class="citetitle">Network Printing</em>,
<em class="citetitle">Essential System Administration</em>, and
<em class="citetitle">Running Linux</em>, all by
O'Reilly and Associates.</p>
<div class="sect1"><a name="samba2-CHP-10-SECT-1"/>
<h2 class="head1">Sending Print Jobs to Samba</h2>
<p><a name="INDEX-2"/>A
printer shared by 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. <a href="ch10.html#samba2-CHP-10-FIG-1">Figure 10-1</a> shows a
Samba printer as it appears in the Network Neighborhood of a Windows
client.</p>
<div class="figure"><a name="samba2-CHP-10-FIG-1"/><img src="figs/sam2_1001.gif"/></div><h4 class="head4">Figure 10-1. A Samba printer in the Network Neighborhood</h4>
<p>To administer printers with Samba, you should understand the basic
process by which
<a name="INDEX-3"/>printing
takes place on a network. On the client system, the application
software prints by utilizing the system's printer
driver for the printer that will be creating the actual output. It is
the printer driver software running on the client system that
translates the application's high-level calls into a
stream of binary data specific to the model of printer in use. In the
case of a serial, parallel, or USB printer, the data is stored in a
temporary file in the local system's printer queue
and then sent through the respective port directly to the printer.
For a network printer, the file is sent over the network.</p>
<a name="samba2-CHP-10-NOTE-150"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
<p>Because the data has already been processed through a printer driver
by the time it reaches the Samba host, make sure the printer on the
Unix system is configured without any printer driver and that it will
print whatever data it receives in raw form. If you already have the
printer configured for use by Unix applications, you might need to
set up another queue for it to print documents received from Windows
clients correctly.</p>
</blockquote>
<p>Sending a <a name="INDEX-4"/>print job to a printer on a
<a name="INDEX-5"/>Samba server involves four steps:</p>
<ol><li>
<p>Opening and authenticating a connection to the printer share</p>
</li><li>
<p>Copying the file over the network</p>
</li><li>
<p>Closing the connection</p>
</li><li>
<p>Printing and deleting the copy of the file</p>
</li></ol>
<p>When a print job arrives at a Samba server, the print data is
temporarily written to disk in the directory specified by the
<tt class="literal">path</tt> option of the printer share. Samba then
executes a Unix print command to send that datafile to the printer.
The job is then printed as the authenticated user of the share. Note
that this can be the guest user, depending on how the share is
configured.</p>
<div class="sect2"><a name="samba2-CHP-10-SECT-1.1"/>
<h3 class="head2">Print Commands</h3>
<p><a name="INDEX-6"/>To print the
document, you'll need to inform Samba of the command
used to print and delete a file. On Linux, which uses a BSD-style
printing system, a command that does this is:</p>
<blockquote><pre class="code">lpr -r -P<em class="replaceable">printer</em> <em class="replaceable">file</em></pre></blockquote>
<p>This command tells <a name="INDEX-7"/><em class="emphasis">lpr</em> to retrieve the
name of the printer in the system configuration file
(<em class="filename">/etc/printcap</em>) 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 <em class="emphasis">-r</em> option has
been specified, the file will be deleted after it has been printed.
Of course, the file removed is just a copy stored on the Samba
server; the original document on the client is unaffected.</p>
<p>The process is similar on System V Unix. Here, printing and deleting
become a compound command:</p>
<blockquote><pre class="code">lp -d<em class="replaceable">printer</em> -s <em class="replaceable">file</em>; rm <em class="replaceable">file</em></pre></blockquote>
<p>In this case, the <em class="filename">/etc/printcap</em> file is replaced
with a different set of configuration files residing in
<em class="filename">/usr/spool/lp</em>. Because the
<em class="emphasis">lp</em> command has no option to delete the file
after it is printed, we have added the <em class="emphasis">rm</em>
command.</p>
</div>
<div class="sect2"><a name="samba2-CHP-10-SECT-1.2"/>
<h3 class="head2">A Minimal Printing Setup</h3>
<p>Let's start with a simple yet illustrative
<a name="INDEX-8"/>printing
share. Assuming that you're on a Linux system and
you have a printer called <tt class="literal">netprinter</tt> listed in the
printer capabilities file, the following addition to your
<em class="filename">smb.conf</em> file makes the printer accessible
through the network:</p>
<blockquote><pre class="code">[printer1]
printable = yes
print command = /usr/bin/lpr -P%p -r %s
printer = netprinter
printing = BSD
path = /var/tmp</pre></blockquote>
<p>The variable <tt class="literal">%s</tt> in the
<tt class="literal">print</tt><a name="INDEX-9"/> <tt class="literal">command</tt>
option is replaced with the name of the file to be printed when Samba
executes the command. There are four Samba configuration-file
variables specifically for use with
<a name="INDEX-10"/>printing
options. They are shown in <a href="ch10.html#samba2-CHP-10-TABLE-1">Table 10-1</a>.</p>
<a name="samba2-CHP-10-TABLE-1"/><h4 class="head4">Table 10-1. Printing variables</h4><table border="1">
<tr>
<th>
<p>Variable</p>
</th>
<th>
<p>Definition</p>
</th>
</tr>
<tr>
<td>
<p><tt class="literal">%s</tt></p>
</td>
<td>
<p>The full pathname of the file on the Samba server to be printed</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">%f</tt></p>
</td>
<td>
<p>The name of the file itself (without the preceding path) on the Samba
server to be printed</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">%p</tt></p>
</td>
<td>
<p>The name of the Unix printer to use</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">%j</tt></p>
</td>
<td>
<p>The number of the print job (for use with <tt class="literal">lprm</tt>,
<tt class="literal">lppause</tt>, and <tt class="literal">lpresume</tt>)</p>
</td>
</tr>
</table>
<p>For other flavors of Unix, it is necessary to modify both the
<tt class="literal">printing</tt> and <tt class="literal">print</tt>
<tt class="literal">command</tt> options. For System V Unix, we would
specify:</p>
<blockquote><pre class="code">[printer1]
printing = SYSV
print command = lp -d%p -s %s; rm %s</pre></blockquote>
<p>With the <tt class="literal">printing</tt> <tt class="literal">=</tt>
<tt class="literal">SYSV</tt> parameter, we notify Samba that the local
printing system uses the System V Unix method. As mentioned earlier,
the <tt class="literal">%p</tt> variable resolves to the name of the
printer, while the <tt class="literal">%s</tt> variable resolves to the
name of the file.</p>
<p>Clients might need to request the status of a print job sent to the
Samba server. Because Samba sends print jobs to the Unix printing
system for spooling, there might be a number of jobs in the queue at
any given time. Consequently, Samba needs to communicate to the
client not only the status of the current printing job, but also
which documents are 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 the following existing Unix commands:</p>
<ul><li>
<p><tt class="literal">lpq</tt><a name="INDEX-11"/></p>
</li><li>
<p><tt class="literal">lprm</tt><a name="INDEX-12"/></p>
</li><li>
<p><tt class="literal">lppause</tt><a name="INDEX-13"/></p>
</li><li>
<p><tt class="literal">lpresume</tt><a name="INDEX-14"/></p>
</li></ul>
<p>We cover these options in more detail later in this chapter. For the
most part, Samba provides reasonable default values for them based on
the value of the <tt class="literal">printing</tt> configuration option, so
you can probably get by without having to formulate your own commands
for them.</p>
<p>Here are a few important items to remember about
<a name="INDEX-15"/>printing shares:</p>
<ul><li>
<p>You must put
<tt class="literal">printable</tt><a name="INDEX-16"/> <tt class="literal">=</tt>
<tt class="literal">yes</tt> in all printer shares (even
<tt class="literal">[printers]</tt>) so that Samba knows they are printer
shares. If you forget, the shares will be unusable for printing and
will instead be treated as disk shares.</p>
</li><li>
<p>If you set the <tt class="literal">path</tt> 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
<em class="filename">/tmp</em>. Because the amount of disk space allocated
to <em class="filename">/tmp</em> can be relatively small in some Unix
operating systems, many administrators prefer to use
<em class="filename">/var/tmp, /var/spool/tmp</em>, or some other
directory instead.</p>
</li><li>
<p>If you set <tt class="literal">guest</tt> <tt class="literal">ok</tt>
<tt class="literal">=</tt> <tt class="literal">yes</tt> in a printer share and
Samba is configured for share-level security, anyone can send data to
the printer as the <tt class="literal">guest</tt>
<tt class="literal">account</tt> user.</p>
</li></ul>
<p>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 select few by adding the
<tt class="literal">valid</tt> <tt class="literal">users</tt> option to its share
definition:</p>
<blockquote><pre class="code">[deskjet]
printable = yes
path = /var/spool/samba/print
valid users = elizabeth cozy jack heather alexander lina emerald</pre></blockquote>
<p>All the other share accessibility options work for printing shares as
well.</p>
</div>
<div class="sect2"><a name="samba2-CHP-10-SECT-1.3"/>
<h3 class="head2">The [printers] Share</h3>
<p>If a share named
<tt class="literal">[printers]</tt><a name="INDEX-17"/> is 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 <tt class="literal">lp</tt>,
<tt class="literal">pcl</tt>, and <tt class="literal">ps</tt> printers in its
printer capabilities file, Samba would provide three printer shares
with those names, each configured with the options in the
<tt class="literal">[printers]</tt> share.</p>
<p>Recall that Samba obeys the following rules when a client requests a
share that has not been created with an explicit share definition in
the <em class="filename">smb.conf</em> file:</p>
<ul><li>
<p>If the share name matches a username in the system password file and
a <tt class="literal">[homes]</tt> share exists, a new share is created
with the name of the user and is initialized using the values given
in the <tt class="literal">[homes]</tt> and <tt class="literal">[global]</tt>
sections.</p>
</li><li>
<p>Otherwise, if the name matches a printer in the system printer
capabilities file and a <tt class="literal">[printers]</tt> share exists, a
new share is created with the name of the printer and initialized
using the values given in the <tt class="literal">[printers]</tt> section.
(Variables in the <tt class="literal">[global]</tt> section do not apply
here.)</p>
</li><li>
<p>If neither of those succeeds, Samba looks for a
<tt class="literal">default</tt> <tt class="literal">service</tt> share. If none
is found, it returns an error.</p>
</li></ul>
<p>This brings to light an important point: be careful that you do not
give a printer the same name as a user. Otherwise, users end up
connecting to a disk share when they might have wanted a printer
share instead.</p>
<p>Here is an example
<tt class="literal">[printers]</tt><a name="INDEX-18"/> share for a Linux system. Some of
these options are already defaults; however, we have listed them
anyway for illustrative purposes:</p>
<blockquote><pre class="code">[printers]
printable = yes
printing = BSD
printcap name = /etc/printcap
print command = /usr/bin/lpr -P%p -r %s
path = /var/spool/lpd/tmp
min print space = 2000</pre></blockquote>
<p>Here, we've given Samba global options that specify
the printing type (BSD), a print command to send data to the printer
and later remove the temporary file, the location of our printer
capabilities file, and a minimum disk space for printing of 2MB.</p>
<p>In addition, we've created a
<tt class="literal">[printers]</tt> share for each system printer. Our
temporary spooling directory is specified by the
<tt class="literal">path</tt> option:
<em class="filename">/var/spool/lpd/tmp</em>. Each share is marked as
printable—this is a necessary option, even in the
<tt class="literal">[printers]</tt> section.</p>
</div>
<div class="sect2"><a name="samba2-CHP-10-SECT-1.4"/>
<h3 class="head2">Testing the Configuration</h3>
<p><a name="INDEX-19"/>After running
<em class="emphasis">testparm</em> and restarting the Samba daemons, you
can check to make sure everything is set up correctly by using
<em class="emphasis">smbclient</em><a name="INDEX-20"/><a name="INDEX-21"/> to send a file to the printer.
Connect to the printer using the command:</p>
<blockquote><pre class="code"># <tt class="userinput"><b>smbclient /</b></tt><em class="replaceable">server</em><tt class="userinput"><b>/</b></tt><em class="replaceable">printshare</em></pre></blockquote>
<p>and then use the <em class="emphasis">print</em> command to print a file:</p>
<blockquote><pre class="code">smb: /> <tt class="userinput"><b>print </b></tt><em class="replaceable">textfile</em></pre></blockquote>
<a name="samba2-CHP-10-NOTE-151"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
<p>If you connect to a print share served by a Windows 95/98/Me system
configured to use user-mode security and cannot authenticate using
what you know to be a correct username and password, try
reconfiguring the Windows system to use share-mode security.</p>
</blockquote>
<p>When you print something through the Samba server via
<em class="emphasis">smbclient</em>, the following actions should occur:</p>
<ul><li>
<p>The job appears (briefly) in the Samba spool directory specified by
the path.</p>
</li><li>
<p>The job shows up in your print system's spool
directory.</p>
</li><li>
<p>The job disappears from the spool directory that Samba used.</p>
</li></ul>
<p>If <em class="emphasis">smbclient</em> cannot print, you can reset the
<tt class="literal">print</tt> <tt class="literal">command</tt> option to collect
debugging information:</p>
<blockquote><pre class="code">print command = echo "printed %s on %p" >>/tmp/printlog</pre></blockquote>
<p>A <a name="INDEX-22"/>common
problem with Samba printer configuration is forgetting to use the
full pathnames for commands. Another frequent problem is not having
the correct permissions on the spooling directory.<a name="FNPTR-1"/><a href="#FOOTNOTE-1">[1]</a> As usual,
check your Samba log files and system log files for error messages.
If you use BSD printing, you can change the <tt class="literal">lp</tt>
keyword in the printer's printcap entry to something
other than <em class="filename">/dev/null</em>, allowing you to collect
error messages from the printing system.</p>
<a name="samba2-CHP-10-NOTE-152"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
<p>More information on
<a name="INDEX-23"/>debugging printers is in the file
<em class="filename">docs/textdocs/Printing.txt</em> in the Samba source
distribution. The Unix print systems are covered in detail in
<a name="INDEX-24"/>Æleen
Frisch's <em class="emphasis">Essential Systems
Administration</em> (published by O'Reilly).</p>
</blockquote>
</div>
<div class="sect2"><a name="samba2-CHP-10-SECT-1.5"/>
<h3 class="head2">Enabling SMB Printer Sharing in Mac OS X</h3>
<p>With Samba preinstalled with
<a name="INDEX-25"/><a name="INDEX-26"/>Mac OS X, sharing access to a printer
among Windows clients is easy. First, of course, you should set up
local access using the Print Center application (located in
<em class="filename">/Applications/Utilities</em>). Under the Printers
menu, select Add Printer..., and make the appropriate selection from
the pop-up menu. For example, if the printer is directly attached,
select USB; if the printer is powered on, it should appear in the
list. Choose the printer, and press the Add button.</p>
<p>Edit <em class="filename">/etc/smb.conf</em>, uncommenting the
<tt class="literal">[printers]</tt> share and making any additional
configuration changes you feel are necessary. Finally, enable the
Samba startup item as described in <a href="ch02.html">Chapter 2</a>,
either by checking Windows File Sharing in Sharing Preferences or by
manually editing <em class="filename">/etc/hostconfig</em>. Now your
printer can be used by remote Windows clients.</p>
<p>On Mac OS X and some other BSD-based systems, you can test your
configuration using
<em class="emphasis">smbutil</em><a name="INDEX-27"/>. The following will send the
file named <em class="filename">print_test_file</em> to the printer named
<em class="filename">printshare</em> on the server
<em class="emphasis">bsdserver</em> :</p>
<blockquote><pre class="code">% <tt class="userinput"><b>smbutil print //bsdserver/printshare print_test_file</b></tt></pre></blockquote>
<p>See <a href="ch05.html">Chapter 5</a> for more information on using
<em class="emphasis">smbutil</em>.</p>
</div>
<div class="sect2"><a name="samba2-CHP-10-SECT-1.6"/>
<h3 class="head2">Setting Up and Testing a Windows Client</h3>
<p><a name="INDEX-28"/>Now that Samba is
offering a workable printer, you can set up your access to it on a
Windows client. Browse through the Samba server in the Network
Neighborhood. It should now show each printer that is available. For
example, in <a href="ch10.html#samba2-CHP-10-FIG-1">Figure 10-1</a>, we saw a printer called
<tt class="literal">lp</tt>.</p>
<p>Next, you need to have the Windows client recognize the printer.
Double-click 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. Click the Yes or OK
button, and the Printer Wizard will open.</p>
<p>If you are installing a printer on Windows 95/98/Me, the first thing
the wizard will ask is whether you need to print from DOS.
Let's assume you don't, so choose
the "No" radio button and press the
Next > button to get to the manufacturer/model window, as shown in
<a href="ch10.html#samba2-CHP-10-FIG-2">Figure 10-2</a>.</p>
<div class="figure"><a name="samba2-CHP-10-FIG-2"/><img src="figs/sam2_1002.gif"/></div><h4 class="head4">Figure 10-2. Setting the manufacturer and model of the printer</h4>
<p>In this dialog box, you should see a large list of manufacturers and
models for a huge number of printers. Select the manufacturer of your
printer in the left side of the dialog box, and then the exact model
of the printer in the list on the right side.</p>
<p>In some cases, you might not find your printer in the list, or the
version of the printer driver included with Windows might be out of
date. In cases such as these, consult the printer
manufacturer's documentation on how to install the
driver. Typically, you will click the Have Disk... button to install
the driver from a CD-ROM or disk file.</p>
<p>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 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 might make your
other printers fail. Therefore, we recommend you keep using your
existing printer drivers as long as they're working
properly.</p>
<p>Click the Next > or OK button. On Windows 95/98/Me, the Printer
Wizard asks you to name the printer. On Windows NT/2000/XP, you need
to right-click the printer's icon and select
Properties to assign the printer a name. <a href="ch10.html#samba2-CHP-10-FIG-3">Figure 10-3</a>
shows how we've named our printer to show that
it's shared by the <tt class="literal">mixtec</tt> Samba
server.</p>
<div class="figure"><a name="samba2-CHP-10-FIG-3"/><img src="figs/sam2_1003.gif"/></div><h4 class="head4">Figure 10-3. Setting the printer name</h4>
<p>Finally, on Windows 95/98/Me the Printing Wizard asks if it should
print a test page. Click the "Yes"
radio button, then the Finish button, and you should be presented
with the dialog box shown in <a href="ch10.html#samba2-CHP-10-FIG-4">Figure 10-4</a>. On Windows
NT/2000/XP, the printer test function is also accessed through the
printer's Properties dialog box.</p>
<div class="figure"><a name="samba2-CHP-10-FIG-4"/><img src="figs/sam2_1004.gif"/></div><h4 class="head4">Figure 10-4. Sending a test page to the printer</h4>
<p>If the test printing was unsuccessful, click the No button and the
Printing Wizard will walk you through some debugging steps for the
client side of the process. If the test printing does work, the
remote printer will now be available to all Windows applications
through the File and Print menu items.</p>
</div>
</div>
<div class="sect1"><a name="samba2-CHP-10-SECT-2"/>
<h2 class="head1">Printing to Windows Printers</h2>
<p><a name="INDEX-29"/>If you have printers
connected to systems running Windows 95/98/Me or Windows NT/2000/XP,
the printers can also be accessed from your Unix system using tools
that are part of the Samba distribution. First, it is necessary to
create a printer share on the Windows system. Then set up the printer
on the Unix side by configuring a new printer and using a Samba
printing program as the printer's filter.</p>
<div class="sect2"><a name="samba2-CHP-10-SECT-2.1"/>
<h3 class="head2">Sharing Windows Printers</h3>
<p>Sharing printers on Windows is not unlike sharing files. In fact, it
is a little simpler. Open the Control Panel, then double-click the
Printers icon to open the Printers window. Right-click the icon for
the printer you want to share, and select Sharing.... This opens the
dialog box shown in <a href="ch10.html#samba2-CHP-10-FIG-5">Figure 10-5</a> for a Windows 98
system, or <a href="ch10.html#samba2-CHP-10-FIG-6">Figure 10-6</a> on a Windows 2000 system.
(The dialog box appears slightly different on other Windows versions,
but functions almost identically.)</p>
<a name="samba2-CHP-10-NOTE-153"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
<p>On Windows 95/98/Me systems, you may need to run file sharing in
share-level (rather than user-level) access control mode to access a
shared printer from Samba. To check or set this mode, go to Control
Panel, then double-click on Network, then click on the Access Control
tab. More detailed information on this can be found in <a href="ch05.html">Chapter 5</a>.</p>
</blockquote>
<div class="figure"><a name="samba2-CHP-10-FIG-5"/><img src="figs/sam2_1005.gif"/></div><h4 class="head4">Figure 10-5. Sharing printers on Windows 98</h4>
<div class="figure"><a name="samba2-CHP-10-FIG-6"/><img src="figs/sam2_1006.gif"/></div><h4 class="head4">Figure 10-6. Sharing printers on Windows 2000</h4>
<p>Click the "Shared as" radio button,
then click the OK button. The printer is now accessible by other
systems on the network.</p>
</div>
<div class="sect2"><a name="samba2-CHP-10-SECT-2.2"/>
<h3 class="head2">Adding a Unix Printer</h3>
<p><a name="INDEX-30"/>The Samba distribution comes with
three programs that assist with printing on shared printers. The
<em class="emphasis">smbprint</em><a name="INDEX-31"/> program works with systems that use the
BSD printing system,
<em class="emphasis">smbprint.sysv</em><a name="INDEX-32"/>
works with systems that use System V printing, and
<em class="emphasis">smbspool</em><a name="INDEX-33"/>
works with systems that use the Common Unix Printing System (CUPS).
In the following sections we show you how to install printers for
each system.</p>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.2.1"/>
<h3 class="head3">BSD printers</h3>
<p><a name="INDEX-34"/><a name="INDEX-35"/>The
BSD printing system is used by many Unix variants, including Red Hat
Linux. With BSD printing, all the printers on the system have an
entry in the <em class="filename">/etc/printcap</em> file, which is the
database of printer capabilities used by the <em class="emphasis">lpd</em>
line printer daemon and other programs that assist with printing. The
Red Hat Linux implementation is a bit different in that
<em class="filename">/etc/printcap</em> is a machine-generated file, which
is re-created every time the <em class="emphasis">lpd</em> daemon is
restarted by the <em class="emphasis">/etc/rc.d/init.d/lpd</em> script.
Instead of editing <em class="filename">/etc/printcap</em>, we will add an
entry for our printer in <em class="filename">/etc/printcap.local</em>,
which the system automatically includes verbatim when creating
<em class="filename">/etc/printcap</em>.</p>
<a name="samba2-CHP-10-NOTE-154"/><blockquote class="note"><h4 class="objtitle">TIP</h4>
<p>If you are using the version of Samba installed from an RPM file as
on Red Hat Linux, you might be able to skip these directions and use
the <em class="emphasis">printconf</em> tool, which has support for SMB
printers. Unfortunately, this tool might not work correctly if you
have installed Samba from the Samba source distribution.</p>
</blockquote>
<p>Here is the entry we added to our
<em class="filename">/etc/printcap.local</em><a name="INDEX-36"/><a name="INDEX-37"/> file to support our Hewlett-Packard
DeskJet 932C printer, which is shared by <tt class="literal">maya</tt>, a
Windows 98 system:</p>
<blockquote><pre class="code">lp|maya-hp932c:\
:cm=HP 932C on maya:\
:sd=/var/spool/lpd/maya:\
:af=/var/spool/lpd/maya/acct:\
:if=/usr/local/samba/bin/smbprint:\
:mx=0:\
:lp=/dev/null:</pre></blockquote>
<p>The first line creates names for the printer. We are calling it both
<tt class="literal">maya-hp932c</tt>, to describe its location on the
network and the type of printer, and <tt class="literal">lp</tt> so that
programs will use it as the default printer. The rest of the lines
specify keywords and values. The <tt class="literal">cm</tt> keyword allows
us to assign a comment string to the printer. The
<tt class="literal">sd</tt> and <tt class="literal">af</tt> keywords assign the
printer's spool directory and accounting files,
respectively. The <tt class="literal">if</tt> keyword assigns the print
filter. We are using the <em class="emphasis">smbprint</em> command to
send the output to the shared SMB printer. The <tt class="literal">mx</tt>
keyword is set to zero to allow any size file to be printed, and
<tt class="literal">lp</tt> is set to <em class="filename">/dev/null</em> to
discard error messages.</p>
<p>You can follow our model to create an entry for your own printer. If
you want to go beyond the capabilities we used, refer to your
system's <em class="emphasis">printcap(5)</em> manual
page for a complete listing of keywords.</p>
<p>Go to your Samba source distribution's root
directory, and install the <em class="emphasis">smbprint</em> program like
this:</p>
<blockquote><pre class="code"># <tt class="userinput"><b>cp examples/printing/smbprint /usr/local/samba/bin</b></tt></pre></blockquote>
<p>We next create the printer's spool directory:</p>
<blockquote><pre class="code"># <tt class="userinput"><b>cd /var/spool/lpd</b></tt>
# <tt class="userinput"><b>mkdir maya</b></tt>
# <tt class="userinput"><b>chown lp:lp maya</b></tt>
# <tt class="userinput"><b>chmod 700 maya</b></tt></pre></blockquote>
<p>The <em class="emphasis">smbprint</em> program looks for a file named
<em class="filename">.config</em> in the printer's spool
directory, which contains information on how to connect to the
printer share. We create this file and then fill in the required
information:</p>
<blockquote><pre class="code"># <tt class="userinput"><b>cd maya</b></tt>
# <tt class="userinput"><b>>.config</b></tt>
# <tt class="userinput"><b>chown lp:lp .config</b></tt>
# <tt class="userinput"><b>chmod 600 .config</b></tt></pre></blockquote>
<p>Use your preferred text editor to edit the
<em class="filename">.config</em> file, and enter three lines, like this:</p>
<blockquote><pre class="code">server=maya
service=hp
password=""</pre></blockquote>
<p>This is for our shared printer having a UNC of
<em class="filename">\\maya\hp</em>. When we created the printer share, we
did not give it a password, so we use a null password here. If your
printer share is on a Windows NT/2000/XP system, use your domain
password.</p>
<p>Finally, restart the printer daemon:</p>
<blockquote><pre class="code"># <tt class="userinput"><b>/etc/rc.d/init.d/lpd restart</b></tt></pre></blockquote>
<p>You can now try printing something. Run the following command:</p>
<blockquote><pre class="code">$ <tt class="userinput"><b>lpr textfile</b></tt></pre></blockquote>
<p>If you have everything set up correctly, the file prints on the
shared printer. If you get "stair
stepping" of text, caused by the printer not
returning to the left margin at the beginning of every line, modify
the <tt class="literal">if</tt> keyword in your printcap entry to run
<em class="emphasis">smbprint</em> with the <em class="emphasis">-t</em>
option. <a name="INDEX-38"/><a name="INDEX-39"/></p>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.2.2"/>
<h3 class="head3">System V printers</h3>
<p><a name="INDEX-40"/><a name="INDEX-41"/>Sending print jobs from a System V Unix
system is a little easier than with the BSD system. Here, you need to
edit the <em class="filename">smbprint.sysv</em> script in the
<em class="filename">examples/printing</em> directory of the Samba
distribution and do the following:</p>
<ol><li>
<p>Change the <tt class="literal">server</tt>, <tt class="literal">service</tt>, and
<tt class="literal">password</tt> parameters in the script to match the
NetBIOS computer name, its shared printer service, and its password,
respectively. For example, the following entries would be correct for
the service in the previous example:</p>
<blockquote><pre class="code">server = maya
service = hp
password = ""</pre></blockquote>
</li>
<li>
<p>Run the following commands, which create a reference for the new
printer (which we are naming <tt class="literal">hp_printer</tt>) in the
printer capabilities file:</p>
<blockquote><pre class="code"># <tt class="userinput"><b>lpadmin -p hp_printer -v /dev/null -i./smbprint.sysv</b></tt>
# <tt class="userinput"><b>enable hp_printer</b></tt>
# <tt class="userinput"><b>accept hp_printer</b></tt></pre></blockquote>
</li></ol>
<p>After you've done that, restart the Samba daemons
and try printing to <tt class="literal">hp_printer</tt> using any standard
Unix program.</p>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.2.3"/>
<h3 class="head3">CUPS printers</h3>
<p><a name="INDEX-42"/><a name="INDEX-43"/><a name="INDEX-44"/>CUPS<a name="FNPTR-2"/><a href="#FOOTNOTE-2">[2]</a> uses
a set of modules, called
<em class="firstterm">backends</em><a name="INDEX-45"/>, to send print jobs to various
destinations, such as local printers attached to parallel, serial, or
Universal Serial Bus (USB) ports, or over the network using Unix line
printer daemon (LPD) protocol, Internet Printing Protocol (IPP),
AppleTalk Printer Access Protocol (PAP), and so on. The software
package does not come with a backend for SMB; the Samba suite
includes the <em class="emphasis">smbspool</em>
<a name="INDEX-46"/>utility for this purpose.</p>
<p>To enable printing to remote SMB printers using CUPS, create a
symbolic link named <em class="filename">smb</em> in the CUPS backend
directory pointing to <em class="emphasis">smbspool</em>. Depending on
installation options, these could be in a number of places in the
directory hierarchy, so be sure to check your system. Using a common
default installation, the command would look like this:</p>
<blockquote><pre class="code"># <tt class="userinput"><b>ln -s /usr/local/samba/bin/smbspool /usr/lib/cups/backend/smb</b></tt></pre></blockquote>
<p>Issue a HUP signal to the CUPS daemon, <em class="emphasis">cupsd</em>,
and check for the existence of SMB support with the <em class="emphasis">lpinfo
-v</em> command. Its output should now include a line that says
<tt class="literal">network</tt> <tt class="literal">smb</tt>.</p>
<p>To add a printer, use the CUPS web interface, accessible on the local
system at <em class="emphasis">http://localhost:631/</em>,
or use the <em class="emphasis">lpadmin</em> command:</p>
<blockquote><pre class="code"># <tt class="userinput"><b>lpadmin -p hp932c -E -v smb://maya/hp932c -D "HP 932C on maya"</b></tt></pre></blockquote>
<p>This creates and enables the new print spool called
<tt class="literal">hp932c</tt>. The <em class="emphasis">-v</em> argument
specifies the printer device, which in this case is accessed over the
network using an SMB URI. If the printer is not guest-accessible,
you'll need to provide a username and password in
the URI. The full format is as follows:</p>
<blockquote><pre class="code">smb://[<em class="replaceable">username</em>[:<em class="replaceable">password</em>]@][<em class="replaceable">workgroup</em>/]<em class="replaceable">server</em>/<em class="replaceable">printshare</em></pre></blockquote>
<p>The <em class="emphasis">lpadmin</em><a name="INDEX-47"/> command makes changes to
<em class="filename">/etc/cups/printers.conf</em> and sends a HUP signal
to the <em class="emphasis">cupsd</em> daemon, resulting in the creation
of a local raw printer spool. In this example, print data is passed
in raw format to the Windows system, which has the necessary printer
drivers and printer description files to format the data
appropriately. The <em class="emphasis">-D</em> option is used to give the
printer a comment string.</p>
<p>Once you have the printer set up, it's time to test
it out. CUPS understands both BSD-style and System V-style printing
commands, so you can use whichever is more comfortable. Using the BSD
<em class="emphasis">lpr</em> command, try something like:</p>
<blockquote><pre class="code">$ <tt class="userinput"><b>lpr -P hp932c textfile</b></tt></pre></blockquote>
<p>You should now be set up to use the printer from any application on
the Unix system. <a name="INDEX-48"/></p>
</div>
</div>
<div class="sect2"><a name="samba2-CHP-10-SECT-2.3"/>
<h3 class="head2">Samba Printing Options</h3>
<p><a href="ch10.html#samba2-CHP-10-TABLE-2">Table 10-2</a> summarizes the Samba <a name="INDEX-49"/><a name="INDEX-50"/>printing
options.</p>
<a name="samba2-CHP-10-TABLE-2"/><h4 class="head4">Table 10-2. Printing configuration options</h4><table border="1">
<tr>
<th>
<p>Option</p>
</th>
<th>
<p>Parameters</p>
</th>
<th>
<p>Function</p>
</th>
<th>
<p>Default</p>
</th>
<th>
<p>Scope</p>
</th>
</tr>
<tr>
<td>
<p><tt class="literal">printing</tt></p>
</td>
<td>
<p><tt class="literal">bsd</tt>, <tt class="literal">sysv</tt>,
<tt class="literal">cups</tt>, <tt class="literal">hpux</tt>,
<tt class="literal">aix</tt>, <tt class="literal">qnx</tt>,
<tt class="literal">plp</tt>, <tt class="literal">softq</tt>, or
<tt class="literal">lprng</tt></p>
</td>
<td>
<p>Printing system type of the Samba host</p>
</td>
<td>
<p>System-dependent</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">printable</tt> <tt class="literal">(print ok)</tt></p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Marks a share as a printing share</p>
</td>
<td>
<p><tt class="literal">no</tt></p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">printer</tt> <tt class="literal">(printer name)</tt></p>
</td>
<td>
<p>string (Unix printer name)</p>
</td>
<td>
<p>Name for the printer that is shown to clients</p>
</td>
<td>
<p>System-dependent</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lpq cache time</tt></p>
</td>
<td>
<p>numeric (time in seconds)</p>
</td>
<td>
<p>Amount of time in seconds that Samba will cache the printer queue
status</p>
</td>
<td>
<p><tt class="literal">10</tt></p>
</td>
<td>
<p>Global</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">postscript</tt></p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Treats all print jobs as PostScript by prefixing
<tt class="literal">%!</tt> at the beginning of each file</p>
</td>
<td>
<p><tt class="literal">no</tt></p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">load printers</tt></p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>If <tt class="literal">yes</tt>, automatically loads each printer in the
<em class="emphasis">printcap</em> file as printing shares</p>
</td>
<td>
<p><tt class="literal">yes</tt></p>
</td>
<td>
<p>Global</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">print command</tt></p>
</td>
<td>
<p>string (shell command)</p>
</td>
<td>
<p>Unix command to perform printing</p>
</td>
<td>
<p>See below</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lpq command</tt></p>
</td>
<td>
<p>string (shell command)</p>
</td>
<td>
<p>Unix command to return the status of the printing queue</p>
</td>
<td>
<p>See below</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lprm command</tt></p>
</td>
<td>
<p>string (shell command)</p>
</td>
<td>
<p>Unix command to remove a job from the printing queue</p>
</td>
<td>
<p>See below</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lppause command</tt></p>
</td>
<td>
<p>string (shell command)</p>
</td>
<td>
<p>Unix command to pause a job on the printing queue</p>
</td>
<td>
<p>See below</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lpresume</tt> <tt class="literal">command</tt></p>
</td>
<td>
<p>string (shell command)</p>
</td>
<td>
<p>Unix command to resume a paused job on the printing queue</p>
</td>
<td>
<p>See below</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">printcap name</tt></p>
<p><tt class="literal">(printcap)</tt></p>
</td>
<td>
<p>string (filename)</p>
</td>
<td>
<p>Location of the printer capabilities file</p>
</td>
<td>
<p>System-dependent</p>
</td>
<td>
<p>Global</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">min print space</tt></p>
</td>
<td>
<p>numeric (size in kilobytes)</p>
</td>
<td>
<p>Minimum amount of free disk space that must be present to print</p>
</td>
<td>
<p><tt class="literal">0</tt></p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">queuepause</tt> <tt class="literal">command</tt></p>
</td>
<td>
<p>string (shell command)</p>
</td>
<td>
<p>Unix command to pause a queue</p>
</td>
<td>
<p>See below</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">queueresume</tt> <tt class="literal">command</tt></p>
</td>
<td>
<p>string (shell command)</p>
</td>
<td>
<p>Unix command to resume a queue</p>
</td>
<td>
<p>See below</p>
</td>
<td>
<p>Share</p>
</td>
</tr>
</table>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.1"/>
<h3 class="head3">printing</h3>
<p>The <tt class="literal">printing</tt><a name="INDEX-51"/> configuration option tells
Samba which <a name="INDEX-52"/>printing system to use. There are
several different families of commands to control printing and print
statusing. Samba supports seven different types, as shown in <a href="ch10.html#samba2-CHP-10-TABLE-3">Table 10-3</a>.</p>
<a name="samba2-CHP-10-TABLE-3"/><h4 class="head4">Table 10-3. Printing system types</h4><table border="1">
<tr>
<th>
<p>Variable</p>
</th>
<th>
<p>Definition</p>
</th>
</tr>
<tr>
<td>
<p>BSD</p>
</td>
<td>
<p>Berkeley Unix system</p>
</td>
</tr>
<tr>
<td>
<p>SYSV</p>
</td>
<td>
<p>System V</p>
</td>
</tr>
<tr>
<td>
<p>CUPS</p>
</td>
<td>
<p>Common Unix Printing System</p>
</td>
</tr>
<tr>
<td>
<p>AIX</p>
</td>
<td>
<p>IBM's AIX operating system</p>
</td>
</tr>
<tr>
<td>
<p>HPUX</p>
</td>
<td>
<p>Hewlett-Packard Unix</p>
</td>
</tr>
<tr>
<td>
<p>QNX</p>
</td>
<td>
<p>QNX Realtime Operating System</p>
</td>
</tr>
<tr>
<td>
<p>LPRNG</p>
</td>
<td>
<p>LPR Next Generation</p>
</td>
</tr>
<tr>
<td>
<p>SOFTQ</p>
</td>
<td>
<p>SOFTQ system</p>
</td>
</tr>
<tr>
<td>
<p>PLP</p>
</td>
<td>
<p>Portable Line Printer</p>
</td>
</tr>
</table>
<p>The value for this option must be one of these seven selections. For
example:</p>
<blockquote><pre class="code">printing = SYSV</pre></blockquote>
<p>The default value of this option is system-dependent and is
configured when Samba is first compiled. For most systems, the
<em class="filename">configure</em> script automatically detects the
printing system to be used and configures it properly in the Samba
makefile. However, if your system is a PLP, LPRNG, or QNX printing
system, you need to specify this explicitly in the makefile or the
printing share.</p>
<p>The most common system types are BSD, SYSV, and CUPS. Each printer on
a BSD Unix server is described in the printer capabilities
file—normally <em class="filename">/etc/printcap</em>. See the
section on the <tt class="literal">printcap</tt> <tt class="literal">file</tt>
parameter for more information on this topic.</p>
<p>Setting the <tt class="literal">printing</tt> configuration option
automatically sets at least three other printing options for the
service in question: <tt class="literal">print</tt>
<tt class="literal">command</tt>, <tt class="literal">lpq</tt>
<tt class="literal">command</tt>, and <tt class="literal">lprm</tt>
<tt class="literal">command</tt>. If you are running Samba on a system that
doesn't support any of the printing styles listed in
<a href="ch10.html#samba2-CHP-10-TABLE-3">Table 10-3</a>, simply set the commands for each of
these manually.</p>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.2"/>
<h3 class="head3">printable</h3>
<p>The <tt class="literal">printable</tt><a name="INDEX-53"/> option must be set to
<tt class="literal">yes</tt> 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:</p>
<blockquote><pre class="code">[printer1]
printable = yes</pre></blockquote>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.3"/>
<a name="INDEX-54"/><h3 class="head3">printer</h3>
<p>The option, also called
<tt class="literal">printer</tt><a name="INDEX-55"/> <tt class="literal">name</tt>,
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 <tt class="literal">lp</tt> for a printer.
For example:</p>
<blockquote><pre class="code">[deskjet]
printer = hpdkjet1</pre></blockquote>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.4"/>
<h3 class="head3">lpq cache time</h3>
<p>The global <tt class="literal">lpq</tt><a name="INDEX-56"/> <tt class="literal">cache</tt>
<tt class="literal">time</tt> option allows you to set the number of
seconds for which Samba will remember the current printer status.
After this time elapses, Samba will issue an <em class="emphasis">lpq</em>
command (or whatever command you specify with the
<tt class="literal">lpq</tt> <tt class="literal">command</tt> option) to get a
more up-to-date status that it can report to users. This defaults to
10 seconds, but can be increased if your <tt class="literal">lpq</tt>
<tt class="literal">command</tt> takes an unusually long time to run or you
have lots of clients. A time setting of 0 disables caching of queue
status. The following example resets the time to 30 seconds:</p>
<blockquote><pre class="code">[deskjet]
lpq cache time = 30</pre></blockquote>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.5"/>
<h3 class="head3">postscript</h3>
<p>The <tt class="literal">postscript</tt><a name="INDEX-57"/> option forces the
printer to treat all data sent to it as PostScript. It does this by
prefixing the characters <tt class="literal">%!</tt> to the beginning of
the first line of each job. It is normally used with PCs that insert
a <tt class="literal">^D</tt> (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 <tt class="literal">no</tt>. You can override it as
follows:</p>
<blockquote><pre class="code">[deskjet]
postscript = yes</pre></blockquote>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.6"/>
<h3 class="head3">load printers</h3>
<p>The <tt class="literal">load</tt><a name="INDEX-58"/> <tt class="literal">printers</tt>
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
<em class="filename">/etc/printcap</em> (or the system equivalent). For
example, if your
<em class="filename">printcap</em><a name="INDEX-59"/> file looks
like this:<a name="FNPTR-3"/><a href="#FOOTNOTE-3">[3]</a></p>
<blockquote><pre class="code">lp:\
:sd=/var/spool/lpd/lp:\ <i class="lineannotation">spool directory</i>
:mx#0:\ <i class="lineannotation">maximum file size (none)</i>
:sh:\ <i class="lineannotation">supress burst header (no)</i>
:lp=/dev/lp1:\ <i class="lineannotation">device name for output</i>
:if=/var/spool/lpd/lp/filter: <i class="lineannotation">text filter</i>
laser:\
:sd=/var/spool/lpd/laser:\ <i class="lineannotation">spool directory</i>
:mx#0:\ <i class="lineannotation">maximum file size (none)</i>
:sh:\ <i class="lineannotation">supress burst header (no)</i>
:lp=/dev/laser:\ <i class="lineannotation">device name for output</i>
:if=/var/spool/lpd/lp/filter: <i class="lineannotation">text filter</i></pre></blockquote>
<p>the shares <tt class="literal">[lp]</tt> and <tt class="literal">[laser]</tt> are
automatically created as valid print shares when Samba is started.
Both shares borrow the configuration options specified in the
<tt class="literal">[printers]</tt> section to configure themselves and are
available in the browse list for the Samba server. The default value
for this option is <tt class="literal">yes</tt>. If you prefer to specify
each printer explicitly in your configuration file, use the
following:</p>
<blockquote><pre class="code">[global]
load printers = no</pre></blockquote>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.7"/>
<a name="INDEX-60"/><a name="INDEX-61"/><a name="INDEX-62"/><a name="INDEX-63"/><a name="INDEX-64"/><h3 class="head3">print command, lpq command, lprm command,lppause command, lpresume command</h3>
<p>These options tell Samba which Unix commands control and send data to
the printer. The Unix commands involved are: <em class="emphasis">lpr</em>
(send to Line PRinter), <em class="emphasis">lpq</em> (List Printer
Queue), <em class="emphasis">lprm</em> (Line Printer ReMove), and
optionally <em class="emphasis">lppause</em> and
<em class="emphasis">lpresume</em>. Samba provides an option named after
each command, in case you need to override any of the system
defaults. For example, consider the following:</p>
<blockquote><pre class="code">lpq command = /usr/ucb/lpq %p</pre></blockquote>
<p>This would set <tt class="literal">lpq</tt> <tt class="literal">command</tt> to
use <em class="filename">/usr/ucb/lpq</em>. Similarly:</p>
<blockquote><pre class="code">lprm command = /usr/local/bin/lprm -P%p %j</pre></blockquote>
<p>would set the Samba printer remove command to
<em class="filename">/usr/local/bin/lprm</em> and provide it the print job
number using the <tt class="literal">%j</tt> variable.</p>
<p>The default values for each option are dependent on the value of the
<tt class="literal">printing</tt> option. <a href="ch10.html#samba2-CHP-10-TABLE-4">Table 10-4</a>
shows the default commands for each printing option. The most popular
printing system is BSD.</p>
<a name="samba2-CHP-10-TABLE-4"/><h4 class="head4">Table 10-4. Default commands for various printing options</h4><table border="1">
<tr>
<th>
<p>Option</p>
</th>
<th>
<p>BSD, AIX, PLP, LPRNG</p>
</th>
<th>
<p>SYSV, HPUX</p>
</th>
<th>
<p>QNX</p>
</th>
<th>
<p>SOFTQ</p>
</th>
</tr>
<tr>
<td>
<p><tt class="literal">print</tt> <tt class="literal">command</tt></p>
</td>
<td>
<p><tt class="literal">lpr -r -P%p %s</tt></p>
</td>
<td>
<p><tt class="literal">lp -c -d%p %s; rm</tt> <tt class="literal">%s</tt></p>
</td>
<td>
<p><tt class="literal">lp -r -P%p %s</tt></p>
</td>
<td>
<p><tt class="literal">lp -d%p -s %s; rm %s</tt></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lpq</tt> <tt class="literal">command</tt></p>
</td>
<td>
<p><tt class="literal">lpq -P%p</tt></p>
</td>
<td>
<p><tt class="literal">lpstat -o%p</tt></p>
</td>
<td>
<p><tt class="literal">lpq -P%p</tt></p>
</td>
<td>
<p><tt class="literal">lpstat -o%p</tt></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lprm</tt> <tt class="literal">command</tt></p>
</td>
<td>
<p><tt class="literal">lprm -P%p %j</tt></p>
</td>
<td>
<p><tt class="literal">cancel %p-%j</tt></p>
</td>
<td>
<p><tt class="literal">cancel %p-%j</tt></p>
</td>
<td>
<p><tt class="literal">cancel %p-%j</tt></p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lppause</tt> <tt class="literal">command</tt></p>
</td>
<td>
<p><tt class="literal">lp -i %p-%j -H</tt> <tt class="literal">hold</tt></p>
<p>(SYSV only)</p>
</td>
<td>
<p>None</p>
</td>
<td>
<p>None</p>
</td>
<td>
<p>None</p>
</td>
</tr>
<tr>
<td>
<p><tt class="literal">lpresume</tt> <tt class="literal">command</tt></p>
</td>
<td>
<p><tt class="literal">lp -i %p-%j -H</tt> <tt class="literal">resume</tt></p>
<p>(SYSV only)</p>
</td>
<td>
<p>None</p>
</td>
<td>
<p>None</p>
</td>
<td>
<p><tt class="literal">qstat -s -j%j -r</tt></p>
</td>
</tr>
</table>
<p>It is usually unnecessary to reset these options in Samba, with the
possible exception of the <tt class="literal">print</tt>
<tt class="literal">command</tt>. This option might need to be set
explicitly if your printing system doesn't have a
<em class="emphasis">-r</em> (remove after printing) option on the
printing command. For example:</p>
<blockquote><pre class="code">print command = /usr/local/lpr -P%p %s; /bin/rm %s</pre></blockquote>
<p>With a bit of judicious programming, these
<em class="filename">smb.conf</em> options can also be used for debugging:</p>
<blockquote><pre class="code">print command = cat %s >>/tmp/printlog; lpr -r -P%p %s</pre></blockquote>
<p>Using the previous configuration, it is possible to verify that files
are actually being delivered to the Samba server. If they are, their
contents will show up in the file <em class="filename">/tmp/printlog</em>.</p>
<p>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 systems do not have an
<em class="filename">/etc/printcap</em> file. Instead, the
<tt class="literal">printcap</tt> <tt class="literal">file</tt> option can be set
to an appropriate <em class="emphasis">lpstat</em> command for the system.
This tells Samba to get a list of printers from the
<em class="emphasis">lpstat</em> command. Alternatively, you can set the
global configuration option <tt class="literal">printcap</tt>
<tt class="literal">name</tt> to the name of a dummy
<em class="filename">printcap</em> file you provide. In the latter case,
the file must contain a series of lines such as:</p>
<blockquote><pre class="code">lp|print1|My Printer 1
print2|My Printer 2
print3|My Printer 3</pre></blockquote>
<p>Each line names a printer followed by aliases for it. In this
example, the first printer is called <tt class="literal">lp</tt>,
<tt class="literal">print1</tt>, or <tt class="literal">My</tt>
<tt class="literal">Printer</tt> <tt class="literal">1</tt>, whichever the user
prefers to use. The first name is used in place of
<tt class="literal">%p</tt> in any command Samba executes for that printer.</p>
<p>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. Samba also supports
the printing systems of the SOFTQ and QNX real-time operating
systems.</p>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.8"/>
<h3 class="head3">printcap name</h3>
<p>If the <tt class="literal">printcap</tt><a name="INDEX-65"/><a name="INDEX-66"/>
<tt class="literal">name</tt> option (also called
<tt class="literal">printcap</tt>) appears in a printing share, Samba uses
the file specified as the system printer capabilities file (normally
<em class="filename">/etc/printcap</em>). However, you can reset it to a
file consisting of only the printers you want to share over the
network. The value must be the filename (with its complete path
specified) of a printer capabilities file on the server:</p>
<blockquote><pre class="code">[deskjet]
printcap name = /usr/local/samba/lib/printcap</pre></blockquote>
<p>The CUPS printing system uses its own method of determining printer
capabilities, rather than the standard <em class="filename">printcap</em>
file. In this case, set <tt class="literal">printcap</tt>
<tt class="literal">name</tt> as follows:</p>
<blockquote><pre class="code">[global]
printing = cups
printcap name = cups</pre></blockquote>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.9"/>
<h3 class="head3">min print space</h3>
<p>The <tt class="literal">min</tt><a name="INDEX-67"/> <tt class="literal">print</tt>
<tt class="literal">space</tt> option sets the amount of space that must be
available on the disk that contains the spool directory if printing
is to be 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 to avoid having print jobs fill
up the remaining disk space on the server, which can cause other
processes to fail:</p>
<blockquote><pre class="code">[deskjet]
min print space = 4000</pre></blockquote>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.10"/>
<a name="INDEX-68"/><h3 class="head3">queuepause command</h3>
<p>This configuration option specifies a command that tells Samba how to
pause an entire print queue, 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.</p>
</div>
<div class="sect3"><a name="samba2-CHP-10-SECT-2.3.11"/>
<a name="INDEX-69"/><h3 class="head3">queueresume command</h3>
<p>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 this option. <a name="INDEX-70"/> <a name="INDEX-71"/> <a name="INDEX-72"/><a name="INDEX-73"/></p>
</div>
</div>
</div>
<hr/><h4 class="head4">Footnotes</h4><blockquote><a name="FOOTNOTE-1"/> <p><a href="#FNPTR-1">[1]</a> If
you are using Linux, you can use the <em class="emphasis">checkpc</em>
command to check for this type of error.</p> <a name="FOOTNOTE-2"/>
<p><a href="#FNPTR-2">[2]</a> CUPS is open source software (<a href="http://www.opensource.org">http://www.opensource.org</a>) developed by Easy
Software Products. For more information, visit <a href="http://www.cups.org">http://www.cups.org</a>.</p> <a name="FOOTNOTE-3"/> <p><a href="#FNPTR-3">[3]</a> We have placed annotated comments off to
the right in case you've never dealt with this file
before.</p> </blockquote><hr/><h4 class="head4"><a href="toc.html">TOC</a></h4></body></html>
|