diff --git a/en/handbook/README b/en/handbook/README index 79875a6c00..74d00cdfef 100644 --- a/en/handbook/README +++ b/en/handbook/README @@ -335,3 +335,24 @@ for example, Also markup other prompts (e.g., the DOS prompt C:\> that occurs in some places) as <prompt>s. + 31. Reviewing the use of <informalexample> and <screen>. + + In some cases <informalexample> wasn't appropriate, and the markup was + changed to <programlisting> or other. + + In some cases there were spurious <para> elements before and after the + <informalexample>. These were removed. + + Reformatted text within <screen> elements because the whitespace *is* + significant. + + Added <prompt> and <userinput> elements within <screen> where necessary. + + If I spotted inappropriate use of markup within the immediate vicinity + of the <informalexample> elements then I fixed that (mostly the use of + <emphasis remap="...">). + + This is part one of these changes -- there's a load of them, and this + goes up to line 11,284 or thereabouts, roughly one third of the way + through. + diff --git a/en/handbook/handbook.sgml b/en/handbook/handbook.sgml index 92c056f5e5..109c1aa0fd 100644 --- a/en/handbook/handbook.sgml +++ b/en/handbook/handbook.sgml @@ -2,8 +2,8 @@ <!ENTITY prompt.root "<prompt>#</prompt>"> <!ENTITY prompt.user "<prompt>%</prompt>"> ]> + <book> - <bookinfo> <bookbiblio> <title>FreeBSD Handbook</title> @@ -768,8 +768,7 @@ <para>If you are using MS-DOS then download <ulink URL="ftp://ftp.FreeBSD.ORG/pub/FreeBSD/tools/fdimage.exe">fdimage.exe</ulink> or get it from <filename>tools\fdimage.exe</filename> on the CDROM and then run it like so: <informalexample> - <screen><prompt>E:\></prompt> tools\fdimage floppies\boot.flp - a:</screen> + <screen><prompt>E:\></prompt> <userinput>tools\fdimage floppies\boot.flp a:</userinput></screen> </informalexample> The <emphasis>fdimage</emphasis> program will format the A: drive and then copy the boot.flp image onto it (assuming that you're at the top @@ -782,9 +781,8 @@ <para>If you are using a UNIX system to create the floppy image: <informalexample> - <screen>&prompt.root; dd if=boot.flp - of=<symbol>disk_device</symbol></screen> - </informalexample> where <symbol>disk_device</symbol> is + <screen>&prompt.root; <userinput>dd if=boot.flp of=<replaceable>disk_device</replaceable></userinput></screen> + </informalexample> where <replaceable>disk_device</replaceable> is the <filename>/dev</filename> entry for the floppy drive. On FreeBSD systems, this is <filename>/dev/rfd0</filename> for the A: drive and <filename>/dev/rfd1</filename> for @@ -799,11 +797,13 @@ <para>With the installation disk in the A: drive, reboot your computer. You should get a boot prompt something like this: <informalexample> - <screen>>> FreeBSD BOOT ...<!-- <br> --> Usage: - [[[0:][wd](0,a)]/kernel][-abcCdhrsv]<!-- <br> --> Use - 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1<!-- <br> - --> Use ? for file list or press Enter for defaults<!-- <br> - --> Boot: </screen> + <screen> +>> FreeBSD BOOT ... +Usage: [[[0:][wd](0,a)]/kernel][-abcCdhrsv] +Use 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1 +Use ? for file list or press Enter for defaults +Boot: + </screen> </informalexample> If you do <emphasis>not</emphasis> type anything, FreeBSD will automatically boot with its default configuration after a delay of about five seconds. As FreeBSD @@ -1449,16 +1449,14 @@ to add the following line to the password file (using the vipw command):</para> - <para> - <informalexample> - <screen>ftp:*:99:99::0:0:FTP:/cdrom:/nonexistent</screen> - </informalexample> - </para> + <programlisting> +ftp:*:99:99::0:0:FTP:/cdrom:/nonexistent + </programlisting> <para>Anyone with network connectivity to your machine (and permission to log into it) can now chose a Media type of FTP and - type in: <filename>ftp://<replaceable>your - machine</replaceable></filename> after picking <quote>Other</quote> in + type in: <userinput>ftp://<replaceable>your + machine</replaceable></userinput> after picking <quote>Other</quote> in the ftp sites menu.</para> </sect2> @@ -1493,12 +1491,18 @@ <para> <informalexample> - <screen>&prompt.root; fdformat -f 1440 fd0.1440 disklabel -w -r - fd0.1440 floppy3 newfs -t 2 -u 18 -l 1 -i 65536 /dev/rfd0 (Use - "fd0.1200" and "floppy5" for 5.25" 1.2MB disks).</screen> + <screen>&prompt.root; <userinput>fdformat -f 1440 fd0.1440</userinput> +&prompt.root; <userinput>disklabel -w -r fd0.1440 floppy3</userinput> +&prompt.root; <userinput>newfs -t 2 -u 18 -l 1 -i 65536 /dev/rfd0</userinput> + </screen> </informalexample> </para> - + + <note> + <para>Use <literal>fd0.1200</literal> and + <literal>floppy5</literal> for 5.25" 1.2MB disks.</para> + </note> + <para>Then you can mount and write to them like any other file system.</para> @@ -1528,9 +1532,9 @@ suggest using the DOS <command>xcopy</command> command. For example, to prepare for a minimal installation of FreeBSD: <informalexample> - <screen><prompt>C></prompt> MD C:\FREEBSD C> XCOPY /S E:\BIN - C:\FREEBSD\BIN\ <prompt>C></prompt> XCOPY /S E:\MANPAGES - C:\FREEBSD\MANPAGES\</screen> + <screen><prompt>C:\></prompt> <userinput>MD C:\FREEBSD</userinput> +<prompt>C:\></prompt> <userinput>XCOPY /S E:\BIN C:\FREEBSD\BIN\</userinput> +<prompt>C:\></prompt> <userinput>XCOPY /S E:\MANPAGES C:\FREEBSD\MANPAGES\</userinput></screen> </informalexample> assuming that <filename>C:</filename> is where you have free space and <filename>E:</filename> is where your CDROM is mounted.</para> @@ -1551,15 +1555,14 @@ after getting all of the files for distribution you are interested in, simply tar them onto the tape with a command like: <informalexample> - <screen>&prompt.root; cd /freebsd/distdir<!-- <br> --> tar cvf /dev/rwt0 (or - /dev/rst0) dist1 .. dist2</screen> + <screen>&prompt.root; <userinput>cd /freebsd/distdir</userinput> +&prompt.root; <userinput>tar cvf /dev/rwt0 dist1 ... dist2</userinput></screen> </informalexample> </para> <para>When you go to do the installation, you should also make sure that you leave enough room in some temporary directory (which you - will be allowed to choose) to accommodate the <emphasis - remap=bf>full</emphasis> contents of the tape you have created. + will be allowed to choose) to accommodate the <emphasis>full</emphasis> contents of the tape you have created. Due to the non-random access nature of tapes, this method of installation requires quite a bit of temporary storage. You should expect to require as much temporary storage as you have @@ -1710,7 +1713,7 @@ <para> <informalexample> - <screen>ftp://165.113.121.81/pub/FreeBSD/&rel.current;-RELEASE</screen> + <screen><userinput>ftp://165.113.121.81/pub/FreeBSD/&rel.current;-RELEASE</userinput></screen> </informalexample> </para> @@ -1757,10 +1760,10 @@ address. As your installation media, you specify FTP (or passive FTP, if the proxy support it), and the URL <informalexample> - <screen>ftp://foo.bar.com:1234/pub/FreeBSD</screen> - </informalexample> /pub/FreeBSD from ftp.freebsd.org is proxied - under foo.bar.com, allowing you to install from _that_ machine - (which fetch the files from ftp.freebsd.org as your installation + <screen><userinput>ftp://foo.bar.com:1234/pub/FreeBSD</userinput></screen> + </informalexample> <filename>/pub/FreeBSD</filename> from <hostid>ftp.freebsd.org</hostid> is proxied + under <hostid>foo.bar.com</hostid>, allowing you to install from _that_ machine + (which fetch the files from <hostid>ftp.freebsd.org</hostid> as your installation requests them).</para> </sect3> @@ -1898,11 +1901,9 @@ mount extended partitions exactly like you would mount any other DOS drive, e.g.:</para> - <para> - <informalexample> - <screen>&prompt.root; mount -t msdos /dev/sd0s5 /dos_d</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mount -t msdos /dev/sd0s5 /dos_d</userinput></screen> + </informalexample> <para><emphasis remap=bf>Can I run MS-DOS binaries under FreeBSD?</emphasis></para> @@ -1931,12 +1932,10 @@ of <emphasis>man pages</emphasis>. Nearly every program on the system comes with a short reference manual explaining the basic operation and various arguments. These manuals can be view with the - <emphasis remap=tt><command>man</command></emphasis> - command. Use of the <emphasis remap=tt><emphasis - remap=bf>man</emphasis></emphasis> command is simple: + <command>man</command> + command. Use of the <command>man</command> command is simple: <informalexample> - <screen>&prompt.user; - <userinput>man <replaceable>command</replaceable></userinput> + <screen>&prompt.user; <userinput>man <replaceable>command</replaceable></userinput> </screen> </informalexample> where <replaceable>command</replaceable> is the name of the command you wish to learn about. For example, to @@ -2040,10 +2039,8 @@ <para>To use the <citerefentry><refentrytitle>info</refentrytitle><manvolnum>1</manvolnum></citerefentry> command, simply type: <informalexample> <screen>&prompt.user; <userinput>info</userinput></screen> - </informalexample> For a brief introduction, type <emphasis - remap=tt><emphasis remap=bf>h</emphasis></emphasis>. For a quick - command reference, type <emphasis remap=tt><emphasis - remap=bf>?</emphasis></emphasis>.</para> + </informalexample> For a brief introduction, type <userinput>h</userinput>. For a quick + command reference, type <userinput>?</userinput>.</para> </sect1> </chapter> @@ -2179,19 +2176,24 @@ <para><emphasis>Note</emphasis> if you are trying this at home, you will need to be root.</para> - <para> - <literallayout> &prompt.root; cd /usr/ports/devel/ElectricFence &prompt.root; make install - >> Checksum OK for ElectricFence-2.0.5.tar.gz. ===> - Extracting for ElectricFence-2.0.5 ===> Patching for - ElectricFence-2.0.5 ===> Applying FreeBSD patches for - ElectricFence-2.0.5 ===> Configuring for ElectricFence-2.0.5 - ===> Building for ElectricFence-2.0.5 [lots of compiler - output...] ===> Installing for ElectricFence-2.0.5 ===> - Warning: your umask is "0002". If this is not desired, set it to - an appropriate value and install this port again by ``make - reinstall''. install -c -o bin -g bin -m 444 - /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.a /usr/local/lib install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.3 /usr/local/man/man3 ===> Compressing manual pages for ElectricFence-2.0.5 ===> Registering installation for ElectricFence-2.0.5</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/devel/ElectricFence</userinput> +&prompt.root; <userinput>make install</userinput> +>> Checksum OK for ElectricFence-2.0.5.tar.gz. +===> Extracting for ElectricFence-2.0.5 +===> Patching for ElectricFence-2.0.5 +===> Applying FreeBSD patches for ElectricFence-2.0.5 +===> Configuring for ElectricFence-2.0.5 +===> Building for ElectricFence-2.0.5 +[lots of compiler output...] +===> Installing for ElectricFence-2.0.5 +===> Warning: your umask is "0002". If this is not desired, set it to + an appropriate value and install this port again by ``make reinstall''. +install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.a /usr/local/lib +install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.3 /usr/local/man/man3 +===> Compressing manual pages for ElectricFence-2.0.5 +===> Registering installation for ElectricFence-2.0.5</screen> + </informalexample> <para> To avoid confusing the issue, I have completely removed the build output.</para> @@ -2199,10 +2201,11 @@ <para>If you tried this yourself, you may well have got something like this at the start:-</para> - <para><anchor id="ports-fetch"> <literallayout>&prompt.root; make install >> - ElectricFence-2.0.5.tar.gz doesn't seem to exist on this system. - >> Attempting to fetch from - ftp://ftp.doc.ic.ac.uk/Mirrors/sunsite.unc.edu/pub/Linux/devel/lang/c/.</literallayout> + <para><anchor id="ports-fetch"> <informalexample> + <screen>&prompt.root; <userinput>make install</userinput> +>> ElectricFence-2.0.5.tar.gz doesn't seem to exist on this system. +>> Attempting to fetch from ftp://ftp.doc.ic.ac.uk/Mirrors/sunsite.unc.edu/pub/Linux/devel/lang/c/.</screen> + </informalexample> </para> <para> The <command>make</command> program has noticed that you did not have a local @@ -2302,10 +2305,11 @@ the drive and mounted on, say, <filename>/cdrom</filename>. Then do</para> - <para> - <literallayout> &prompt.root; mkdir /usr/ports &prompt.root; cd /usr/ports &prompt.root; ln -s - /cdrom/ports/distfiles distfiles</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mkdir /usr/ports</userinput> +&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>ln -s /cdrom/ports/distfiles distfiles</userinput></screen> + </informalexample> <para>to enable the ports make mechanism to find the tarballs (it expects to find them in <filename>/usr/ports/distfiles</filename>, @@ -2315,19 +2319,23 @@ <para>Now, suppose you want to install the gnats program from the databases directory. Here is how to do it:-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; mkdir databases &prompt.root; cp -R - /cdrom/ports/databases/gnats databases &prompt.root; cd databases/gnats &prompt.root; - make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>mkdir databases</userinput> +&prompt.root; <userinput>cp -R /cdrom/ports/databases/gnats databases</userinput> +&prompt.root; <userinput>cd databases/gnats</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> <para>Or if you are a serious database user and you want to compare all the ones available in the Ports collection, do</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; cp -R /cdrom/ports/databases . &prompt.root; - cd databases &prompt.root; make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>cp -R /cdrom/ports/databases .</userinput> +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> <para>(yes, that really is a dot on its own after the cp command and not a mistake. It is Unix-ese for <quote>the current @@ -2346,8 +2354,11 @@ invoke the <citerefentry><refentrytitle>lndir</refentrytitle><manvolnum>1</manvolnum></citerefentry> command with the full pathname of the <filename>ports</filename> directory on the CDROM as the first argument and . (the current directory) as the second. This might - be, for example, something like: <literallayout> lndir - /cdrom/ports .</literallayout> + be, for example, something like: + + <informalexample> + <screen>&prompt.root; <userinput>lndir /cdrom/ports .</userinput></screen> + </informalexample> </para> <para>Then you can build ports directly off the CDROM by building @@ -2379,16 +2390,23 @@ an example (the bits in square brackets are comments. Do not type them in if you are trying this yourself!):-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; mkdir databases &prompt.root; cd databases &prompt.root; - ftp ftp.freebsd.org [log in as `ftp' and give your email address - when asked for a password. Remember to use binary (also known as - image) mode!] > cd /pub/FreeBSD/ports/databases > get - gnats.tar [tars up the gnats skeleton for us] > quit - &prompt.root; tar xf gnats.tar [extract the gnats skeleton] &prompt.root; - cd gnats &prompt.root; make install [build and install - gnats]</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>mkdir databases</userinput> +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>ftp ftp.freebsd.org</userinput> +[log in as `ftp' and give your email address when asked for a +password. Remember to use binary (also known as image) mode!] +<prompt>></prompt> <userinput>cd /pub/FreeBSD/ports/databases</userinput> +<prompt>></prompt> <userinput>get gnats.tar</userinput> +[tars up the gnats skeleton for us] +<prompt>></prompt> <userinput>quit</userinput> +&prompt.root; <userinput>tar xf gnats.tar</userinput> +[extract the gnats skeleton] +&prompt.root; <userinput>cd gnats</userinput> +&prompt.root; <userinput>make install</userinput> +[build and install gnats]</screen> + </informalexample> <para>What happened here? We connected to the FTP server in the usual way and went to its databases sub-directory. When we gave it @@ -2408,16 +2426,21 @@ all the database skeletons in the ports collection. It looks almost the same:-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; ftp ftp.freebsd.org [log in as - `ftp' and give your email address when asked for a password. - Remember to use binary (also known as image) mode!] > cd - /pub/FreeBSD/ports > get databases.tar [tars up the - databases directory for us] > quit &prompt.root; tar xf databases.tar - [extract all the database skeletons] &prompt.root; cd databases &prompt.root; make - install [build and install all the database - ports]</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>ftp ftp.freebsd.org</userinput> +[log in as `ftp' and give your email address when asked for a +password. Remember to use binary (also known as image) mode!] +<prompt>></prompt> <userinput>cd /pub/FreeBSD/ports</userinput> +<prompt>></prompt> <userinput>get databases.tar</userinput> +[tars up the databases directory for us] +<prompt>></prompt> <userinput>quit</userinput> +&prompt.root; <userinput>tar xf databases.tar</userinput> +[extract all the database skeletons] +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>make install</userinput> +[build and install all the database ports]</screen> + </informalexample> <para>With half a dozen straightforward commands, we have now got a set of database programs on our FreeBSD machine! All we did that @@ -2450,18 +2473,30 @@ be compiled and installed. Here is the Makefile for ElectricFence:-</para> - <para> - <literallayout># New ports collection makefile for: Electric - Fence # Version required: 2.0.5 # Date created: 13 November - 1997 # Whom: jraynard # # $Id: - handbook.sgml,v 1.1 1998/04/01 18:25:32 nik Exp $ # DISTNAME= - ElectricFence-2.0.5 CATEGORIES= devel MASTER_SITES= - ${MASTER_SITE_SUNSITE} MASTER_SITE_SUBDIR= devel/lang/c - MAINTAINER= jraynard@freebsd.org MAN3= - libefence.3 do-install: ${INSTALL_DATA} ${WRKSRC}/libefence.a - ${PREFIX}/lib ${INSTALL_MAN} ${WRKSRC}/libefence.3 - ${PREFIX}/man/man3 .include <bsd.port.mk></literallayout> - </para> + <programlisting> +# New ports collection makefile for: Electric Fence +# Version required: 2.0.5 +# Date created: 13 November 1997 +# Whom: jraynard +# +# $Id: handbook.sgml,v 1.1 1998/04/01 18:25:32 nik +# + +DISTNAME= ElectricFence-2.0.5 +CATEGORIES= devel +MASTER_SITES= ${MASTER_SITE_SUNSITE} +MASTER_SITE_SUBDIR= devel/lang/c + +MAINTAINER= jraynard@freebsd.org + +MAN3= libefence.3 + +do-install: + ${INSTALL_DATA} ${WRKSRC}/libefence.a ${PREFIX}/lib + ${INSTALL_MAN} ${WRKSRC}/libefence.3 ${PREFIX}/man/man3 + +.include <bsd.port.mk> + </programlisting> <para>The lines beginning with a "#" sign are comments for the benefit of human readers (as in most Unix script @@ -2732,15 +2767,13 @@ yourself, by using the standard Unix tar program, which comes with the base FreeBSD system, like this:-</para> - <para> - <literallayout>&prompt.user; tar tvzf foobar.tar.gz # View - contents of foobar.tar.gz &prompt.user; tar xzvf foobar.tar.gz - # Extract contents into the current directory &prompt.user; tar tvf - foobar.tar # View contents of foobar.tar - &prompt.user; tar xvf - foobar.tar # Extract contents into the current - directory</literallayout> - </para> + <informalexample> + <screen>&prompt.user; <userinput>tar tvzf foobar.tar.gz</userinput> +&prompt.user; <userinput>tar xzvf foobar.tar.gz</userinput> +&prompt.user; <userinput>tar tvf foobar.tar</userinput> +&prompt.user; <userinput>tar xvf foobar.tar</userinput> + </screen> + </informalexample> </listitem> <listitem> @@ -2759,10 +2792,13 @@ <listitem> <para>Q. I did what you said for <xref linkend="ports-cd" remap="compiling ports from a CDROM"> and it worked great - until I tried to install the kermit port:- <literallayout> # - make install >> cku190.tar.gz doesn't seem to exist on - this system. >> Attempting to fetch from - ftp://kermit.columbia.edu/kermit/archives/.</literallayout> + until I tried to install the kermit port:- + + <informalexample> + <screen>&prompt.root; <userinput>make install</userinput> +>> cku190.tar.gz doesn't seem to exist on this system. +>> Attempting to fetch from ftp://kermit.columbia.edu/kermit/archives/.</screen> + </informalexample> Why can it not be found? Have I got a dud CDROM? </para> @@ -2788,10 +2824,9 @@ CDROM, which is read-only. You can tell it to look somewhere else by doing</para> - <para> - <literallayout> DISTDIR=/where/you/put/it make - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make DISTDIR=/where/you/put/it install</userinput></screen> + </informalexample> </listitem> <listitem> @@ -2806,21 +2841,18 @@ the ports mechanism to use different directories. For instance,</para> - <para> - <literallayout> make - PORTSDIR=/u/people/guests/wurzburger/ports - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PORTSDIR=/u/people/guests/wurzburger/ports install</userinput></screen> + </informalexample> <para>will compile the port in <filename>/u/people/guests/wurzburger/ports</filename> and install everything under <filename>/usr/local</filename>. </para> - <para> - <literallayout> make PREFIX=/u/people/guests/wurzburger/local - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PREFIX=/u/people/guests/wurzburger/local install</userinput></screen> + </informalexample> <para>will compile it in <filename>/usr/ports</filename> and install it in @@ -2829,10 +2861,9 @@ <para>And of course</para> - <para> - <literallayout> make PORTSDIR=.../ports PREFIX=.../local - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PORTSDIR=.../ports PREFIX=.../local install</userinput></screen> + </informalexample> <para>will combine the two (it is too long to fit on the page if I write it in full, but I am sure you get the idea).</para> @@ -2852,17 +2883,18 @@ <para>A. To get every single tarball for the ports collection, do</para> - <para> - <literallayout> # cd /usr/ports # make fetch</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make fetch</userinput></screen> + </informalexample> <para>For all the tarballs for a single ports directory, do</para> - <para> - <literallayout> # cd /usr/ports/directory # make - fetch</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/directory</userinput> +&prompt.root; <userinput>make fetch</userinput></screen> + </informalexample> <para>and for just one port - well, I think you have guessed already.</para> @@ -2877,8 +2909,12 @@ <para>A. Yes. If you know, for example, ftp.FreeBSD.ORG is much closer than sites listed in MASTER_SITES, do as following - example. <literallayout> # cd /usr/ports/directory # make - MASTER_SITE_OVERRIDE=ftp://ftp.FreeBSD.ORG/pub/FreeBSD/distfiles/ fetch</literallayout> + example. + + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/directory</userinput> +&prompt.root; <userinput>make MASTER_SITE_OVERRIDE=ftp://ftp.FreeBSD.ORG/pub/FreeBSD/distfiles/ fetch</userinput></screen> + </informalexample> </para> </listitem> @@ -2887,7 +2923,7 @@ it tries to pull them down. </para> - <para>A. 'make fetch-list' will display a list of the files + <para>A. <command>make fetch-list</command> will display a list of the files needed for a port.</para> </listitem> @@ -2898,7 +2934,7 @@ every time. </para> - <para>A. Doing 'make extract' will stop it after it has fetched + <para>A. Doing <command>make extract</command> will stop it after it has fetched and extracted the source code.</para> </listitem> @@ -2909,7 +2945,7 @@ extract', but for patches? </para> - <para>A. Yep, 'make patch' is what you want. You will probably + <para>A. Yep, <command>make patch</command> is what you want. You will probably find the PATCH_DEBUG option useful as well. And by the way, thank you for your efforts!</para> </listitem> @@ -2921,16 +2957,15 @@ </para> <para>A. Yes, with version 2.6.3 of gcc (the version shipped - with FreeBSD 2.1.0 and 2.1.5), the -O2 option could result in - buggy code unless you used the -fno-strength-reduce option as - well. (Most of the ports don't use -O2). You + with FreeBSD 2.1.0 and 2.1.5), the <option>-O2</option> option could result in + buggy code unless you used the <option>-fno-strength-reduce</option> option as + well. (Most of the ports don't use <option>-O2</option>). You <emphasis>should</emphasis> be able to specify the compiler options used by something like</para> - <para> - <literallayout> make CFLAGS='-O2 -fno-strength-reduce' - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make CFLAGS='-O2 -fno-strength-reduce' install</userinput></screen> + </informalexample> <para>or by editing <filename>/etc/make.conf</filename>, but unfortunately not all ports respect this. The surest way is to @@ -2945,7 +2980,7 @@ want. Is there a list anywhere of what ports are available? </para> - <para>A. Look in the INDEX file in /usr/ports.</para> + <para>A. Look in the <filename>INDEX</filename> file in <filename>/usr/ports</filename>.</para> </listitem> <listitem> @@ -2970,9 +3005,9 @@ <para>A. No problem, just do</para> - <para> - <literallayout> pkg_delete grizzle-6.5</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>pkg_delete grizzle-6.5</userinput></screen> + </informalexample> </listitem> <listitem> @@ -2984,17 +3019,11 @@ <para>A. Not at all, you can find it out by doing</para> - <para> - <literallayout> pkg_info -a | grep grizzle</literallayout> - </para> - - <para>And it will tell you:-</para> - - <para> - <literallayout> Information for grizzle-6.5: grizzle-6.5 - the - combined piano tutorial, LOGO interpreter and shoot 'em up - arcade game.</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>pkg_info -a | grep grizzle</userinput> +Information for grizzle-6.5: +grizzle-6.5 - the combined piano tutorial, LOGO interpreter and shoot 'em up arcade game.</screen> + </informalexample> </listitem> <listitem> @@ -3008,9 +3037,10 @@ in keeping it hanging around. The best way to do this is</para> - <para> - <literallayout> # cd /usr/ports # make clean</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make clean</userinput></screen> + </informalexample> <para>which will go through all the ports subdirectories and delete everything except the skeletons for each port.</para> @@ -3033,9 +3063,10 @@ <para>A. Just do</para> - <para> - <literallayout> # cd /usr/ports # make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> </listitem> <listitem> @@ -3059,19 +3090,19 @@ <para>A. OK, do this before you go to bed/work/the local park:-</para> - <para> - <literallayout> # cd /usr/ports # make -DBATCH - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make -DBATCH install</userinput></screen> + </informalexample> <para>This will install every port that does <emphasis>not</emphasis> require user input. Then, when you come back, do</para> - <para> - <literallayout> # cd /usr/ports # make -DIS_INTERACTIVE - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make -DIS_INTERACTIVE install</userinput></screen> + </informalexample> <para>to finish the job.</para> </listitem> @@ -3086,11 +3117,14 @@ <para>A. No problem, assuming you know how to make patches for your changes:-</para> - <para> - <literallayout> # cd /usr/ports/somewhere/frobble # make - extract # cd work/frobble-2.8 [Apply your patches] # cd - ../.. # make package</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/somewhere/frobble</userinput> +&prompt.root; <userinput>make extract</userinput> +&prompt.root; <userinput>cd work/frobble-2.8</userinput> +[Apply your patches] +&prompt.root; <userinput>cd ../..</userinput> +&prompt.root; <userinput>make package</userinput></screen> + </informalexample> </listitem> <listitem> @@ -3213,7 +3247,8 @@ copy the <filename>GENERIC</filename> configuration file to the name you want to give your kernel. For example: <informalexample> - <screen>&prompt.root; cd /usr/src/sys/i386/conf &prompt.root; cp GENERIC MYKERNEL</screen> + <screen>&prompt.root; <userinput>cd /usr/src/sys/i386/conf</userinput> +&prompt.root; <userinput>cp GENERIC MYKERNEL</userinput></screen> </informalexample> Traditionally, this name is in all capital letters and, if you are maintaining multiple FreeBSD machines with different hardware, it is a good idea to name it after your @@ -3258,8 +3293,11 @@ <para>When you are finished, type the following to compile and install your kernel: <informalexample> - <screen>&prompt.root; /usr/sbin/config MYKERNEL &prompt.root; cd ../../compile/MYKERNEL &prompt.root; - make depend &prompt.root; make &prompt.root; make install</screen> + <screen>&prompt.root; <userinput>/usr/sbin/config MYKERNEL</userinput> +&prompt.root; <userinput>cd ../../compile/MYKERNEL</userinput> +&prompt.root; <userinput>make depend</userinput> +&prompt.root; <userinput>make</userinput> +&prompt.root; <userinput>make install</userinput></screen> </informalexample> The new kernel will be copied to the root directory as <filename>/kernel</filename> and the old kernel will be moved to <filename>/kernel.old</filename>. Now, shutdown the system @@ -3644,18 +3682,18 @@ <filename>/tmp</filename>, add the following line to <filename>/etc/fstab</filename> and then reboot or type <command>mount /tmp</command>: - <informalexample> - <screen>/dev/wd1s2b /tmp mfs rw 0 0 </screen> - </informalexample> + <programlisting> +/dev/wd1s2b /tmp mfs rw 0 0 + </programlisting> </para> <note> <para>Replace the <filename>/dev/wd1s2b</filename> with the name of your swap partition, which will be listed in your <filename>/etc/fstab</filename> as follows: - <informalexample> - <screen>/dev/wd1s2b none swap sw 0 0</screen> - </informalexample> + <programlisting> +/dev/wd1s2b none swap sw 0 0 + </programlisting> </para> </note> @@ -4686,23 +4724,23 @@ <para>Suppose you add the IDE CD-ROM support to the kernel. The line to add is: - <informalexample> - <screen>controller wcd0</screen> - </informalexample> This means that you should look for some entries + <programlisting> +controller wcd0 + </programlisting> This means that you should look for some entries that start with <filename>wcd0</filename> in the <filename>/dev</filename> directory, possibly followed by a letter, such as <token>c</token>, or preceded by the letter <token>r</token>, which means a <quote>raw</quote> device. It turns out that those files are not there, so I must change to the <filename>/dev</filename> directory and type: <informalexample> - <screen>&prompt.root; sh MAKEDEV wcd0</screen> + <screen>&prompt.root; <userinput>sh MAKEDEV wcd0</userinput></screen> </informalexample> When this script finishes, you will find that there are now <filename>wcd0c</filename> and <filename>rwcd0c</filename> entries in <filename>/dev</filename> so you know that it executed correctly.</para> <para>For sound cards, the command: <informalexample> - <screen>&prompt.root; sh MAKEDEV snd0</screen> + <screen>&prompt.root; <userinput>sh MAKEDEV snd0</userinput></screen> </informalexample> creates the appropriate entries.</para> <note> @@ -4801,13 +4839,13 @@ kernel file that <command>make</command> installs (in order to move another kernel back permanently) is: <informalexample> - <screen>&prompt.root; chflags noschg /kernel</screen> + <screen>&prompt.root; <userinput>chflags noschg /kernel</userinput></screen> </informalexample> And, if you want to <quote>lock</quote> your new kernel into place, or any file for that matter, so that it cannot be moved or tampered with: <informalexample> - <screen>&prompt.root; chflags schg /kernel</screen> + <screen>&prompt.root; <userinput>chflags schg /kernel</userinput></screen> </informalexample> </para> </note> @@ -4909,25 +4947,23 @@ fairly easy for most programs, except for those like <command>init</command> which are statically linked. (For those programs, the only way is to try them on a known password and see if it works.) Programs which use <emphasis - remap=tt>crypt</emphasis> are linked against <emphasis - remap=tt>libcrypt</emphasis>, which for each type of library is + remap=tt>crypt</emphasis> are linked against <filename>libcrypt</filename>, which for each type of library is a symbolic link to the appropriate implementation. For example, on a system using the DES versions:</para> <para> <informalexample> - <screen>&prompt.user; cd /usr/lib $ ls -l /usr/lib/libcrypt* lrwxr-xr-x 1 - bin bin 13 Sep 5 12:50 libcrypt.a -> libdescrypt.a - lrwxr-xr-x 1 bin bin 18 Sep 5 12:50 libcrypt.so.2.0 -> - libdescrypt.so.2.0 lrwxr-xr-x 1 bin bin 15 Sep 5 12:50 - libcrypt_p.a -> libdescrypt_p.a</screen> + <screen>&prompt.user;<userinput> cd /usr/lib</userinput> +&prompt.user; <userinput>ls -l /usr/lib/libcrypt*</userinput> +lrwxr-xr-x 1 bin bin 13 Sep 5 12:50 libcrypt.a -> libdescrypt.a +lrwxr-xr-x 1 bin bin 18 Sep 5 12:50 libcrypt.so.2.0 -> libdescrypt.so.2.0 +lrwxr-xr-x 1 bin bin 15 Sep 5 12:50 libcrypt_p.a -> libdescrypt_p.a</screen> </informalexample> </para> <para>On a system using the MD5-based libraries, the same links will - be present, but the target will be <emphasis - remap=tt>libscrypt</emphasis> rather than <emphasis - remap=tt>libdescrypt</emphasis>. + be present, but the target will be <filename>libscrypt</filename> + rather than <filename>libdescrypt</filename>. </para> </sect2> @@ -5020,19 +5056,20 @@ <para> <informalexample> - <screen>&prompt.user; keyinit Updating wollman: ) - these will not appear if you Old key: ha73895 - ) have not used S/Key before Reminder - Only use this method - if you are directly connected. If you are using telnet or - rlogin exit with no password and use keyinit -s. Enter secret - password: ) I typed my pass phrase here - Again secret password: ) I typed it again ID - wollman s/key is 99 ha73896 ) discussed below SAG - HAS FONT GOUT FATE BOOM )</screen> + <screen>&prompt.user; keyinit +Updating wollman: ) these will not appear if you +Old key: ha73895 ) have not used S/Key before +Reminder - Only use this method if you are directly connected. +If you are using telnet or rlogin exit with no password and use keyinit -s. +<prompt>Enter secret password:</prompt> ) I typed my pass phrase here +<prompt>Again secret password:</prompt> ) I typed it again ID + +wollman s/key is 99 ha73896 ) discussed below SAG +HAS FONT GOUT FATE BOOM )</screen> </informalexample> </para> - <para>There is a lot of information here. At the `Enter secret + <para>There is a lot of information here. At the`Enter secret password:' prompt, you should enter some password or phrase (I use phrases of minimum seven words) which will be needed to generate login keys. The line starting `ID' gives the parameters of your @@ -5061,10 +5098,12 @@ <para> <informalexample> - <screen>&prompt.user; keyinit -s Updating wollman: Old key: kh94741 - Reminder you need the 6 English words from the skey command. - Enter sequence count from 1 to 9999: 100 ) I typed this - Enter new key [default kh94742]: s/key 100 kh94742</screen> + <screen>&prompt.user; <userinput>keyinit -s</userinput> +Updating wollman: Old key: kh94741 +Reminder you need the 6 English words from the skey command. +<prompt>Enter sequence count from 1 to 9999:</prompt> <userinput>100</userinput> ) I typed this +<prompt>Enter new key [default kh94742]:</prompt> +s/key 100 kh94742</screen> </informalexample> </para> @@ -5075,10 +5114,10 @@ <para> <informalexample> - <screen>&prompt.user; key 100 kh94742 Reminder - Do not use this program - while logged in via telnet or rlogin. Enter secret password: - ) I typed my secret password HULL NAY YANG TREE TOUT - VETO</screen> + <screen>&prompt.user; <userinput>key 100 kh94742</userinput> +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> ) I typed my secret password +HULL NAY YANG TREE TOUT VETO</screen> </informalexample> </para> @@ -5089,9 +5128,9 @@ <para> <informalexample> - <screen>s/key access password: HULL NAY YANG TREE TOUT VETO ID - wollman s/key is 100 kh94742 HULL NAY YANG TREE TOUT - VETO</screen> + <screen><prompt>s/key access password:</prompt> <userinput>HULL NAY YANG TREE TOUT VETO</userinput> +ID wollman s/key is 100 kh94742 +HULL NAY YANG TREE TOUT VETO</screen> </informalexample> </para> @@ -5108,9 +5147,12 @@ <para> <informalexample> - <screen>&prompt.user; telnet himalia Trying 18.26.0.186... Connected to - himalia.lcs.mit.edu. Escape character is '^]'. s/key 92 - hi52030 Password:</screen> + <screen>&prompt.user; <userinput>telnet himalia</userinput> +Trying 18.26.0.186... +Connected to himalia.lcs.mit.edu. +Escape character is '^]'. +s/key 92 hi52030 +<prompt>Password:</prompt></screen> </informalexample> </para> @@ -5145,11 +5187,10 @@ <para> <informalexample> - <screen>&prompt.user; key 92 hi52030 ) pasted from - previous section Reminder - Do not use this program while - logged in via telnet or rlogin. Enter secret password: - ) I typed my secret password ADEN BED WOLF HAW HOT - STUN</screen> + <screen>&prompt.user; <userinput>key 92 hi52030</userinput> ) pasted from previous section +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> ) I typed my secret password +ADEN BED WOLF HAW HOT STUN</screen> </informalexample> </para> @@ -5157,10 +5198,12 @@ <para> <informalexample> - <screen>s/key 92 hi52030 ) from - previous section Password: (turning echo on) Password:ADEN BED - WOLF HAW HOT STUN Last login: Wed Jun 28 15:31:00 from - halloran-eldar.l [etc.]</screen> + <screen>s/key 92 hi52030 ) from previous section +<prompt>Password:</prompt> + (turning echo on) +<prompt>Password:</prompt>ADEN BED WOLF HAW HOT STUN +Last login: Wed Jun 28 15:31:00 from halloran-eldar.l +[etc.]</screen> </informalexample> </para> @@ -5183,16 +5226,19 @@ <para> <informalexample> - <screen>&prompt.user; key -n 25 57 zz99999 Reminder - Do not use this - program while logged in via telnet or rlogin. Enter secret - password: 33: WALT THY MALI DARN NIT HEAD 34: ASK RICE BEAU - GINA DOUR STAG [...] 56: AMOS BOWL LUG FAT CAIN INCH 57: - GROW HAYS TUN DISH CAR BALM </screen> + <screen>&prompt.user; <userinput>key -n 25 57 zz99999</userinput> +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> +33: WALT THY MALI DARN NIT HEAD +34: ASK RICE BEAU GINA DOUR STAG +… +56: AMOS BOWL LUG FAT CAIN INCH +57: GROW HAYS TUN DISH CAR BALM</screen> </informalexample> </para> <para>The <option>-n 25</option> requests twenty-five keys in - sequence; the <emphasis remap=tt>57</emphasis> indicates the + sequence; the <option>57</option> indicates the <emphasis>ending</emphasis> iteration number; and the rest is as before. Note that these are printed out in <emphasis>reverse</emphasis> order of eventual use. If you are @@ -5225,12 +5271,11 @@ <para>Here is a sample configuration file which illustrates the three most common sorts of configuration statements:</para> - <para> - <informalexample> - <screen>permit internet 18.26.0.0 255.255.0.0 permit user jrl - permit port ttyd0</screen> - </informalexample> - </para> + <programlisting> +permit internet 18.26.0.0 255.255.0.0 +permit user jrl +permit port ttyd0 + </programlisting> <para>The first line (<literal>permit internet</literal>) allows users whose IP source address @@ -5295,8 +5340,9 @@ <para> <informalexample> - <screen>&prompt.root; cd /etc/kerberosIV &prompt.root; ls README - krb.conf krb.realms</screen> + <screen>&prompt.root; <userinput>cd /etc/kerberosIV</userinput> +&prompt.root; <userinput>ls</userinput> +README krb.conf krb.realms</screen> </informalexample> </para> @@ -5314,17 +5360,19 @@ <filename>grunt.grondar.za</filename>. We edit or create the <filename>krb.conf</filename> file:</para> - <para> - <informalexample> - <screen>&prompt.root; cat krb.conf GRONDAR.ZA GRONDAR.ZA - grunt.grondar.za admin server CS.BERKELEY.EDU - okeeffe.berkeley.edu ATHENA.MIT.EDU kerberos.mit.edu - ATHENA.MIT.EDU kerberos-1.mit.edu ATHENA.MIT.EDU - kerberos-2.mit.edu ATHENA.MIT.EDU kerberos-3.mit.edu - LCS.MIT.EDU kerberos.lcs.mit.edu TELECOM.MIT.EDU bitsy.mit.edu - ARC.NASA.GOV trident.arc.nasa.gov</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat krb.conf</userinput> +GRONDAR.ZA +GRONDAR.ZA grunt.grondar.za admin server +CS.BERKELEY.EDU okeeffe.berkeley.edu +ATHENA.MIT.EDU kerberos.mit.edu +ATHENA.MIT.EDU kerberos-1.mit.edu +ATHENA.MIT.EDU kerberos-2.mit.edu +ATHENA.MIT.EDU kerberos-3.mit.edu +LCS.MIT.EDU kerberos.lcs.mit.edu +TELECOM.MIT.EDU bitsy.mit.edu +ARC.NASA.GOV trident.arc.nasa.gov</screen> + </informalexample> <para>In this case, the other realms do not need to be there. They are here as an example of how a machine may be made aware of @@ -5346,13 +5394,14 @@ <filename>krb.realms</filename> file would be updated as follows:</para> - <para> - <informalexample> - <screen>&prompt.root; cat krb.realms grunt.grondar.za GRONDAR.ZA - .grondar.za GRONDAR.ZA .berkeley.edu CS.BERKELEY.EDU .MIT.EDU - ATHENA.MIT.EDU .mit.edu ATHENA.MIT.EDU</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat krb.realms</userinput> +grunt.grondar.za GRONDAR.ZA +.grondar.za GRONDAR.ZA +.berkeley.edu CS.BERKELEY.EDU +.MIT.EDU ATHENA.MIT.EDU +.mit.edu ATHENA.MIT.EDU</screen> + </informalexample> <para>Again, the other realms do not need to be there. They are here as an example of how a machine may be made aware of multiple @@ -5366,25 +5415,27 @@ run on the Kerberos server (or Key Distribution Centre). Issue the <symbol>kdb_init</symbol> command to do this:</para> - <para> - <informalexample> - <screen>&prompt.root; kdb_init Realm name [default ATHENA.MIT.EDU ]: - GRONDAR.ZA You will be prompted for the database Master - Password. It is important that you NOT FORGET this password. - Enter Kerberos master key: </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_init</userinput> +<prompt>Realm name [default ATHENA.MIT.EDU ]:</prompt> <userinput>GRONDAR.ZA</userinput> +You will be prompted for the database Master Password. +It is important that you NOT FORGET this password. + +<prompt>Enter Kerberos master key:</prompt> </screen> + </informalexample> <para>Now we have to save the key so that servers on the local machine can pick it up. Use the <command>kstash</command> command to do this.</para> - <para> - <informalexample> - <screen>&prompt.root; kstash Enter Kerberos master key: Current - Kerberos master key version is 1. Master key entered. - BEWARE!</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kstash</userinput> + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE!</screen> + </informalexample> <para>This saves the encrypted master password in <filename>/etc/kerberosIV/master_key</filename>.</para> @@ -5394,8 +5445,7 @@ <sect2> <title>Making it all run</title> - <para>Two principals need to be added to the database for <emphasis - remap=it>each</emphasis> system that will be secured with + <para>Two principals need to be added to the database for <emphasis>each</emphasis> system that will be secured with Kerberos. Their names are <command>kpasswd</command> and <command>rcmd</command> These two principals are made for each system, with the instance being the name of the @@ -5410,26 +5460,54 @@ <para> <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: passwd Instance: grunt <Not found>, - Create [y] ? y Principal: passwd, Instance: grunt, - kdc_key_ver: 1 New Password: <---- enter - RANDOM here Verifying password New Password: - <---- enter RANDOM here Random password [y] ? y Principal's - new key version = 1 Expiration date (enter yyyy-mm-dd) [ - 2000-01-01 ] ? Max ticket lifetime (*5 minutes) [ 255 ] ? - Attributes [ 0 ] ? Edit O.K. Principal name: rcmd Instance: - grunt <Not found>, Create [y] ? Principal: rcmd, - Instance: grunt, kdc_key_ver: 1 New Password: - <---- enter RANDOM here Verifying password New Password: - <---- enter RANDOM here Random password [y] ? Principal's - new key version = 1 Expiration date (enter yyyy-mm-dd) [ - 2000-01-01 ] ? Max ticket lifetime (*5 minutes) [ 255 ] ? - Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>passwd</userinput> +<prompt>Instance:</prompt> <userinput>grunt</userinput> + +<Not found>, <prompt>Create [y] ?</prompt> <userinput>y</userinput> + +Principal: passwd, Instance: grunt, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter RANDOM here +Verifying password + +<prompt>New Password:</prompt> <---- enter RANDOM here + +<prompt>Random password [y] ?</prompt> <userinput>y</userinput> + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <userinput>rcmd</userinput> +<prompt>Instance:</prompt> <userinput>grunt</userinput> + +<Not found>, <prompt>Create [y] ?</prompt> + +Principal: rcmd, Instance: grunt, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter RANDOM here +Verifying password + +<prompt>New Password:</prompt> <---- enter RANDOM here + +<prompt>Random password [y] ?</prompt> + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> </informalexample> </para> @@ -5440,73 +5518,80 @@ <para>We now have to extract all the instances which define the services on each machine. For this we use the - <symbol>ext_srvtab</symbol> command. This will create a file which + <command>ext_srvtab</command> command. This will create a file which must be copied or moved <emphasis>by secure means</emphasis> to each Kerberos client's /etc/kerberosIV directory. This file must be present on each server and client, and is crucial to the operation of Kerberos.</para> - <para> - <informalexample> - <screen>&prompt.root; ext_srvtab grunt Enter Kerberos master key: - Current Kerberos master key version is 1. Master key entered. - BEWARE! Generating 'grunt-new-srvtab'....</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ext_srvtab grunt</userinput> +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Generating 'grunt-new-srvtab'....</screen> + </informalexample> <para>Now, this command only generates a temporary file which must be renamed to <filename>srvtab</filename> so that all the server can pick it up. Use the <command>mv</command> command to move it into place on the original system:</para> - <para> - <informalexample> - <screen>&prompt.root; mv grunt-new-srvtab srvtab</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mv grunt-new-srvtab srvtab</userinput></screen> + </informalexample> <para>If the file is for a client system, and the network is not - deemed safe, then copy the <emphasis - remap=tt><client>-new-srvtab</emphasis> to removable media + deemed safe, then copy the <filename><replaceable>client</replaceable>-new-srvtab</filename> to removable media and transport it by secure physical means. Be sure to rename it to <filename>srvtab</filename> in the client's <filename>/etc/kerberosIV</filename> directory, and make sure it is mode 600:</para> - <para> - <informalexample> - <screen>&prompt.root; mv grumble-new-srvtab srvtab &prompt.root; chmod 600 - srvtab</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; <userinput>mv grumble-new-srvtab srvtab</userinput> +&prompt.root; <userinput>chmod 600 srvtab</userinput></screen> + </informalexample> </sect2> <sect2> <title>Populating the database</title> <para>We now have to add some user entries into the database. First - let's create an entry for the user <emphasis - remap=it>jane</emphasis>. Use the <symbol>kdb_edit</symbol> - command to do this:</para> - - <para> - <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: jane Instance: <Not found>, Create [y] ? - y Principal: jane, Instance: , kdc_key_ver: 1 New Password: - <---- enter a secure password here Verifying password New - Password: <---- re-enter the password - here Principal's new key version = 1 Expiration date (enter - yyyy-mm-dd) [ 2000-01-01 ] ? Max ticket lifetime (*5 minutes) - [ 255 ] ? Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> - </informalexample> - </para> + let's create an entry for the user <username>jane</username>. Use + the <command>kdb_edit</command> command to do this:</para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>jane</userinput> +<prompt>Instance:</prompt> + +<Not found>, <prompt>Create [y] ?</prompt> <userinput>y</userinput> + +Principal: jane, Instance: , kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter a secure password here +Verifying password + +<prompt>New Password:</prompt> <---- re-enter the password here +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> + </informalexample> </sect2> <sect2> @@ -5519,52 +5604,60 @@ automagically get what they need from the <filename>/etc/kerberosIV</filename> directory.</para> - <para> - <informalexample> - <screen>&prompt.root; kerberos & &prompt.root; Kerberos server starting - Sleep forever on error Log file is /var/log/kerberos.log - Current Kerberos master key version is 1. Master key entered. - BEWARE! Current Kerberos master key version is 1 Local realm: - GRONDAR.ZA &prompt.root; kadmind -n & &prompt.root; KADM Server KADM0.0A - initializing Please do not use 'kill -9' to kill this job, use - a regular kill instead Current Kerberos master key version is - 1. Master key entered. BEWARE!</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kerberos &</userinput> +Kerberos server starting +Sleep forever on error +Log file is /var/log/kerberos.log +Current Kerberos master key version is 1. + +Master key entered. BEWARE! + +Current Kerberos master key version is 1 +Local realm: GRONDAR.ZA +&prompt.root; <userinput>kadmind -n &</userinput> +KADM Server KADM0.0A initializing +Please do not use 'kill -9' to kill this job, use a +regular kill instead + +Current Kerberos master key version is 1. + +Master key entered. BEWARE!</screen> + </informalexample> <para>Now we can try using the <command>kinit</command> - command to get a ticket for the id <emphasis - remap=it>jane</emphasis> that we created above:</para> + command to get a ticket for the id <username>jane</username> that we created above:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit jane MIT Project Athena (grunt.grondar.za) - Kerberos Initialization for "jane" Password: </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>kinit jane</userinput> +MIT Project Athena (grunt.grondar.za) +Kerberos Initialization for "jane" +<prompt>Password:</prompt> </screen> + </informalexample> <para>Try listing the tokens using <command>klist</command> to see if we really have them:</para> - <para> - <informalexample> - <screen>&prompt.user; klist Ticket file: /tmp/tkt245 Principal: - jane@GRONDAR.ZA Issued Expires Principal - Apr 30 11:23:22 Apr 30 19:23:22 - krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>klist</userinput> +Ticket file: /tmp/tkt245 +Principal: jane@GRONDAR.ZA + + Issued Expires Principal +Apr 30 11:23:22 Apr 30 19:23:22 krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> + </informalexample> <para>Now try changing the password using <command>passwd</command> to check if the kpasswd daemon can get authorization to the Kerberos database:</para> - <para> - <informalexample> - <screen>&prompt.user; passwd realm GRONDAR.ZA Old password for jane: - New Password for jane: Verifying password New Password for - jane: Password changed.</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.user; <userinput>passwd</userinput> +realm GRONDAR.ZA +<prompt>Old password for jane:</prompt> +<prompt>New Password for jane:</prompt> +Verifying password +<prompt>New Password for jane:</prompt> +Password changed.</screen> + </informalexample> </sect2> <sect2> @@ -5573,71 +5666,77 @@ <para>Kerberos allows us to give <emphasis>each</emphasis> user who needs root privileges their own <emphasis remap=it>separate</emphasis> <command>su</command>password. We could now add an id which is - authorized to <command>su</command> to <emphasis - remap=it>root</emphasis>. This is controlled by having an - instance of <emphasis remap=it>root</emphasis> associated with a - principal. Using <symbol>kdb_edit</symbol> we can create the - entry <filename>jane.root</filename> in the Kerberos + authorized to <command>su</command> to <username>root</username>. This is controlled by having an + instance of <username>root</username> associated with a + principal. Using <command>kdb_edit</command> we can create the + entry <literal>jane.root</literal> in the Kerberos database:</para> - <para> - <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: jane Instance: root <Not found>, Create - [y] ? y Principal: jane, Instance: root, kdc_key_ver: 1 New - Password: <---- enter a SECURE password - here Verifying password New Password: - <---- re-enter the password here Principal's new key - version = 1 Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] - ? Max ticket lifetime (*5 minutes) [ 255 ] ? 12 <--- Keep - this short! Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>jane</userinput> +<prompt>Instance:</prompt> <userinput>root</userinput> + +<Not found>, Create [y] ? y + +Principal: jane, Instance: root, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter a SECURE password here +Verifying password + +<prompt>New Password:</prompt> <---- re-enter the password here + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> <userinput>12</userinput> <--- Keep this short! +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> + </informalexample> <para>Now try getting tokens for it to make sure it works:</para> - <para> - <informalexample> - <screen>&prompt.root; kinit jane.root MIT Project Athena - (grunt.grondar.za) Kerberos Initialization for "jane.root" - Password: - </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kinit jane.root</userinput> +MIT Project Athena (grunt.grondar.za) +Kerberos Initialization for "jane.root" +<prompt>Password:</prompt></screen> + </informalexample> <para>Now we need to add the user to root's <filename>.klogin</filename> file:</para> - <para> - <informalexample> - <screen>&prompt.root; cat /root/.klogin jane.root@GRONDAR.ZA</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; <userinput>cat /root/.klogin</userinput> +jane.root@GRONDAR.ZA</screen> + </informalexample> + <para>Now try doing the <command>su</command>:</para> - <para> - <informalexample> - <screen>&prompt.user; su Password: &prompt.root; - </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <prompt>su</prompt> +<prompt>Password:</prompt></screen> + </informalexample> <para>and take a look at what tokens we have:</para> - <para> - <informalexample> - <screen>&prompt.root; klist Ticket file: /tmp/tkt_root_245 Principal: - jane.root@GRONDAR.ZA Issued Expires - Principal May 2 20:43:12 May 3 04:43:12 - krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; klist +Ticket file: /tmp/tkt_root_245 +Principal: jane.root@GRONDAR.ZA + + Issued Expires Principal +May 2 20:43:12 May 3 04:43:12 krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> + </informalexample> </sect2> <sect2> @@ -5654,21 +5753,19 @@ the <filename>.klogin</filename> file in <emphasis remap=tt>root</emphasis>'s home directory:</para> - <para> - <informalexample> - <screen>&prompt.root; cat /root/.klogin jane.root@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat /root/.klogin</userinput> +jane.root@GRONDAR.ZA</screen> + </informalexample> <para>Likewise, if a user has in their own home directory lines of the form:</para> - <para> - <informalexample> - <screen>&prompt.user;cat ~/.klogin jane@GRONDAR.ZA - jack@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>cat ~/.klogin</userinput> +jane@GRONDAR.ZA +jack@GRONDAR.ZA</screen> + </informalexample> <para>This allows anyone in the <filename>GRONDAR.ZA</filename> realm who has authenticated themselves to @@ -5682,36 +5779,33 @@ <para>For example, Jane now logs into another system, using Kerberos:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit MIT Project Athena - (grunt.grondar.za) Password: %prompt.user; rlogin grunt - Last login: Mon May 1 21:14:47 from grumble Copyright (c) - 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 The Regents of - the University of California. All rights reserved. FreeBSD - BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995 - &prompt.user;</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>kinit</userinput> +MIT Project Athena (grunt.grondar.za) +<prompt>Password:</prompt> +%prompt.user; <userinput>rlogin grunt</userinput> +Last login: Mon May 1 21:14:47 from grumble +Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 + The Regents of the University of California. All rights reserved. + +FreeBSD BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995</screen> + </informalexample> <para>Or Jack logs into Jane's account on the same machine (Jane having set up the <filename>.klogin</filename> file as above, and the person in charge of Kerberos having set up principal <emphasis>jack</emphasis> with a null instance:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit &prompt.user; rlogin grunt - -l jane MIT Project Athena (grunt.grondar.za) Password: Last - login: Mon May 1 21:16:55 from grumble Copyright (c) 1980, - 1983, 1986, 1988, 1990, 1991, 1993, 1994 The Regents of the - University of California. All rights reserved. FreeBSD - BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995 - [jane@grunt 10578]</screen> - </informalexample> - - </para> - + <informalexample> + <screen>&prompt.user; <userinput>kinit</userinput> +&prompt.user; <userinput>rlogin grunt -l jane</userinput> +MIT Project Athena (grunt.grondar.za) +<prompt>Password:</prompt> +Last login: Mon May 1 21:16:55 from grumble +Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 + The Regents of the University of California. All rights reserved. +FreeBSD BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995</screen> + </informalexample> </sect2> </sect1> @@ -5913,11 +6007,9 @@ counter using the <citerefentry><refentrytitle>ipfw</refentrytitle><manvolnum>8</manvolnum></citerefentry> utility:</para> - <para> - <informalexample> - <screen>&prompt.root; ipfw zero 4500</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw zero 4500</userinput></screen> + </informalexample> <para>Where 4500 is the chain entry you wish to continue logging.</para> @@ -6098,14 +6190,17 @@ </variablelist> </para> - <para>The <emphasis>address</emphasis> specification is: - <informalexample> - <screen><emphasis remap=bf>from</emphasis> - <<filename>address/mask</filename>>[<emphasis>port</emphasis>] <emphasis remap=bf>to</emphasis> <<filename>address/mask</filename>>[<emphasis>port</emphasis>] [<emphasis remap=bf>via</emphasis> <<emphasis>interface</emphasis>>]</screen> - </informalexample> - </para> + <para>The <emphasis>address</emphasis> specification is:</para> + + <cmdsynopsis> + <arg choice="plain">from</arg> + <arg choice="plain"><replaceable>address/mask</replaceable></arg><arg><replaceable>port</replaceable></arg> + <arg choice="plain">to</arg> + <arg choice="plain"><replaceable>address/mark</replaceable></arg><arg><replaceable>port</replaceable></arg> + <arg>via <replaceable>interface</replaceable></arg> + </cmdsynopsis> - <para>You can only specify <emphasis>port</emphasis> in + <para>You can only specify <replaceable>port</replaceable> in conjunction with <emphasis>protocols</emphasis> which support ports (UDP and TCP).</para> @@ -6118,25 +6213,29 @@ interfaces.</para> <para>The syntax used to specify an - <filename><address/mask></filename> is: + <replaceable>address/mask</replaceable> is: + <informalexample> - <screen><address></screen> - </informalexample> or + <screen>address</screen> + </informalexample> + + or + <informalexample> - <screen><address>/mask-bits</screen> - </informalexample> or + <screen>address/mask-bits</screen> + </informalexample> + + or + <informalexample> - <screen><address>:mask-pattern</screen> + <screen>address:mask-pattern</screen> </informalexample> </para> <para>A valid hostname may be specified in place of the IP address. <emphasis remap=tt>mask-bits</emphasis> is a decimal number representing how many bits in the address mask should be - set. e.g. specifying - <informalexample> - <screen>192.216.222.1/24</screen> - </informalexample> will create a mask which will allow any + set. e.g. specifying <literal> 192.216.222.1/24</literal> will create a mask which will allow any address in a class C subnet (in this case, 192.216.222) to be matched. <emphasis remap=tt>mask-pattern</emphasis> is an IP address which will be logically AND'ed with the address given. @@ -6144,13 +6243,15 @@ specify <quote>any IP address</quote>.</para> <para>The port numbers to be blocked are specified as: - <informalexample> - <screen>port[,port[,port[...]]]</screen> - </informalexample> to specify either a single port or a list of + + <cmdsynopsis> + <arg choice="plain"><replaceable>port</replaceable><arg>,<replaceable>port</replaceable><arg>,<replaceable>port</replaceable><arg>…</arg></arg></arg></arg> + </cmdsynopsis>to specify either a single port or a list of ports, or - <informalexample> - <screen>port-port</screen> - </informalexample> to specify a range of ports. You may also + + <cmdsynopsis> + <arg choice="plain"><replaceable>port</replaceable>-<replaceable>port</replaceable></arg> + </cmdsynopsis> to specify a range of ports. You may also combine a single range with a list, but the range must always be specified first.</para> @@ -6300,9 +6401,10 @@ <title>Flushing the IPFW rules</title> <para>The syntax for flushing the chain is: - <informalexample> - <screen>ipfw flush</screen> - </informalexample> + <cmdsynopsis> + <command>ipfw</command> + <arg choice="plain">flush</arg> + </cmdsynopsis> </para> <para>This causes all entries in the firewall chain to be removed @@ -6320,13 +6422,13 @@ <cmdsynopsis> <command>ipfw</command> <arg choice="plain">zero</arg> - <arg>index</arg> + <arg><replaceable>index</replaceable></arg> </cmdsynopsis> </para> - <para>When used without an <emphasis>index</emphasis> argument, + <para>When used without an <replaceable>index</replaceable> argument, all packet counters are cleared. If an - <emphasis>index</emphasis> is supplied, the clearing operation + <replaceable>index</replaceable> is supplied, the clearing operation only affects a specific chain entry.</para> </sect3> @@ -6340,45 +6442,36 @@ host <filename>nice.people.org</filename> by being forwarded by the router:</para> - <para> - <informalexample> - <screen>ipfw add deny tcp from evil.hacker.org to - nice.people.org 23</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root <userinput>ipfw add deny tcp from evil.hacker.org to nice.people.org 23</userinput></screen> + </informalexample> <para>The next example denies and logs any TCP traffic from the entire <filename>hacker.org</filename> network (a class C) to the <filename>nice.people.org</filename> machine (any port).</para> - <para> - <informalexample> - <screen>ipfw add deny log tcp from evil.hacker.org/24 to - nice.people.org</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw add deny log tcp from evil.hacker.org/24 to nice.people.org</userinput></screen> + </informalexample> <para>If you do not want people sending X sessions to your internal network (a subnet of a class C), the following command will do the necessary filtering:</para> - <para> - <informalexample> - <screen>ipfw add deny tcp from any to my.org/28 6000 - setup</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw add deny tcp from any to my.org/28 6000 setup</userinput></screen> + </informalexample> <para>To see the accounting records: <informalexample> - <screen>ipfw -a list</screen> + <screen>&prompt.root; <userinput>ipfw -a list</userinput></screen> </informalexample> or in the short form <informalexample> - <screen>ipfw -a l</screen> + <screen>&prompt.root; <userinput>ipfw -a l</userinput></screen> </informalexample> You can also see the last time a chain entry was matched with <informalexample> - <screen>ipfw -at l</screen> + <screen>&prompt.root; <userinput>ipfw -at l</userinput></screen> </informalexample> </para> @@ -6430,11 +6523,9 @@ you. There is currently no support in the <command>ipfw</command> utility for loading multiple rules in the one command. The system I use is to use the command:</para> - <para> - <informalexample> - <screen>&prompt.root; ipfw list</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw list</userinput></screen> + </informalexample> <para>to write a list of the current rules out to a file, and then use a text editor to prepend `<literal>ipfw @@ -6944,21 +7035,19 @@ <para>To find out if the kernel you are currently using supports a serial interface, type <informalexample> - <screen>&prompt.root; <userinput>dmesg | grep - sio<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>dmesg | grep sio<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the serial port, starting from zero. If you see output similar to the following <informalexample> - <screen> sio2 at 0x3e8-0x3ef irq 5 on isa sio2: type - 16550A</screen> + <screen>sio2 at 0x3e8-0x3ef irq 5 on isa +sio2: type 16550A</screen> </informalexample> then the kernel supports the port.</para> <para>To find out if the kernel supports a parallel interface, type <informalexample> - <screen>&prompt.root; <userinput>dmesg | grep - lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>dmesg | grep lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the parallel port, starting from zero. If you see output similar to the following @@ -7010,8 +7099,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput> ./MAKEDEV - <replaceable>port</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>./MAKEDEV <replaceable>port</replaceable></userinput></screen> </informalexample> where <replaceable>port</replaceable> is the device entry for the port you want to make. Use <literal>lpt0</literal> for the first parallel port, <literal>lpt1</literal> for the second, and @@ -7088,11 +7176,9 @@ <listitem> <para>If you want interrupt-driven mode, add the <literal>irq</literal> specifier: - <informalexample> - <screen>device lpt0 at isa? - port? tty irq <replaceable>N</replaceable> - vector lptintr</screen> - </informalexample> where <replaceable>N</replaceable> is the IRQ number for your + <programlisting> +device lpt0 at isa? port? tty irq <replaceable>N</replaceable> vector lptintr + </programlisting> where <replaceable>N</replaceable> is the IRQ number for your computer's parallel port. </para> </listitem> @@ -7100,11 +7186,9 @@ <listitem> <para>If you want polled mode, do not add the <literal>irq</literal> specifier: - <informalexample> - <screen>device lpt0 at isa? - port? tty vector lptintr - </screen> - </informalexample> + <programlisting> +device lpt0 at isa? port? tty vector lptintr + </programlisting> </para> </listitem> @@ -7130,8 +7214,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput>lptcontrol -i -u - <replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptcontrol -i -u <replaceable>N</replaceable></userinput></screen> </informalexample> to set interrupt-driven mode for <literal>lpt<replaceable>N</replaceable></literal>. </para> @@ -7140,8 +7223,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput>lptcontrol -p -u - <replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptcontrol -p -u <replaceable>N</replaceable></userinput></screen> </informalexample> to set polled-mode for <literal>lpt<replaceable>N</replaceable></literal>.</para> </listitem> @@ -7168,11 +7250,14 @@ <para>For a PostScript (or other language-based) printer, we will need a more sophisticated test. A small PostScript program, such as the following, will suffice: - <informalexample> - <programlisting>%!PS 100 100 moveto 300 300 lineto stroke - 310 310 moveto /Helvetica findfont 12 scalefont setfont - (Is this thing working?) show showpage</programlisting> - </informalexample> + + <programlisting> +%!PS +100 100 moveto 300 300 lineto stroke +310 310 moveto /Helvetica findfont 12 scalefont setfont +(Is this thing working?) show +showpage + </programlisting> </para> <note> @@ -7211,8 +7296,7 @@ use <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.root; <userinput>lptest > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptest > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the parallel port, starting from zero. </para> @@ -7223,8 +7307,7 @@ other printer language, then send a small program to the printer. Type <informalexample> - <screen>&prompt.root; <userinput>cat > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>cat > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> Then, line by line, type the program <emphasis>carefully</emphasis> as you cannot edit a line once you have pressed RETURN @@ -7237,9 +7320,7 @@ <para> Alternatively, you can put the program in a file and type <informalexample> - <screen>&prompt.root; <userinput>cat - <replaceable>file</replaceable> > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>cat <replaceable>file</replaceable> > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>file</replaceable> is the name of the file containing the program you want to send to the printer.</para> @@ -7278,9 +7359,9 @@ <listitem> <para>Edit the file <filename>/etc/remote</filename>. Add the following entry: - <informalexample> - <screen><literal>printer:dv=/dev/<replaceable>port</replaceable>:br#<replaceable>bps-rate</replaceable>:pa=<replaceable>parity</replaceable></literal></screen> - </informalexample> where <replaceable>port</replaceable> is the device entry for the + <programlisting> +printer:dv=/dev/<replaceable>port</replaceable>:br#<replaceable>bps-rate</replaceable>:pa=<replaceable>parity</replaceable> + </programlisting> where <replaceable>port</replaceable> is the device entry for the serial port (<literal>ttyd0</literal>, <literal>ttyd1</literal>, etc.), <replaceable>bps-rate</replaceable> is the bits-per-second rate at which the printer communicates, and @@ -7291,9 +7372,9 @@ <para>Here is a sample entry for a printer connected via a serial line to the third serial port at 19200 bps with no parity: - <informalexample> - <programlisting>printer:dv=/dev/ttyd2:br#19200:pa=none</programlisting> - </informalexample> + <programlisting> +printer:dv=/dev/ttyd2:br#19200:pa=none + </programlisting> </para> </listitem> @@ -7301,7 +7382,7 @@ <para>Connect to the printer with <citerefentry> <refentrytitle>tip</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.root; tip printer</screen> + <screen>&prompt.root; <userinput>tip printer</userinput></screen> </informalexample> If this step does not work, edit the file <filename>/etc/remote</filename> again and try using @@ -7318,7 +7399,7 @@ use <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.user; lptest</screen> + <screen><prompt>~</prompt><userinput>$lptest</userinput></screen> </informalexample> </para> @@ -7340,7 +7421,7 @@ <para> Alternatively, you can put the program in a file and type <informalexample> - <screen><userinput>~><replaceable>file</replaceable></userinput></screen> + <screen><prompt>~</prompt><userinput>><replaceable>file</replaceable></userinput></screen> </informalexample> where <replaceable>file</replaceable> is the name of the file containing the program. After <citerefentry> @@ -7498,12 +7579,16 @@ <filename>/etc/printcap</filename> that defines two printers (a Diablo 630 line printer and a Panasonic KX-P4455 PostScript laser printer): - <informalexample> - <programlisting># # /etc/printcap for host rose # - rattan|line|diablo|lp|Diablo 630 Line Printer: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:</programlisting> - </informalexample> In this example, the first printer is named + + <programlisting> +# +# /etc/printcap for host rose +# +rattan|line|diablo|lp|Diablo 630 Line Printer: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4: + </programlisting> + In this example, the first printer is named <hostid>rattan</hostid> and has as aliases <emphasis remap=tt>line</emphasis>, <emphasis remap=tt>diablo</emphasis>, <emphasis @@ -7536,12 +7621,18 @@ printer in <filename>/etc/printcap</filename>. Here is the example <filename>/etc/printcap</filename> with <emphasis remap=tt>sh</emphasis> added: - <informalexample> - <programlisting># # /etc/printcap for host rose - no header - pages anywhere # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ :sh:</programlisting> - </informalexample> Note how we used the correct format: the + + <programlisting> +# +# /etc/printcap for host rose - no header pages anywhere +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh: + </programlisting> + Note how we used the correct format: the first line starts in the leftmost column, and subsequent lines are indented with a single TAB. Every line in an entry except the last ends in a backslash character.</para> @@ -7567,16 +7658,16 @@ <para>It is also customary to make the directory with a name that is identical to the name of the printer, as shown below: <informalexample> - <screen>&prompt.root; <userinput>mkdir - /var/spool/<replaceable>printer-name</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>mkdir /var/spool/<replaceable>printer-name</replaceable></userinput></screen> </informalexample> However, if you have a lot of printers on your network, you might want to put the spooling directories under a single directory that you reserve just for printing with LPD. We will do this for our two example printers <hostid>rattan</hostid> and <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.root; mkdir /var/spool/lpd mkdir /var/spool/lpd/rattan - mkdir /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>mkdir /var/spool/lpd</userinput> +&prompt.root; <userinput>mkdir /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>mkdir /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> @@ -7590,10 +7681,10 @@ <para> <informalexample> - <screen>&prompt.root; chown daemon.daemon /var/spool/lpd/rattan chown - daemon.daemon /var/spool/lpd/bamboo chmod 770 - /var/spool/lpd/rattan chmod 770 - /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> </note> @@ -7602,13 +7693,18 @@ using the <filename>/etc/printcap</filename> file. You specify the pathname of the spooling directory with the <emphasis remap=tt>sd</emphasis> capability: - <informalexample> - <programlisting># # /etc/printcap for host rose - added - spooling directories # rattan|line|diablo|lp|Diablo 630 - Line Printer:\ :sh:sd=/var/spool/lpd/rattan: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:</programlisting> - </informalexample> Note that the name of the printer starts in + + <programlisting> +# +# /etc/printcap for host rose - added spooling directories +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo: + </programlisting> + Note that the name of the printer starts in the first column but all other entries describing the printer should be indented with a tab and each line escaped with a backslash.</para> @@ -7640,15 +7736,19 @@ and <hostid>bamboo</hostid> is on a sixth serial port; here are the additions to <filename>/etc/printcap</filename>: - <informalexample> - <programlisting># # /etc/printcap for host rose - - identified what devices to use # - rattan|line|diablo|lp|Diablo 630 Line Printer:\ - :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host rose - identified what devices to use +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5: + </programlisting> </para> <para>If you do not specify the <emphasis remap=tt>lp</emphasis> @@ -7768,11 +7868,12 @@ we will set the TANDEM, ANYP, LITOUT, FLUSHO, and PASS8 flags. For the local mode bits, we will set the LITOUT and PASS8 flags: - <informalexample> - <screen>bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000c1:xs#0x820:</screen> - </informalexample> + + <programlisting> +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000c1:xs#0x820: + </programlisting> </para> </sect4> @@ -7811,15 +7912,21 @@ <filename>/usr/local/libexec/if-simple</filename> be a simple text filter. Put the following text into that file with your favorite text editor: + + <programlisting> +#!/bin/sh +# +# if-simple - Simple text input filter for lpd +# Installed in /usr/local/libexec/if-simple +# +# Simply copies stdin to stdout. Ignores all filter arguments. + +/bin/cat && exit 0 +exit 2 + </programlisting> + Make the file executable: <informalexample> - <programlisting>#!/bin/sh # # if-simple - Simple text input - filter for lpd # Installed in /usr/local/libexec/if-simple - # # Simply copies stdin to stdout. Ignores all filter - arguments. /bin/cat && exit 0 exit - 2</programlisting> - </informalexample> Make the file executable: - <informalexample> - <screen>&prompt.root; chmod 555 /usr/local/libexec/if-simple</screen> + <screen>&prompt.root; <userinput>chmod 555 /usr/local/libexec/if-simple</userinput></screen> </informalexample> </para> @@ -7828,16 +7935,20 @@ <filename>/etc/printcap</filename>. We will add it to the two printers we have so far in the example <filename>/etc/printcap</filename>: - <informalexample> - <programlisting># # /etc/printcap for host rose - added - text filter # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:\ - :if=/usr/local/libexec/if-simple:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host rose - added text filter +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:\ + :if=/usr/local/libexec/if-simple: + </programlisting> </para> </sect4> @@ -7866,8 +7977,7 @@ <para> Type: <informalexample> - <screen>&prompt.root; <userinput>lptest 20 5 | lpr - -P<replaceable>printer-name</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptest 20 5 | lpr -P<replaceable>printer-name</replaceable></userinput></screen> </informalexample> where <emphasis remap=it>printer-name</emphasis> is a the name of a printer (or an alias) specified in <filename>/etc/printcap</filename>. @@ -7882,13 +7992,13 @@ the program. If you are using <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>, then your results should look like the following:</para> - <para> - <informalexample> - <screen>!"#$%&'()*+,-./01234 "#$%&'()*+,-./012345 - #$%&'()*+,-./0123456 $%&'()*+,-./01234567 - %&'()*+,-./012345678</screen> - </informalexample> - </para> + <programlisting> +!"#$%&'()*+,-./01234 +"#$%&'()*+,-./012345 +#$%&'()*+,-./0123456 +$%&'()*+,-./01234567 +%&'()*+,-./012345678 + </programlisting> <para>To further test the printer, try downloading larger programs (for language-based printers) or running</para> @@ -7933,15 +8043,19 @@ <filename>/usr/local/libexec/if-simple</filename> prints a form feed after it sends the job to the printer: - <informalexample> - <programlisting>#!/bin/sh # # if-simple - Simple - text input filter for lpd # Installed in - /usr/local/libexec/if-simple # # Simply copies - stdin to stdout. Ignores all filter arguments. # - Writes a form feed character (\f) after printing - job. /bin/cat && printf "\f" && - exit 0 exit 2</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# if-simple - Simple text input filter for lpd +# Installed in /usr/local/libexec/if-simple +# +# Simply copies stdin to stdout. Ignores all filter arguments. +# Writes a form feed character (\f) after printing job. + +/bin/cat && printf "\f" && exit 0 +exit 2 + </programlisting> </para> </listitem> </varlistentry> @@ -7951,11 +8065,13 @@ <listitem> <para>You got the following on paper: - <informalexample> - <screen>!"#$%&'()*+,-./01234 + + <programlisting> +!"#$%&'()*+,-./01234 "#$%&'()*+,-./012345 - #$%&'()*+,-./0123456</screen> - </informalexample> You have become another victim of + #$%&'()*+,-./0123456 + </programlisting> + You have become another victim of the <emphasis>staircase effect</emphasis>, caused by conflicting interpretations of what characters should indicate a new-line. UNIX-style operating systems use @@ -7973,7 +8089,8 @@ carriage return is for: to move the location of the next character to print to the left edge of the paper.</para> - + + <!-- This para needs to be rewritten - Nik --> <para>Here is what FreeBSD wants your printer to do: <informalexample> <screen>Printer received CR Printer prints @@ -8035,20 +8152,19 @@ page of the job. It should work with nearly all Hewlett Packard printers.</para> - <para> - <informalexample> - <programlisting>#!/bin/sh # # hpif - Simple - text input filter for lpd for HP-PCL based - printers # Installed in - /usr/local/libexec/hpif # # Simply copies - stdin to stdout. Ignores all filter - arguments. # Tells printer to treat LF as - CR+LF. Writes a form feed character # after - printing job. printf "\033&k2G" - && cat && printf "\f" - && exit 0 exit 2</programlisting> - </informalexample> - </para> + <programlisting> +#!/bin/sh +# +# hpif - Simple text input filter for lpd for HP-PCL based printers +# Installed in /usr/local/libexec/hpif +# +# Simply copies stdin to stdout. Ignores all filter arguments. +# Tells printer to treat LF as CR+LF. Writes a form feed character +# after printing job. + +printf "\033&k2G" && cat && printf "\f" && exit 0 +exit 2 + </programlisting> <para>Here is an example <filename>/etc/printcap</filename> from a host @@ -8056,12 +8172,15 @@ to its first parallel port, a Hewlett Packard LaserJet 3Si named <hostid>teak</hostid>. It is using the above script as its text filter: - <informalexample> - <programlisting># # /etc/printcap for host - orchid # teak|hp|laserjet|Hewlett Packard - LaserJet 3Si:\ - :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ :if=/usr/local/libexec/hpif:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif: + </programlisting> </para> </listitem> @@ -8083,7 +8202,8 @@ being treated as CR characters to return the print location to the left edge of the paper, but not also down a line.</para> - + + <!-- Need to rewrite this para --> <para>Use the printer's configuration switches or control panel to enforce the following interpretation of LF and CR characters: @@ -8170,12 +8290,14 @@ <filename>/etc/printcap</filename> file. For example, here is the entry for <hostid>rattan</hostid>, with the <emphasis remap=tt>lf</emphasis> capability: - <informalexample> - <screen>rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ - :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple:\ - :lf=/var/log/rattan.log</screen> - </informalexample> Then, try printing again. Check + + <programlisting> +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple:\ + :lf=/var/log/rattan.log + </programlisting> + Then, try printing again. Check the log file (in our example, <filename>/var/log/rattan.log</filename>) to see any error messages that might appear. Based on the @@ -8261,23 +8383,21 @@ <para>To print files, type <informalexample> - <screen><userinput>lpr - <replaceable>filename...</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lpr <replaceable>filename</replaceable> <replaceable>...</replaceable></userinput></screen> </informalexample> This prints each of the listed files to the default printer. If you list no files, <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> reads data to print from standard input. For example, this command prints some important system files: <informalexample> - <screen>&prompt.user; lpr /etc/host.conf /etc/hosts.equiv</screen> + <screen>&prompt.user; <userinput>lpr /etc/host.conf /etc/hosts.equiv</userinput></screen> </informalexample> To select a specific printer, type <informalexample> - <screen>&prompt.user; <userinput>lpr -P <replaceable>printer-name</replaceable> - <replaceable>filename...</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lpr -P <replaceable>printer-name</replaceable> <replaceable>filename</replaceable> <replaceable>...</replaceable></userinput></screen> </informalexample> This example prints a long listing of the current directory to the printer named <hostid>rattan</hostid>: <informalexample> - <screen>&prompt.user; ls -l | lpr -P rattan</screen> + <screen>&prompt.user; <userinput>ls -l | lpr -P rattan</userinput></screen> </informalexample> Because no files were listed for the <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> @@ -8314,15 +8434,15 @@ specific printer, use the <option>-P</option> option. For example, the command <informalexample> - <screen>&prompt.user; lpq -P bamboo</screen> + <screen>&prompt.user; <userinput>lpq -P bamboo</userinput></screen> </informalexample> shows the queue for the printer named <hostid>bamboo</hostid>. Here is an example of the output of the <command>lpq</command> command: <informalexample> - <screen>bamboo is ready and printing Rank Owner Job Files - Total Size active kelly 9 /etc/host.conf, - /etc/hosts.equiv 88 bytes 2nd kelly 10 (standard - input) 1635 bytes 3rd mary 11 ... - 78519 bytes</screen> + <screen>bamboo is ready and printing +Rank Owner Job Files Total Size +active kelly 9 /etc/host.conf, /etc/hosts.equiv 88 bytes +2nd kelly 10 (standard input) 1635 bytes +3rd mary 11 ... 78519 bytes</screen> </informalexample> This shows three jobs in the queue for <hostid>bamboo</hostid>. The first job, submitted by user kelly, got assigned <emphasis>job number</emphasis> 9. Every @@ -8359,14 +8479,16 @@ also support a <option>-l</option> option to generate a detailed long listing. Here is an example of <command>lpq -l</command>: <informalexample> - <screen>waiting for bamboo to become ready (offline ?) kelly: - 1st [job 009rose] /etc/host.conf - 73 bytes /etc/hosts.equiv 15 bytes - kelly: 2nd [job 010rose] - (standard input) 1635 bytes mary: 3rd - [job 011rose] - /home/orchid/mary/research/venus/alpha-regio/mapping 78519 - bytes</screen> + <screen>waiting for bamboo to become ready (offline ?) +kelly: 1st [job 009rose] + /etc/host.conf 73 bytes + /etc/hosts.equiv 15 bytes + +kelly: 2nd [job 010rose] + (standard input) 1635 bytes + +mary: 3rd [job 011rose] + /home/orchid/mary/research/venus/alpha-regio/mapping 78519 bytes</screen> </informalexample> </para> @@ -8389,13 +8511,12 @@ <refentrytitle>lpq</refentrytitle></citerefentry> to find the job number. Then type <informalexample> - <screen>&prompt.user; <userinput>lprm - <replaceable>job-number</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lprm <replaceable>job-number</replaceable></userinput></screen> </informalexample> To remove the job from a specific printer, add the <option>-P</option> option. The following command removes job number 10 from the queue for the printer <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.user; lprm -P bamboo 10</screen> + <screen>&prompt.user; <userinput>lprm -P bamboo 10</userinput></screen> </informalexample> The <citerefentry> <refentrytitle>lprm</refentrytitle></citerefentry> command has a few shortcuts: @@ -8436,11 +8557,9 @@ For example, the following command removes all jobs for the current user in the queue for the printer named <hostid>rattan</hostid>:</para> - <para> - <informalexample> - <screen>&prompt.user; lprm -P rattan -</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>lprm -P rattan -</userinput></screen> + </informalexample> <note> <para>If you are working in a networked @@ -8452,13 +8571,19 @@ were submitted, even if the same printer is available from other hosts. The following command sequence demonstrates this: <informalexample> - <programlisting>&prompt.user; lpr -P rattan myfile &prompt.user; rlogin orchid - &prompt.user; lpq -P rattan Rank Owner Job Files Total - Size active seeyan 12 ... 49123 bytes 2nd kelly - 13 myfile 12 bytes &prompt.user; lprm -P rattan 13 rose: - Permission denied &prompt.user; logout &prompt.user; lprm -P rattan 13 - dfA013rose dequeued cfA013rose dequeued &prompt.user; - </programlisting> + <screen>&prompt.user; <userinput>lpr -P rattan myfile</userinput> +&prompt.user; <userinput>rlogin orchid</userinput> +&prompt.user; <userinput>lpq -P rattan</userinput> +Rank Owner Job Files Total Size +active seeyan 12 ... 49123 bytes +2nd kelly 13 myfile 12 bytes +&prompt.user; <userinput>lprm -P rattan 13</userinput> +rose: Permission denied +&prompt.user; <userinput>logout</userinput> +&prompt.user; <userinput>lprm -P rattan 13</userinput> +dfA013rose dequeued +cfA013rose dequeued + </screen> </informalexample> </para> </note> @@ -8493,7 +8618,7 @@ <filename>fish-report.dvi</filename> to the printer named <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.user; lpr -P bamboo -d fish-report.dvi</screen> + <screen>&prompt.user; <userinput>lpr -P bamboo -d fish-report.dvi</userinput></screen> </informalexample> These options apply to every file in the job, so you cannot mix (say) DVI and ditroff files together in a job. Instead, submit the files as separate jobs, using a different @@ -8613,8 +8738,7 @@ <refentrytitle>ls</refentrytitle></citerefentry> manual page on the default printer: <informalexample> - <screen>&prompt.user; zcat /usr/share/man/man1/ls.1.gz | troff -t -man | lpr - -t</screen> + <screen>&prompt.user; <userinput>zcat /usr/share/man/man1/ls.1.gz | troff -t -man | lpr -t</userinput></screen> </informalexample> The <citerefentry> <refentrytitle>zcat</refentrytitle></citerefentry> command uncompresses the source of the</para> @@ -8661,7 +8785,7 @@ <filename>parser.c</filename> followed by three copies of <filename>parser.h</filename> to the default printer: <informalexample> - <screen>&prompt.user; lpr -#3 parser.c parser.h</screen> + <screen>&prompt.user; <userinput>lpr -#3 parser.c parser.h</userinput></screen> </informalexample> </para> </listitem> @@ -9155,14 +9279,16 @@ and comparing that to the number of lines per page the printer supports. The text filter is started with the following argument list: - <informalexample> - <screen><command>[-c] -w<replaceable>width</replaceable> - -l<replaceable>length</replaceable> - -i<replaceable>indent</replaceable> -n - <replaceable>login</replaceable> -h - <replaceable>host</replaceable> - <replaceable>acct-file</replaceable></command></screen> - </informalexample> where + <cmdsynopsis> + <command>filter-name</command> + <arg>-c</arg> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + <arg choice="plain">-l<replaceable>length</replaceable></arg> + <arg choice="plain">-i<replaceable>indent</replaceable></arg> + <arg choice="plain">-n <replaceable>login</replaceable></arg> + <arg choice="plain">-h <replaceable>host</replaceable></arg> + <arg choice="plain"><replaceable>acct-file</replaceable></arg> + </cmdsynopsis> where <variablelist> <varlistentry><term><option>-c</option></term> <listitem> @@ -9245,12 +9371,17 @@ Conversion filters also need to do accounting, if you need printer accounting. Conversion filters are started with the following arguments: - <informalexample> - <screen><command>-x<replaceable>pixel-width</replaceable> -y<replaceable>pixel-height</replaceable> -n <replaceable>login</replaceable> -h <replaceable>host</replaceable> <replaceable>acct-file</replaceable></command></screen> - </informalexample> where <emphasis - remap=it>pixel-width</emphasis> is the value from the + <cmdsynopsis> + <command>filter-name</command> + <arg + choice="plain">-x<replaceable>pixel-width</replaceable></arg> + <arg choice="plain">-y<replaceable>pixel-height</replaceable></arg> + <arg choice="plain">-n <replaceable>login</replaceable></arg> + <arg choice="plain">-h <replaceable>host</replaceable></arg> + <arg choice="plain"><replaceable>acct-file</replaceable></arg> + </cmdsynopsis> where <replaceable>pixel-width</replaceable> is the value from the <emphasis remap=tt>px</emphasis> capability (default 0) - and <emphasis remap=it>pixel-height</emphasis> is the + and <replaceable>pixel-height</replaceable> is the value from the <emphasis remap=tt>py</emphasis> capability (default 0). </para> @@ -9263,10 +9394,12 @@ <xref linkend="printing-advanced-of" remap="Output Filters"> describe them. There are only two arguments to an output filter: - <informalexample> - <screen><command>-w<replaceable>width</replaceable> - -l<replaceable>length</replaceable></command></screen> - </informalexample> which are identical to the text filters + <cmdsynopsis> + <command>filter-name</command> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + + <arg choice="plain">-l<replaceable>length</replaceable></arg> + </cmdsynopsis> which are identical to the text filters <option>-w</option> and <option>-l</option> arguments.</para> </listitem> @@ -9365,9 +9498,9 @@ installed <command>lprps</command> from the ports collection, use the following in the serial PostScript printer's entry in <filename>/etc/printcap</filename>: - <informalexample> - <screen> :if=/usr/local/libexec/psif:</screen> - </informalexample> You should also specify the <emphasis + <programlisting> +:if=/usr/local/libexec/psif: + </programlisting> You should also specify the <emphasis remap=tt>rw</emphasis> capability; that tells LPD to open the printer in read-write mode.</para> @@ -9375,19 +9508,33 @@ cannot use two-way communication with the printer, which <command>lprps</command> needs), you can use the following shell script as the text filter: - <informalexample> - <programlisting>#!/bin/sh # # psif - Print PostScript or - plain text on a PostScript printer # Script version; NOT - the version that comes with lprps # Installed in - /usr/local/libexec/psif # read first_line - first_two_chars=`expr "$first_line" : '\(..\)'` if [ - "$first_two_chars" = "%!" ]; then # # PostScript job, print - it. # echo $first_line && cat && printf - "\004" && exit 0 exit 2 else # # Plain text, - convert it, then print it. # ( echo $first_line; cat ) | - /usr/local/bin/textps && printf "\004" && - exit 0 exit 2 fi</programlisting> - </informalexample> In the above script, <command>textps</command> is a program we installed + + <programlisting> +#!/bin/sh +# +# psif - Print PostScript or plain text on a PostScript printer +# Script version; NOT the version that comes with lprps +# Installed in /usr/local/libexec/psif +# + +read first_line +first_two_chars=`expr "$first_line" : '\(..\)'` + +if [ "$first_two_chars" = "%!" ]; then + # + # PostScript job, print it. + # + echo $first_line && cat && printf "\004" && exit 0 + exit 2 +else + # + # Plain text, convert it, then print it. + # + ( echo $first_line; cat ) | /usr/local/bin/textps && printf "\004" && exit 0 + exit 2 +fi + </programlisting> + In the above script, <command>textps</command> is a program we installed separately to convert plain text to PostScript. You can use any text-to-PostScript program you wish. The FreeBSD ports collection (see <xref linkend="ports" remap="The Ports @@ -9430,25 +9577,45 @@ <para><citerefentry> <refentrytitle>gs</refentrytitle></citerefentry> (Ghostscript) command. (Type <command>gs -h</command> to get a list of devices the current installation of Ghostscript supports.) - <informalexample> - <programlisting>#!/bin/sh # # ifhp - Print - Ghostscript-simulated PostScript on a DeskJet 500 # - Installed in /usr/local/libexec/hpif # # Treat LF as CR+LF: - # printf "\033&k2G" || exit 2 # # Read first two - characters of the file # read first_line - first_two_chars=`expr "$first_line" : '\(..\)'` if [ - "$first_two_chars" = "%!" ]; then # # It is PostScript; use - Ghostscript to scan-convert and print it # /usr/local/bin/gs - -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \ - && exit 0 else # # Plain text or HP/PCL, so just - print it directly; print a form # at the end to eject the - last page. # echo $first_line && cat && - printf "\f" && exit 0 fi exit 2</programlisting> - </informalexample> Finally, you need to notify LPD of the filter + + <programlisting> +#!/bin/sh +# +# ifhp - Print Ghostscript-simulated PostScript on a DeskJet 500 +# Installed in /usr/local/libexec/hpif + +# +# Treat LF as CR+LF: +# +printf "\033&k2G" || exit 2 + +# +# Read first two characters of the file +# +read first_line +first_two_chars=`expr "$first_line" : '\(..\)'` + +if [ "$first_two_chars" = "%!" ]; then + # + # It is PostScript; use Ghostscript to scan-convert and print it + # + /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \ + && exit 0 +else + # + # Plain text or HP/PCL, so just print it directly; print a form + # at the end to eject the last page. + # + echo $first_line && cat && printf "\f" && exit 0 +fi + +exit 2 + </programlisting> + Finally, you need to notify LPD of the filter via the <emphasis remap=tt>if</emphasis> capability: - <informalexample> - <screen> :if=/usr/local/libexec/hpif:</screen> - </informalexample> That is it. You can type <command>lpr plain.text</command> and <filename>lpr + <programlisting> +:if=/usr/local/libexec/hpif: + </programlisting> That is it. You can type <command>lpr plain.text</command> and <filename>lpr whatever.ps</filename> and both should print successfully.</para> @@ -9475,15 +9642,14 @@ directly until we convert the DVI file into PostScript. The command sequence goes like this: <informalexample> - <screen>&prompt.user; dvips seaweed-analysis.dvi - &prompt.user; lpr - seaweed-analysis.ps</screen> + <screen>&prompt.user; <userinput>dvips seaweed-analysis.dvi</userinput> +&prompt.user; <userinput>lpr seaweed-analysis.ps</userinput></screen> </informalexample> By installing a conversion filter for DVI files, we can skip the hand conversion step each time by having LPD do it for us. Now, each time we get a DVI file, we are just one step away from printing it: <informalexample> - <screen>&prompt.user; lpr -d seaweed-analysis.dvi</screen> + <screen>&prompt.user; <userinput>lpr -d seaweed-analysis.dvi</userinput></screen> </informalexample> We got LPD to do the DVI file conversion for us by specifying the <option>-d</option> option. Section <xref @@ -9514,15 +9680,68 @@ with, their capability entries for the <filename>/etc/printcap</filename> file, and how to invoke them with the <command>lpr</command> command: - <informalexample> - <programlisting> /etc/printcap File type - Capability lpr option ------------ ------------- - ---------- cifplot cf -c DVI - df -d plot gf -g ditroff - nf -n FORTRAN text rf -f troff - tf -t raster vf -v plain - text if none, -p, or -l</programlisting> - </informalexample> + + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>File type</entry> + <entry><filename>/etc/printcap</filename> + capability</entry> + <entry><command>lpr</command> option</entry> + </row> + </thead> + <tbody> + <row> + <entry>cifplot</entry> + <entry><literal>cf</literal></entry> + <entry><option>-c</option></entry> + </row> + + <row> + <entry>DVI</entry> + <entry><literal>df</literal></entry> + <entry><option>-d</option></entry> + </row> + + <row> + <entry>plot</entry> + <entry><literal>gf</literal></entry> + <entry><option>-g</option></entry> + </row> + + <row> + <entry>ditroff</entry> + <entry><literal>nf</literal></entry> + <entry><option>-n</option></entry> + </row> + + <row> + <entry>FORTRAN text</entry> + <entry><literal>rf</literal></entry> + <entry><option>-f</option></entry> + </row> + + <row> + <entry>troff</entry> + <entry><literal>rf</literal></entry> + <entry><option>-f</option></entry> + </row> + + <row> + <entry>raster</entry> + <entry><literal>vf</literal></entry> + <entry><option>-v</option></entry> + </row> + + <row> + <entry>plain text</entry> + <entry><literal>if</literal></entry> + <entry>none, <option>-p</option>, or <option>-l</option></entry> + </row> + </tbody> + </tgroup> + </informaltable> </para> <para>In our example, using <command>lpr -d</command> means the @@ -9561,26 +9780,37 @@ <filename>/etc/printcap</filename> file again, with the new <emphasis remap=tt>df</emphasis> capability for the printer <hostid>bamboo</hostid> - <informalexample> - <programlisting># # /etc/printcap for host rose - added df - filter for bamboo # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> The DVI filter is a shell script named + + <programlisting> +# +# /etc/printcap for host rose - added df filter for bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + The DVI filter is a shell script named <filename>/usr/local/libexec/psdf</filename>. Here is that script: - <informalexample> - <programlisting>#!bin/sh # # psdf - DVI to PostScript - printer filter # Installed in /usr/local/libexec/psdf # # - Invoked by lpd when user runs lpr -d # exec - /usr/local/bin/dvips -f | /usr/local/libexec/lprps - "$@"</programlisting> - </informalexample> This script runs <citerefentry> + + <programlisting> +#!bin/sh +# +# psdf - DVI to PostScript printer filter +# Installed in /usr/local/libexec/psdf +# +# Invoked by lpd when user runs lpr -d +# +exec /usr/local/bin/dvips -f | /usr/local/libexec/lprps "$@" + </programlisting> + This script runs <citerefentry> <refentrytitle>dvips</refentrytitle></citerefentry> in filter mode (the <option>-f</option> argument) on standard input, which is the job to print. It then starts the PostScript printer filter <command>lprps</command> (see section <xref linkend="printing-advanced-if-conversion" remap="Accommodating Plain Text Jobs on PostScript Printers">) with the arguments LPD passed to this script. @@ -9600,74 +9830,97 @@ <para>This example script is a raster (well, GIF file, actually) conversion filter for a Hewlett Packard LaserJet III-Si printer: - <informalexample> - <programlisting>#!/bin/sh # # hpvf - Convert GIF files into - HP/PCL, then print # Installed in /usr/local/libexec/hpvf - PATH=/usr/X11R6/bin:$PATH; export PATH giftopnm | ppmtopgm - | pgmtopbm | pbmtolj -resolution 300 \ && exit 0 \ - || exit 2</programlisting> - </informalexample> It works by converting the GIF file into a + + <programlisting> +#!/bin/sh +# +# hpvf - Convert GIF files into HP/PCL, then print +# Installed in /usr/local/libexec/hpvf + +PATH=/usr/X11R6/bin:$PATH; export PATH giftopnm | ppmtopgm | pgmtopbm | pbmtolj -resolution 300 \ + && exit 0 \ + || exit 2 + </programlisting> + It works by converting the GIF file into a portable anymap, converting that into a portable graymap, converting that into a portable bitmap, and converting that into LaserJet/PCL-compatible data.</para> <para>Here is the <filename>/etc/printcap</filename> file with an entry for a printer using the above filter: - <informalexample> - <programlisting># # /etc/printcap for host orchid # - teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/hpif:\ - :vf=/usr/local/libexec/hpvf:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif:\ + :vf=/usr/local/libexec/hpvf: + </programlisting> </para> <para>The following script is a conversion filter for troff data from the groff typesetting system for the PostScript printer named <hostid>bamboo</hostid>: - <informalexample> - <programlisting>#!/bin/sh # # pstf - Convert groff's troff - data into PS, then print. # Installed in - /usr/local/libexec/pstf # exec grops | - /usr/local/libexec/lprps "$@"</programlisting> - </informalexample> The above script makes use of <command>lprps</command> again to handle the communication + + <programlisting> +#!/bin/sh +# +# pstf - Convert groff's troff data into PS, then print. +# Installed in /usr/local/libexec/pstf +# +exec grops | /usr/local/libexec/lprps "$@" + </programlisting> + The above script makes use of <command>lprps</command> again to handle the communication with the printer. If the printer were on a parallel port, we would use this script instead: - <informalexample> - <programlisting>#!/bin/sh # # pstf - Convert groff's troff - data into PS, then print. # Installed in - /usr/local/libexec/pstf # exec grops</programlisting> - </informalexample> That is it. Here is the entry we need to + + <programlisting> +#!/bin/sh +# +# pstf - Convert groff's troff data into PS, then print. +# Installed in /usr/local/libexec/pstf +# +exec grops + </programlisting> + That is it. Here is the entry we need to add to <filename>/etc/printcap</filename> to enable the filter: - <informalexample> - <screen> :tf=/usr/local/libexec/pstf:</screen> - </informalexample> + <programlisting> +:tf=/usr/local/libexec/pstf: + </programlisting> </para> <para>Here is an example that might make old hands at FORTRAN blush. It is a FORTRAN-text filter for any printer that can directly print plain text. We will install it for the printer <hostid>teak</hostid>: - <informalexample> - <programlisting>#!/bin/sh # # hprf - FORTRAN text filter for - LaserJet 3si: # Installed in /usr/local/libexec/hprf # - printf "\033&k2G" && fpr && printf - "\f" && exit 0 exit 2</programlisting> - </informalexample> And we will add this line to the + + <programlisting> +#!/bin/sh +# +# hprf - FORTRAN text filter for LaserJet 3si: +# Installed in /usr/local/libexec/hprf +# + +printf "\033&k2G" && fpr && printf "\f" && exit 0 +exit 2 + </programlisting> + And we will add this line to the <filename>/etc/printcap</filename> for the printer <hostid>teak</hostid> to enable this filter: - <informalexample> - <screen> :rf=/usr/local/libexec/hprf:</screen> - </informalexample> + <programlisting> +:rf=/usr/local/libexec/hprf: + </programlisting> </para> <para>Here is one final, somewhat complex example. We will add a DVI filter to the LaserJet printer <hostid>teak</hostid> introduced earlier. First, the easy part: updating <filename>/etc/printcap</filename> with the location of the DVI filter: - <informalexample> - <screen> :df=/usr/local/libexec/hpdf:</screen> - </informalexample> + <programlisting> +:df=/usr/local/libexec/hpdf: + </programlisting> </para> <para>Now, for the hard part: making the filter. For that, we @@ -9713,29 +9966,68 @@ than under <filename>/tmp</filename>.</para> <para>Here, finally, is the filter: - <informalexample> - <programlisting>#!/bin/sh # # hpdf - Print DVI data on - HP/PCL printer # Installed in /usr/local/libexec/hpdf - PATH=/usr/local/bin:$PATH; export PATH # # Define a - function to clean up our temporary files. These exist # - in the current directory, which will be the spooling - directory # for the printer. # cleanup() { rm -f - hpdf$$.dvi } # # Define a function to handle fatal - errors: print the given message # and exit 2. Exiting - with 2 tells LPD to do not try to reprint the # job. # - fatal() { echo "$@" 1>&2 cleanup exit 2 } # # If - user removes the job, LPD will send SIGINT, so trap SIGINT - # (and a few other signals) to clean up after ourselves. - # trap cleanup 1 2 15 # # Make sure we are not colliding - with any existing files. # cleanup # # Link the DVI input - file to standard input (the file to print). # ln -s - /dev/fd/0 hpdf$$.dvi || fatal "Cannot symlink /dev/fd/0" # - # Make LF = CR+LF # printf "\033&k2G" || fatal - "Cannot initialize printer" # # Convert and print. - Return value from dvilj2p does not seem to be # reliable, - so we ignore it. # dvilj2p -M1 -q -e- dfhp$$.dvi # # - Clean up and exit # cleanup exit 0</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# hpdf - Print DVI data on HP/PCL printer +# Installed in /usr/local/libexec/hpdf + +PATH=/usr/local/bin:$PATH; export PATH + +# +# Define a function to clean up our temporary files. These exist +# in the current directory, which will be the spooling directory +# for the printer. +# +cleanup() { + rm -f hpdf$$.dvi +} + +# +# Define a function to handle fatal errors: print the given message +# and exit 2. Exiting with 2 tells LPD to do not try to reprint the +# job. +# +fatal() { + echo "$@" 1>&2 + cleanup + exit 2 +} + +# +# If user removes the job, LPD will send SIGINT, so trap SIGINT +# (and a few other signals) to clean up after ourselves. +# +trap cleanup 1 2 15 + +# +# Make sure we are not colliding with any existing files. +# +cleanup + +# +# Link the DVI input file to standard input (the file to print). +# +ln -s /dev/fd/0 hpdf$$.dvi || fatal "Cannot symlink /dev/fd/0" + +# +# Make LF = CR+LF +# +printf "\033&k2G" || fatal "Cannot initialize printer" + +# +# Convert and print. Return value from dvilj2p does not seem to be +# reliable, so we ignore it. +# +dvilj2p -M1 -q -e- dfhp$$.dvi + +# +# Clean up and exit +# +cleanup +exit 0 + </programlisting> </para> </sect4> @@ -9800,13 +10092,12 @@ <para>LPD does not pass the user's login or host to the filter, so it is not intended to do accounting. In fact, it gets only two arguments: - <informalexample> - <screen><command>-w<replaceable>width</replaceable> - -l<replaceable>length</replaceable></command></screen> - </informalexample> where <emphasis - remap=it>width</emphasis> is from the <emphasis - remap=tt>pw</emphasis> capability and <emphasis - remap=it>length</emphasis> is from the <emphasis + <cmdsynopsis> + <command>filter-name</command> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + <arg choice="plain">-l<replaceable>length</replaceable></arg> + </cmdsynopsis> where <replaceable>width</replaceable> is from the <emphasis + remap=tt>pw</emphasis> capability and <replaceable>length</replaceable> is from the <emphasis remap=tt>pl</emphasis> capability for the printer in question.</para> </listitem> @@ -9938,12 +10229,17 @@ provide an output filter to send initialization strings to the printer. Here is an example output filter for Hewlett Packard PCL-compatible printers: - <informalexample> - <programlisting>#!/bin/sh # # hpof - Output filter for - Hewlett Packard PCL-compatible printers # Installed in - /usr/local/libexec/hpof printf "\033&k2G" || exit 2 exec - /usr/libexec/lpr/lpf</programlisting> - </informalexample> Specify the path to the output filter in the + + <programlisting> +#!/bin/sh +# +# hpof - Output filter for Hewlett Packard PCL-compatible printers +# Installed in /usr/local/libexec/hpof + +printf "\033&k2G" || exit 2 exec +/usr/libexec/lpr/lpf + </programlisting> + Specify the path to the output filter in the <emphasis remap=tt>of</emphasis> capability. See <xref linkend="printing-advanced-of" remap="Output Filters"> for more information.</para> @@ -9952,13 +10248,18 @@ for the printer <hostid>teak</hostid> that we introduced earlier; we enabled header pages and added the above output filter: - <informalexample> - <programlisting># # /etc/printcap for host orchid # - teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/hpif:\ :vf=/usr/local/libexec/hpvf:\ - :of=/usr/local/libexec/hpof:</programlisting> - </informalexample> Now, when users print jobs to <hostid>teak</hostid>, they get a header page with each + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif:\ + :vf=/usr/local/libexec/hpvf:\ + :of=/usr/local/libexec/hpof: + </programlisting> + Now, when users print jobs to <hostid>teak</hostid>, they get a header page with each job. If users want to spend time searching for their printouts, they can suppress header pages by submitting the job with <command>lpr -h</command>; see <xref @@ -9985,25 +10286,55 @@ header</emphasis>, a full page of large letters identifying the user, host, and job. Here is an example (kelly printed the job named outline from host rose): - <informalexample> - <screen>k ll ll k l - l k l l k k eeee l - l y y k k e e l l y y k k - eeeeee l l y y kk k e l - l y y k k e e l l y yy k - k eeee lll lll yyy y y y y yyyy ll t - l i t l oooo u u ttttt l - ii n nnn eeee o o u u t l - i nn n e e o o u u t l - i n n eeeeee o o u u t l - i n n e o o u uu t t l i - n n e e oooo uuu u tt lll iii - n n eeee r rrr oooo ssss eeee rr r o - o s s e e r o o ss eeeeee r - o o ss e r o o s s e e r - oooo ssss eeee Job: outline Date: Sun Sep 17 - 11:04:58 1995</screen> - </informalexample> LPD appends a form feed after this text so + <programlisting> + k ll ll + k l l + k l l + k k eeee l l y y + k k e e l l y y + k k eeeeee l l y y + kk k e l l y y + k k e e l l y yy + k k eeee lll lll yyy y + y + y y + yyyy + + + ll + t l i + t l + oooo u u ttttt l ii n nnn eeee + o o u u t l i nn n e e + o o u u t l i n n eeeeee + o o u u t l i n n e + o o u uu t t l i n n e e + oooo uuu u tt lll iii n n eeee + + + + + + + + + + r rrr oooo ssss eeee + rr r o o s s e e + r o o ss eeeeee + r o o ss e + r o o s s e e + r oooo ssss eeee + + + + + + + + Job: outline + Date: Sun Sep 17 11:04:58 1995 + </programlisting> LPD appends a form feed after this text so the job starts on a new page (unless you have <emphasis remap=tt>sf</emphasis> (suppress form feeds) in the destination printer's entry in @@ -10013,10 +10344,9 @@ header</emphasis>; specify <literal>sb</literal> (short banner) in the <filename>/etc/printcap</filename> file. The header page will look like this: - <informalexample> - <screen>rose:kelly Job: outline Date: Sun Sep 17 11:07:51 - 1995</screen> - </informalexample> Also by default, LPD prints the header page + <programlisting> +rose:kelly Job: outline Date: Sun Sep 17 11:07:51 1995 + </programlisting> Also by default, LPD prints the header page first, then the job. To reverse that, specify <literal>hl</literal> (header last) in <filename>/etc/printcap</filename>.</para> @@ -10120,53 +10450,128 @@ <para>Let us explore this method. The following script takes three arguments (user login name, host name, and job name) and makes a simple PostScript header page: - <informalexample> - <programlisting>#!/bin/sh # # make-ps-header - make a - PostScript header page on stdout # Installed in - /usr/local/libexec/make-ps-header # # # These are - PostScript units (72 to the inch). Modify for A4 or # - whatever size paper you are using: # page_width=612 - page_height=792 border=72 # # Check arguments # if [ $# -ne - 3 ]; then echo "Usage: `basename $0` <user> - <host> <job>" 1>&2 exit 1 fi # # Save - these, mostly for readability in the PostScript, below. # - user=$1 host=$2 job=$3 date=`date` # # Send the PostScript - code to stdout. # exec cat <<EOF %!PS % % Make sure - we do not interfere with user's job that will follow % save - % % Make a thick, unpleasant border around the edge of the - paper. % $border $border moveto $page_width $border 2 mul - sub 0 rlineto 0 $page_height $border 2 mul sub rlineto - currentscreen 3 -1 roll pop 100 3 1 roll setscreen $border 2 - mul $page_width sub 0 rlineto closepath 0.8 setgray 10 - setlinewidth stroke 0 setgray % % Display user's login - name, nice and large and prominent % /Helvetica-Bold - findfont 64 scalefont setfont $page_width ($user) - stringwidth pop sub 2 div $page_height 200 sub moveto - ($user) show % % Now show the boring particulars % - /Helvetica findfont 14 scalefont setfont /y 200 def [ (Job:) - (Host:) (Date:) ] { 200 y moveto show /y y 18 sub def } - forall /Helvetica-Bold findfont 14 scalefont setfont /y 200 - def [ ($job) ($host) ($date) ] { 270 y moveto show /y y 18 - sub def } forall % % That is it % restore showpage - EOF</programlisting> - </informalexample> Now, each of the conversion filters and the + + <programlisting> +#!/bin/sh +# +# make-ps-header - make a PostScript header page on stdout +# Installed in /usr/local/libexec/make-ps-header +# + +# +# These are PostScript units (72 to the inch). Modify for A4 or +# whatever size paper you are using: +# +page_width=612 +page_height=792 +border=72 + +# +# Check arguments +# +if [ $# -ne 3 ]; then + echo "Usage: `basename $0` <user> <host> <job>" 1>&2 + exit 1 +fi + +# +# Save these, mostly for readability in the PostScript, below. +# +user=$1 +host=$2 +job=$3 +date=`date` + +# +# Send the PostScript code to stdout. +# +exec cat <<EOF +%!PS + +% +% Make sure we do not interfere with user's job that will follow +% +save + +% +% Make a thick, unpleasant border around the edge of the paper. +% +$border $border moveto +$page_width $border 2 mul sub 0 rlineto +0 $page_height $border 2 mul sub rlineto +currentscreen 3 -1 roll pop 100 3 1 roll setscreen +$border 2 mul $page_width sub 0 rlineto closepath +0.8 setgray 10 setlinewidth stroke 0 setgray + +% +% Display user's login name, nice and large and prominent +% +/Helvetica-Bold findfont 64 scalefont setfont +$page_width ($user) stringwidth pop sub 2 div $page_height 200 sub moveto +($user) show + +% +% Now show the boring particulars +% +/Helvetica findfont 14 scalefont setfont +/y 200 def +[ (Job:) (Host:) (Date:) ] { +200 y moveto show /y y 18 sub def } +forall + +/Helvetica-Bold findfont 14 scalefont setfont +/y 200 def +[ ($job) ($host) ($date) ] { + 270 y moveto show /y y 18 sub def +} forall + +% +% That is it +% +restore +showpage +EOF + </programlisting> + Now, each of the conversion filters and the text filter can call this script to first generate the header page, and then print the user's job. Here is the DVI conversion filter from earlier in this document, modified to make a header page: - <informalexample> - <programlisting>#!/bin/sh # # psdf - DVI to PostScript - printer filter # Installed in /usr/local/libexec/psdf # # - Invoked by lpd when user runs lpr -d # orig_args="$@" fail() - { echo "$@" 1>&2 exit 2 } while getopts "x:y:n:h:" - option; do case $option in x|y) ;; # Ignore n) - login=$OPTARG ;; h) host=$OPTARG ;; *) echo "LPD - started `basename $0` wrong." 1>&2 exit 2 ;; esac - done [ "$login" ] || fail "No login name" [ "$host" ] || - fail "No host name" ( /usr/local/libexec/make-ps-header - $login $host "DVI File" /usr/local/bin/dvips -f ) | eval - /usr/local/libexec/lprps $orig_args</programlisting> - </informalexample> Notice how the filter has to parse the + + <programlisting> +#!/bin/sh +# +# psdf - DVI to PostScript printer filter +# Installed in /usr/local/libexec/psdf +# +# Invoked by lpd when user runs lpr -d +# + +orig_args="$@" + +fail() { + echo "$@" 1>&2 + exit 2 +} + +while getopts "x:y:n:h:" option; do + case $option in + x|y) ;; # Ignore + n) login=$OPTARG ;; + h) host=$OPTARG ;; + *) echo "LPD started `basename $0` wrong." 1>&2 + exit 2 + ;; + esac +done + +[ "$login" ] || fail "No login name" +[ "$host" ] || fail "No host name" + +( /usr/local/libexec/make-ps-header $login $host "DVI File" + /usr/local/bin/dvips -f ) | eval /usr/local/libexec/lprps $orig_args + </programlisting> + Notice how the filter has to parse the argument list in order to determine the user and host name. The parsing for the other conversion filters is identical. The text filter takes a slightly different set of arguments, though (see @@ -10336,36 +10741,47 @@ remap="Enabling Header Pages">). It already had the entry for the printer <hostid>teak</hostid>; we have added entries for the two printers on the host rose: - <informalexample> - <programlisting># # /etc/printcap for host orchid - added - (remote) printers on rose # # # teak is local; it is - connected directly to orchid: # teak|hp|laserjet|Hewlett - Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/ifhp:\ :vf=/usr/local/libexec/vfhp:\ - :of=/usr/local/libexec/ofhp: # # rattan is connected to - rose; send jobs for rattan to rose: # - rattan|line|diablo|lp|Diablo 630 Line Printer:\ - :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: # # bamboo - is connected to rose as well: # - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ - :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:</programlisting> - </informalexample> Then, we just need to make spooling + + <programlisting> +# +# /etc/printcap for host orchid - added (remote) printers on rose +# + +# +# teak is local; it is connected directly to orchid: +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/ifhp:\ + :vf=/usr/local/libexec/vfhp:\ + :of=/usr/local/libexec/ofhp: + +# +# rattan is connected to rose; send jobs for rattan to rose: +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: + +# +# bamboo is connected to rose as well: +# +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo: + </programlisting> + Then, we just need to make spooling directories on orchid: + <informalexample> - <screen>&prompt.root; mkdir -p /var/spool/lpd/rattan /var/spool/lpd/bamboo - &prompt.root; chmod 770 /var/spool/lpd/rattan - /var/spool/lpd/bamboo &prompt.root; chown - daemon.daemon /var/spool/lpd/rattan - /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>mkdir -p /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> <para>Now, users on orchid can print to <hostid>rattan</hostid> and <hostid>bamboo</hostid>. If, for example, a user on orchid typed <informalexample> - <screen>&prompt.user; lpr -P bamboo -d sushi-review.dvi</screen> + <screen>&prompt.user; <userinput>lpr -P bamboo -d sushi-review.dvi</userinput></screen> </informalexample> the LPD system on orchid would copy the job to the spooling directory <filename>/var/spool/lpd/bamboo</filename> and note that it was @@ -10410,33 +10826,45 @@ printers support two-way communication, and you might want to take advantage of that (to get printer status, perform accounting, etc.). - <informalexample> - <programlisting>#!/usr/bin/perl # # netprint - Text filter - for printer attached to network # Installed in - /usr/local/libexec/netprint # $#ARGV eq 1 || die "Usage: $0 - <printer-hostname> <port-number>"; $printer_host - = $ARGV[0]; $printer_port = $ARGV[1]; require - 'sys/socket.ph'; ($ignore, $ignore, $protocol) = - getprotobyname('tcp'); ($ignore, $ignore, $ignore, $ignore, - $address) = gethostbyname($printer_host); $sockaddr = - pack('S n a4 x8', &AF_INET, $printer_port, $address); - socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol) - || die "Can't create TCP/IP stream socket: $!"; - connect(PRINTER, $sockaddr) || die "Can't contact - $printer_host: $!"; while (<STDIN>) { print PRINTER; } - exit 0;</programlisting> - </informalexample> We can then use this script in various + + <programlisting> +#!/usr/bin/perl +# +# netprint - Text filter for printer attached to network +# Installed in /usr/local/libexec/netprint +# +$#ARGV eq 1 || die "Usage: $0 <printer-hostname> <port-number>"; + +$printer_host = $ARGV[0]; +$printer_port = $ARGV[1]; + +require 'sys/socket.ph'; + +($ignore, $ignore, $protocol) = getprotobyname('tcp'); +($ignore, $ignore, $ignore, $ignore, $address) + = gethostbyname($printer_host); + +$sockaddr = pack('S n a4 x8', &AF_INET, $printer_port, $address); + +socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol) + || die "Can't create TCP/IP stream socket: $!"; +connect(PRINTER, $sockaddr) || die "Can't contact $printer_host: $!"; +while (<STDIN>) { print PRINTER; } +exit 0; + </programlisting> + We can then use this script in various filters. Suppose we had a Diablo 750-N line printer connected to the network. The printer accepts data to print on port number 5100. The host name of the printer is scrivener. Here is the text filter for the printer: - <informalexample> - <programlisting>#!/bin/sh # # diablo-if-net - Text filter for - Diablo printer `scrivener' listening # on port 5100. - Installed in /usr/local/libexec/diablo-if-net # exec - /usr/libexec/lpr/lpf "$@" | /usr/local/libexec/netprint - scrivener 5100</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# diablo-if-net - Text filter for Diablo printer `scrivener' listening +# on port 5100. Installed in /usr/local/libexec/diablo-if-net # exec +/usr/libexec/lpr/lpf "$@" | /usr/local/libexec/netprint scrivener 5100 + </programlisting> </para> </sect3> @@ -10488,41 +10916,51 @@ we will allow multiple copies, but the laser printer <hostid>bamboo</hostid>'s a bit more delicate, so we will disable multiple copies by adding the <emphasis remap=tt>sc</emphasis> capability: - <informalexample> - <programlisting># # /etc/printcap for host rose - restrict - multiple copies on bamboo # rattan|line|diablo|lp|Diablo 630 - Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ - :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Now, we also need to add the <emphasis + + <programlisting> +# +# /etc/printcap for host rose - restrict multiple copies on bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Now, we also need to add the <emphasis remap=tt>sc</emphasis> capability on the host orchid's <filename>/etc/printcap</filename> (and while we are at it, let us disable multiple copies for the printer <hostid>teak</hostid>): - <informalexample> - <programlisting># # /etc/printcap for host orchid - no - multiple copies for local # printer teak or remote printer - bamboo teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:sc:\ - :if=/usr/local/libexec/ifhp:\ :vf=/usr/local/libexec/vfhp:\ - :of=/usr/local/libexec/ofhp: rattan|line|diablo|lp|Diablo - 630 Line Printer:\ - :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ - :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:sc:</programlisting> - </informalexample> By using the <emphasis remap=tt>sc</emphasis> + + <programlisting> +# +# /etc/printcap for host orchid - no multiple copies for local +# printer teak or remote printer bamboo +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:sc:\ + :if=/usr/local/libexec/ifhp:\ + :vf=/usr/local/libexec/vfhp:\ + :of=/usr/local/libexec/ofhp: + +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:sc: + </programlisting> + By using the <emphasis remap=tt>sc</emphasis> capability, we prevent the use of <command>lpr -#</command>, but that still does not prevent users from running <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> multiple times, or from submitting the same file multiple times in one job like this: <informalexample> - <screen>&prompt.user; lpr forsale.sign forsale.sign forsale.sign - forsale.sign forsale.sign </screen> + <screen>&prompt.user; <userinput>lpr forsale.sign forsale.sign forsale.sign forsale.sign forsale.sign</userinput></screen> </informalexample> There are many ways to prevent this abuse (including ignoring it) which you are free to explore.</para> @@ -10556,17 +10994,23 @@ <para>For example, we will let anyone access the printer <hostid>rattan</hostid>, but only those in group <emphasis remap=tt>artists</emphasis> can use <hostid>bamboo</hostid>. Here is the familiar <filename>/etc/printcap</filename> for host rose: - <informalexample> - <programlisting># # /etc/printcap for host rose - restricted - group for bamboo # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Let us leave the other example + + <programlisting> +# +# /etc/printcap for host rose - restricted group for bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Let us leave the other example <filename>/etc/printcap</filename> file (for the host orchid) alone. Of course, anyone on orchid can print to <hostid>bamboo</hostid>. It might be the case that we only allow certain logins on orchid anyway, and want them to have @@ -10608,18 +11052,30 @@ <para>Let us add limits to our example printers <hostid>rattan</hostid> and <hostid>bamboo</hostid>. Since those artists' PostScript files tend to be large, we will limit them to five megabytes. We will put no limit on the plain text line printer: - <informalexample> - <programlisting># # /etc/printcap for host rose # # # No - limit on job size: # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: # # Limit of five - megabytes: # bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ - :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Again, the limits apply to the local users + + <programlisting> +# +# /etc/printcap for host rose +# + +# +# No limit on job size: +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +# +# Limit of five megabytes: +# +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Again, the limits apply to the local users only. If you have set up access to your printers remotely, remote users will not get those limits. You will need to specify the <emphasis remap=tt>mx</emphasis> capability in the @@ -10667,10 +11123,13 @@ <para>For example, here is the <filename>/etc/hosts.lpd</filename> file on the host rose: - <informalexample> - <programlisting>orchid violet - madrigal.fishbaum.de</programlisting> - </informalexample> This means rose will accept requests + + <programlisting> +orchid +violet +madrigal.fishbaum.de + </programlisting> + This means rose will accept requests from the hosts orchid, violet, and madrigal.fishbaum.de. If any other host tries to access rose's LPD, LPD will refuse them.</para> @@ -10701,21 +11160,20 @@ <hostid>bamboo</hostid>. We examine <filename>/etc/printcap</filename> to find the spooling directory for this printer; here is <hostid>bamboo</hostid>'s entry: - <informalexample> - <screen>bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ - :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:mx#5000:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</screen> - </informalexample> The spooling directory is the given + <programlisting> +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:mx#5000:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + The spooling directory is the given in the <emphasis remap=tt>sd</emphasis> capability. We will make three megabytes (which is 6144 disk blocks) the amount of free disk space that must exist on the filesystem for LPD to accept remote jobs: <informalexample> - <screen>&prompt.root; echo 6144 > - /var/spool/lpd/bamboo/minfree</screen> + <screen>&prompt.root; <userinput>echo 6144 > /var/spool/lpd/bamboo/minfree</userinput></screen> </informalexample> </para> @@ -10852,10 +11310,14 @@ much paper will be used. After sending the file to the printer, it then writes an accounting entry in the accounting file. The entries look like this: - <informalexample> - <screen> 2.00 rose:andy 3.00 rose:kelly 3.00 orchid:mary - 5.00 orchid:mary 2.00 orchid:zhang</screen> - </informalexample> You should use a separate accounting file for + + <programlisting> +2.00 rose:andy +3.00 rose:kelly +3.00 orchid:mary +5.00 orchid:mary +2.00 orchid:zhang</programlisting> + You should use a separate accounting file for each printer, as <command>lpf</command> has no file locking logic built into it, and two <command>lpf</command>s might corrupt each other's entries if they were to write to the same file at the same time. A easy way diff --git a/en_US.ISO8859-1/books/handbook/book.sgml b/en_US.ISO8859-1/books/handbook/book.sgml index 92c056f5e5..109c1aa0fd 100644 --- a/en_US.ISO8859-1/books/handbook/book.sgml +++ b/en_US.ISO8859-1/books/handbook/book.sgml @@ -2,8 +2,8 @@ <!ENTITY prompt.root "<prompt>#</prompt>"> <!ENTITY prompt.user "<prompt>%</prompt>"> ]> + <book> - <bookinfo> <bookbiblio> <title>FreeBSD Handbook</title> @@ -768,8 +768,7 @@ <para>If you are using MS-DOS then download <ulink URL="ftp://ftp.FreeBSD.ORG/pub/FreeBSD/tools/fdimage.exe">fdimage.exe</ulink> or get it from <filename>tools\fdimage.exe</filename> on the CDROM and then run it like so: <informalexample> - <screen><prompt>E:\></prompt> tools\fdimage floppies\boot.flp - a:</screen> + <screen><prompt>E:\></prompt> <userinput>tools\fdimage floppies\boot.flp a:</userinput></screen> </informalexample> The <emphasis>fdimage</emphasis> program will format the A: drive and then copy the boot.flp image onto it (assuming that you're at the top @@ -782,9 +781,8 @@ <para>If you are using a UNIX system to create the floppy image: <informalexample> - <screen>&prompt.root; dd if=boot.flp - of=<symbol>disk_device</symbol></screen> - </informalexample> where <symbol>disk_device</symbol> is + <screen>&prompt.root; <userinput>dd if=boot.flp of=<replaceable>disk_device</replaceable></userinput></screen> + </informalexample> where <replaceable>disk_device</replaceable> is the <filename>/dev</filename> entry for the floppy drive. On FreeBSD systems, this is <filename>/dev/rfd0</filename> for the A: drive and <filename>/dev/rfd1</filename> for @@ -799,11 +797,13 @@ <para>With the installation disk in the A: drive, reboot your computer. You should get a boot prompt something like this: <informalexample> - <screen>>> FreeBSD BOOT ...<!-- <br> --> Usage: - [[[0:][wd](0,a)]/kernel][-abcCdhrsv]<!-- <br> --> Use - 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1<!-- <br> - --> Use ? for file list or press Enter for defaults<!-- <br> - --> Boot: </screen> + <screen> +>> FreeBSD BOOT ... +Usage: [[[0:][wd](0,a)]/kernel][-abcCdhrsv] +Use 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1 +Use ? for file list or press Enter for defaults +Boot: + </screen> </informalexample> If you do <emphasis>not</emphasis> type anything, FreeBSD will automatically boot with its default configuration after a delay of about five seconds. As FreeBSD @@ -1449,16 +1449,14 @@ to add the following line to the password file (using the vipw command):</para> - <para> - <informalexample> - <screen>ftp:*:99:99::0:0:FTP:/cdrom:/nonexistent</screen> - </informalexample> - </para> + <programlisting> +ftp:*:99:99::0:0:FTP:/cdrom:/nonexistent + </programlisting> <para>Anyone with network connectivity to your machine (and permission to log into it) can now chose a Media type of FTP and - type in: <filename>ftp://<replaceable>your - machine</replaceable></filename> after picking <quote>Other</quote> in + type in: <userinput>ftp://<replaceable>your + machine</replaceable></userinput> after picking <quote>Other</quote> in the ftp sites menu.</para> </sect2> @@ -1493,12 +1491,18 @@ <para> <informalexample> - <screen>&prompt.root; fdformat -f 1440 fd0.1440 disklabel -w -r - fd0.1440 floppy3 newfs -t 2 -u 18 -l 1 -i 65536 /dev/rfd0 (Use - "fd0.1200" and "floppy5" for 5.25" 1.2MB disks).</screen> + <screen>&prompt.root; <userinput>fdformat -f 1440 fd0.1440</userinput> +&prompt.root; <userinput>disklabel -w -r fd0.1440 floppy3</userinput> +&prompt.root; <userinput>newfs -t 2 -u 18 -l 1 -i 65536 /dev/rfd0</userinput> + </screen> </informalexample> </para> - + + <note> + <para>Use <literal>fd0.1200</literal> and + <literal>floppy5</literal> for 5.25" 1.2MB disks.</para> + </note> + <para>Then you can mount and write to them like any other file system.</para> @@ -1528,9 +1532,9 @@ suggest using the DOS <command>xcopy</command> command. For example, to prepare for a minimal installation of FreeBSD: <informalexample> - <screen><prompt>C></prompt> MD C:\FREEBSD C> XCOPY /S E:\BIN - C:\FREEBSD\BIN\ <prompt>C></prompt> XCOPY /S E:\MANPAGES - C:\FREEBSD\MANPAGES\</screen> + <screen><prompt>C:\></prompt> <userinput>MD C:\FREEBSD</userinput> +<prompt>C:\></prompt> <userinput>XCOPY /S E:\BIN C:\FREEBSD\BIN\</userinput> +<prompt>C:\></prompt> <userinput>XCOPY /S E:\MANPAGES C:\FREEBSD\MANPAGES\</userinput></screen> </informalexample> assuming that <filename>C:</filename> is where you have free space and <filename>E:</filename> is where your CDROM is mounted.</para> @@ -1551,15 +1555,14 @@ after getting all of the files for distribution you are interested in, simply tar them onto the tape with a command like: <informalexample> - <screen>&prompt.root; cd /freebsd/distdir<!-- <br> --> tar cvf /dev/rwt0 (or - /dev/rst0) dist1 .. dist2</screen> + <screen>&prompt.root; <userinput>cd /freebsd/distdir</userinput> +&prompt.root; <userinput>tar cvf /dev/rwt0 dist1 ... dist2</userinput></screen> </informalexample> </para> <para>When you go to do the installation, you should also make sure that you leave enough room in some temporary directory (which you - will be allowed to choose) to accommodate the <emphasis - remap=bf>full</emphasis> contents of the tape you have created. + will be allowed to choose) to accommodate the <emphasis>full</emphasis> contents of the tape you have created. Due to the non-random access nature of tapes, this method of installation requires quite a bit of temporary storage. You should expect to require as much temporary storage as you have @@ -1710,7 +1713,7 @@ <para> <informalexample> - <screen>ftp://165.113.121.81/pub/FreeBSD/&rel.current;-RELEASE</screen> + <screen><userinput>ftp://165.113.121.81/pub/FreeBSD/&rel.current;-RELEASE</userinput></screen> </informalexample> </para> @@ -1757,10 +1760,10 @@ address. As your installation media, you specify FTP (or passive FTP, if the proxy support it), and the URL <informalexample> - <screen>ftp://foo.bar.com:1234/pub/FreeBSD</screen> - </informalexample> /pub/FreeBSD from ftp.freebsd.org is proxied - under foo.bar.com, allowing you to install from _that_ machine - (which fetch the files from ftp.freebsd.org as your installation + <screen><userinput>ftp://foo.bar.com:1234/pub/FreeBSD</userinput></screen> + </informalexample> <filename>/pub/FreeBSD</filename> from <hostid>ftp.freebsd.org</hostid> is proxied + under <hostid>foo.bar.com</hostid>, allowing you to install from _that_ machine + (which fetch the files from <hostid>ftp.freebsd.org</hostid> as your installation requests them).</para> </sect3> @@ -1898,11 +1901,9 @@ mount extended partitions exactly like you would mount any other DOS drive, e.g.:</para> - <para> - <informalexample> - <screen>&prompt.root; mount -t msdos /dev/sd0s5 /dos_d</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mount -t msdos /dev/sd0s5 /dos_d</userinput></screen> + </informalexample> <para><emphasis remap=bf>Can I run MS-DOS binaries under FreeBSD?</emphasis></para> @@ -1931,12 +1932,10 @@ of <emphasis>man pages</emphasis>. Nearly every program on the system comes with a short reference manual explaining the basic operation and various arguments. These manuals can be view with the - <emphasis remap=tt><command>man</command></emphasis> - command. Use of the <emphasis remap=tt><emphasis - remap=bf>man</emphasis></emphasis> command is simple: + <command>man</command> + command. Use of the <command>man</command> command is simple: <informalexample> - <screen>&prompt.user; - <userinput>man <replaceable>command</replaceable></userinput> + <screen>&prompt.user; <userinput>man <replaceable>command</replaceable></userinput> </screen> </informalexample> where <replaceable>command</replaceable> is the name of the command you wish to learn about. For example, to @@ -2040,10 +2039,8 @@ <para>To use the <citerefentry><refentrytitle>info</refentrytitle><manvolnum>1</manvolnum></citerefentry> command, simply type: <informalexample> <screen>&prompt.user; <userinput>info</userinput></screen> - </informalexample> For a brief introduction, type <emphasis - remap=tt><emphasis remap=bf>h</emphasis></emphasis>. For a quick - command reference, type <emphasis remap=tt><emphasis - remap=bf>?</emphasis></emphasis>.</para> + </informalexample> For a brief introduction, type <userinput>h</userinput>. For a quick + command reference, type <userinput>?</userinput>.</para> </sect1> </chapter> @@ -2179,19 +2176,24 @@ <para><emphasis>Note</emphasis> if you are trying this at home, you will need to be root.</para> - <para> - <literallayout> &prompt.root; cd /usr/ports/devel/ElectricFence &prompt.root; make install - >> Checksum OK for ElectricFence-2.0.5.tar.gz. ===> - Extracting for ElectricFence-2.0.5 ===> Patching for - ElectricFence-2.0.5 ===> Applying FreeBSD patches for - ElectricFence-2.0.5 ===> Configuring for ElectricFence-2.0.5 - ===> Building for ElectricFence-2.0.5 [lots of compiler - output...] ===> Installing for ElectricFence-2.0.5 ===> - Warning: your umask is "0002". If this is not desired, set it to - an appropriate value and install this port again by ``make - reinstall''. install -c -o bin -g bin -m 444 - /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.a /usr/local/lib install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.3 /usr/local/man/man3 ===> Compressing manual pages for ElectricFence-2.0.5 ===> Registering installation for ElectricFence-2.0.5</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/devel/ElectricFence</userinput> +&prompt.root; <userinput>make install</userinput> +>> Checksum OK for ElectricFence-2.0.5.tar.gz. +===> Extracting for ElectricFence-2.0.5 +===> Patching for ElectricFence-2.0.5 +===> Applying FreeBSD patches for ElectricFence-2.0.5 +===> Configuring for ElectricFence-2.0.5 +===> Building for ElectricFence-2.0.5 +[lots of compiler output...] +===> Installing for ElectricFence-2.0.5 +===> Warning: your umask is "0002". If this is not desired, set it to + an appropriate value and install this port again by ``make reinstall''. +install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.a /usr/local/lib +install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.3 /usr/local/man/man3 +===> Compressing manual pages for ElectricFence-2.0.5 +===> Registering installation for ElectricFence-2.0.5</screen> + </informalexample> <para> To avoid confusing the issue, I have completely removed the build output.</para> @@ -2199,10 +2201,11 @@ <para>If you tried this yourself, you may well have got something like this at the start:-</para> - <para><anchor id="ports-fetch"> <literallayout>&prompt.root; make install >> - ElectricFence-2.0.5.tar.gz doesn't seem to exist on this system. - >> Attempting to fetch from - ftp://ftp.doc.ic.ac.uk/Mirrors/sunsite.unc.edu/pub/Linux/devel/lang/c/.</literallayout> + <para><anchor id="ports-fetch"> <informalexample> + <screen>&prompt.root; <userinput>make install</userinput> +>> ElectricFence-2.0.5.tar.gz doesn't seem to exist on this system. +>> Attempting to fetch from ftp://ftp.doc.ic.ac.uk/Mirrors/sunsite.unc.edu/pub/Linux/devel/lang/c/.</screen> + </informalexample> </para> <para> The <command>make</command> program has noticed that you did not have a local @@ -2302,10 +2305,11 @@ the drive and mounted on, say, <filename>/cdrom</filename>. Then do</para> - <para> - <literallayout> &prompt.root; mkdir /usr/ports &prompt.root; cd /usr/ports &prompt.root; ln -s - /cdrom/ports/distfiles distfiles</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mkdir /usr/ports</userinput> +&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>ln -s /cdrom/ports/distfiles distfiles</userinput></screen> + </informalexample> <para>to enable the ports make mechanism to find the tarballs (it expects to find them in <filename>/usr/ports/distfiles</filename>, @@ -2315,19 +2319,23 @@ <para>Now, suppose you want to install the gnats program from the databases directory. Here is how to do it:-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; mkdir databases &prompt.root; cp -R - /cdrom/ports/databases/gnats databases &prompt.root; cd databases/gnats &prompt.root; - make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>mkdir databases</userinput> +&prompt.root; <userinput>cp -R /cdrom/ports/databases/gnats databases</userinput> +&prompt.root; <userinput>cd databases/gnats</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> <para>Or if you are a serious database user and you want to compare all the ones available in the Ports collection, do</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; cp -R /cdrom/ports/databases . &prompt.root; - cd databases &prompt.root; make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>cp -R /cdrom/ports/databases .</userinput> +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> <para>(yes, that really is a dot on its own after the cp command and not a mistake. It is Unix-ese for <quote>the current @@ -2346,8 +2354,11 @@ invoke the <citerefentry><refentrytitle>lndir</refentrytitle><manvolnum>1</manvolnum></citerefentry> command with the full pathname of the <filename>ports</filename> directory on the CDROM as the first argument and . (the current directory) as the second. This might - be, for example, something like: <literallayout> lndir - /cdrom/ports .</literallayout> + be, for example, something like: + + <informalexample> + <screen>&prompt.root; <userinput>lndir /cdrom/ports .</userinput></screen> + </informalexample> </para> <para>Then you can build ports directly off the CDROM by building @@ -2379,16 +2390,23 @@ an example (the bits in square brackets are comments. Do not type them in if you are trying this yourself!):-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; mkdir databases &prompt.root; cd databases &prompt.root; - ftp ftp.freebsd.org [log in as `ftp' and give your email address - when asked for a password. Remember to use binary (also known as - image) mode!] > cd /pub/FreeBSD/ports/databases > get - gnats.tar [tars up the gnats skeleton for us] > quit - &prompt.root; tar xf gnats.tar [extract the gnats skeleton] &prompt.root; - cd gnats &prompt.root; make install [build and install - gnats]</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>mkdir databases</userinput> +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>ftp ftp.freebsd.org</userinput> +[log in as `ftp' and give your email address when asked for a +password. Remember to use binary (also known as image) mode!] +<prompt>></prompt> <userinput>cd /pub/FreeBSD/ports/databases</userinput> +<prompt>></prompt> <userinput>get gnats.tar</userinput> +[tars up the gnats skeleton for us] +<prompt>></prompt> <userinput>quit</userinput> +&prompt.root; <userinput>tar xf gnats.tar</userinput> +[extract the gnats skeleton] +&prompt.root; <userinput>cd gnats</userinput> +&prompt.root; <userinput>make install</userinput> +[build and install gnats]</screen> + </informalexample> <para>What happened here? We connected to the FTP server in the usual way and went to its databases sub-directory. When we gave it @@ -2408,16 +2426,21 @@ all the database skeletons in the ports collection. It looks almost the same:-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; ftp ftp.freebsd.org [log in as - `ftp' and give your email address when asked for a password. - Remember to use binary (also known as image) mode!] > cd - /pub/FreeBSD/ports > get databases.tar [tars up the - databases directory for us] > quit &prompt.root; tar xf databases.tar - [extract all the database skeletons] &prompt.root; cd databases &prompt.root; make - install [build and install all the database - ports]</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>ftp ftp.freebsd.org</userinput> +[log in as `ftp' and give your email address when asked for a +password. Remember to use binary (also known as image) mode!] +<prompt>></prompt> <userinput>cd /pub/FreeBSD/ports</userinput> +<prompt>></prompt> <userinput>get databases.tar</userinput> +[tars up the databases directory for us] +<prompt>></prompt> <userinput>quit</userinput> +&prompt.root; <userinput>tar xf databases.tar</userinput> +[extract all the database skeletons] +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>make install</userinput> +[build and install all the database ports]</screen> + </informalexample> <para>With half a dozen straightforward commands, we have now got a set of database programs on our FreeBSD machine! All we did that @@ -2450,18 +2473,30 @@ be compiled and installed. Here is the Makefile for ElectricFence:-</para> - <para> - <literallayout># New ports collection makefile for: Electric - Fence # Version required: 2.0.5 # Date created: 13 November - 1997 # Whom: jraynard # # $Id: - handbook.sgml,v 1.1 1998/04/01 18:25:32 nik Exp $ # DISTNAME= - ElectricFence-2.0.5 CATEGORIES= devel MASTER_SITES= - ${MASTER_SITE_SUNSITE} MASTER_SITE_SUBDIR= devel/lang/c - MAINTAINER= jraynard@freebsd.org MAN3= - libefence.3 do-install: ${INSTALL_DATA} ${WRKSRC}/libefence.a - ${PREFIX}/lib ${INSTALL_MAN} ${WRKSRC}/libefence.3 - ${PREFIX}/man/man3 .include <bsd.port.mk></literallayout> - </para> + <programlisting> +# New ports collection makefile for: Electric Fence +# Version required: 2.0.5 +# Date created: 13 November 1997 +# Whom: jraynard +# +# $Id: handbook.sgml,v 1.1 1998/04/01 18:25:32 nik +# + +DISTNAME= ElectricFence-2.0.5 +CATEGORIES= devel +MASTER_SITES= ${MASTER_SITE_SUNSITE} +MASTER_SITE_SUBDIR= devel/lang/c + +MAINTAINER= jraynard@freebsd.org + +MAN3= libefence.3 + +do-install: + ${INSTALL_DATA} ${WRKSRC}/libefence.a ${PREFIX}/lib + ${INSTALL_MAN} ${WRKSRC}/libefence.3 ${PREFIX}/man/man3 + +.include <bsd.port.mk> + </programlisting> <para>The lines beginning with a "#" sign are comments for the benefit of human readers (as in most Unix script @@ -2732,15 +2767,13 @@ yourself, by using the standard Unix tar program, which comes with the base FreeBSD system, like this:-</para> - <para> - <literallayout>&prompt.user; tar tvzf foobar.tar.gz # View - contents of foobar.tar.gz &prompt.user; tar xzvf foobar.tar.gz - # Extract contents into the current directory &prompt.user; tar tvf - foobar.tar # View contents of foobar.tar - &prompt.user; tar xvf - foobar.tar # Extract contents into the current - directory</literallayout> - </para> + <informalexample> + <screen>&prompt.user; <userinput>tar tvzf foobar.tar.gz</userinput> +&prompt.user; <userinput>tar xzvf foobar.tar.gz</userinput> +&prompt.user; <userinput>tar tvf foobar.tar</userinput> +&prompt.user; <userinput>tar xvf foobar.tar</userinput> + </screen> + </informalexample> </listitem> <listitem> @@ -2759,10 +2792,13 @@ <listitem> <para>Q. I did what you said for <xref linkend="ports-cd" remap="compiling ports from a CDROM"> and it worked great - until I tried to install the kermit port:- <literallayout> # - make install >> cku190.tar.gz doesn't seem to exist on - this system. >> Attempting to fetch from - ftp://kermit.columbia.edu/kermit/archives/.</literallayout> + until I tried to install the kermit port:- + + <informalexample> + <screen>&prompt.root; <userinput>make install</userinput> +>> cku190.tar.gz doesn't seem to exist on this system. +>> Attempting to fetch from ftp://kermit.columbia.edu/kermit/archives/.</screen> + </informalexample> Why can it not be found? Have I got a dud CDROM? </para> @@ -2788,10 +2824,9 @@ CDROM, which is read-only. You can tell it to look somewhere else by doing</para> - <para> - <literallayout> DISTDIR=/where/you/put/it make - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make DISTDIR=/where/you/put/it install</userinput></screen> + </informalexample> </listitem> <listitem> @@ -2806,21 +2841,18 @@ the ports mechanism to use different directories. For instance,</para> - <para> - <literallayout> make - PORTSDIR=/u/people/guests/wurzburger/ports - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PORTSDIR=/u/people/guests/wurzburger/ports install</userinput></screen> + </informalexample> <para>will compile the port in <filename>/u/people/guests/wurzburger/ports</filename> and install everything under <filename>/usr/local</filename>. </para> - <para> - <literallayout> make PREFIX=/u/people/guests/wurzburger/local - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PREFIX=/u/people/guests/wurzburger/local install</userinput></screen> + </informalexample> <para>will compile it in <filename>/usr/ports</filename> and install it in @@ -2829,10 +2861,9 @@ <para>And of course</para> - <para> - <literallayout> make PORTSDIR=.../ports PREFIX=.../local - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PORTSDIR=.../ports PREFIX=.../local install</userinput></screen> + </informalexample> <para>will combine the two (it is too long to fit on the page if I write it in full, but I am sure you get the idea).</para> @@ -2852,17 +2883,18 @@ <para>A. To get every single tarball for the ports collection, do</para> - <para> - <literallayout> # cd /usr/ports # make fetch</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make fetch</userinput></screen> + </informalexample> <para>For all the tarballs for a single ports directory, do</para> - <para> - <literallayout> # cd /usr/ports/directory # make - fetch</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/directory</userinput> +&prompt.root; <userinput>make fetch</userinput></screen> + </informalexample> <para>and for just one port - well, I think you have guessed already.</para> @@ -2877,8 +2909,12 @@ <para>A. Yes. If you know, for example, ftp.FreeBSD.ORG is much closer than sites listed in MASTER_SITES, do as following - example. <literallayout> # cd /usr/ports/directory # make - MASTER_SITE_OVERRIDE=ftp://ftp.FreeBSD.ORG/pub/FreeBSD/distfiles/ fetch</literallayout> + example. + + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/directory</userinput> +&prompt.root; <userinput>make MASTER_SITE_OVERRIDE=ftp://ftp.FreeBSD.ORG/pub/FreeBSD/distfiles/ fetch</userinput></screen> + </informalexample> </para> </listitem> @@ -2887,7 +2923,7 @@ it tries to pull them down. </para> - <para>A. 'make fetch-list' will display a list of the files + <para>A. <command>make fetch-list</command> will display a list of the files needed for a port.</para> </listitem> @@ -2898,7 +2934,7 @@ every time. </para> - <para>A. Doing 'make extract' will stop it after it has fetched + <para>A. Doing <command>make extract</command> will stop it after it has fetched and extracted the source code.</para> </listitem> @@ -2909,7 +2945,7 @@ extract', but for patches? </para> - <para>A. Yep, 'make patch' is what you want. You will probably + <para>A. Yep, <command>make patch</command> is what you want. You will probably find the PATCH_DEBUG option useful as well. And by the way, thank you for your efforts!</para> </listitem> @@ -2921,16 +2957,15 @@ </para> <para>A. Yes, with version 2.6.3 of gcc (the version shipped - with FreeBSD 2.1.0 and 2.1.5), the -O2 option could result in - buggy code unless you used the -fno-strength-reduce option as - well. (Most of the ports don't use -O2). You + with FreeBSD 2.1.0 and 2.1.5), the <option>-O2</option> option could result in + buggy code unless you used the <option>-fno-strength-reduce</option> option as + well. (Most of the ports don't use <option>-O2</option>). You <emphasis>should</emphasis> be able to specify the compiler options used by something like</para> - <para> - <literallayout> make CFLAGS='-O2 -fno-strength-reduce' - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make CFLAGS='-O2 -fno-strength-reduce' install</userinput></screen> + </informalexample> <para>or by editing <filename>/etc/make.conf</filename>, but unfortunately not all ports respect this. The surest way is to @@ -2945,7 +2980,7 @@ want. Is there a list anywhere of what ports are available? </para> - <para>A. Look in the INDEX file in /usr/ports.</para> + <para>A. Look in the <filename>INDEX</filename> file in <filename>/usr/ports</filename>.</para> </listitem> <listitem> @@ -2970,9 +3005,9 @@ <para>A. No problem, just do</para> - <para> - <literallayout> pkg_delete grizzle-6.5</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>pkg_delete grizzle-6.5</userinput></screen> + </informalexample> </listitem> <listitem> @@ -2984,17 +3019,11 @@ <para>A. Not at all, you can find it out by doing</para> - <para> - <literallayout> pkg_info -a | grep grizzle</literallayout> - </para> - - <para>And it will tell you:-</para> - - <para> - <literallayout> Information for grizzle-6.5: grizzle-6.5 - the - combined piano tutorial, LOGO interpreter and shoot 'em up - arcade game.</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>pkg_info -a | grep grizzle</userinput> +Information for grizzle-6.5: +grizzle-6.5 - the combined piano tutorial, LOGO interpreter and shoot 'em up arcade game.</screen> + </informalexample> </listitem> <listitem> @@ -3008,9 +3037,10 @@ in keeping it hanging around. The best way to do this is</para> - <para> - <literallayout> # cd /usr/ports # make clean</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make clean</userinput></screen> + </informalexample> <para>which will go through all the ports subdirectories and delete everything except the skeletons for each port.</para> @@ -3033,9 +3063,10 @@ <para>A. Just do</para> - <para> - <literallayout> # cd /usr/ports # make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> </listitem> <listitem> @@ -3059,19 +3090,19 @@ <para>A. OK, do this before you go to bed/work/the local park:-</para> - <para> - <literallayout> # cd /usr/ports # make -DBATCH - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make -DBATCH install</userinput></screen> + </informalexample> <para>This will install every port that does <emphasis>not</emphasis> require user input. Then, when you come back, do</para> - <para> - <literallayout> # cd /usr/ports # make -DIS_INTERACTIVE - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make -DIS_INTERACTIVE install</userinput></screen> + </informalexample> <para>to finish the job.</para> </listitem> @@ -3086,11 +3117,14 @@ <para>A. No problem, assuming you know how to make patches for your changes:-</para> - <para> - <literallayout> # cd /usr/ports/somewhere/frobble # make - extract # cd work/frobble-2.8 [Apply your patches] # cd - ../.. # make package</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/somewhere/frobble</userinput> +&prompt.root; <userinput>make extract</userinput> +&prompt.root; <userinput>cd work/frobble-2.8</userinput> +[Apply your patches] +&prompt.root; <userinput>cd ../..</userinput> +&prompt.root; <userinput>make package</userinput></screen> + </informalexample> </listitem> <listitem> @@ -3213,7 +3247,8 @@ copy the <filename>GENERIC</filename> configuration file to the name you want to give your kernel. For example: <informalexample> - <screen>&prompt.root; cd /usr/src/sys/i386/conf &prompt.root; cp GENERIC MYKERNEL</screen> + <screen>&prompt.root; <userinput>cd /usr/src/sys/i386/conf</userinput> +&prompt.root; <userinput>cp GENERIC MYKERNEL</userinput></screen> </informalexample> Traditionally, this name is in all capital letters and, if you are maintaining multiple FreeBSD machines with different hardware, it is a good idea to name it after your @@ -3258,8 +3293,11 @@ <para>When you are finished, type the following to compile and install your kernel: <informalexample> - <screen>&prompt.root; /usr/sbin/config MYKERNEL &prompt.root; cd ../../compile/MYKERNEL &prompt.root; - make depend &prompt.root; make &prompt.root; make install</screen> + <screen>&prompt.root; <userinput>/usr/sbin/config MYKERNEL</userinput> +&prompt.root; <userinput>cd ../../compile/MYKERNEL</userinput> +&prompt.root; <userinput>make depend</userinput> +&prompt.root; <userinput>make</userinput> +&prompt.root; <userinput>make install</userinput></screen> </informalexample> The new kernel will be copied to the root directory as <filename>/kernel</filename> and the old kernel will be moved to <filename>/kernel.old</filename>. Now, shutdown the system @@ -3644,18 +3682,18 @@ <filename>/tmp</filename>, add the following line to <filename>/etc/fstab</filename> and then reboot or type <command>mount /tmp</command>: - <informalexample> - <screen>/dev/wd1s2b /tmp mfs rw 0 0 </screen> - </informalexample> + <programlisting> +/dev/wd1s2b /tmp mfs rw 0 0 + </programlisting> </para> <note> <para>Replace the <filename>/dev/wd1s2b</filename> with the name of your swap partition, which will be listed in your <filename>/etc/fstab</filename> as follows: - <informalexample> - <screen>/dev/wd1s2b none swap sw 0 0</screen> - </informalexample> + <programlisting> +/dev/wd1s2b none swap sw 0 0 + </programlisting> </para> </note> @@ -4686,23 +4724,23 @@ <para>Suppose you add the IDE CD-ROM support to the kernel. The line to add is: - <informalexample> - <screen>controller wcd0</screen> - </informalexample> This means that you should look for some entries + <programlisting> +controller wcd0 + </programlisting> This means that you should look for some entries that start with <filename>wcd0</filename> in the <filename>/dev</filename> directory, possibly followed by a letter, such as <token>c</token>, or preceded by the letter <token>r</token>, which means a <quote>raw</quote> device. It turns out that those files are not there, so I must change to the <filename>/dev</filename> directory and type: <informalexample> - <screen>&prompt.root; sh MAKEDEV wcd0</screen> + <screen>&prompt.root; <userinput>sh MAKEDEV wcd0</userinput></screen> </informalexample> When this script finishes, you will find that there are now <filename>wcd0c</filename> and <filename>rwcd0c</filename> entries in <filename>/dev</filename> so you know that it executed correctly.</para> <para>For sound cards, the command: <informalexample> - <screen>&prompt.root; sh MAKEDEV snd0</screen> + <screen>&prompt.root; <userinput>sh MAKEDEV snd0</userinput></screen> </informalexample> creates the appropriate entries.</para> <note> @@ -4801,13 +4839,13 @@ kernel file that <command>make</command> installs (in order to move another kernel back permanently) is: <informalexample> - <screen>&prompt.root; chflags noschg /kernel</screen> + <screen>&prompt.root; <userinput>chflags noschg /kernel</userinput></screen> </informalexample> And, if you want to <quote>lock</quote> your new kernel into place, or any file for that matter, so that it cannot be moved or tampered with: <informalexample> - <screen>&prompt.root; chflags schg /kernel</screen> + <screen>&prompt.root; <userinput>chflags schg /kernel</userinput></screen> </informalexample> </para> </note> @@ -4909,25 +4947,23 @@ fairly easy for most programs, except for those like <command>init</command> which are statically linked. (For those programs, the only way is to try them on a known password and see if it works.) Programs which use <emphasis - remap=tt>crypt</emphasis> are linked against <emphasis - remap=tt>libcrypt</emphasis>, which for each type of library is + remap=tt>crypt</emphasis> are linked against <filename>libcrypt</filename>, which for each type of library is a symbolic link to the appropriate implementation. For example, on a system using the DES versions:</para> <para> <informalexample> - <screen>&prompt.user; cd /usr/lib $ ls -l /usr/lib/libcrypt* lrwxr-xr-x 1 - bin bin 13 Sep 5 12:50 libcrypt.a -> libdescrypt.a - lrwxr-xr-x 1 bin bin 18 Sep 5 12:50 libcrypt.so.2.0 -> - libdescrypt.so.2.0 lrwxr-xr-x 1 bin bin 15 Sep 5 12:50 - libcrypt_p.a -> libdescrypt_p.a</screen> + <screen>&prompt.user;<userinput> cd /usr/lib</userinput> +&prompt.user; <userinput>ls -l /usr/lib/libcrypt*</userinput> +lrwxr-xr-x 1 bin bin 13 Sep 5 12:50 libcrypt.a -> libdescrypt.a +lrwxr-xr-x 1 bin bin 18 Sep 5 12:50 libcrypt.so.2.0 -> libdescrypt.so.2.0 +lrwxr-xr-x 1 bin bin 15 Sep 5 12:50 libcrypt_p.a -> libdescrypt_p.a</screen> </informalexample> </para> <para>On a system using the MD5-based libraries, the same links will - be present, but the target will be <emphasis - remap=tt>libscrypt</emphasis> rather than <emphasis - remap=tt>libdescrypt</emphasis>. + be present, but the target will be <filename>libscrypt</filename> + rather than <filename>libdescrypt</filename>. </para> </sect2> @@ -5020,19 +5056,20 @@ <para> <informalexample> - <screen>&prompt.user; keyinit Updating wollman: ) - these will not appear if you Old key: ha73895 - ) have not used S/Key before Reminder - Only use this method - if you are directly connected. If you are using telnet or - rlogin exit with no password and use keyinit -s. Enter secret - password: ) I typed my pass phrase here - Again secret password: ) I typed it again ID - wollman s/key is 99 ha73896 ) discussed below SAG - HAS FONT GOUT FATE BOOM )</screen> + <screen>&prompt.user; keyinit +Updating wollman: ) these will not appear if you +Old key: ha73895 ) have not used S/Key before +Reminder - Only use this method if you are directly connected. +If you are using telnet or rlogin exit with no password and use keyinit -s. +<prompt>Enter secret password:</prompt> ) I typed my pass phrase here +<prompt>Again secret password:</prompt> ) I typed it again ID + +wollman s/key is 99 ha73896 ) discussed below SAG +HAS FONT GOUT FATE BOOM )</screen> </informalexample> </para> - <para>There is a lot of information here. At the `Enter secret + <para>There is a lot of information here. At the`Enter secret password:' prompt, you should enter some password or phrase (I use phrases of minimum seven words) which will be needed to generate login keys. The line starting `ID' gives the parameters of your @@ -5061,10 +5098,12 @@ <para> <informalexample> - <screen>&prompt.user; keyinit -s Updating wollman: Old key: kh94741 - Reminder you need the 6 English words from the skey command. - Enter sequence count from 1 to 9999: 100 ) I typed this - Enter new key [default kh94742]: s/key 100 kh94742</screen> + <screen>&prompt.user; <userinput>keyinit -s</userinput> +Updating wollman: Old key: kh94741 +Reminder you need the 6 English words from the skey command. +<prompt>Enter sequence count from 1 to 9999:</prompt> <userinput>100</userinput> ) I typed this +<prompt>Enter new key [default kh94742]:</prompt> +s/key 100 kh94742</screen> </informalexample> </para> @@ -5075,10 +5114,10 @@ <para> <informalexample> - <screen>&prompt.user; key 100 kh94742 Reminder - Do not use this program - while logged in via telnet or rlogin. Enter secret password: - ) I typed my secret password HULL NAY YANG TREE TOUT - VETO</screen> + <screen>&prompt.user; <userinput>key 100 kh94742</userinput> +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> ) I typed my secret password +HULL NAY YANG TREE TOUT VETO</screen> </informalexample> </para> @@ -5089,9 +5128,9 @@ <para> <informalexample> - <screen>s/key access password: HULL NAY YANG TREE TOUT VETO ID - wollman s/key is 100 kh94742 HULL NAY YANG TREE TOUT - VETO</screen> + <screen><prompt>s/key access password:</prompt> <userinput>HULL NAY YANG TREE TOUT VETO</userinput> +ID wollman s/key is 100 kh94742 +HULL NAY YANG TREE TOUT VETO</screen> </informalexample> </para> @@ -5108,9 +5147,12 @@ <para> <informalexample> - <screen>&prompt.user; telnet himalia Trying 18.26.0.186... Connected to - himalia.lcs.mit.edu. Escape character is '^]'. s/key 92 - hi52030 Password:</screen> + <screen>&prompt.user; <userinput>telnet himalia</userinput> +Trying 18.26.0.186... +Connected to himalia.lcs.mit.edu. +Escape character is '^]'. +s/key 92 hi52030 +<prompt>Password:</prompt></screen> </informalexample> </para> @@ -5145,11 +5187,10 @@ <para> <informalexample> - <screen>&prompt.user; key 92 hi52030 ) pasted from - previous section Reminder - Do not use this program while - logged in via telnet or rlogin. Enter secret password: - ) I typed my secret password ADEN BED WOLF HAW HOT - STUN</screen> + <screen>&prompt.user; <userinput>key 92 hi52030</userinput> ) pasted from previous section +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> ) I typed my secret password +ADEN BED WOLF HAW HOT STUN</screen> </informalexample> </para> @@ -5157,10 +5198,12 @@ <para> <informalexample> - <screen>s/key 92 hi52030 ) from - previous section Password: (turning echo on) Password:ADEN BED - WOLF HAW HOT STUN Last login: Wed Jun 28 15:31:00 from - halloran-eldar.l [etc.]</screen> + <screen>s/key 92 hi52030 ) from previous section +<prompt>Password:</prompt> + (turning echo on) +<prompt>Password:</prompt>ADEN BED WOLF HAW HOT STUN +Last login: Wed Jun 28 15:31:00 from halloran-eldar.l +[etc.]</screen> </informalexample> </para> @@ -5183,16 +5226,19 @@ <para> <informalexample> - <screen>&prompt.user; key -n 25 57 zz99999 Reminder - Do not use this - program while logged in via telnet or rlogin. Enter secret - password: 33: WALT THY MALI DARN NIT HEAD 34: ASK RICE BEAU - GINA DOUR STAG [...] 56: AMOS BOWL LUG FAT CAIN INCH 57: - GROW HAYS TUN DISH CAR BALM </screen> + <screen>&prompt.user; <userinput>key -n 25 57 zz99999</userinput> +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> +33: WALT THY MALI DARN NIT HEAD +34: ASK RICE BEAU GINA DOUR STAG +… +56: AMOS BOWL LUG FAT CAIN INCH +57: GROW HAYS TUN DISH CAR BALM</screen> </informalexample> </para> <para>The <option>-n 25</option> requests twenty-five keys in - sequence; the <emphasis remap=tt>57</emphasis> indicates the + sequence; the <option>57</option> indicates the <emphasis>ending</emphasis> iteration number; and the rest is as before. Note that these are printed out in <emphasis>reverse</emphasis> order of eventual use. If you are @@ -5225,12 +5271,11 @@ <para>Here is a sample configuration file which illustrates the three most common sorts of configuration statements:</para> - <para> - <informalexample> - <screen>permit internet 18.26.0.0 255.255.0.0 permit user jrl - permit port ttyd0</screen> - </informalexample> - </para> + <programlisting> +permit internet 18.26.0.0 255.255.0.0 +permit user jrl +permit port ttyd0 + </programlisting> <para>The first line (<literal>permit internet</literal>) allows users whose IP source address @@ -5295,8 +5340,9 @@ <para> <informalexample> - <screen>&prompt.root; cd /etc/kerberosIV &prompt.root; ls README - krb.conf krb.realms</screen> + <screen>&prompt.root; <userinput>cd /etc/kerberosIV</userinput> +&prompt.root; <userinput>ls</userinput> +README krb.conf krb.realms</screen> </informalexample> </para> @@ -5314,17 +5360,19 @@ <filename>grunt.grondar.za</filename>. We edit or create the <filename>krb.conf</filename> file:</para> - <para> - <informalexample> - <screen>&prompt.root; cat krb.conf GRONDAR.ZA GRONDAR.ZA - grunt.grondar.za admin server CS.BERKELEY.EDU - okeeffe.berkeley.edu ATHENA.MIT.EDU kerberos.mit.edu - ATHENA.MIT.EDU kerberos-1.mit.edu ATHENA.MIT.EDU - kerberos-2.mit.edu ATHENA.MIT.EDU kerberos-3.mit.edu - LCS.MIT.EDU kerberos.lcs.mit.edu TELECOM.MIT.EDU bitsy.mit.edu - ARC.NASA.GOV trident.arc.nasa.gov</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat krb.conf</userinput> +GRONDAR.ZA +GRONDAR.ZA grunt.grondar.za admin server +CS.BERKELEY.EDU okeeffe.berkeley.edu +ATHENA.MIT.EDU kerberos.mit.edu +ATHENA.MIT.EDU kerberos-1.mit.edu +ATHENA.MIT.EDU kerberos-2.mit.edu +ATHENA.MIT.EDU kerberos-3.mit.edu +LCS.MIT.EDU kerberos.lcs.mit.edu +TELECOM.MIT.EDU bitsy.mit.edu +ARC.NASA.GOV trident.arc.nasa.gov</screen> + </informalexample> <para>In this case, the other realms do not need to be there. They are here as an example of how a machine may be made aware of @@ -5346,13 +5394,14 @@ <filename>krb.realms</filename> file would be updated as follows:</para> - <para> - <informalexample> - <screen>&prompt.root; cat krb.realms grunt.grondar.za GRONDAR.ZA - .grondar.za GRONDAR.ZA .berkeley.edu CS.BERKELEY.EDU .MIT.EDU - ATHENA.MIT.EDU .mit.edu ATHENA.MIT.EDU</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat krb.realms</userinput> +grunt.grondar.za GRONDAR.ZA +.grondar.za GRONDAR.ZA +.berkeley.edu CS.BERKELEY.EDU +.MIT.EDU ATHENA.MIT.EDU +.mit.edu ATHENA.MIT.EDU</screen> + </informalexample> <para>Again, the other realms do not need to be there. They are here as an example of how a machine may be made aware of multiple @@ -5366,25 +5415,27 @@ run on the Kerberos server (or Key Distribution Centre). Issue the <symbol>kdb_init</symbol> command to do this:</para> - <para> - <informalexample> - <screen>&prompt.root; kdb_init Realm name [default ATHENA.MIT.EDU ]: - GRONDAR.ZA You will be prompted for the database Master - Password. It is important that you NOT FORGET this password. - Enter Kerberos master key: </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_init</userinput> +<prompt>Realm name [default ATHENA.MIT.EDU ]:</prompt> <userinput>GRONDAR.ZA</userinput> +You will be prompted for the database Master Password. +It is important that you NOT FORGET this password. + +<prompt>Enter Kerberos master key:</prompt> </screen> + </informalexample> <para>Now we have to save the key so that servers on the local machine can pick it up. Use the <command>kstash</command> command to do this.</para> - <para> - <informalexample> - <screen>&prompt.root; kstash Enter Kerberos master key: Current - Kerberos master key version is 1. Master key entered. - BEWARE!</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kstash</userinput> + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE!</screen> + </informalexample> <para>This saves the encrypted master password in <filename>/etc/kerberosIV/master_key</filename>.</para> @@ -5394,8 +5445,7 @@ <sect2> <title>Making it all run</title> - <para>Two principals need to be added to the database for <emphasis - remap=it>each</emphasis> system that will be secured with + <para>Two principals need to be added to the database for <emphasis>each</emphasis> system that will be secured with Kerberos. Their names are <command>kpasswd</command> and <command>rcmd</command> These two principals are made for each system, with the instance being the name of the @@ -5410,26 +5460,54 @@ <para> <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: passwd Instance: grunt <Not found>, - Create [y] ? y Principal: passwd, Instance: grunt, - kdc_key_ver: 1 New Password: <---- enter - RANDOM here Verifying password New Password: - <---- enter RANDOM here Random password [y] ? y Principal's - new key version = 1 Expiration date (enter yyyy-mm-dd) [ - 2000-01-01 ] ? Max ticket lifetime (*5 minutes) [ 255 ] ? - Attributes [ 0 ] ? Edit O.K. Principal name: rcmd Instance: - grunt <Not found>, Create [y] ? Principal: rcmd, - Instance: grunt, kdc_key_ver: 1 New Password: - <---- enter RANDOM here Verifying password New Password: - <---- enter RANDOM here Random password [y] ? Principal's - new key version = 1 Expiration date (enter yyyy-mm-dd) [ - 2000-01-01 ] ? Max ticket lifetime (*5 minutes) [ 255 ] ? - Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>passwd</userinput> +<prompt>Instance:</prompt> <userinput>grunt</userinput> + +<Not found>, <prompt>Create [y] ?</prompt> <userinput>y</userinput> + +Principal: passwd, Instance: grunt, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter RANDOM here +Verifying password + +<prompt>New Password:</prompt> <---- enter RANDOM here + +<prompt>Random password [y] ?</prompt> <userinput>y</userinput> + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <userinput>rcmd</userinput> +<prompt>Instance:</prompt> <userinput>grunt</userinput> + +<Not found>, <prompt>Create [y] ?</prompt> + +Principal: rcmd, Instance: grunt, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter RANDOM here +Verifying password + +<prompt>New Password:</prompt> <---- enter RANDOM here + +<prompt>Random password [y] ?</prompt> + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> </informalexample> </para> @@ -5440,73 +5518,80 @@ <para>We now have to extract all the instances which define the services on each machine. For this we use the - <symbol>ext_srvtab</symbol> command. This will create a file which + <command>ext_srvtab</command> command. This will create a file which must be copied or moved <emphasis>by secure means</emphasis> to each Kerberos client's /etc/kerberosIV directory. This file must be present on each server and client, and is crucial to the operation of Kerberos.</para> - <para> - <informalexample> - <screen>&prompt.root; ext_srvtab grunt Enter Kerberos master key: - Current Kerberos master key version is 1. Master key entered. - BEWARE! Generating 'grunt-new-srvtab'....</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ext_srvtab grunt</userinput> +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Generating 'grunt-new-srvtab'....</screen> + </informalexample> <para>Now, this command only generates a temporary file which must be renamed to <filename>srvtab</filename> so that all the server can pick it up. Use the <command>mv</command> command to move it into place on the original system:</para> - <para> - <informalexample> - <screen>&prompt.root; mv grunt-new-srvtab srvtab</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mv grunt-new-srvtab srvtab</userinput></screen> + </informalexample> <para>If the file is for a client system, and the network is not - deemed safe, then copy the <emphasis - remap=tt><client>-new-srvtab</emphasis> to removable media + deemed safe, then copy the <filename><replaceable>client</replaceable>-new-srvtab</filename> to removable media and transport it by secure physical means. Be sure to rename it to <filename>srvtab</filename> in the client's <filename>/etc/kerberosIV</filename> directory, and make sure it is mode 600:</para> - <para> - <informalexample> - <screen>&prompt.root; mv grumble-new-srvtab srvtab &prompt.root; chmod 600 - srvtab</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; <userinput>mv grumble-new-srvtab srvtab</userinput> +&prompt.root; <userinput>chmod 600 srvtab</userinput></screen> + </informalexample> </sect2> <sect2> <title>Populating the database</title> <para>We now have to add some user entries into the database. First - let's create an entry for the user <emphasis - remap=it>jane</emphasis>. Use the <symbol>kdb_edit</symbol> - command to do this:</para> - - <para> - <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: jane Instance: <Not found>, Create [y] ? - y Principal: jane, Instance: , kdc_key_ver: 1 New Password: - <---- enter a secure password here Verifying password New - Password: <---- re-enter the password - here Principal's new key version = 1 Expiration date (enter - yyyy-mm-dd) [ 2000-01-01 ] ? Max ticket lifetime (*5 minutes) - [ 255 ] ? Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> - </informalexample> - </para> + let's create an entry for the user <username>jane</username>. Use + the <command>kdb_edit</command> command to do this:</para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>jane</userinput> +<prompt>Instance:</prompt> + +<Not found>, <prompt>Create [y] ?</prompt> <userinput>y</userinput> + +Principal: jane, Instance: , kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter a secure password here +Verifying password + +<prompt>New Password:</prompt> <---- re-enter the password here +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> + </informalexample> </sect2> <sect2> @@ -5519,52 +5604,60 @@ automagically get what they need from the <filename>/etc/kerberosIV</filename> directory.</para> - <para> - <informalexample> - <screen>&prompt.root; kerberos & &prompt.root; Kerberos server starting - Sleep forever on error Log file is /var/log/kerberos.log - Current Kerberos master key version is 1. Master key entered. - BEWARE! Current Kerberos master key version is 1 Local realm: - GRONDAR.ZA &prompt.root; kadmind -n & &prompt.root; KADM Server KADM0.0A - initializing Please do not use 'kill -9' to kill this job, use - a regular kill instead Current Kerberos master key version is - 1. Master key entered. BEWARE!</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kerberos &</userinput> +Kerberos server starting +Sleep forever on error +Log file is /var/log/kerberos.log +Current Kerberos master key version is 1. + +Master key entered. BEWARE! + +Current Kerberos master key version is 1 +Local realm: GRONDAR.ZA +&prompt.root; <userinput>kadmind -n &</userinput> +KADM Server KADM0.0A initializing +Please do not use 'kill -9' to kill this job, use a +regular kill instead + +Current Kerberos master key version is 1. + +Master key entered. BEWARE!</screen> + </informalexample> <para>Now we can try using the <command>kinit</command> - command to get a ticket for the id <emphasis - remap=it>jane</emphasis> that we created above:</para> + command to get a ticket for the id <username>jane</username> that we created above:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit jane MIT Project Athena (grunt.grondar.za) - Kerberos Initialization for "jane" Password: </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>kinit jane</userinput> +MIT Project Athena (grunt.grondar.za) +Kerberos Initialization for "jane" +<prompt>Password:</prompt> </screen> + </informalexample> <para>Try listing the tokens using <command>klist</command> to see if we really have them:</para> - <para> - <informalexample> - <screen>&prompt.user; klist Ticket file: /tmp/tkt245 Principal: - jane@GRONDAR.ZA Issued Expires Principal - Apr 30 11:23:22 Apr 30 19:23:22 - krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>klist</userinput> +Ticket file: /tmp/tkt245 +Principal: jane@GRONDAR.ZA + + Issued Expires Principal +Apr 30 11:23:22 Apr 30 19:23:22 krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> + </informalexample> <para>Now try changing the password using <command>passwd</command> to check if the kpasswd daemon can get authorization to the Kerberos database:</para> - <para> - <informalexample> - <screen>&prompt.user; passwd realm GRONDAR.ZA Old password for jane: - New Password for jane: Verifying password New Password for - jane: Password changed.</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.user; <userinput>passwd</userinput> +realm GRONDAR.ZA +<prompt>Old password for jane:</prompt> +<prompt>New Password for jane:</prompt> +Verifying password +<prompt>New Password for jane:</prompt> +Password changed.</screen> + </informalexample> </sect2> <sect2> @@ -5573,71 +5666,77 @@ <para>Kerberos allows us to give <emphasis>each</emphasis> user who needs root privileges their own <emphasis remap=it>separate</emphasis> <command>su</command>password. We could now add an id which is - authorized to <command>su</command> to <emphasis - remap=it>root</emphasis>. This is controlled by having an - instance of <emphasis remap=it>root</emphasis> associated with a - principal. Using <symbol>kdb_edit</symbol> we can create the - entry <filename>jane.root</filename> in the Kerberos + authorized to <command>su</command> to <username>root</username>. This is controlled by having an + instance of <username>root</username> associated with a + principal. Using <command>kdb_edit</command> we can create the + entry <literal>jane.root</literal> in the Kerberos database:</para> - <para> - <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: jane Instance: root <Not found>, Create - [y] ? y Principal: jane, Instance: root, kdc_key_ver: 1 New - Password: <---- enter a SECURE password - here Verifying password New Password: - <---- re-enter the password here Principal's new key - version = 1 Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] - ? Max ticket lifetime (*5 minutes) [ 255 ] ? 12 <--- Keep - this short! Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>jane</userinput> +<prompt>Instance:</prompt> <userinput>root</userinput> + +<Not found>, Create [y] ? y + +Principal: jane, Instance: root, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter a SECURE password here +Verifying password + +<prompt>New Password:</prompt> <---- re-enter the password here + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> <userinput>12</userinput> <--- Keep this short! +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> + </informalexample> <para>Now try getting tokens for it to make sure it works:</para> - <para> - <informalexample> - <screen>&prompt.root; kinit jane.root MIT Project Athena - (grunt.grondar.za) Kerberos Initialization for "jane.root" - Password: - </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kinit jane.root</userinput> +MIT Project Athena (grunt.grondar.za) +Kerberos Initialization for "jane.root" +<prompt>Password:</prompt></screen> + </informalexample> <para>Now we need to add the user to root's <filename>.klogin</filename> file:</para> - <para> - <informalexample> - <screen>&prompt.root; cat /root/.klogin jane.root@GRONDAR.ZA</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; <userinput>cat /root/.klogin</userinput> +jane.root@GRONDAR.ZA</screen> + </informalexample> + <para>Now try doing the <command>su</command>:</para> - <para> - <informalexample> - <screen>&prompt.user; su Password: &prompt.root; - </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <prompt>su</prompt> +<prompt>Password:</prompt></screen> + </informalexample> <para>and take a look at what tokens we have:</para> - <para> - <informalexample> - <screen>&prompt.root; klist Ticket file: /tmp/tkt_root_245 Principal: - jane.root@GRONDAR.ZA Issued Expires - Principal May 2 20:43:12 May 3 04:43:12 - krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; klist +Ticket file: /tmp/tkt_root_245 +Principal: jane.root@GRONDAR.ZA + + Issued Expires Principal +May 2 20:43:12 May 3 04:43:12 krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> + </informalexample> </sect2> <sect2> @@ -5654,21 +5753,19 @@ the <filename>.klogin</filename> file in <emphasis remap=tt>root</emphasis>'s home directory:</para> - <para> - <informalexample> - <screen>&prompt.root; cat /root/.klogin jane.root@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat /root/.klogin</userinput> +jane.root@GRONDAR.ZA</screen> + </informalexample> <para>Likewise, if a user has in their own home directory lines of the form:</para> - <para> - <informalexample> - <screen>&prompt.user;cat ~/.klogin jane@GRONDAR.ZA - jack@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>cat ~/.klogin</userinput> +jane@GRONDAR.ZA +jack@GRONDAR.ZA</screen> + </informalexample> <para>This allows anyone in the <filename>GRONDAR.ZA</filename> realm who has authenticated themselves to @@ -5682,36 +5779,33 @@ <para>For example, Jane now logs into another system, using Kerberos:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit MIT Project Athena - (grunt.grondar.za) Password: %prompt.user; rlogin grunt - Last login: Mon May 1 21:14:47 from grumble Copyright (c) - 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 The Regents of - the University of California. All rights reserved. FreeBSD - BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995 - &prompt.user;</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>kinit</userinput> +MIT Project Athena (grunt.grondar.za) +<prompt>Password:</prompt> +%prompt.user; <userinput>rlogin grunt</userinput> +Last login: Mon May 1 21:14:47 from grumble +Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 + The Regents of the University of California. All rights reserved. + +FreeBSD BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995</screen> + </informalexample> <para>Or Jack logs into Jane's account on the same machine (Jane having set up the <filename>.klogin</filename> file as above, and the person in charge of Kerberos having set up principal <emphasis>jack</emphasis> with a null instance:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit &prompt.user; rlogin grunt - -l jane MIT Project Athena (grunt.grondar.za) Password: Last - login: Mon May 1 21:16:55 from grumble Copyright (c) 1980, - 1983, 1986, 1988, 1990, 1991, 1993, 1994 The Regents of the - University of California. All rights reserved. FreeBSD - BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995 - [jane@grunt 10578]</screen> - </informalexample> - - </para> - + <informalexample> + <screen>&prompt.user; <userinput>kinit</userinput> +&prompt.user; <userinput>rlogin grunt -l jane</userinput> +MIT Project Athena (grunt.grondar.za) +<prompt>Password:</prompt> +Last login: Mon May 1 21:16:55 from grumble +Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 + The Regents of the University of California. All rights reserved. +FreeBSD BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995</screen> + </informalexample> </sect2> </sect1> @@ -5913,11 +6007,9 @@ counter using the <citerefentry><refentrytitle>ipfw</refentrytitle><manvolnum>8</manvolnum></citerefentry> utility:</para> - <para> - <informalexample> - <screen>&prompt.root; ipfw zero 4500</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw zero 4500</userinput></screen> + </informalexample> <para>Where 4500 is the chain entry you wish to continue logging.</para> @@ -6098,14 +6190,17 @@ </variablelist> </para> - <para>The <emphasis>address</emphasis> specification is: - <informalexample> - <screen><emphasis remap=bf>from</emphasis> - <<filename>address/mask</filename>>[<emphasis>port</emphasis>] <emphasis remap=bf>to</emphasis> <<filename>address/mask</filename>>[<emphasis>port</emphasis>] [<emphasis remap=bf>via</emphasis> <<emphasis>interface</emphasis>>]</screen> - </informalexample> - </para> + <para>The <emphasis>address</emphasis> specification is:</para> + + <cmdsynopsis> + <arg choice="plain">from</arg> + <arg choice="plain"><replaceable>address/mask</replaceable></arg><arg><replaceable>port</replaceable></arg> + <arg choice="plain">to</arg> + <arg choice="plain"><replaceable>address/mark</replaceable></arg><arg><replaceable>port</replaceable></arg> + <arg>via <replaceable>interface</replaceable></arg> + </cmdsynopsis> - <para>You can only specify <emphasis>port</emphasis> in + <para>You can only specify <replaceable>port</replaceable> in conjunction with <emphasis>protocols</emphasis> which support ports (UDP and TCP).</para> @@ -6118,25 +6213,29 @@ interfaces.</para> <para>The syntax used to specify an - <filename><address/mask></filename> is: + <replaceable>address/mask</replaceable> is: + <informalexample> - <screen><address></screen> - </informalexample> or + <screen>address</screen> + </informalexample> + + or + <informalexample> - <screen><address>/mask-bits</screen> - </informalexample> or + <screen>address/mask-bits</screen> + </informalexample> + + or + <informalexample> - <screen><address>:mask-pattern</screen> + <screen>address:mask-pattern</screen> </informalexample> </para> <para>A valid hostname may be specified in place of the IP address. <emphasis remap=tt>mask-bits</emphasis> is a decimal number representing how many bits in the address mask should be - set. e.g. specifying - <informalexample> - <screen>192.216.222.1/24</screen> - </informalexample> will create a mask which will allow any + set. e.g. specifying <literal> 192.216.222.1/24</literal> will create a mask which will allow any address in a class C subnet (in this case, 192.216.222) to be matched. <emphasis remap=tt>mask-pattern</emphasis> is an IP address which will be logically AND'ed with the address given. @@ -6144,13 +6243,15 @@ specify <quote>any IP address</quote>.</para> <para>The port numbers to be blocked are specified as: - <informalexample> - <screen>port[,port[,port[...]]]</screen> - </informalexample> to specify either a single port or a list of + + <cmdsynopsis> + <arg choice="plain"><replaceable>port</replaceable><arg>,<replaceable>port</replaceable><arg>,<replaceable>port</replaceable><arg>…</arg></arg></arg></arg> + </cmdsynopsis>to specify either a single port or a list of ports, or - <informalexample> - <screen>port-port</screen> - </informalexample> to specify a range of ports. You may also + + <cmdsynopsis> + <arg choice="plain"><replaceable>port</replaceable>-<replaceable>port</replaceable></arg> + </cmdsynopsis> to specify a range of ports. You may also combine a single range with a list, but the range must always be specified first.</para> @@ -6300,9 +6401,10 @@ <title>Flushing the IPFW rules</title> <para>The syntax for flushing the chain is: - <informalexample> - <screen>ipfw flush</screen> - </informalexample> + <cmdsynopsis> + <command>ipfw</command> + <arg choice="plain">flush</arg> + </cmdsynopsis> </para> <para>This causes all entries in the firewall chain to be removed @@ -6320,13 +6422,13 @@ <cmdsynopsis> <command>ipfw</command> <arg choice="plain">zero</arg> - <arg>index</arg> + <arg><replaceable>index</replaceable></arg> </cmdsynopsis> </para> - <para>When used without an <emphasis>index</emphasis> argument, + <para>When used without an <replaceable>index</replaceable> argument, all packet counters are cleared. If an - <emphasis>index</emphasis> is supplied, the clearing operation + <replaceable>index</replaceable> is supplied, the clearing operation only affects a specific chain entry.</para> </sect3> @@ -6340,45 +6442,36 @@ host <filename>nice.people.org</filename> by being forwarded by the router:</para> - <para> - <informalexample> - <screen>ipfw add deny tcp from evil.hacker.org to - nice.people.org 23</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root <userinput>ipfw add deny tcp from evil.hacker.org to nice.people.org 23</userinput></screen> + </informalexample> <para>The next example denies and logs any TCP traffic from the entire <filename>hacker.org</filename> network (a class C) to the <filename>nice.people.org</filename> machine (any port).</para> - <para> - <informalexample> - <screen>ipfw add deny log tcp from evil.hacker.org/24 to - nice.people.org</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw add deny log tcp from evil.hacker.org/24 to nice.people.org</userinput></screen> + </informalexample> <para>If you do not want people sending X sessions to your internal network (a subnet of a class C), the following command will do the necessary filtering:</para> - <para> - <informalexample> - <screen>ipfw add deny tcp from any to my.org/28 6000 - setup</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw add deny tcp from any to my.org/28 6000 setup</userinput></screen> + </informalexample> <para>To see the accounting records: <informalexample> - <screen>ipfw -a list</screen> + <screen>&prompt.root; <userinput>ipfw -a list</userinput></screen> </informalexample> or in the short form <informalexample> - <screen>ipfw -a l</screen> + <screen>&prompt.root; <userinput>ipfw -a l</userinput></screen> </informalexample> You can also see the last time a chain entry was matched with <informalexample> - <screen>ipfw -at l</screen> + <screen>&prompt.root; <userinput>ipfw -at l</userinput></screen> </informalexample> </para> @@ -6430,11 +6523,9 @@ you. There is currently no support in the <command>ipfw</command> utility for loading multiple rules in the one command. The system I use is to use the command:</para> - <para> - <informalexample> - <screen>&prompt.root; ipfw list</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw list</userinput></screen> + </informalexample> <para>to write a list of the current rules out to a file, and then use a text editor to prepend `<literal>ipfw @@ -6944,21 +7035,19 @@ <para>To find out if the kernel you are currently using supports a serial interface, type <informalexample> - <screen>&prompt.root; <userinput>dmesg | grep - sio<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>dmesg | grep sio<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the serial port, starting from zero. If you see output similar to the following <informalexample> - <screen> sio2 at 0x3e8-0x3ef irq 5 on isa sio2: type - 16550A</screen> + <screen>sio2 at 0x3e8-0x3ef irq 5 on isa +sio2: type 16550A</screen> </informalexample> then the kernel supports the port.</para> <para>To find out if the kernel supports a parallel interface, type <informalexample> - <screen>&prompt.root; <userinput>dmesg | grep - lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>dmesg | grep lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the parallel port, starting from zero. If you see output similar to the following @@ -7010,8 +7099,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput> ./MAKEDEV - <replaceable>port</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>./MAKEDEV <replaceable>port</replaceable></userinput></screen> </informalexample> where <replaceable>port</replaceable> is the device entry for the port you want to make. Use <literal>lpt0</literal> for the first parallel port, <literal>lpt1</literal> for the second, and @@ -7088,11 +7176,9 @@ <listitem> <para>If you want interrupt-driven mode, add the <literal>irq</literal> specifier: - <informalexample> - <screen>device lpt0 at isa? - port? tty irq <replaceable>N</replaceable> - vector lptintr</screen> - </informalexample> where <replaceable>N</replaceable> is the IRQ number for your + <programlisting> +device lpt0 at isa? port? tty irq <replaceable>N</replaceable> vector lptintr + </programlisting> where <replaceable>N</replaceable> is the IRQ number for your computer's parallel port. </para> </listitem> @@ -7100,11 +7186,9 @@ <listitem> <para>If you want polled mode, do not add the <literal>irq</literal> specifier: - <informalexample> - <screen>device lpt0 at isa? - port? tty vector lptintr - </screen> - </informalexample> + <programlisting> +device lpt0 at isa? port? tty vector lptintr + </programlisting> </para> </listitem> @@ -7130,8 +7214,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput>lptcontrol -i -u - <replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptcontrol -i -u <replaceable>N</replaceable></userinput></screen> </informalexample> to set interrupt-driven mode for <literal>lpt<replaceable>N</replaceable></literal>. </para> @@ -7140,8 +7223,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput>lptcontrol -p -u - <replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptcontrol -p -u <replaceable>N</replaceable></userinput></screen> </informalexample> to set polled-mode for <literal>lpt<replaceable>N</replaceable></literal>.</para> </listitem> @@ -7168,11 +7250,14 @@ <para>For a PostScript (or other language-based) printer, we will need a more sophisticated test. A small PostScript program, such as the following, will suffice: - <informalexample> - <programlisting>%!PS 100 100 moveto 300 300 lineto stroke - 310 310 moveto /Helvetica findfont 12 scalefont setfont - (Is this thing working?) show showpage</programlisting> - </informalexample> + + <programlisting> +%!PS +100 100 moveto 300 300 lineto stroke +310 310 moveto /Helvetica findfont 12 scalefont setfont +(Is this thing working?) show +showpage + </programlisting> </para> <note> @@ -7211,8 +7296,7 @@ use <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.root; <userinput>lptest > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptest > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the parallel port, starting from zero. </para> @@ -7223,8 +7307,7 @@ other printer language, then send a small program to the printer. Type <informalexample> - <screen>&prompt.root; <userinput>cat > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>cat > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> Then, line by line, type the program <emphasis>carefully</emphasis> as you cannot edit a line once you have pressed RETURN @@ -7237,9 +7320,7 @@ <para> Alternatively, you can put the program in a file and type <informalexample> - <screen>&prompt.root; <userinput>cat - <replaceable>file</replaceable> > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>cat <replaceable>file</replaceable> > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>file</replaceable> is the name of the file containing the program you want to send to the printer.</para> @@ -7278,9 +7359,9 @@ <listitem> <para>Edit the file <filename>/etc/remote</filename>. Add the following entry: - <informalexample> - <screen><literal>printer:dv=/dev/<replaceable>port</replaceable>:br#<replaceable>bps-rate</replaceable>:pa=<replaceable>parity</replaceable></literal></screen> - </informalexample> where <replaceable>port</replaceable> is the device entry for the + <programlisting> +printer:dv=/dev/<replaceable>port</replaceable>:br#<replaceable>bps-rate</replaceable>:pa=<replaceable>parity</replaceable> + </programlisting> where <replaceable>port</replaceable> is the device entry for the serial port (<literal>ttyd0</literal>, <literal>ttyd1</literal>, etc.), <replaceable>bps-rate</replaceable> is the bits-per-second rate at which the printer communicates, and @@ -7291,9 +7372,9 @@ <para>Here is a sample entry for a printer connected via a serial line to the third serial port at 19200 bps with no parity: - <informalexample> - <programlisting>printer:dv=/dev/ttyd2:br#19200:pa=none</programlisting> - </informalexample> + <programlisting> +printer:dv=/dev/ttyd2:br#19200:pa=none + </programlisting> </para> </listitem> @@ -7301,7 +7382,7 @@ <para>Connect to the printer with <citerefentry> <refentrytitle>tip</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.root; tip printer</screen> + <screen>&prompt.root; <userinput>tip printer</userinput></screen> </informalexample> If this step does not work, edit the file <filename>/etc/remote</filename> again and try using @@ -7318,7 +7399,7 @@ use <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.user; lptest</screen> + <screen><prompt>~</prompt><userinput>$lptest</userinput></screen> </informalexample> </para> @@ -7340,7 +7421,7 @@ <para> Alternatively, you can put the program in a file and type <informalexample> - <screen><userinput>~><replaceable>file</replaceable></userinput></screen> + <screen><prompt>~</prompt><userinput>><replaceable>file</replaceable></userinput></screen> </informalexample> where <replaceable>file</replaceable> is the name of the file containing the program. After <citerefentry> @@ -7498,12 +7579,16 @@ <filename>/etc/printcap</filename> that defines two printers (a Diablo 630 line printer and a Panasonic KX-P4455 PostScript laser printer): - <informalexample> - <programlisting># # /etc/printcap for host rose # - rattan|line|diablo|lp|Diablo 630 Line Printer: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:</programlisting> - </informalexample> In this example, the first printer is named + + <programlisting> +# +# /etc/printcap for host rose +# +rattan|line|diablo|lp|Diablo 630 Line Printer: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4: + </programlisting> + In this example, the first printer is named <hostid>rattan</hostid> and has as aliases <emphasis remap=tt>line</emphasis>, <emphasis remap=tt>diablo</emphasis>, <emphasis @@ -7536,12 +7621,18 @@ printer in <filename>/etc/printcap</filename>. Here is the example <filename>/etc/printcap</filename> with <emphasis remap=tt>sh</emphasis> added: - <informalexample> - <programlisting># # /etc/printcap for host rose - no header - pages anywhere # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ :sh:</programlisting> - </informalexample> Note how we used the correct format: the + + <programlisting> +# +# /etc/printcap for host rose - no header pages anywhere +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh: + </programlisting> + Note how we used the correct format: the first line starts in the leftmost column, and subsequent lines are indented with a single TAB. Every line in an entry except the last ends in a backslash character.</para> @@ -7567,16 +7658,16 @@ <para>It is also customary to make the directory with a name that is identical to the name of the printer, as shown below: <informalexample> - <screen>&prompt.root; <userinput>mkdir - /var/spool/<replaceable>printer-name</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>mkdir /var/spool/<replaceable>printer-name</replaceable></userinput></screen> </informalexample> However, if you have a lot of printers on your network, you might want to put the spooling directories under a single directory that you reserve just for printing with LPD. We will do this for our two example printers <hostid>rattan</hostid> and <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.root; mkdir /var/spool/lpd mkdir /var/spool/lpd/rattan - mkdir /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>mkdir /var/spool/lpd</userinput> +&prompt.root; <userinput>mkdir /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>mkdir /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> @@ -7590,10 +7681,10 @@ <para> <informalexample> - <screen>&prompt.root; chown daemon.daemon /var/spool/lpd/rattan chown - daemon.daemon /var/spool/lpd/bamboo chmod 770 - /var/spool/lpd/rattan chmod 770 - /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> </note> @@ -7602,13 +7693,18 @@ using the <filename>/etc/printcap</filename> file. You specify the pathname of the spooling directory with the <emphasis remap=tt>sd</emphasis> capability: - <informalexample> - <programlisting># # /etc/printcap for host rose - added - spooling directories # rattan|line|diablo|lp|Diablo 630 - Line Printer:\ :sh:sd=/var/spool/lpd/rattan: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:</programlisting> - </informalexample> Note that the name of the printer starts in + + <programlisting> +# +# /etc/printcap for host rose - added spooling directories +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo: + </programlisting> + Note that the name of the printer starts in the first column but all other entries describing the printer should be indented with a tab and each line escaped with a backslash.</para> @@ -7640,15 +7736,19 @@ and <hostid>bamboo</hostid> is on a sixth serial port; here are the additions to <filename>/etc/printcap</filename>: - <informalexample> - <programlisting># # /etc/printcap for host rose - - identified what devices to use # - rattan|line|diablo|lp|Diablo 630 Line Printer:\ - :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host rose - identified what devices to use +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5: + </programlisting> </para> <para>If you do not specify the <emphasis remap=tt>lp</emphasis> @@ -7768,11 +7868,12 @@ we will set the TANDEM, ANYP, LITOUT, FLUSHO, and PASS8 flags. For the local mode bits, we will set the LITOUT and PASS8 flags: - <informalexample> - <screen>bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000c1:xs#0x820:</screen> - </informalexample> + + <programlisting> +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000c1:xs#0x820: + </programlisting> </para> </sect4> @@ -7811,15 +7912,21 @@ <filename>/usr/local/libexec/if-simple</filename> be a simple text filter. Put the following text into that file with your favorite text editor: + + <programlisting> +#!/bin/sh +# +# if-simple - Simple text input filter for lpd +# Installed in /usr/local/libexec/if-simple +# +# Simply copies stdin to stdout. Ignores all filter arguments. + +/bin/cat && exit 0 +exit 2 + </programlisting> + Make the file executable: <informalexample> - <programlisting>#!/bin/sh # # if-simple - Simple text input - filter for lpd # Installed in /usr/local/libexec/if-simple - # # Simply copies stdin to stdout. Ignores all filter - arguments. /bin/cat && exit 0 exit - 2</programlisting> - </informalexample> Make the file executable: - <informalexample> - <screen>&prompt.root; chmod 555 /usr/local/libexec/if-simple</screen> + <screen>&prompt.root; <userinput>chmod 555 /usr/local/libexec/if-simple</userinput></screen> </informalexample> </para> @@ -7828,16 +7935,20 @@ <filename>/etc/printcap</filename>. We will add it to the two printers we have so far in the example <filename>/etc/printcap</filename>: - <informalexample> - <programlisting># # /etc/printcap for host rose - added - text filter # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:\ - :if=/usr/local/libexec/if-simple:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host rose - added text filter +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:\ + :if=/usr/local/libexec/if-simple: + </programlisting> </para> </sect4> @@ -7866,8 +7977,7 @@ <para> Type: <informalexample> - <screen>&prompt.root; <userinput>lptest 20 5 | lpr - -P<replaceable>printer-name</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptest 20 5 | lpr -P<replaceable>printer-name</replaceable></userinput></screen> </informalexample> where <emphasis remap=it>printer-name</emphasis> is a the name of a printer (or an alias) specified in <filename>/etc/printcap</filename>. @@ -7882,13 +7992,13 @@ the program. If you are using <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>, then your results should look like the following:</para> - <para> - <informalexample> - <screen>!"#$%&'()*+,-./01234 "#$%&'()*+,-./012345 - #$%&'()*+,-./0123456 $%&'()*+,-./01234567 - %&'()*+,-./012345678</screen> - </informalexample> - </para> + <programlisting> +!"#$%&'()*+,-./01234 +"#$%&'()*+,-./012345 +#$%&'()*+,-./0123456 +$%&'()*+,-./01234567 +%&'()*+,-./012345678 + </programlisting> <para>To further test the printer, try downloading larger programs (for language-based printers) or running</para> @@ -7933,15 +8043,19 @@ <filename>/usr/local/libexec/if-simple</filename> prints a form feed after it sends the job to the printer: - <informalexample> - <programlisting>#!/bin/sh # # if-simple - Simple - text input filter for lpd # Installed in - /usr/local/libexec/if-simple # # Simply copies - stdin to stdout. Ignores all filter arguments. # - Writes a form feed character (\f) after printing - job. /bin/cat && printf "\f" && - exit 0 exit 2</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# if-simple - Simple text input filter for lpd +# Installed in /usr/local/libexec/if-simple +# +# Simply copies stdin to stdout. Ignores all filter arguments. +# Writes a form feed character (\f) after printing job. + +/bin/cat && printf "\f" && exit 0 +exit 2 + </programlisting> </para> </listitem> </varlistentry> @@ -7951,11 +8065,13 @@ <listitem> <para>You got the following on paper: - <informalexample> - <screen>!"#$%&'()*+,-./01234 + + <programlisting> +!"#$%&'()*+,-./01234 "#$%&'()*+,-./012345 - #$%&'()*+,-./0123456</screen> - </informalexample> You have become another victim of + #$%&'()*+,-./0123456 + </programlisting> + You have become another victim of the <emphasis>staircase effect</emphasis>, caused by conflicting interpretations of what characters should indicate a new-line. UNIX-style operating systems use @@ -7973,7 +8089,8 @@ carriage return is for: to move the location of the next character to print to the left edge of the paper.</para> - + + <!-- This para needs to be rewritten - Nik --> <para>Here is what FreeBSD wants your printer to do: <informalexample> <screen>Printer received CR Printer prints @@ -8035,20 +8152,19 @@ page of the job. It should work with nearly all Hewlett Packard printers.</para> - <para> - <informalexample> - <programlisting>#!/bin/sh # # hpif - Simple - text input filter for lpd for HP-PCL based - printers # Installed in - /usr/local/libexec/hpif # # Simply copies - stdin to stdout. Ignores all filter - arguments. # Tells printer to treat LF as - CR+LF. Writes a form feed character # after - printing job. printf "\033&k2G" - && cat && printf "\f" - && exit 0 exit 2</programlisting> - </informalexample> - </para> + <programlisting> +#!/bin/sh +# +# hpif - Simple text input filter for lpd for HP-PCL based printers +# Installed in /usr/local/libexec/hpif +# +# Simply copies stdin to stdout. Ignores all filter arguments. +# Tells printer to treat LF as CR+LF. Writes a form feed character +# after printing job. + +printf "\033&k2G" && cat && printf "\f" && exit 0 +exit 2 + </programlisting> <para>Here is an example <filename>/etc/printcap</filename> from a host @@ -8056,12 +8172,15 @@ to its first parallel port, a Hewlett Packard LaserJet 3Si named <hostid>teak</hostid>. It is using the above script as its text filter: - <informalexample> - <programlisting># # /etc/printcap for host - orchid # teak|hp|laserjet|Hewlett Packard - LaserJet 3Si:\ - :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ :if=/usr/local/libexec/hpif:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif: + </programlisting> </para> </listitem> @@ -8083,7 +8202,8 @@ being treated as CR characters to return the print location to the left edge of the paper, but not also down a line.</para> - + + <!-- Need to rewrite this para --> <para>Use the printer's configuration switches or control panel to enforce the following interpretation of LF and CR characters: @@ -8170,12 +8290,14 @@ <filename>/etc/printcap</filename> file. For example, here is the entry for <hostid>rattan</hostid>, with the <emphasis remap=tt>lf</emphasis> capability: - <informalexample> - <screen>rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ - :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple:\ - :lf=/var/log/rattan.log</screen> - </informalexample> Then, try printing again. Check + + <programlisting> +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple:\ + :lf=/var/log/rattan.log + </programlisting> + Then, try printing again. Check the log file (in our example, <filename>/var/log/rattan.log</filename>) to see any error messages that might appear. Based on the @@ -8261,23 +8383,21 @@ <para>To print files, type <informalexample> - <screen><userinput>lpr - <replaceable>filename...</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lpr <replaceable>filename</replaceable> <replaceable>...</replaceable></userinput></screen> </informalexample> This prints each of the listed files to the default printer. If you list no files, <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> reads data to print from standard input. For example, this command prints some important system files: <informalexample> - <screen>&prompt.user; lpr /etc/host.conf /etc/hosts.equiv</screen> + <screen>&prompt.user; <userinput>lpr /etc/host.conf /etc/hosts.equiv</userinput></screen> </informalexample> To select a specific printer, type <informalexample> - <screen>&prompt.user; <userinput>lpr -P <replaceable>printer-name</replaceable> - <replaceable>filename...</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lpr -P <replaceable>printer-name</replaceable> <replaceable>filename</replaceable> <replaceable>...</replaceable></userinput></screen> </informalexample> This example prints a long listing of the current directory to the printer named <hostid>rattan</hostid>: <informalexample> - <screen>&prompt.user; ls -l | lpr -P rattan</screen> + <screen>&prompt.user; <userinput>ls -l | lpr -P rattan</userinput></screen> </informalexample> Because no files were listed for the <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> @@ -8314,15 +8434,15 @@ specific printer, use the <option>-P</option> option. For example, the command <informalexample> - <screen>&prompt.user; lpq -P bamboo</screen> + <screen>&prompt.user; <userinput>lpq -P bamboo</userinput></screen> </informalexample> shows the queue for the printer named <hostid>bamboo</hostid>. Here is an example of the output of the <command>lpq</command> command: <informalexample> - <screen>bamboo is ready and printing Rank Owner Job Files - Total Size active kelly 9 /etc/host.conf, - /etc/hosts.equiv 88 bytes 2nd kelly 10 (standard - input) 1635 bytes 3rd mary 11 ... - 78519 bytes</screen> + <screen>bamboo is ready and printing +Rank Owner Job Files Total Size +active kelly 9 /etc/host.conf, /etc/hosts.equiv 88 bytes +2nd kelly 10 (standard input) 1635 bytes +3rd mary 11 ... 78519 bytes</screen> </informalexample> This shows three jobs in the queue for <hostid>bamboo</hostid>. The first job, submitted by user kelly, got assigned <emphasis>job number</emphasis> 9. Every @@ -8359,14 +8479,16 @@ also support a <option>-l</option> option to generate a detailed long listing. Here is an example of <command>lpq -l</command>: <informalexample> - <screen>waiting for bamboo to become ready (offline ?) kelly: - 1st [job 009rose] /etc/host.conf - 73 bytes /etc/hosts.equiv 15 bytes - kelly: 2nd [job 010rose] - (standard input) 1635 bytes mary: 3rd - [job 011rose] - /home/orchid/mary/research/venus/alpha-regio/mapping 78519 - bytes</screen> + <screen>waiting for bamboo to become ready (offline ?) +kelly: 1st [job 009rose] + /etc/host.conf 73 bytes + /etc/hosts.equiv 15 bytes + +kelly: 2nd [job 010rose] + (standard input) 1635 bytes + +mary: 3rd [job 011rose] + /home/orchid/mary/research/venus/alpha-regio/mapping 78519 bytes</screen> </informalexample> </para> @@ -8389,13 +8511,12 @@ <refentrytitle>lpq</refentrytitle></citerefentry> to find the job number. Then type <informalexample> - <screen>&prompt.user; <userinput>lprm - <replaceable>job-number</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lprm <replaceable>job-number</replaceable></userinput></screen> </informalexample> To remove the job from a specific printer, add the <option>-P</option> option. The following command removes job number 10 from the queue for the printer <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.user; lprm -P bamboo 10</screen> + <screen>&prompt.user; <userinput>lprm -P bamboo 10</userinput></screen> </informalexample> The <citerefentry> <refentrytitle>lprm</refentrytitle></citerefentry> command has a few shortcuts: @@ -8436,11 +8557,9 @@ For example, the following command removes all jobs for the current user in the queue for the printer named <hostid>rattan</hostid>:</para> - <para> - <informalexample> - <screen>&prompt.user; lprm -P rattan -</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>lprm -P rattan -</userinput></screen> + </informalexample> <note> <para>If you are working in a networked @@ -8452,13 +8571,19 @@ were submitted, even if the same printer is available from other hosts. The following command sequence demonstrates this: <informalexample> - <programlisting>&prompt.user; lpr -P rattan myfile &prompt.user; rlogin orchid - &prompt.user; lpq -P rattan Rank Owner Job Files Total - Size active seeyan 12 ... 49123 bytes 2nd kelly - 13 myfile 12 bytes &prompt.user; lprm -P rattan 13 rose: - Permission denied &prompt.user; logout &prompt.user; lprm -P rattan 13 - dfA013rose dequeued cfA013rose dequeued &prompt.user; - </programlisting> + <screen>&prompt.user; <userinput>lpr -P rattan myfile</userinput> +&prompt.user; <userinput>rlogin orchid</userinput> +&prompt.user; <userinput>lpq -P rattan</userinput> +Rank Owner Job Files Total Size +active seeyan 12 ... 49123 bytes +2nd kelly 13 myfile 12 bytes +&prompt.user; <userinput>lprm -P rattan 13</userinput> +rose: Permission denied +&prompt.user; <userinput>logout</userinput> +&prompt.user; <userinput>lprm -P rattan 13</userinput> +dfA013rose dequeued +cfA013rose dequeued + </screen> </informalexample> </para> </note> @@ -8493,7 +8618,7 @@ <filename>fish-report.dvi</filename> to the printer named <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.user; lpr -P bamboo -d fish-report.dvi</screen> + <screen>&prompt.user; <userinput>lpr -P bamboo -d fish-report.dvi</userinput></screen> </informalexample> These options apply to every file in the job, so you cannot mix (say) DVI and ditroff files together in a job. Instead, submit the files as separate jobs, using a different @@ -8613,8 +8738,7 @@ <refentrytitle>ls</refentrytitle></citerefentry> manual page on the default printer: <informalexample> - <screen>&prompt.user; zcat /usr/share/man/man1/ls.1.gz | troff -t -man | lpr - -t</screen> + <screen>&prompt.user; <userinput>zcat /usr/share/man/man1/ls.1.gz | troff -t -man | lpr -t</userinput></screen> </informalexample> The <citerefentry> <refentrytitle>zcat</refentrytitle></citerefentry> command uncompresses the source of the</para> @@ -8661,7 +8785,7 @@ <filename>parser.c</filename> followed by three copies of <filename>parser.h</filename> to the default printer: <informalexample> - <screen>&prompt.user; lpr -#3 parser.c parser.h</screen> + <screen>&prompt.user; <userinput>lpr -#3 parser.c parser.h</userinput></screen> </informalexample> </para> </listitem> @@ -9155,14 +9279,16 @@ and comparing that to the number of lines per page the printer supports. The text filter is started with the following argument list: - <informalexample> - <screen><command>[-c] -w<replaceable>width</replaceable> - -l<replaceable>length</replaceable> - -i<replaceable>indent</replaceable> -n - <replaceable>login</replaceable> -h - <replaceable>host</replaceable> - <replaceable>acct-file</replaceable></command></screen> - </informalexample> where + <cmdsynopsis> + <command>filter-name</command> + <arg>-c</arg> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + <arg choice="plain">-l<replaceable>length</replaceable></arg> + <arg choice="plain">-i<replaceable>indent</replaceable></arg> + <arg choice="plain">-n <replaceable>login</replaceable></arg> + <arg choice="plain">-h <replaceable>host</replaceable></arg> + <arg choice="plain"><replaceable>acct-file</replaceable></arg> + </cmdsynopsis> where <variablelist> <varlistentry><term><option>-c</option></term> <listitem> @@ -9245,12 +9371,17 @@ Conversion filters also need to do accounting, if you need printer accounting. Conversion filters are started with the following arguments: - <informalexample> - <screen><command>-x<replaceable>pixel-width</replaceable> -y<replaceable>pixel-height</replaceable> -n <replaceable>login</replaceable> -h <replaceable>host</replaceable> <replaceable>acct-file</replaceable></command></screen> - </informalexample> where <emphasis - remap=it>pixel-width</emphasis> is the value from the + <cmdsynopsis> + <command>filter-name</command> + <arg + choice="plain">-x<replaceable>pixel-width</replaceable></arg> + <arg choice="plain">-y<replaceable>pixel-height</replaceable></arg> + <arg choice="plain">-n <replaceable>login</replaceable></arg> + <arg choice="plain">-h <replaceable>host</replaceable></arg> + <arg choice="plain"><replaceable>acct-file</replaceable></arg> + </cmdsynopsis> where <replaceable>pixel-width</replaceable> is the value from the <emphasis remap=tt>px</emphasis> capability (default 0) - and <emphasis remap=it>pixel-height</emphasis> is the + and <replaceable>pixel-height</replaceable> is the value from the <emphasis remap=tt>py</emphasis> capability (default 0). </para> @@ -9263,10 +9394,12 @@ <xref linkend="printing-advanced-of" remap="Output Filters"> describe them. There are only two arguments to an output filter: - <informalexample> - <screen><command>-w<replaceable>width</replaceable> - -l<replaceable>length</replaceable></command></screen> - </informalexample> which are identical to the text filters + <cmdsynopsis> + <command>filter-name</command> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + + <arg choice="plain">-l<replaceable>length</replaceable></arg> + </cmdsynopsis> which are identical to the text filters <option>-w</option> and <option>-l</option> arguments.</para> </listitem> @@ -9365,9 +9498,9 @@ installed <command>lprps</command> from the ports collection, use the following in the serial PostScript printer's entry in <filename>/etc/printcap</filename>: - <informalexample> - <screen> :if=/usr/local/libexec/psif:</screen> - </informalexample> You should also specify the <emphasis + <programlisting> +:if=/usr/local/libexec/psif: + </programlisting> You should also specify the <emphasis remap=tt>rw</emphasis> capability; that tells LPD to open the printer in read-write mode.</para> @@ -9375,19 +9508,33 @@ cannot use two-way communication with the printer, which <command>lprps</command> needs), you can use the following shell script as the text filter: - <informalexample> - <programlisting>#!/bin/sh # # psif - Print PostScript or - plain text on a PostScript printer # Script version; NOT - the version that comes with lprps # Installed in - /usr/local/libexec/psif # read first_line - first_two_chars=`expr "$first_line" : '\(..\)'` if [ - "$first_two_chars" = "%!" ]; then # # PostScript job, print - it. # echo $first_line && cat && printf - "\004" && exit 0 exit 2 else # # Plain text, - convert it, then print it. # ( echo $first_line; cat ) | - /usr/local/bin/textps && printf "\004" && - exit 0 exit 2 fi</programlisting> - </informalexample> In the above script, <command>textps</command> is a program we installed + + <programlisting> +#!/bin/sh +# +# psif - Print PostScript or plain text on a PostScript printer +# Script version; NOT the version that comes with lprps +# Installed in /usr/local/libexec/psif +# + +read first_line +first_two_chars=`expr "$first_line" : '\(..\)'` + +if [ "$first_two_chars" = "%!" ]; then + # + # PostScript job, print it. + # + echo $first_line && cat && printf "\004" && exit 0 + exit 2 +else + # + # Plain text, convert it, then print it. + # + ( echo $first_line; cat ) | /usr/local/bin/textps && printf "\004" && exit 0 + exit 2 +fi + </programlisting> + In the above script, <command>textps</command> is a program we installed separately to convert plain text to PostScript. You can use any text-to-PostScript program you wish. The FreeBSD ports collection (see <xref linkend="ports" remap="The Ports @@ -9430,25 +9577,45 @@ <para><citerefentry> <refentrytitle>gs</refentrytitle></citerefentry> (Ghostscript) command. (Type <command>gs -h</command> to get a list of devices the current installation of Ghostscript supports.) - <informalexample> - <programlisting>#!/bin/sh # # ifhp - Print - Ghostscript-simulated PostScript on a DeskJet 500 # - Installed in /usr/local/libexec/hpif # # Treat LF as CR+LF: - # printf "\033&k2G" || exit 2 # # Read first two - characters of the file # read first_line - first_two_chars=`expr "$first_line" : '\(..\)'` if [ - "$first_two_chars" = "%!" ]; then # # It is PostScript; use - Ghostscript to scan-convert and print it # /usr/local/bin/gs - -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \ - && exit 0 else # # Plain text or HP/PCL, so just - print it directly; print a form # at the end to eject the - last page. # echo $first_line && cat && - printf "\f" && exit 0 fi exit 2</programlisting> - </informalexample> Finally, you need to notify LPD of the filter + + <programlisting> +#!/bin/sh +# +# ifhp - Print Ghostscript-simulated PostScript on a DeskJet 500 +# Installed in /usr/local/libexec/hpif + +# +# Treat LF as CR+LF: +# +printf "\033&k2G" || exit 2 + +# +# Read first two characters of the file +# +read first_line +first_two_chars=`expr "$first_line" : '\(..\)'` + +if [ "$first_two_chars" = "%!" ]; then + # + # It is PostScript; use Ghostscript to scan-convert and print it + # + /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \ + && exit 0 +else + # + # Plain text or HP/PCL, so just print it directly; print a form + # at the end to eject the last page. + # + echo $first_line && cat && printf "\f" && exit 0 +fi + +exit 2 + </programlisting> + Finally, you need to notify LPD of the filter via the <emphasis remap=tt>if</emphasis> capability: - <informalexample> - <screen> :if=/usr/local/libexec/hpif:</screen> - </informalexample> That is it. You can type <command>lpr plain.text</command> and <filename>lpr + <programlisting> +:if=/usr/local/libexec/hpif: + </programlisting> That is it. You can type <command>lpr plain.text</command> and <filename>lpr whatever.ps</filename> and both should print successfully.</para> @@ -9475,15 +9642,14 @@ directly until we convert the DVI file into PostScript. The command sequence goes like this: <informalexample> - <screen>&prompt.user; dvips seaweed-analysis.dvi - &prompt.user; lpr - seaweed-analysis.ps</screen> + <screen>&prompt.user; <userinput>dvips seaweed-analysis.dvi</userinput> +&prompt.user; <userinput>lpr seaweed-analysis.ps</userinput></screen> </informalexample> By installing a conversion filter for DVI files, we can skip the hand conversion step each time by having LPD do it for us. Now, each time we get a DVI file, we are just one step away from printing it: <informalexample> - <screen>&prompt.user; lpr -d seaweed-analysis.dvi</screen> + <screen>&prompt.user; <userinput>lpr -d seaweed-analysis.dvi</userinput></screen> </informalexample> We got LPD to do the DVI file conversion for us by specifying the <option>-d</option> option. Section <xref @@ -9514,15 +9680,68 @@ with, their capability entries for the <filename>/etc/printcap</filename> file, and how to invoke them with the <command>lpr</command> command: - <informalexample> - <programlisting> /etc/printcap File type - Capability lpr option ------------ ------------- - ---------- cifplot cf -c DVI - df -d plot gf -g ditroff - nf -n FORTRAN text rf -f troff - tf -t raster vf -v plain - text if none, -p, or -l</programlisting> - </informalexample> + + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>File type</entry> + <entry><filename>/etc/printcap</filename> + capability</entry> + <entry><command>lpr</command> option</entry> + </row> + </thead> + <tbody> + <row> + <entry>cifplot</entry> + <entry><literal>cf</literal></entry> + <entry><option>-c</option></entry> + </row> + + <row> + <entry>DVI</entry> + <entry><literal>df</literal></entry> + <entry><option>-d</option></entry> + </row> + + <row> + <entry>plot</entry> + <entry><literal>gf</literal></entry> + <entry><option>-g</option></entry> + </row> + + <row> + <entry>ditroff</entry> + <entry><literal>nf</literal></entry> + <entry><option>-n</option></entry> + </row> + + <row> + <entry>FORTRAN text</entry> + <entry><literal>rf</literal></entry> + <entry><option>-f</option></entry> + </row> + + <row> + <entry>troff</entry> + <entry><literal>rf</literal></entry> + <entry><option>-f</option></entry> + </row> + + <row> + <entry>raster</entry> + <entry><literal>vf</literal></entry> + <entry><option>-v</option></entry> + </row> + + <row> + <entry>plain text</entry> + <entry><literal>if</literal></entry> + <entry>none, <option>-p</option>, or <option>-l</option></entry> + </row> + </tbody> + </tgroup> + </informaltable> </para> <para>In our example, using <command>lpr -d</command> means the @@ -9561,26 +9780,37 @@ <filename>/etc/printcap</filename> file again, with the new <emphasis remap=tt>df</emphasis> capability for the printer <hostid>bamboo</hostid> - <informalexample> - <programlisting># # /etc/printcap for host rose - added df - filter for bamboo # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> The DVI filter is a shell script named + + <programlisting> +# +# /etc/printcap for host rose - added df filter for bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + The DVI filter is a shell script named <filename>/usr/local/libexec/psdf</filename>. Here is that script: - <informalexample> - <programlisting>#!bin/sh # # psdf - DVI to PostScript - printer filter # Installed in /usr/local/libexec/psdf # # - Invoked by lpd when user runs lpr -d # exec - /usr/local/bin/dvips -f | /usr/local/libexec/lprps - "$@"</programlisting> - </informalexample> This script runs <citerefentry> + + <programlisting> +#!bin/sh +# +# psdf - DVI to PostScript printer filter +# Installed in /usr/local/libexec/psdf +# +# Invoked by lpd when user runs lpr -d +# +exec /usr/local/bin/dvips -f | /usr/local/libexec/lprps "$@" + </programlisting> + This script runs <citerefentry> <refentrytitle>dvips</refentrytitle></citerefentry> in filter mode (the <option>-f</option> argument) on standard input, which is the job to print. It then starts the PostScript printer filter <command>lprps</command> (see section <xref linkend="printing-advanced-if-conversion" remap="Accommodating Plain Text Jobs on PostScript Printers">) with the arguments LPD passed to this script. @@ -9600,74 +9830,97 @@ <para>This example script is a raster (well, GIF file, actually) conversion filter for a Hewlett Packard LaserJet III-Si printer: - <informalexample> - <programlisting>#!/bin/sh # # hpvf - Convert GIF files into - HP/PCL, then print # Installed in /usr/local/libexec/hpvf - PATH=/usr/X11R6/bin:$PATH; export PATH giftopnm | ppmtopgm - | pgmtopbm | pbmtolj -resolution 300 \ && exit 0 \ - || exit 2</programlisting> - </informalexample> It works by converting the GIF file into a + + <programlisting> +#!/bin/sh +# +# hpvf - Convert GIF files into HP/PCL, then print +# Installed in /usr/local/libexec/hpvf + +PATH=/usr/X11R6/bin:$PATH; export PATH giftopnm | ppmtopgm | pgmtopbm | pbmtolj -resolution 300 \ + && exit 0 \ + || exit 2 + </programlisting> + It works by converting the GIF file into a portable anymap, converting that into a portable graymap, converting that into a portable bitmap, and converting that into LaserJet/PCL-compatible data.</para> <para>Here is the <filename>/etc/printcap</filename> file with an entry for a printer using the above filter: - <informalexample> - <programlisting># # /etc/printcap for host orchid # - teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/hpif:\ - :vf=/usr/local/libexec/hpvf:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif:\ + :vf=/usr/local/libexec/hpvf: + </programlisting> </para> <para>The following script is a conversion filter for troff data from the groff typesetting system for the PostScript printer named <hostid>bamboo</hostid>: - <informalexample> - <programlisting>#!/bin/sh # # pstf - Convert groff's troff - data into PS, then print. # Installed in - /usr/local/libexec/pstf # exec grops | - /usr/local/libexec/lprps "$@"</programlisting> - </informalexample> The above script makes use of <command>lprps</command> again to handle the communication + + <programlisting> +#!/bin/sh +# +# pstf - Convert groff's troff data into PS, then print. +# Installed in /usr/local/libexec/pstf +# +exec grops | /usr/local/libexec/lprps "$@" + </programlisting> + The above script makes use of <command>lprps</command> again to handle the communication with the printer. If the printer were on a parallel port, we would use this script instead: - <informalexample> - <programlisting>#!/bin/sh # # pstf - Convert groff's troff - data into PS, then print. # Installed in - /usr/local/libexec/pstf # exec grops</programlisting> - </informalexample> That is it. Here is the entry we need to + + <programlisting> +#!/bin/sh +# +# pstf - Convert groff's troff data into PS, then print. +# Installed in /usr/local/libexec/pstf +# +exec grops + </programlisting> + That is it. Here is the entry we need to add to <filename>/etc/printcap</filename> to enable the filter: - <informalexample> - <screen> :tf=/usr/local/libexec/pstf:</screen> - </informalexample> + <programlisting> +:tf=/usr/local/libexec/pstf: + </programlisting> </para> <para>Here is an example that might make old hands at FORTRAN blush. It is a FORTRAN-text filter for any printer that can directly print plain text. We will install it for the printer <hostid>teak</hostid>: - <informalexample> - <programlisting>#!/bin/sh # # hprf - FORTRAN text filter for - LaserJet 3si: # Installed in /usr/local/libexec/hprf # - printf "\033&k2G" && fpr && printf - "\f" && exit 0 exit 2</programlisting> - </informalexample> And we will add this line to the + + <programlisting> +#!/bin/sh +# +# hprf - FORTRAN text filter for LaserJet 3si: +# Installed in /usr/local/libexec/hprf +# + +printf "\033&k2G" && fpr && printf "\f" && exit 0 +exit 2 + </programlisting> + And we will add this line to the <filename>/etc/printcap</filename> for the printer <hostid>teak</hostid> to enable this filter: - <informalexample> - <screen> :rf=/usr/local/libexec/hprf:</screen> - </informalexample> + <programlisting> +:rf=/usr/local/libexec/hprf: + </programlisting> </para> <para>Here is one final, somewhat complex example. We will add a DVI filter to the LaserJet printer <hostid>teak</hostid> introduced earlier. First, the easy part: updating <filename>/etc/printcap</filename> with the location of the DVI filter: - <informalexample> - <screen> :df=/usr/local/libexec/hpdf:</screen> - </informalexample> + <programlisting> +:df=/usr/local/libexec/hpdf: + </programlisting> </para> <para>Now, for the hard part: making the filter. For that, we @@ -9713,29 +9966,68 @@ than under <filename>/tmp</filename>.</para> <para>Here, finally, is the filter: - <informalexample> - <programlisting>#!/bin/sh # # hpdf - Print DVI data on - HP/PCL printer # Installed in /usr/local/libexec/hpdf - PATH=/usr/local/bin:$PATH; export PATH # # Define a - function to clean up our temporary files. These exist # - in the current directory, which will be the spooling - directory # for the printer. # cleanup() { rm -f - hpdf$$.dvi } # # Define a function to handle fatal - errors: print the given message # and exit 2. Exiting - with 2 tells LPD to do not try to reprint the # job. # - fatal() { echo "$@" 1>&2 cleanup exit 2 } # # If - user removes the job, LPD will send SIGINT, so trap SIGINT - # (and a few other signals) to clean up after ourselves. - # trap cleanup 1 2 15 # # Make sure we are not colliding - with any existing files. # cleanup # # Link the DVI input - file to standard input (the file to print). # ln -s - /dev/fd/0 hpdf$$.dvi || fatal "Cannot symlink /dev/fd/0" # - # Make LF = CR+LF # printf "\033&k2G" || fatal - "Cannot initialize printer" # # Convert and print. - Return value from dvilj2p does not seem to be # reliable, - so we ignore it. # dvilj2p -M1 -q -e- dfhp$$.dvi # # - Clean up and exit # cleanup exit 0</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# hpdf - Print DVI data on HP/PCL printer +# Installed in /usr/local/libexec/hpdf + +PATH=/usr/local/bin:$PATH; export PATH + +# +# Define a function to clean up our temporary files. These exist +# in the current directory, which will be the spooling directory +# for the printer. +# +cleanup() { + rm -f hpdf$$.dvi +} + +# +# Define a function to handle fatal errors: print the given message +# and exit 2. Exiting with 2 tells LPD to do not try to reprint the +# job. +# +fatal() { + echo "$@" 1>&2 + cleanup + exit 2 +} + +# +# If user removes the job, LPD will send SIGINT, so trap SIGINT +# (and a few other signals) to clean up after ourselves. +# +trap cleanup 1 2 15 + +# +# Make sure we are not colliding with any existing files. +# +cleanup + +# +# Link the DVI input file to standard input (the file to print). +# +ln -s /dev/fd/0 hpdf$$.dvi || fatal "Cannot symlink /dev/fd/0" + +# +# Make LF = CR+LF +# +printf "\033&k2G" || fatal "Cannot initialize printer" + +# +# Convert and print. Return value from dvilj2p does not seem to be +# reliable, so we ignore it. +# +dvilj2p -M1 -q -e- dfhp$$.dvi + +# +# Clean up and exit +# +cleanup +exit 0 + </programlisting> </para> </sect4> @@ -9800,13 +10092,12 @@ <para>LPD does not pass the user's login or host to the filter, so it is not intended to do accounting. In fact, it gets only two arguments: - <informalexample> - <screen><command>-w<replaceable>width</replaceable> - -l<replaceable>length</replaceable></command></screen> - </informalexample> where <emphasis - remap=it>width</emphasis> is from the <emphasis - remap=tt>pw</emphasis> capability and <emphasis - remap=it>length</emphasis> is from the <emphasis + <cmdsynopsis> + <command>filter-name</command> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + <arg choice="plain">-l<replaceable>length</replaceable></arg> + </cmdsynopsis> where <replaceable>width</replaceable> is from the <emphasis + remap=tt>pw</emphasis> capability and <replaceable>length</replaceable> is from the <emphasis remap=tt>pl</emphasis> capability for the printer in question.</para> </listitem> @@ -9938,12 +10229,17 @@ provide an output filter to send initialization strings to the printer. Here is an example output filter for Hewlett Packard PCL-compatible printers: - <informalexample> - <programlisting>#!/bin/sh # # hpof - Output filter for - Hewlett Packard PCL-compatible printers # Installed in - /usr/local/libexec/hpof printf "\033&k2G" || exit 2 exec - /usr/libexec/lpr/lpf</programlisting> - </informalexample> Specify the path to the output filter in the + + <programlisting> +#!/bin/sh +# +# hpof - Output filter for Hewlett Packard PCL-compatible printers +# Installed in /usr/local/libexec/hpof + +printf "\033&k2G" || exit 2 exec +/usr/libexec/lpr/lpf + </programlisting> + Specify the path to the output filter in the <emphasis remap=tt>of</emphasis> capability. See <xref linkend="printing-advanced-of" remap="Output Filters"> for more information.</para> @@ -9952,13 +10248,18 @@ for the printer <hostid>teak</hostid> that we introduced earlier; we enabled header pages and added the above output filter: - <informalexample> - <programlisting># # /etc/printcap for host orchid # - teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/hpif:\ :vf=/usr/local/libexec/hpvf:\ - :of=/usr/local/libexec/hpof:</programlisting> - </informalexample> Now, when users print jobs to <hostid>teak</hostid>, they get a header page with each + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif:\ + :vf=/usr/local/libexec/hpvf:\ + :of=/usr/local/libexec/hpof: + </programlisting> + Now, when users print jobs to <hostid>teak</hostid>, they get a header page with each job. If users want to spend time searching for their printouts, they can suppress header pages by submitting the job with <command>lpr -h</command>; see <xref @@ -9985,25 +10286,55 @@ header</emphasis>, a full page of large letters identifying the user, host, and job. Here is an example (kelly printed the job named outline from host rose): - <informalexample> - <screen>k ll ll k l - l k l l k k eeee l - l y y k k e e l l y y k k - eeeeee l l y y kk k e l - l y y k k e e l l y yy k - k eeee lll lll yyy y y y y yyyy ll t - l i t l oooo u u ttttt l - ii n nnn eeee o o u u t l - i nn n e e o o u u t l - i n n eeeeee o o u u t l - i n n e o o u uu t t l i - n n e e oooo uuu u tt lll iii - n n eeee r rrr oooo ssss eeee rr r o - o s s e e r o o ss eeeeee r - o o ss e r o o s s e e r - oooo ssss eeee Job: outline Date: Sun Sep 17 - 11:04:58 1995</screen> - </informalexample> LPD appends a form feed after this text so + <programlisting> + k ll ll + k l l + k l l + k k eeee l l y y + k k e e l l y y + k k eeeeee l l y y + kk k e l l y y + k k e e l l y yy + k k eeee lll lll yyy y + y + y y + yyyy + + + ll + t l i + t l + oooo u u ttttt l ii n nnn eeee + o o u u t l i nn n e e + o o u u t l i n n eeeeee + o o u u t l i n n e + o o u uu t t l i n n e e + oooo uuu u tt lll iii n n eeee + + + + + + + + + + r rrr oooo ssss eeee + rr r o o s s e e + r o o ss eeeeee + r o o ss e + r o o s s e e + r oooo ssss eeee + + + + + + + + Job: outline + Date: Sun Sep 17 11:04:58 1995 + </programlisting> LPD appends a form feed after this text so the job starts on a new page (unless you have <emphasis remap=tt>sf</emphasis> (suppress form feeds) in the destination printer's entry in @@ -10013,10 +10344,9 @@ header</emphasis>; specify <literal>sb</literal> (short banner) in the <filename>/etc/printcap</filename> file. The header page will look like this: - <informalexample> - <screen>rose:kelly Job: outline Date: Sun Sep 17 11:07:51 - 1995</screen> - </informalexample> Also by default, LPD prints the header page + <programlisting> +rose:kelly Job: outline Date: Sun Sep 17 11:07:51 1995 + </programlisting> Also by default, LPD prints the header page first, then the job. To reverse that, specify <literal>hl</literal> (header last) in <filename>/etc/printcap</filename>.</para> @@ -10120,53 +10450,128 @@ <para>Let us explore this method. The following script takes three arguments (user login name, host name, and job name) and makes a simple PostScript header page: - <informalexample> - <programlisting>#!/bin/sh # # make-ps-header - make a - PostScript header page on stdout # Installed in - /usr/local/libexec/make-ps-header # # # These are - PostScript units (72 to the inch). Modify for A4 or # - whatever size paper you are using: # page_width=612 - page_height=792 border=72 # # Check arguments # if [ $# -ne - 3 ]; then echo "Usage: `basename $0` <user> - <host> <job>" 1>&2 exit 1 fi # # Save - these, mostly for readability in the PostScript, below. # - user=$1 host=$2 job=$3 date=`date` # # Send the PostScript - code to stdout. # exec cat <<EOF %!PS % % Make sure - we do not interfere with user's job that will follow % save - % % Make a thick, unpleasant border around the edge of the - paper. % $border $border moveto $page_width $border 2 mul - sub 0 rlineto 0 $page_height $border 2 mul sub rlineto - currentscreen 3 -1 roll pop 100 3 1 roll setscreen $border 2 - mul $page_width sub 0 rlineto closepath 0.8 setgray 10 - setlinewidth stroke 0 setgray % % Display user's login - name, nice and large and prominent % /Helvetica-Bold - findfont 64 scalefont setfont $page_width ($user) - stringwidth pop sub 2 div $page_height 200 sub moveto - ($user) show % % Now show the boring particulars % - /Helvetica findfont 14 scalefont setfont /y 200 def [ (Job:) - (Host:) (Date:) ] { 200 y moveto show /y y 18 sub def } - forall /Helvetica-Bold findfont 14 scalefont setfont /y 200 - def [ ($job) ($host) ($date) ] { 270 y moveto show /y y 18 - sub def } forall % % That is it % restore showpage - EOF</programlisting> - </informalexample> Now, each of the conversion filters and the + + <programlisting> +#!/bin/sh +# +# make-ps-header - make a PostScript header page on stdout +# Installed in /usr/local/libexec/make-ps-header +# + +# +# These are PostScript units (72 to the inch). Modify for A4 or +# whatever size paper you are using: +# +page_width=612 +page_height=792 +border=72 + +# +# Check arguments +# +if [ $# -ne 3 ]; then + echo "Usage: `basename $0` <user> <host> <job>" 1>&2 + exit 1 +fi + +# +# Save these, mostly for readability in the PostScript, below. +# +user=$1 +host=$2 +job=$3 +date=`date` + +# +# Send the PostScript code to stdout. +# +exec cat <<EOF +%!PS + +% +% Make sure we do not interfere with user's job that will follow +% +save + +% +% Make a thick, unpleasant border around the edge of the paper. +% +$border $border moveto +$page_width $border 2 mul sub 0 rlineto +0 $page_height $border 2 mul sub rlineto +currentscreen 3 -1 roll pop 100 3 1 roll setscreen +$border 2 mul $page_width sub 0 rlineto closepath +0.8 setgray 10 setlinewidth stroke 0 setgray + +% +% Display user's login name, nice and large and prominent +% +/Helvetica-Bold findfont 64 scalefont setfont +$page_width ($user) stringwidth pop sub 2 div $page_height 200 sub moveto +($user) show + +% +% Now show the boring particulars +% +/Helvetica findfont 14 scalefont setfont +/y 200 def +[ (Job:) (Host:) (Date:) ] { +200 y moveto show /y y 18 sub def } +forall + +/Helvetica-Bold findfont 14 scalefont setfont +/y 200 def +[ ($job) ($host) ($date) ] { + 270 y moveto show /y y 18 sub def +} forall + +% +% That is it +% +restore +showpage +EOF + </programlisting> + Now, each of the conversion filters and the text filter can call this script to first generate the header page, and then print the user's job. Here is the DVI conversion filter from earlier in this document, modified to make a header page: - <informalexample> - <programlisting>#!/bin/sh # # psdf - DVI to PostScript - printer filter # Installed in /usr/local/libexec/psdf # # - Invoked by lpd when user runs lpr -d # orig_args="$@" fail() - { echo "$@" 1>&2 exit 2 } while getopts "x:y:n:h:" - option; do case $option in x|y) ;; # Ignore n) - login=$OPTARG ;; h) host=$OPTARG ;; *) echo "LPD - started `basename $0` wrong." 1>&2 exit 2 ;; esac - done [ "$login" ] || fail "No login name" [ "$host" ] || - fail "No host name" ( /usr/local/libexec/make-ps-header - $login $host "DVI File" /usr/local/bin/dvips -f ) | eval - /usr/local/libexec/lprps $orig_args</programlisting> - </informalexample> Notice how the filter has to parse the + + <programlisting> +#!/bin/sh +# +# psdf - DVI to PostScript printer filter +# Installed in /usr/local/libexec/psdf +# +# Invoked by lpd when user runs lpr -d +# + +orig_args="$@" + +fail() { + echo "$@" 1>&2 + exit 2 +} + +while getopts "x:y:n:h:" option; do + case $option in + x|y) ;; # Ignore + n) login=$OPTARG ;; + h) host=$OPTARG ;; + *) echo "LPD started `basename $0` wrong." 1>&2 + exit 2 + ;; + esac +done + +[ "$login" ] || fail "No login name" +[ "$host" ] || fail "No host name" + +( /usr/local/libexec/make-ps-header $login $host "DVI File" + /usr/local/bin/dvips -f ) | eval /usr/local/libexec/lprps $orig_args + </programlisting> + Notice how the filter has to parse the argument list in order to determine the user and host name. The parsing for the other conversion filters is identical. The text filter takes a slightly different set of arguments, though (see @@ -10336,36 +10741,47 @@ remap="Enabling Header Pages">). It already had the entry for the printer <hostid>teak</hostid>; we have added entries for the two printers on the host rose: - <informalexample> - <programlisting># # /etc/printcap for host orchid - added - (remote) printers on rose # # # teak is local; it is - connected directly to orchid: # teak|hp|laserjet|Hewlett - Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/ifhp:\ :vf=/usr/local/libexec/vfhp:\ - :of=/usr/local/libexec/ofhp: # # rattan is connected to - rose; send jobs for rattan to rose: # - rattan|line|diablo|lp|Diablo 630 Line Printer:\ - :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: # # bamboo - is connected to rose as well: # - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ - :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:</programlisting> - </informalexample> Then, we just need to make spooling + + <programlisting> +# +# /etc/printcap for host orchid - added (remote) printers on rose +# + +# +# teak is local; it is connected directly to orchid: +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/ifhp:\ + :vf=/usr/local/libexec/vfhp:\ + :of=/usr/local/libexec/ofhp: + +# +# rattan is connected to rose; send jobs for rattan to rose: +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: + +# +# bamboo is connected to rose as well: +# +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo: + </programlisting> + Then, we just need to make spooling directories on orchid: + <informalexample> - <screen>&prompt.root; mkdir -p /var/spool/lpd/rattan /var/spool/lpd/bamboo - &prompt.root; chmod 770 /var/spool/lpd/rattan - /var/spool/lpd/bamboo &prompt.root; chown - daemon.daemon /var/spool/lpd/rattan - /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>mkdir -p /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> <para>Now, users on orchid can print to <hostid>rattan</hostid> and <hostid>bamboo</hostid>. If, for example, a user on orchid typed <informalexample> - <screen>&prompt.user; lpr -P bamboo -d sushi-review.dvi</screen> + <screen>&prompt.user; <userinput>lpr -P bamboo -d sushi-review.dvi</userinput></screen> </informalexample> the LPD system on orchid would copy the job to the spooling directory <filename>/var/spool/lpd/bamboo</filename> and note that it was @@ -10410,33 +10826,45 @@ printers support two-way communication, and you might want to take advantage of that (to get printer status, perform accounting, etc.). - <informalexample> - <programlisting>#!/usr/bin/perl # # netprint - Text filter - for printer attached to network # Installed in - /usr/local/libexec/netprint # $#ARGV eq 1 || die "Usage: $0 - <printer-hostname> <port-number>"; $printer_host - = $ARGV[0]; $printer_port = $ARGV[1]; require - 'sys/socket.ph'; ($ignore, $ignore, $protocol) = - getprotobyname('tcp'); ($ignore, $ignore, $ignore, $ignore, - $address) = gethostbyname($printer_host); $sockaddr = - pack('S n a4 x8', &AF_INET, $printer_port, $address); - socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol) - || die "Can't create TCP/IP stream socket: $!"; - connect(PRINTER, $sockaddr) || die "Can't contact - $printer_host: $!"; while (<STDIN>) { print PRINTER; } - exit 0;</programlisting> - </informalexample> We can then use this script in various + + <programlisting> +#!/usr/bin/perl +# +# netprint - Text filter for printer attached to network +# Installed in /usr/local/libexec/netprint +# +$#ARGV eq 1 || die "Usage: $0 <printer-hostname> <port-number>"; + +$printer_host = $ARGV[0]; +$printer_port = $ARGV[1]; + +require 'sys/socket.ph'; + +($ignore, $ignore, $protocol) = getprotobyname('tcp'); +($ignore, $ignore, $ignore, $ignore, $address) + = gethostbyname($printer_host); + +$sockaddr = pack('S n a4 x8', &AF_INET, $printer_port, $address); + +socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol) + || die "Can't create TCP/IP stream socket: $!"; +connect(PRINTER, $sockaddr) || die "Can't contact $printer_host: $!"; +while (<STDIN>) { print PRINTER; } +exit 0; + </programlisting> + We can then use this script in various filters. Suppose we had a Diablo 750-N line printer connected to the network. The printer accepts data to print on port number 5100. The host name of the printer is scrivener. Here is the text filter for the printer: - <informalexample> - <programlisting>#!/bin/sh # # diablo-if-net - Text filter for - Diablo printer `scrivener' listening # on port 5100. - Installed in /usr/local/libexec/diablo-if-net # exec - /usr/libexec/lpr/lpf "$@" | /usr/local/libexec/netprint - scrivener 5100</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# diablo-if-net - Text filter for Diablo printer `scrivener' listening +# on port 5100. Installed in /usr/local/libexec/diablo-if-net # exec +/usr/libexec/lpr/lpf "$@" | /usr/local/libexec/netprint scrivener 5100 + </programlisting> </para> </sect3> @@ -10488,41 +10916,51 @@ we will allow multiple copies, but the laser printer <hostid>bamboo</hostid>'s a bit more delicate, so we will disable multiple copies by adding the <emphasis remap=tt>sc</emphasis> capability: - <informalexample> - <programlisting># # /etc/printcap for host rose - restrict - multiple copies on bamboo # rattan|line|diablo|lp|Diablo 630 - Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ - :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Now, we also need to add the <emphasis + + <programlisting> +# +# /etc/printcap for host rose - restrict multiple copies on bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Now, we also need to add the <emphasis remap=tt>sc</emphasis> capability on the host orchid's <filename>/etc/printcap</filename> (and while we are at it, let us disable multiple copies for the printer <hostid>teak</hostid>): - <informalexample> - <programlisting># # /etc/printcap for host orchid - no - multiple copies for local # printer teak or remote printer - bamboo teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:sc:\ - :if=/usr/local/libexec/ifhp:\ :vf=/usr/local/libexec/vfhp:\ - :of=/usr/local/libexec/ofhp: rattan|line|diablo|lp|Diablo - 630 Line Printer:\ - :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ - :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:sc:</programlisting> - </informalexample> By using the <emphasis remap=tt>sc</emphasis> + + <programlisting> +# +# /etc/printcap for host orchid - no multiple copies for local +# printer teak or remote printer bamboo +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:sc:\ + :if=/usr/local/libexec/ifhp:\ + :vf=/usr/local/libexec/vfhp:\ + :of=/usr/local/libexec/ofhp: + +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:sc: + </programlisting> + By using the <emphasis remap=tt>sc</emphasis> capability, we prevent the use of <command>lpr -#</command>, but that still does not prevent users from running <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> multiple times, or from submitting the same file multiple times in one job like this: <informalexample> - <screen>&prompt.user; lpr forsale.sign forsale.sign forsale.sign - forsale.sign forsale.sign </screen> + <screen>&prompt.user; <userinput>lpr forsale.sign forsale.sign forsale.sign forsale.sign forsale.sign</userinput></screen> </informalexample> There are many ways to prevent this abuse (including ignoring it) which you are free to explore.</para> @@ -10556,17 +10994,23 @@ <para>For example, we will let anyone access the printer <hostid>rattan</hostid>, but only those in group <emphasis remap=tt>artists</emphasis> can use <hostid>bamboo</hostid>. Here is the familiar <filename>/etc/printcap</filename> for host rose: - <informalexample> - <programlisting># # /etc/printcap for host rose - restricted - group for bamboo # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Let us leave the other example + + <programlisting> +# +# /etc/printcap for host rose - restricted group for bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Let us leave the other example <filename>/etc/printcap</filename> file (for the host orchid) alone. Of course, anyone on orchid can print to <hostid>bamboo</hostid>. It might be the case that we only allow certain logins on orchid anyway, and want them to have @@ -10608,18 +11052,30 @@ <para>Let us add limits to our example printers <hostid>rattan</hostid> and <hostid>bamboo</hostid>. Since those artists' PostScript files tend to be large, we will limit them to five megabytes. We will put no limit on the plain text line printer: - <informalexample> - <programlisting># # /etc/printcap for host rose # # # No - limit on job size: # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: # # Limit of five - megabytes: # bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ - :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Again, the limits apply to the local users + + <programlisting> +# +# /etc/printcap for host rose +# + +# +# No limit on job size: +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +# +# Limit of five megabytes: +# +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Again, the limits apply to the local users only. If you have set up access to your printers remotely, remote users will not get those limits. You will need to specify the <emphasis remap=tt>mx</emphasis> capability in the @@ -10667,10 +11123,13 @@ <para>For example, here is the <filename>/etc/hosts.lpd</filename> file on the host rose: - <informalexample> - <programlisting>orchid violet - madrigal.fishbaum.de</programlisting> - </informalexample> This means rose will accept requests + + <programlisting> +orchid +violet +madrigal.fishbaum.de + </programlisting> + This means rose will accept requests from the hosts orchid, violet, and madrigal.fishbaum.de. If any other host tries to access rose's LPD, LPD will refuse them.</para> @@ -10701,21 +11160,20 @@ <hostid>bamboo</hostid>. We examine <filename>/etc/printcap</filename> to find the spooling directory for this printer; here is <hostid>bamboo</hostid>'s entry: - <informalexample> - <screen>bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ - :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:mx#5000:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</screen> - </informalexample> The spooling directory is the given + <programlisting> +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:mx#5000:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + The spooling directory is the given in the <emphasis remap=tt>sd</emphasis> capability. We will make three megabytes (which is 6144 disk blocks) the amount of free disk space that must exist on the filesystem for LPD to accept remote jobs: <informalexample> - <screen>&prompt.root; echo 6144 > - /var/spool/lpd/bamboo/minfree</screen> + <screen>&prompt.root; <userinput>echo 6144 > /var/spool/lpd/bamboo/minfree</userinput></screen> </informalexample> </para> @@ -10852,10 +11310,14 @@ much paper will be used. After sending the file to the printer, it then writes an accounting entry in the accounting file. The entries look like this: - <informalexample> - <screen> 2.00 rose:andy 3.00 rose:kelly 3.00 orchid:mary - 5.00 orchid:mary 2.00 orchid:zhang</screen> - </informalexample> You should use a separate accounting file for + + <programlisting> +2.00 rose:andy +3.00 rose:kelly +3.00 orchid:mary +5.00 orchid:mary +2.00 orchid:zhang</programlisting> + You should use a separate accounting file for each printer, as <command>lpf</command> has no file locking logic built into it, and two <command>lpf</command>s might corrupt each other's entries if they were to write to the same file at the same time. A easy way diff --git a/en_US.ISO_8859-1/books/handbook/book.sgml b/en_US.ISO_8859-1/books/handbook/book.sgml index 92c056f5e5..109c1aa0fd 100644 --- a/en_US.ISO_8859-1/books/handbook/book.sgml +++ b/en_US.ISO_8859-1/books/handbook/book.sgml @@ -2,8 +2,8 @@ <!ENTITY prompt.root "<prompt>#</prompt>"> <!ENTITY prompt.user "<prompt>%</prompt>"> ]> + <book> - <bookinfo> <bookbiblio> <title>FreeBSD Handbook</title> @@ -768,8 +768,7 @@ <para>If you are using MS-DOS then download <ulink URL="ftp://ftp.FreeBSD.ORG/pub/FreeBSD/tools/fdimage.exe">fdimage.exe</ulink> or get it from <filename>tools\fdimage.exe</filename> on the CDROM and then run it like so: <informalexample> - <screen><prompt>E:\></prompt> tools\fdimage floppies\boot.flp - a:</screen> + <screen><prompt>E:\></prompt> <userinput>tools\fdimage floppies\boot.flp a:</userinput></screen> </informalexample> The <emphasis>fdimage</emphasis> program will format the A: drive and then copy the boot.flp image onto it (assuming that you're at the top @@ -782,9 +781,8 @@ <para>If you are using a UNIX system to create the floppy image: <informalexample> - <screen>&prompt.root; dd if=boot.flp - of=<symbol>disk_device</symbol></screen> - </informalexample> where <symbol>disk_device</symbol> is + <screen>&prompt.root; <userinput>dd if=boot.flp of=<replaceable>disk_device</replaceable></userinput></screen> + </informalexample> where <replaceable>disk_device</replaceable> is the <filename>/dev</filename> entry for the floppy drive. On FreeBSD systems, this is <filename>/dev/rfd0</filename> for the A: drive and <filename>/dev/rfd1</filename> for @@ -799,11 +797,13 @@ <para>With the installation disk in the A: drive, reboot your computer. You should get a boot prompt something like this: <informalexample> - <screen>>> FreeBSD BOOT ...<!-- <br> --> Usage: - [[[0:][wd](0,a)]/kernel][-abcCdhrsv]<!-- <br> --> Use - 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1<!-- <br> - --> Use ? for file list or press Enter for defaults<!-- <br> - --> Boot: </screen> + <screen> +>> FreeBSD BOOT ... +Usage: [[[0:][wd](0,a)]/kernel][-abcCdhrsv] +Use 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1 +Use ? for file list or press Enter for defaults +Boot: + </screen> </informalexample> If you do <emphasis>not</emphasis> type anything, FreeBSD will automatically boot with its default configuration after a delay of about five seconds. As FreeBSD @@ -1449,16 +1449,14 @@ to add the following line to the password file (using the vipw command):</para> - <para> - <informalexample> - <screen>ftp:*:99:99::0:0:FTP:/cdrom:/nonexistent</screen> - </informalexample> - </para> + <programlisting> +ftp:*:99:99::0:0:FTP:/cdrom:/nonexistent + </programlisting> <para>Anyone with network connectivity to your machine (and permission to log into it) can now chose a Media type of FTP and - type in: <filename>ftp://<replaceable>your - machine</replaceable></filename> after picking <quote>Other</quote> in + type in: <userinput>ftp://<replaceable>your + machine</replaceable></userinput> after picking <quote>Other</quote> in the ftp sites menu.</para> </sect2> @@ -1493,12 +1491,18 @@ <para> <informalexample> - <screen>&prompt.root; fdformat -f 1440 fd0.1440 disklabel -w -r - fd0.1440 floppy3 newfs -t 2 -u 18 -l 1 -i 65536 /dev/rfd0 (Use - "fd0.1200" and "floppy5" for 5.25" 1.2MB disks).</screen> + <screen>&prompt.root; <userinput>fdformat -f 1440 fd0.1440</userinput> +&prompt.root; <userinput>disklabel -w -r fd0.1440 floppy3</userinput> +&prompt.root; <userinput>newfs -t 2 -u 18 -l 1 -i 65536 /dev/rfd0</userinput> + </screen> </informalexample> </para> - + + <note> + <para>Use <literal>fd0.1200</literal> and + <literal>floppy5</literal> for 5.25" 1.2MB disks.</para> + </note> + <para>Then you can mount and write to them like any other file system.</para> @@ -1528,9 +1532,9 @@ suggest using the DOS <command>xcopy</command> command. For example, to prepare for a minimal installation of FreeBSD: <informalexample> - <screen><prompt>C></prompt> MD C:\FREEBSD C> XCOPY /S E:\BIN - C:\FREEBSD\BIN\ <prompt>C></prompt> XCOPY /S E:\MANPAGES - C:\FREEBSD\MANPAGES\</screen> + <screen><prompt>C:\></prompt> <userinput>MD C:\FREEBSD</userinput> +<prompt>C:\></prompt> <userinput>XCOPY /S E:\BIN C:\FREEBSD\BIN\</userinput> +<prompt>C:\></prompt> <userinput>XCOPY /S E:\MANPAGES C:\FREEBSD\MANPAGES\</userinput></screen> </informalexample> assuming that <filename>C:</filename> is where you have free space and <filename>E:</filename> is where your CDROM is mounted.</para> @@ -1551,15 +1555,14 @@ after getting all of the files for distribution you are interested in, simply tar them onto the tape with a command like: <informalexample> - <screen>&prompt.root; cd /freebsd/distdir<!-- <br> --> tar cvf /dev/rwt0 (or - /dev/rst0) dist1 .. dist2</screen> + <screen>&prompt.root; <userinput>cd /freebsd/distdir</userinput> +&prompt.root; <userinput>tar cvf /dev/rwt0 dist1 ... dist2</userinput></screen> </informalexample> </para> <para>When you go to do the installation, you should also make sure that you leave enough room in some temporary directory (which you - will be allowed to choose) to accommodate the <emphasis - remap=bf>full</emphasis> contents of the tape you have created. + will be allowed to choose) to accommodate the <emphasis>full</emphasis> contents of the tape you have created. Due to the non-random access nature of tapes, this method of installation requires quite a bit of temporary storage. You should expect to require as much temporary storage as you have @@ -1710,7 +1713,7 @@ <para> <informalexample> - <screen>ftp://165.113.121.81/pub/FreeBSD/&rel.current;-RELEASE</screen> + <screen><userinput>ftp://165.113.121.81/pub/FreeBSD/&rel.current;-RELEASE</userinput></screen> </informalexample> </para> @@ -1757,10 +1760,10 @@ address. As your installation media, you specify FTP (or passive FTP, if the proxy support it), and the URL <informalexample> - <screen>ftp://foo.bar.com:1234/pub/FreeBSD</screen> - </informalexample> /pub/FreeBSD from ftp.freebsd.org is proxied - under foo.bar.com, allowing you to install from _that_ machine - (which fetch the files from ftp.freebsd.org as your installation + <screen><userinput>ftp://foo.bar.com:1234/pub/FreeBSD</userinput></screen> + </informalexample> <filename>/pub/FreeBSD</filename> from <hostid>ftp.freebsd.org</hostid> is proxied + under <hostid>foo.bar.com</hostid>, allowing you to install from _that_ machine + (which fetch the files from <hostid>ftp.freebsd.org</hostid> as your installation requests them).</para> </sect3> @@ -1898,11 +1901,9 @@ mount extended partitions exactly like you would mount any other DOS drive, e.g.:</para> - <para> - <informalexample> - <screen>&prompt.root; mount -t msdos /dev/sd0s5 /dos_d</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mount -t msdos /dev/sd0s5 /dos_d</userinput></screen> + </informalexample> <para><emphasis remap=bf>Can I run MS-DOS binaries under FreeBSD?</emphasis></para> @@ -1931,12 +1932,10 @@ of <emphasis>man pages</emphasis>. Nearly every program on the system comes with a short reference manual explaining the basic operation and various arguments. These manuals can be view with the - <emphasis remap=tt><command>man</command></emphasis> - command. Use of the <emphasis remap=tt><emphasis - remap=bf>man</emphasis></emphasis> command is simple: + <command>man</command> + command. Use of the <command>man</command> command is simple: <informalexample> - <screen>&prompt.user; - <userinput>man <replaceable>command</replaceable></userinput> + <screen>&prompt.user; <userinput>man <replaceable>command</replaceable></userinput> </screen> </informalexample> where <replaceable>command</replaceable> is the name of the command you wish to learn about. For example, to @@ -2040,10 +2039,8 @@ <para>To use the <citerefentry><refentrytitle>info</refentrytitle><manvolnum>1</manvolnum></citerefentry> command, simply type: <informalexample> <screen>&prompt.user; <userinput>info</userinput></screen> - </informalexample> For a brief introduction, type <emphasis - remap=tt><emphasis remap=bf>h</emphasis></emphasis>. For a quick - command reference, type <emphasis remap=tt><emphasis - remap=bf>?</emphasis></emphasis>.</para> + </informalexample> For a brief introduction, type <userinput>h</userinput>. For a quick + command reference, type <userinput>?</userinput>.</para> </sect1> </chapter> @@ -2179,19 +2176,24 @@ <para><emphasis>Note</emphasis> if you are trying this at home, you will need to be root.</para> - <para> - <literallayout> &prompt.root; cd /usr/ports/devel/ElectricFence &prompt.root; make install - >> Checksum OK for ElectricFence-2.0.5.tar.gz. ===> - Extracting for ElectricFence-2.0.5 ===> Patching for - ElectricFence-2.0.5 ===> Applying FreeBSD patches for - ElectricFence-2.0.5 ===> Configuring for ElectricFence-2.0.5 - ===> Building for ElectricFence-2.0.5 [lots of compiler - output...] ===> Installing for ElectricFence-2.0.5 ===> - Warning: your umask is "0002". If this is not desired, set it to - an appropriate value and install this port again by ``make - reinstall''. install -c -o bin -g bin -m 444 - /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.a /usr/local/lib install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.3 /usr/local/man/man3 ===> Compressing manual pages for ElectricFence-2.0.5 ===> Registering installation for ElectricFence-2.0.5</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/devel/ElectricFence</userinput> +&prompt.root; <userinput>make install</userinput> +>> Checksum OK for ElectricFence-2.0.5.tar.gz. +===> Extracting for ElectricFence-2.0.5 +===> Patching for ElectricFence-2.0.5 +===> Applying FreeBSD patches for ElectricFence-2.0.5 +===> Configuring for ElectricFence-2.0.5 +===> Building for ElectricFence-2.0.5 +[lots of compiler output...] +===> Installing for ElectricFence-2.0.5 +===> Warning: your umask is "0002". If this is not desired, set it to + an appropriate value and install this port again by ``make reinstall''. +install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.a /usr/local/lib +install -c -o bin -g bin -m 444 /usr/ports/devel/ElectricFence/work/ElectricFence-2.0.5/libefence.3 /usr/local/man/man3 +===> Compressing manual pages for ElectricFence-2.0.5 +===> Registering installation for ElectricFence-2.0.5</screen> + </informalexample> <para> To avoid confusing the issue, I have completely removed the build output.</para> @@ -2199,10 +2201,11 @@ <para>If you tried this yourself, you may well have got something like this at the start:-</para> - <para><anchor id="ports-fetch"> <literallayout>&prompt.root; make install >> - ElectricFence-2.0.5.tar.gz doesn't seem to exist on this system. - >> Attempting to fetch from - ftp://ftp.doc.ic.ac.uk/Mirrors/sunsite.unc.edu/pub/Linux/devel/lang/c/.</literallayout> + <para><anchor id="ports-fetch"> <informalexample> + <screen>&prompt.root; <userinput>make install</userinput> +>> ElectricFence-2.0.5.tar.gz doesn't seem to exist on this system. +>> Attempting to fetch from ftp://ftp.doc.ic.ac.uk/Mirrors/sunsite.unc.edu/pub/Linux/devel/lang/c/.</screen> + </informalexample> </para> <para> The <command>make</command> program has noticed that you did not have a local @@ -2302,10 +2305,11 @@ the drive and mounted on, say, <filename>/cdrom</filename>. Then do</para> - <para> - <literallayout> &prompt.root; mkdir /usr/ports &prompt.root; cd /usr/ports &prompt.root; ln -s - /cdrom/ports/distfiles distfiles</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mkdir /usr/ports</userinput> +&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>ln -s /cdrom/ports/distfiles distfiles</userinput></screen> + </informalexample> <para>to enable the ports make mechanism to find the tarballs (it expects to find them in <filename>/usr/ports/distfiles</filename>, @@ -2315,19 +2319,23 @@ <para>Now, suppose you want to install the gnats program from the databases directory. Here is how to do it:-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; mkdir databases &prompt.root; cp -R - /cdrom/ports/databases/gnats databases &prompt.root; cd databases/gnats &prompt.root; - make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>mkdir databases</userinput> +&prompt.root; <userinput>cp -R /cdrom/ports/databases/gnats databases</userinput> +&prompt.root; <userinput>cd databases/gnats</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> <para>Or if you are a serious database user and you want to compare all the ones available in the Ports collection, do</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; cp -R /cdrom/ports/databases . &prompt.root; - cd databases &prompt.root; make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>cp -R /cdrom/ports/databases .</userinput> +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> <para>(yes, that really is a dot on its own after the cp command and not a mistake. It is Unix-ese for <quote>the current @@ -2346,8 +2354,11 @@ invoke the <citerefentry><refentrytitle>lndir</refentrytitle><manvolnum>1</manvolnum></citerefentry> command with the full pathname of the <filename>ports</filename> directory on the CDROM as the first argument and . (the current directory) as the second. This might - be, for example, something like: <literallayout> lndir - /cdrom/ports .</literallayout> + be, for example, something like: + + <informalexample> + <screen>&prompt.root; <userinput>lndir /cdrom/ports .</userinput></screen> + </informalexample> </para> <para>Then you can build ports directly off the CDROM by building @@ -2379,16 +2390,23 @@ an example (the bits in square brackets are comments. Do not type them in if you are trying this yourself!):-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; mkdir databases &prompt.root; cd databases &prompt.root; - ftp ftp.freebsd.org [log in as `ftp' and give your email address - when asked for a password. Remember to use binary (also known as - image) mode!] > cd /pub/FreeBSD/ports/databases > get - gnats.tar [tars up the gnats skeleton for us] > quit - &prompt.root; tar xf gnats.tar [extract the gnats skeleton] &prompt.root; - cd gnats &prompt.root; make install [build and install - gnats]</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>mkdir databases</userinput> +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>ftp ftp.freebsd.org</userinput> +[log in as `ftp' and give your email address when asked for a +password. Remember to use binary (also known as image) mode!] +<prompt>></prompt> <userinput>cd /pub/FreeBSD/ports/databases</userinput> +<prompt>></prompt> <userinput>get gnats.tar</userinput> +[tars up the gnats skeleton for us] +<prompt>></prompt> <userinput>quit</userinput> +&prompt.root; <userinput>tar xf gnats.tar</userinput> +[extract the gnats skeleton] +&prompt.root; <userinput>cd gnats</userinput> +&prompt.root; <userinput>make install</userinput> +[build and install gnats]</screen> + </informalexample> <para>What happened here? We connected to the FTP server in the usual way and went to its databases sub-directory. When we gave it @@ -2408,16 +2426,21 @@ all the database skeletons in the ports collection. It looks almost the same:-</para> - <para> - <literallayout> &prompt.root; cd /usr/ports &prompt.root; ftp ftp.freebsd.org [log in as - `ftp' and give your email address when asked for a password. - Remember to use binary (also known as image) mode!] > cd - /pub/FreeBSD/ports > get databases.tar [tars up the - databases directory for us] > quit &prompt.root; tar xf databases.tar - [extract all the database skeletons] &prompt.root; cd databases &prompt.root; make - install [build and install all the database - ports]</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>ftp ftp.freebsd.org</userinput> +[log in as `ftp' and give your email address when asked for a +password. Remember to use binary (also known as image) mode!] +<prompt>></prompt> <userinput>cd /pub/FreeBSD/ports</userinput> +<prompt>></prompt> <userinput>get databases.tar</userinput> +[tars up the databases directory for us] +<prompt>></prompt> <userinput>quit</userinput> +&prompt.root; <userinput>tar xf databases.tar</userinput> +[extract all the database skeletons] +&prompt.root; <userinput>cd databases</userinput> +&prompt.root; <userinput>make install</userinput> +[build and install all the database ports]</screen> + </informalexample> <para>With half a dozen straightforward commands, we have now got a set of database programs on our FreeBSD machine! All we did that @@ -2450,18 +2473,30 @@ be compiled and installed. Here is the Makefile for ElectricFence:-</para> - <para> - <literallayout># New ports collection makefile for: Electric - Fence # Version required: 2.0.5 # Date created: 13 November - 1997 # Whom: jraynard # # $Id: - handbook.sgml,v 1.1 1998/04/01 18:25:32 nik Exp $ # DISTNAME= - ElectricFence-2.0.5 CATEGORIES= devel MASTER_SITES= - ${MASTER_SITE_SUNSITE} MASTER_SITE_SUBDIR= devel/lang/c - MAINTAINER= jraynard@freebsd.org MAN3= - libefence.3 do-install: ${INSTALL_DATA} ${WRKSRC}/libefence.a - ${PREFIX}/lib ${INSTALL_MAN} ${WRKSRC}/libefence.3 - ${PREFIX}/man/man3 .include <bsd.port.mk></literallayout> - </para> + <programlisting> +# New ports collection makefile for: Electric Fence +# Version required: 2.0.5 +# Date created: 13 November 1997 +# Whom: jraynard +# +# $Id: handbook.sgml,v 1.1 1998/04/01 18:25:32 nik +# + +DISTNAME= ElectricFence-2.0.5 +CATEGORIES= devel +MASTER_SITES= ${MASTER_SITE_SUNSITE} +MASTER_SITE_SUBDIR= devel/lang/c + +MAINTAINER= jraynard@freebsd.org + +MAN3= libefence.3 + +do-install: + ${INSTALL_DATA} ${WRKSRC}/libefence.a ${PREFIX}/lib + ${INSTALL_MAN} ${WRKSRC}/libefence.3 ${PREFIX}/man/man3 + +.include <bsd.port.mk> + </programlisting> <para>The lines beginning with a "#" sign are comments for the benefit of human readers (as in most Unix script @@ -2732,15 +2767,13 @@ yourself, by using the standard Unix tar program, which comes with the base FreeBSD system, like this:-</para> - <para> - <literallayout>&prompt.user; tar tvzf foobar.tar.gz # View - contents of foobar.tar.gz &prompt.user; tar xzvf foobar.tar.gz - # Extract contents into the current directory &prompt.user; tar tvf - foobar.tar # View contents of foobar.tar - &prompt.user; tar xvf - foobar.tar # Extract contents into the current - directory</literallayout> - </para> + <informalexample> + <screen>&prompt.user; <userinput>tar tvzf foobar.tar.gz</userinput> +&prompt.user; <userinput>tar xzvf foobar.tar.gz</userinput> +&prompt.user; <userinput>tar tvf foobar.tar</userinput> +&prompt.user; <userinput>tar xvf foobar.tar</userinput> + </screen> + </informalexample> </listitem> <listitem> @@ -2759,10 +2792,13 @@ <listitem> <para>Q. I did what you said for <xref linkend="ports-cd" remap="compiling ports from a CDROM"> and it worked great - until I tried to install the kermit port:- <literallayout> # - make install >> cku190.tar.gz doesn't seem to exist on - this system. >> Attempting to fetch from - ftp://kermit.columbia.edu/kermit/archives/.</literallayout> + until I tried to install the kermit port:- + + <informalexample> + <screen>&prompt.root; <userinput>make install</userinput> +>> cku190.tar.gz doesn't seem to exist on this system. +>> Attempting to fetch from ftp://kermit.columbia.edu/kermit/archives/.</screen> + </informalexample> Why can it not be found? Have I got a dud CDROM? </para> @@ -2788,10 +2824,9 @@ CDROM, which is read-only. You can tell it to look somewhere else by doing</para> - <para> - <literallayout> DISTDIR=/where/you/put/it make - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make DISTDIR=/where/you/put/it install</userinput></screen> + </informalexample> </listitem> <listitem> @@ -2806,21 +2841,18 @@ the ports mechanism to use different directories. For instance,</para> - <para> - <literallayout> make - PORTSDIR=/u/people/guests/wurzburger/ports - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PORTSDIR=/u/people/guests/wurzburger/ports install</userinput></screen> + </informalexample> <para>will compile the port in <filename>/u/people/guests/wurzburger/ports</filename> and install everything under <filename>/usr/local</filename>. </para> - <para> - <literallayout> make PREFIX=/u/people/guests/wurzburger/local - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PREFIX=/u/people/guests/wurzburger/local install</userinput></screen> + </informalexample> <para>will compile it in <filename>/usr/ports</filename> and install it in @@ -2829,10 +2861,9 @@ <para>And of course</para> - <para> - <literallayout> make PORTSDIR=.../ports PREFIX=.../local - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make PORTSDIR=.../ports PREFIX=.../local install</userinput></screen> + </informalexample> <para>will combine the two (it is too long to fit on the page if I write it in full, but I am sure you get the idea).</para> @@ -2852,17 +2883,18 @@ <para>A. To get every single tarball for the ports collection, do</para> - <para> - <literallayout> # cd /usr/ports # make fetch</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make fetch</userinput></screen> + </informalexample> <para>For all the tarballs for a single ports directory, do</para> - <para> - <literallayout> # cd /usr/ports/directory # make - fetch</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/directory</userinput> +&prompt.root; <userinput>make fetch</userinput></screen> + </informalexample> <para>and for just one port - well, I think you have guessed already.</para> @@ -2877,8 +2909,12 @@ <para>A. Yes. If you know, for example, ftp.FreeBSD.ORG is much closer than sites listed in MASTER_SITES, do as following - example. <literallayout> # cd /usr/ports/directory # make - MASTER_SITE_OVERRIDE=ftp://ftp.FreeBSD.ORG/pub/FreeBSD/distfiles/ fetch</literallayout> + example. + + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/directory</userinput> +&prompt.root; <userinput>make MASTER_SITE_OVERRIDE=ftp://ftp.FreeBSD.ORG/pub/FreeBSD/distfiles/ fetch</userinput></screen> + </informalexample> </para> </listitem> @@ -2887,7 +2923,7 @@ it tries to pull them down. </para> - <para>A. 'make fetch-list' will display a list of the files + <para>A. <command>make fetch-list</command> will display a list of the files needed for a port.</para> </listitem> @@ -2898,7 +2934,7 @@ every time. </para> - <para>A. Doing 'make extract' will stop it after it has fetched + <para>A. Doing <command>make extract</command> will stop it after it has fetched and extracted the source code.</para> </listitem> @@ -2909,7 +2945,7 @@ extract', but for patches? </para> - <para>A. Yep, 'make patch' is what you want. You will probably + <para>A. Yep, <command>make patch</command> is what you want. You will probably find the PATCH_DEBUG option useful as well. And by the way, thank you for your efforts!</para> </listitem> @@ -2921,16 +2957,15 @@ </para> <para>A. Yes, with version 2.6.3 of gcc (the version shipped - with FreeBSD 2.1.0 and 2.1.5), the -O2 option could result in - buggy code unless you used the -fno-strength-reduce option as - well. (Most of the ports don't use -O2). You + with FreeBSD 2.1.0 and 2.1.5), the <option>-O2</option> option could result in + buggy code unless you used the <option>-fno-strength-reduce</option> option as + well. (Most of the ports don't use <option>-O2</option>). You <emphasis>should</emphasis> be able to specify the compiler options used by something like</para> - <para> - <literallayout> make CFLAGS='-O2 -fno-strength-reduce' - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>make CFLAGS='-O2 -fno-strength-reduce' install</userinput></screen> + </informalexample> <para>or by editing <filename>/etc/make.conf</filename>, but unfortunately not all ports respect this. The surest way is to @@ -2945,7 +2980,7 @@ want. Is there a list anywhere of what ports are available? </para> - <para>A. Look in the INDEX file in /usr/ports.</para> + <para>A. Look in the <filename>INDEX</filename> file in <filename>/usr/ports</filename>.</para> </listitem> <listitem> @@ -2970,9 +3005,9 @@ <para>A. No problem, just do</para> - <para> - <literallayout> pkg_delete grizzle-6.5</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>pkg_delete grizzle-6.5</userinput></screen> + </informalexample> </listitem> <listitem> @@ -2984,17 +3019,11 @@ <para>A. Not at all, you can find it out by doing</para> - <para> - <literallayout> pkg_info -a | grep grizzle</literallayout> - </para> - - <para>And it will tell you:-</para> - - <para> - <literallayout> Information for grizzle-6.5: grizzle-6.5 - the - combined piano tutorial, LOGO interpreter and shoot 'em up - arcade game.</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>pkg_info -a | grep grizzle</userinput> +Information for grizzle-6.5: +grizzle-6.5 - the combined piano tutorial, LOGO interpreter and shoot 'em up arcade game.</screen> + </informalexample> </listitem> <listitem> @@ -3008,9 +3037,10 @@ in keeping it hanging around. The best way to do this is</para> - <para> - <literallayout> # cd /usr/ports # make clean</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make clean</userinput></screen> + </informalexample> <para>which will go through all the ports subdirectories and delete everything except the skeletons for each port.</para> @@ -3033,9 +3063,10 @@ <para>A. Just do</para> - <para> - <literallayout> # cd /usr/ports # make install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make install</userinput></screen> + </informalexample> </listitem> <listitem> @@ -3059,19 +3090,19 @@ <para>A. OK, do this before you go to bed/work/the local park:-</para> - <para> - <literallayout> # cd /usr/ports # make -DBATCH - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make -DBATCH install</userinput></screen> + </informalexample> <para>This will install every port that does <emphasis>not</emphasis> require user input. Then, when you come back, do</para> - <para> - <literallayout> # cd /usr/ports # make -DIS_INTERACTIVE - install</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports</userinput> +&prompt.root; <userinput>make -DIS_INTERACTIVE install</userinput></screen> + </informalexample> <para>to finish the job.</para> </listitem> @@ -3086,11 +3117,14 @@ <para>A. No problem, assuming you know how to make patches for your changes:-</para> - <para> - <literallayout> # cd /usr/ports/somewhere/frobble # make - extract # cd work/frobble-2.8 [Apply your patches] # cd - ../.. # make package</literallayout> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cd /usr/ports/somewhere/frobble</userinput> +&prompt.root; <userinput>make extract</userinput> +&prompt.root; <userinput>cd work/frobble-2.8</userinput> +[Apply your patches] +&prompt.root; <userinput>cd ../..</userinput> +&prompt.root; <userinput>make package</userinput></screen> + </informalexample> </listitem> <listitem> @@ -3213,7 +3247,8 @@ copy the <filename>GENERIC</filename> configuration file to the name you want to give your kernel. For example: <informalexample> - <screen>&prompt.root; cd /usr/src/sys/i386/conf &prompt.root; cp GENERIC MYKERNEL</screen> + <screen>&prompt.root; <userinput>cd /usr/src/sys/i386/conf</userinput> +&prompt.root; <userinput>cp GENERIC MYKERNEL</userinput></screen> </informalexample> Traditionally, this name is in all capital letters and, if you are maintaining multiple FreeBSD machines with different hardware, it is a good idea to name it after your @@ -3258,8 +3293,11 @@ <para>When you are finished, type the following to compile and install your kernel: <informalexample> - <screen>&prompt.root; /usr/sbin/config MYKERNEL &prompt.root; cd ../../compile/MYKERNEL &prompt.root; - make depend &prompt.root; make &prompt.root; make install</screen> + <screen>&prompt.root; <userinput>/usr/sbin/config MYKERNEL</userinput> +&prompt.root; <userinput>cd ../../compile/MYKERNEL</userinput> +&prompt.root; <userinput>make depend</userinput> +&prompt.root; <userinput>make</userinput> +&prompt.root; <userinput>make install</userinput></screen> </informalexample> The new kernel will be copied to the root directory as <filename>/kernel</filename> and the old kernel will be moved to <filename>/kernel.old</filename>. Now, shutdown the system @@ -3644,18 +3682,18 @@ <filename>/tmp</filename>, add the following line to <filename>/etc/fstab</filename> and then reboot or type <command>mount /tmp</command>: - <informalexample> - <screen>/dev/wd1s2b /tmp mfs rw 0 0 </screen> - </informalexample> + <programlisting> +/dev/wd1s2b /tmp mfs rw 0 0 + </programlisting> </para> <note> <para>Replace the <filename>/dev/wd1s2b</filename> with the name of your swap partition, which will be listed in your <filename>/etc/fstab</filename> as follows: - <informalexample> - <screen>/dev/wd1s2b none swap sw 0 0</screen> - </informalexample> + <programlisting> +/dev/wd1s2b none swap sw 0 0 + </programlisting> </para> </note> @@ -4686,23 +4724,23 @@ <para>Suppose you add the IDE CD-ROM support to the kernel. The line to add is: - <informalexample> - <screen>controller wcd0</screen> - </informalexample> This means that you should look for some entries + <programlisting> +controller wcd0 + </programlisting> This means that you should look for some entries that start with <filename>wcd0</filename> in the <filename>/dev</filename> directory, possibly followed by a letter, such as <token>c</token>, or preceded by the letter <token>r</token>, which means a <quote>raw</quote> device. It turns out that those files are not there, so I must change to the <filename>/dev</filename> directory and type: <informalexample> - <screen>&prompt.root; sh MAKEDEV wcd0</screen> + <screen>&prompt.root; <userinput>sh MAKEDEV wcd0</userinput></screen> </informalexample> When this script finishes, you will find that there are now <filename>wcd0c</filename> and <filename>rwcd0c</filename> entries in <filename>/dev</filename> so you know that it executed correctly.</para> <para>For sound cards, the command: <informalexample> - <screen>&prompt.root; sh MAKEDEV snd0</screen> + <screen>&prompt.root; <userinput>sh MAKEDEV snd0</userinput></screen> </informalexample> creates the appropriate entries.</para> <note> @@ -4801,13 +4839,13 @@ kernel file that <command>make</command> installs (in order to move another kernel back permanently) is: <informalexample> - <screen>&prompt.root; chflags noschg /kernel</screen> + <screen>&prompt.root; <userinput>chflags noschg /kernel</userinput></screen> </informalexample> And, if you want to <quote>lock</quote> your new kernel into place, or any file for that matter, so that it cannot be moved or tampered with: <informalexample> - <screen>&prompt.root; chflags schg /kernel</screen> + <screen>&prompt.root; <userinput>chflags schg /kernel</userinput></screen> </informalexample> </para> </note> @@ -4909,25 +4947,23 @@ fairly easy for most programs, except for those like <command>init</command> which are statically linked. (For those programs, the only way is to try them on a known password and see if it works.) Programs which use <emphasis - remap=tt>crypt</emphasis> are linked against <emphasis - remap=tt>libcrypt</emphasis>, which for each type of library is + remap=tt>crypt</emphasis> are linked against <filename>libcrypt</filename>, which for each type of library is a symbolic link to the appropriate implementation. For example, on a system using the DES versions:</para> <para> <informalexample> - <screen>&prompt.user; cd /usr/lib $ ls -l /usr/lib/libcrypt* lrwxr-xr-x 1 - bin bin 13 Sep 5 12:50 libcrypt.a -> libdescrypt.a - lrwxr-xr-x 1 bin bin 18 Sep 5 12:50 libcrypt.so.2.0 -> - libdescrypt.so.2.0 lrwxr-xr-x 1 bin bin 15 Sep 5 12:50 - libcrypt_p.a -> libdescrypt_p.a</screen> + <screen>&prompt.user;<userinput> cd /usr/lib</userinput> +&prompt.user; <userinput>ls -l /usr/lib/libcrypt*</userinput> +lrwxr-xr-x 1 bin bin 13 Sep 5 12:50 libcrypt.a -> libdescrypt.a +lrwxr-xr-x 1 bin bin 18 Sep 5 12:50 libcrypt.so.2.0 -> libdescrypt.so.2.0 +lrwxr-xr-x 1 bin bin 15 Sep 5 12:50 libcrypt_p.a -> libdescrypt_p.a</screen> </informalexample> </para> <para>On a system using the MD5-based libraries, the same links will - be present, but the target will be <emphasis - remap=tt>libscrypt</emphasis> rather than <emphasis - remap=tt>libdescrypt</emphasis>. + be present, but the target will be <filename>libscrypt</filename> + rather than <filename>libdescrypt</filename>. </para> </sect2> @@ -5020,19 +5056,20 @@ <para> <informalexample> - <screen>&prompt.user; keyinit Updating wollman: ) - these will not appear if you Old key: ha73895 - ) have not used S/Key before Reminder - Only use this method - if you are directly connected. If you are using telnet or - rlogin exit with no password and use keyinit -s. Enter secret - password: ) I typed my pass phrase here - Again secret password: ) I typed it again ID - wollman s/key is 99 ha73896 ) discussed below SAG - HAS FONT GOUT FATE BOOM )</screen> + <screen>&prompt.user; keyinit +Updating wollman: ) these will not appear if you +Old key: ha73895 ) have not used S/Key before +Reminder - Only use this method if you are directly connected. +If you are using telnet or rlogin exit with no password and use keyinit -s. +<prompt>Enter secret password:</prompt> ) I typed my pass phrase here +<prompt>Again secret password:</prompt> ) I typed it again ID + +wollman s/key is 99 ha73896 ) discussed below SAG +HAS FONT GOUT FATE BOOM )</screen> </informalexample> </para> - <para>There is a lot of information here. At the `Enter secret + <para>There is a lot of information here. At the`Enter secret password:' prompt, you should enter some password or phrase (I use phrases of minimum seven words) which will be needed to generate login keys. The line starting `ID' gives the parameters of your @@ -5061,10 +5098,12 @@ <para> <informalexample> - <screen>&prompt.user; keyinit -s Updating wollman: Old key: kh94741 - Reminder you need the 6 English words from the skey command. - Enter sequence count from 1 to 9999: 100 ) I typed this - Enter new key [default kh94742]: s/key 100 kh94742</screen> + <screen>&prompt.user; <userinput>keyinit -s</userinput> +Updating wollman: Old key: kh94741 +Reminder you need the 6 English words from the skey command. +<prompt>Enter sequence count from 1 to 9999:</prompt> <userinput>100</userinput> ) I typed this +<prompt>Enter new key [default kh94742]:</prompt> +s/key 100 kh94742</screen> </informalexample> </para> @@ -5075,10 +5114,10 @@ <para> <informalexample> - <screen>&prompt.user; key 100 kh94742 Reminder - Do not use this program - while logged in via telnet or rlogin. Enter secret password: - ) I typed my secret password HULL NAY YANG TREE TOUT - VETO</screen> + <screen>&prompt.user; <userinput>key 100 kh94742</userinput> +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> ) I typed my secret password +HULL NAY YANG TREE TOUT VETO</screen> </informalexample> </para> @@ -5089,9 +5128,9 @@ <para> <informalexample> - <screen>s/key access password: HULL NAY YANG TREE TOUT VETO ID - wollman s/key is 100 kh94742 HULL NAY YANG TREE TOUT - VETO</screen> + <screen><prompt>s/key access password:</prompt> <userinput>HULL NAY YANG TREE TOUT VETO</userinput> +ID wollman s/key is 100 kh94742 +HULL NAY YANG TREE TOUT VETO</screen> </informalexample> </para> @@ -5108,9 +5147,12 @@ <para> <informalexample> - <screen>&prompt.user; telnet himalia Trying 18.26.0.186... Connected to - himalia.lcs.mit.edu. Escape character is '^]'. s/key 92 - hi52030 Password:</screen> + <screen>&prompt.user; <userinput>telnet himalia</userinput> +Trying 18.26.0.186... +Connected to himalia.lcs.mit.edu. +Escape character is '^]'. +s/key 92 hi52030 +<prompt>Password:</prompt></screen> </informalexample> </para> @@ -5145,11 +5187,10 @@ <para> <informalexample> - <screen>&prompt.user; key 92 hi52030 ) pasted from - previous section Reminder - Do not use this program while - logged in via telnet or rlogin. Enter secret password: - ) I typed my secret password ADEN BED WOLF HAW HOT - STUN</screen> + <screen>&prompt.user; <userinput>key 92 hi52030</userinput> ) pasted from previous section +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> ) I typed my secret password +ADEN BED WOLF HAW HOT STUN</screen> </informalexample> </para> @@ -5157,10 +5198,12 @@ <para> <informalexample> - <screen>s/key 92 hi52030 ) from - previous section Password: (turning echo on) Password:ADEN BED - WOLF HAW HOT STUN Last login: Wed Jun 28 15:31:00 from - halloran-eldar.l [etc.]</screen> + <screen>s/key 92 hi52030 ) from previous section +<prompt>Password:</prompt> + (turning echo on) +<prompt>Password:</prompt>ADEN BED WOLF HAW HOT STUN +Last login: Wed Jun 28 15:31:00 from halloran-eldar.l +[etc.]</screen> </informalexample> </para> @@ -5183,16 +5226,19 @@ <para> <informalexample> - <screen>&prompt.user; key -n 25 57 zz99999 Reminder - Do not use this - program while logged in via telnet or rlogin. Enter secret - password: 33: WALT THY MALI DARN NIT HEAD 34: ASK RICE BEAU - GINA DOUR STAG [...] 56: AMOS BOWL LUG FAT CAIN INCH 57: - GROW HAYS TUN DISH CAR BALM </screen> + <screen>&prompt.user; <userinput>key -n 25 57 zz99999</userinput> +Reminder - Do not use this program while logged in via telnet or rlogin. +<prompt>Enter secret password:</prompt> +33: WALT THY MALI DARN NIT HEAD +34: ASK RICE BEAU GINA DOUR STAG +… +56: AMOS BOWL LUG FAT CAIN INCH +57: GROW HAYS TUN DISH CAR BALM</screen> </informalexample> </para> <para>The <option>-n 25</option> requests twenty-five keys in - sequence; the <emphasis remap=tt>57</emphasis> indicates the + sequence; the <option>57</option> indicates the <emphasis>ending</emphasis> iteration number; and the rest is as before. Note that these are printed out in <emphasis>reverse</emphasis> order of eventual use. If you are @@ -5225,12 +5271,11 @@ <para>Here is a sample configuration file which illustrates the three most common sorts of configuration statements:</para> - <para> - <informalexample> - <screen>permit internet 18.26.0.0 255.255.0.0 permit user jrl - permit port ttyd0</screen> - </informalexample> - </para> + <programlisting> +permit internet 18.26.0.0 255.255.0.0 +permit user jrl +permit port ttyd0 + </programlisting> <para>The first line (<literal>permit internet</literal>) allows users whose IP source address @@ -5295,8 +5340,9 @@ <para> <informalexample> - <screen>&prompt.root; cd /etc/kerberosIV &prompt.root; ls README - krb.conf krb.realms</screen> + <screen>&prompt.root; <userinput>cd /etc/kerberosIV</userinput> +&prompt.root; <userinput>ls</userinput> +README krb.conf krb.realms</screen> </informalexample> </para> @@ -5314,17 +5360,19 @@ <filename>grunt.grondar.za</filename>. We edit or create the <filename>krb.conf</filename> file:</para> - <para> - <informalexample> - <screen>&prompt.root; cat krb.conf GRONDAR.ZA GRONDAR.ZA - grunt.grondar.za admin server CS.BERKELEY.EDU - okeeffe.berkeley.edu ATHENA.MIT.EDU kerberos.mit.edu - ATHENA.MIT.EDU kerberos-1.mit.edu ATHENA.MIT.EDU - kerberos-2.mit.edu ATHENA.MIT.EDU kerberos-3.mit.edu - LCS.MIT.EDU kerberos.lcs.mit.edu TELECOM.MIT.EDU bitsy.mit.edu - ARC.NASA.GOV trident.arc.nasa.gov</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat krb.conf</userinput> +GRONDAR.ZA +GRONDAR.ZA grunt.grondar.za admin server +CS.BERKELEY.EDU okeeffe.berkeley.edu +ATHENA.MIT.EDU kerberos.mit.edu +ATHENA.MIT.EDU kerberos-1.mit.edu +ATHENA.MIT.EDU kerberos-2.mit.edu +ATHENA.MIT.EDU kerberos-3.mit.edu +LCS.MIT.EDU kerberos.lcs.mit.edu +TELECOM.MIT.EDU bitsy.mit.edu +ARC.NASA.GOV trident.arc.nasa.gov</screen> + </informalexample> <para>In this case, the other realms do not need to be there. They are here as an example of how a machine may be made aware of @@ -5346,13 +5394,14 @@ <filename>krb.realms</filename> file would be updated as follows:</para> - <para> - <informalexample> - <screen>&prompt.root; cat krb.realms grunt.grondar.za GRONDAR.ZA - .grondar.za GRONDAR.ZA .berkeley.edu CS.BERKELEY.EDU .MIT.EDU - ATHENA.MIT.EDU .mit.edu ATHENA.MIT.EDU</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat krb.realms</userinput> +grunt.grondar.za GRONDAR.ZA +.grondar.za GRONDAR.ZA +.berkeley.edu CS.BERKELEY.EDU +.MIT.EDU ATHENA.MIT.EDU +.mit.edu ATHENA.MIT.EDU</screen> + </informalexample> <para>Again, the other realms do not need to be there. They are here as an example of how a machine may be made aware of multiple @@ -5366,25 +5415,27 @@ run on the Kerberos server (or Key Distribution Centre). Issue the <symbol>kdb_init</symbol> command to do this:</para> - <para> - <informalexample> - <screen>&prompt.root; kdb_init Realm name [default ATHENA.MIT.EDU ]: - GRONDAR.ZA You will be prompted for the database Master - Password. It is important that you NOT FORGET this password. - Enter Kerberos master key: </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_init</userinput> +<prompt>Realm name [default ATHENA.MIT.EDU ]:</prompt> <userinput>GRONDAR.ZA</userinput> +You will be prompted for the database Master Password. +It is important that you NOT FORGET this password. + +<prompt>Enter Kerberos master key:</prompt> </screen> + </informalexample> <para>Now we have to save the key so that servers on the local machine can pick it up. Use the <command>kstash</command> command to do this.</para> - <para> - <informalexample> - <screen>&prompt.root; kstash Enter Kerberos master key: Current - Kerberos master key version is 1. Master key entered. - BEWARE!</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kstash</userinput> + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE!</screen> + </informalexample> <para>This saves the encrypted master password in <filename>/etc/kerberosIV/master_key</filename>.</para> @@ -5394,8 +5445,7 @@ <sect2> <title>Making it all run</title> - <para>Two principals need to be added to the database for <emphasis - remap=it>each</emphasis> system that will be secured with + <para>Two principals need to be added to the database for <emphasis>each</emphasis> system that will be secured with Kerberos. Their names are <command>kpasswd</command> and <command>rcmd</command> These two principals are made for each system, with the instance being the name of the @@ -5410,26 +5460,54 @@ <para> <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: passwd Instance: grunt <Not found>, - Create [y] ? y Principal: passwd, Instance: grunt, - kdc_key_ver: 1 New Password: <---- enter - RANDOM here Verifying password New Password: - <---- enter RANDOM here Random password [y] ? y Principal's - new key version = 1 Expiration date (enter yyyy-mm-dd) [ - 2000-01-01 ] ? Max ticket lifetime (*5 minutes) [ 255 ] ? - Attributes [ 0 ] ? Edit O.K. Principal name: rcmd Instance: - grunt <Not found>, Create [y] ? Principal: rcmd, - Instance: grunt, kdc_key_ver: 1 New Password: - <---- enter RANDOM here Verifying password New Password: - <---- enter RANDOM here Random password [y] ? Principal's - new key version = 1 Expiration date (enter yyyy-mm-dd) [ - 2000-01-01 ] ? Max ticket lifetime (*5 minutes) [ 255 ] ? - Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>passwd</userinput> +<prompt>Instance:</prompt> <userinput>grunt</userinput> + +<Not found>, <prompt>Create [y] ?</prompt> <userinput>y</userinput> + +Principal: passwd, Instance: grunt, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter RANDOM here +Verifying password + +<prompt>New Password:</prompt> <---- enter RANDOM here + +<prompt>Random password [y] ?</prompt> <userinput>y</userinput> + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <userinput>rcmd</userinput> +<prompt>Instance:</prompt> <userinput>grunt</userinput> + +<Not found>, <prompt>Create [y] ?</prompt> + +Principal: rcmd, Instance: grunt, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter RANDOM here +Verifying password + +<prompt>New Password:</prompt> <---- enter RANDOM here + +<prompt>Random password [y] ?</prompt> + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> </informalexample> </para> @@ -5440,73 +5518,80 @@ <para>We now have to extract all the instances which define the services on each machine. For this we use the - <symbol>ext_srvtab</symbol> command. This will create a file which + <command>ext_srvtab</command> command. This will create a file which must be copied or moved <emphasis>by secure means</emphasis> to each Kerberos client's /etc/kerberosIV directory. This file must be present on each server and client, and is crucial to the operation of Kerberos.</para> - <para> - <informalexample> - <screen>&prompt.root; ext_srvtab grunt Enter Kerberos master key: - Current Kerberos master key version is 1. Master key entered. - BEWARE! Generating 'grunt-new-srvtab'....</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ext_srvtab grunt</userinput> +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Generating 'grunt-new-srvtab'....</screen> + </informalexample> <para>Now, this command only generates a temporary file which must be renamed to <filename>srvtab</filename> so that all the server can pick it up. Use the <command>mv</command> command to move it into place on the original system:</para> - <para> - <informalexample> - <screen>&prompt.root; mv grunt-new-srvtab srvtab</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>mv grunt-new-srvtab srvtab</userinput></screen> + </informalexample> <para>If the file is for a client system, and the network is not - deemed safe, then copy the <emphasis - remap=tt><client>-new-srvtab</emphasis> to removable media + deemed safe, then copy the <filename><replaceable>client</replaceable>-new-srvtab</filename> to removable media and transport it by secure physical means. Be sure to rename it to <filename>srvtab</filename> in the client's <filename>/etc/kerberosIV</filename> directory, and make sure it is mode 600:</para> - <para> - <informalexample> - <screen>&prompt.root; mv grumble-new-srvtab srvtab &prompt.root; chmod 600 - srvtab</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; <userinput>mv grumble-new-srvtab srvtab</userinput> +&prompt.root; <userinput>chmod 600 srvtab</userinput></screen> + </informalexample> </sect2> <sect2> <title>Populating the database</title> <para>We now have to add some user entries into the database. First - let's create an entry for the user <emphasis - remap=it>jane</emphasis>. Use the <symbol>kdb_edit</symbol> - command to do this:</para> - - <para> - <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: jane Instance: <Not found>, Create [y] ? - y Principal: jane, Instance: , kdc_key_ver: 1 New Password: - <---- enter a secure password here Verifying password New - Password: <---- re-enter the password - here Principal's new key version = 1 Expiration date (enter - yyyy-mm-dd) [ 2000-01-01 ] ? Max ticket lifetime (*5 minutes) - [ 255 ] ? Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> - </informalexample> - </para> + let's create an entry for the user <username>jane</username>. Use + the <command>kdb_edit</command> command to do this:</para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>jane</userinput> +<prompt>Instance:</prompt> + +<Not found>, <prompt>Create [y] ?</prompt> <userinput>y</userinput> + +Principal: jane, Instance: , kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter a secure password here +Verifying password + +<prompt>New Password:</prompt> <---- re-enter the password here +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> + </informalexample> </sect2> <sect2> @@ -5519,52 +5604,60 @@ automagically get what they need from the <filename>/etc/kerberosIV</filename> directory.</para> - <para> - <informalexample> - <screen>&prompt.root; kerberos & &prompt.root; Kerberos server starting - Sleep forever on error Log file is /var/log/kerberos.log - Current Kerberos master key version is 1. Master key entered. - BEWARE! Current Kerberos master key version is 1 Local realm: - GRONDAR.ZA &prompt.root; kadmind -n & &prompt.root; KADM Server KADM0.0A - initializing Please do not use 'kill -9' to kill this job, use - a regular kill instead Current Kerberos master key version is - 1. Master key entered. BEWARE!</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kerberos &</userinput> +Kerberos server starting +Sleep forever on error +Log file is /var/log/kerberos.log +Current Kerberos master key version is 1. + +Master key entered. BEWARE! + +Current Kerberos master key version is 1 +Local realm: GRONDAR.ZA +&prompt.root; <userinput>kadmind -n &</userinput> +KADM Server KADM0.0A initializing +Please do not use 'kill -9' to kill this job, use a +regular kill instead + +Current Kerberos master key version is 1. + +Master key entered. BEWARE!</screen> + </informalexample> <para>Now we can try using the <command>kinit</command> - command to get a ticket for the id <emphasis - remap=it>jane</emphasis> that we created above:</para> + command to get a ticket for the id <username>jane</username> that we created above:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit jane MIT Project Athena (grunt.grondar.za) - Kerberos Initialization for "jane" Password: </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>kinit jane</userinput> +MIT Project Athena (grunt.grondar.za) +Kerberos Initialization for "jane" +<prompt>Password:</prompt> </screen> + </informalexample> <para>Try listing the tokens using <command>klist</command> to see if we really have them:</para> - <para> - <informalexample> - <screen>&prompt.user; klist Ticket file: /tmp/tkt245 Principal: - jane@GRONDAR.ZA Issued Expires Principal - Apr 30 11:23:22 Apr 30 19:23:22 - krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>klist</userinput> +Ticket file: /tmp/tkt245 +Principal: jane@GRONDAR.ZA + + Issued Expires Principal +Apr 30 11:23:22 Apr 30 19:23:22 krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> + </informalexample> <para>Now try changing the password using <command>passwd</command> to check if the kpasswd daemon can get authorization to the Kerberos database:</para> - <para> - <informalexample> - <screen>&prompt.user; passwd realm GRONDAR.ZA Old password for jane: - New Password for jane: Verifying password New Password for - jane: Password changed.</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.user; <userinput>passwd</userinput> +realm GRONDAR.ZA +<prompt>Old password for jane:</prompt> +<prompt>New Password for jane:</prompt> +Verifying password +<prompt>New Password for jane:</prompt> +Password changed.</screen> + </informalexample> </sect2> <sect2> @@ -5573,71 +5666,77 @@ <para>Kerberos allows us to give <emphasis>each</emphasis> user who needs root privileges their own <emphasis remap=it>separate</emphasis> <command>su</command>password. We could now add an id which is - authorized to <command>su</command> to <emphasis - remap=it>root</emphasis>. This is controlled by having an - instance of <emphasis remap=it>root</emphasis> associated with a - principal. Using <symbol>kdb_edit</symbol> we can create the - entry <filename>jane.root</filename> in the Kerberos + authorized to <command>su</command> to <username>root</username>. This is controlled by having an + instance of <username>root</username> associated with a + principal. Using <command>kdb_edit</command> we can create the + entry <literal>jane.root</literal> in the Kerberos database:</para> - <para> - <informalexample> - <screen>&prompt.root; kdb_edit Opening database... Enter Kerberos - master key: Current Kerberos master key version is 1. Master - key entered. BEWARE! Previous or default values are in - [brackets] , enter return to leave the same, or new value. - Principal name: jane Instance: root <Not found>, Create - [y] ? y Principal: jane, Instance: root, kdc_key_ver: 1 New - Password: <---- enter a SECURE password - here Verifying password New Password: - <---- re-enter the password here Principal's new key - version = 1 Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] - ? Max ticket lifetime (*5 minutes) [ 255 ] ? 12 <--- Keep - this short! Attributes [ 0 ] ? Edit O.K. Principal name: - <---- null entry here will cause an exit</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kdb_edit</userinput> +Opening database... + +<prompt>Enter Kerberos master key:</prompt> + +Current Kerberos master key version is 1. + +Master key entered. BEWARE! +Previous or default values are in [brackets] , +enter return to leave the same, or new value. + +<prompt>Principal name:</prompt> <userinput>jane</userinput> +<prompt>Instance:</prompt> <userinput>root</userinput> + +<Not found>, Create [y] ? y + +Principal: jane, Instance: root, kdc_key_ver: 1 +<prompt>New Password:</prompt> <---- enter a SECURE password here +Verifying password + +<prompt>New Password:</prompt> <---- re-enter the password here + +Principal's new key version = 1 +<prompt>Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?</prompt> +<prompt>Max ticket lifetime (*5 minutes) [ 255 ] ?</prompt> <userinput>12</userinput> <--- Keep this short! +<prompt>Attributes [ 0 ] ?</prompt> +Edit O.K. +<prompt>Principal name:</prompt> <---- null entry here will cause an exit</screen> + </informalexample> <para>Now try getting tokens for it to make sure it works:</para> - <para> - <informalexample> - <screen>&prompt.root; kinit jane.root MIT Project Athena - (grunt.grondar.za) Kerberos Initialization for "jane.root" - Password: - </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>kinit jane.root</userinput> +MIT Project Athena (grunt.grondar.za) +Kerberos Initialization for "jane.root" +<prompt>Password:</prompt></screen> + </informalexample> <para>Now we need to add the user to root's <filename>.klogin</filename> file:</para> - <para> - <informalexample> - <screen>&prompt.root; cat /root/.klogin jane.root@GRONDAR.ZA</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; <userinput>cat /root/.klogin</userinput> +jane.root@GRONDAR.ZA</screen> + </informalexample> + <para>Now try doing the <command>su</command>:</para> - <para> - <informalexample> - <screen>&prompt.user; su Password: &prompt.root; - </screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <prompt>su</prompt> +<prompt>Password:</prompt></screen> + </informalexample> <para>and take a look at what tokens we have:</para> - <para> - <informalexample> - <screen>&prompt.root; klist Ticket file: /tmp/tkt_root_245 Principal: - jane.root@GRONDAR.ZA Issued Expires - Principal May 2 20:43:12 May 3 04:43:12 - krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> - </informalexample> - </para> - + <informalexample> + <screen>&prompt.root; klist +Ticket file: /tmp/tkt_root_245 +Principal: jane.root@GRONDAR.ZA + + Issued Expires Principal +May 2 20:43:12 May 3 04:43:12 krbtgt.GRONDAR.ZA@GRONDAR.ZA</screen> + </informalexample> </sect2> <sect2> @@ -5654,21 +5753,19 @@ the <filename>.klogin</filename> file in <emphasis remap=tt>root</emphasis>'s home directory:</para> - <para> - <informalexample> - <screen>&prompt.root; cat /root/.klogin jane.root@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>cat /root/.klogin</userinput> +jane.root@GRONDAR.ZA</screen> + </informalexample> <para>Likewise, if a user has in their own home directory lines of the form:</para> - <para> - <informalexample> - <screen>&prompt.user;cat ~/.klogin jane@GRONDAR.ZA - jack@GRONDAR.ZA</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>cat ~/.klogin</userinput> +jane@GRONDAR.ZA +jack@GRONDAR.ZA</screen> + </informalexample> <para>This allows anyone in the <filename>GRONDAR.ZA</filename> realm who has authenticated themselves to @@ -5682,36 +5779,33 @@ <para>For example, Jane now logs into another system, using Kerberos:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit MIT Project Athena - (grunt.grondar.za) Password: %prompt.user; rlogin grunt - Last login: Mon May 1 21:14:47 from grumble Copyright (c) - 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 The Regents of - the University of California. All rights reserved. FreeBSD - BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995 - &prompt.user;</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>kinit</userinput> +MIT Project Athena (grunt.grondar.za) +<prompt>Password:</prompt> +%prompt.user; <userinput>rlogin grunt</userinput> +Last login: Mon May 1 21:14:47 from grumble +Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 + The Regents of the University of California. All rights reserved. + +FreeBSD BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995</screen> + </informalexample> <para>Or Jack logs into Jane's account on the same machine (Jane having set up the <filename>.klogin</filename> file as above, and the person in charge of Kerberos having set up principal <emphasis>jack</emphasis> with a null instance:</para> - <para> - <informalexample> - <screen>&prompt.user; kinit &prompt.user; rlogin grunt - -l jane MIT Project Athena (grunt.grondar.za) Password: Last - login: Mon May 1 21:16:55 from grumble Copyright (c) 1980, - 1983, 1986, 1988, 1990, 1991, 1993, 1994 The Regents of the - University of California. All rights reserved. FreeBSD - BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995 - [jane@grunt 10578]</screen> - </informalexample> - - </para> - + <informalexample> + <screen>&prompt.user; <userinput>kinit</userinput> +&prompt.user; <userinput>rlogin grunt -l jane</userinput> +MIT Project Athena (grunt.grondar.za) +<prompt>Password:</prompt> +Last login: Mon May 1 21:16:55 from grumble +Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994 + The Regents of the University of California. All rights reserved. +FreeBSD BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995</screen> + </informalexample> </sect2> </sect1> @@ -5913,11 +6007,9 @@ counter using the <citerefentry><refentrytitle>ipfw</refentrytitle><manvolnum>8</manvolnum></citerefentry> utility:</para> - <para> - <informalexample> - <screen>&prompt.root; ipfw zero 4500</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw zero 4500</userinput></screen> + </informalexample> <para>Where 4500 is the chain entry you wish to continue logging.</para> @@ -6098,14 +6190,17 @@ </variablelist> </para> - <para>The <emphasis>address</emphasis> specification is: - <informalexample> - <screen><emphasis remap=bf>from</emphasis> - <<filename>address/mask</filename>>[<emphasis>port</emphasis>] <emphasis remap=bf>to</emphasis> <<filename>address/mask</filename>>[<emphasis>port</emphasis>] [<emphasis remap=bf>via</emphasis> <<emphasis>interface</emphasis>>]</screen> - </informalexample> - </para> + <para>The <emphasis>address</emphasis> specification is:</para> + + <cmdsynopsis> + <arg choice="plain">from</arg> + <arg choice="plain"><replaceable>address/mask</replaceable></arg><arg><replaceable>port</replaceable></arg> + <arg choice="plain">to</arg> + <arg choice="plain"><replaceable>address/mark</replaceable></arg><arg><replaceable>port</replaceable></arg> + <arg>via <replaceable>interface</replaceable></arg> + </cmdsynopsis> - <para>You can only specify <emphasis>port</emphasis> in + <para>You can only specify <replaceable>port</replaceable> in conjunction with <emphasis>protocols</emphasis> which support ports (UDP and TCP).</para> @@ -6118,25 +6213,29 @@ interfaces.</para> <para>The syntax used to specify an - <filename><address/mask></filename> is: + <replaceable>address/mask</replaceable> is: + <informalexample> - <screen><address></screen> - </informalexample> or + <screen>address</screen> + </informalexample> + + or + <informalexample> - <screen><address>/mask-bits</screen> - </informalexample> or + <screen>address/mask-bits</screen> + </informalexample> + + or + <informalexample> - <screen><address>:mask-pattern</screen> + <screen>address:mask-pattern</screen> </informalexample> </para> <para>A valid hostname may be specified in place of the IP address. <emphasis remap=tt>mask-bits</emphasis> is a decimal number representing how many bits in the address mask should be - set. e.g. specifying - <informalexample> - <screen>192.216.222.1/24</screen> - </informalexample> will create a mask which will allow any + set. e.g. specifying <literal> 192.216.222.1/24</literal> will create a mask which will allow any address in a class C subnet (in this case, 192.216.222) to be matched. <emphasis remap=tt>mask-pattern</emphasis> is an IP address which will be logically AND'ed with the address given. @@ -6144,13 +6243,15 @@ specify <quote>any IP address</quote>.</para> <para>The port numbers to be blocked are specified as: - <informalexample> - <screen>port[,port[,port[...]]]</screen> - </informalexample> to specify either a single port or a list of + + <cmdsynopsis> + <arg choice="plain"><replaceable>port</replaceable><arg>,<replaceable>port</replaceable><arg>,<replaceable>port</replaceable><arg>…</arg></arg></arg></arg> + </cmdsynopsis>to specify either a single port or a list of ports, or - <informalexample> - <screen>port-port</screen> - </informalexample> to specify a range of ports. You may also + + <cmdsynopsis> + <arg choice="plain"><replaceable>port</replaceable>-<replaceable>port</replaceable></arg> + </cmdsynopsis> to specify a range of ports. You may also combine a single range with a list, but the range must always be specified first.</para> @@ -6300,9 +6401,10 @@ <title>Flushing the IPFW rules</title> <para>The syntax for flushing the chain is: - <informalexample> - <screen>ipfw flush</screen> - </informalexample> + <cmdsynopsis> + <command>ipfw</command> + <arg choice="plain">flush</arg> + </cmdsynopsis> </para> <para>This causes all entries in the firewall chain to be removed @@ -6320,13 +6422,13 @@ <cmdsynopsis> <command>ipfw</command> <arg choice="plain">zero</arg> - <arg>index</arg> + <arg><replaceable>index</replaceable></arg> </cmdsynopsis> </para> - <para>When used without an <emphasis>index</emphasis> argument, + <para>When used without an <replaceable>index</replaceable> argument, all packet counters are cleared. If an - <emphasis>index</emphasis> is supplied, the clearing operation + <replaceable>index</replaceable> is supplied, the clearing operation only affects a specific chain entry.</para> </sect3> @@ -6340,45 +6442,36 @@ host <filename>nice.people.org</filename> by being forwarded by the router:</para> - <para> - <informalexample> - <screen>ipfw add deny tcp from evil.hacker.org to - nice.people.org 23</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root <userinput>ipfw add deny tcp from evil.hacker.org to nice.people.org 23</userinput></screen> + </informalexample> <para>The next example denies and logs any TCP traffic from the entire <filename>hacker.org</filename> network (a class C) to the <filename>nice.people.org</filename> machine (any port).</para> - <para> - <informalexample> - <screen>ipfw add deny log tcp from evil.hacker.org/24 to - nice.people.org</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw add deny log tcp from evil.hacker.org/24 to nice.people.org</userinput></screen> + </informalexample> <para>If you do not want people sending X sessions to your internal network (a subnet of a class C), the following command will do the necessary filtering:</para> - <para> - <informalexample> - <screen>ipfw add deny tcp from any to my.org/28 6000 - setup</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw add deny tcp from any to my.org/28 6000 setup</userinput></screen> + </informalexample> <para>To see the accounting records: <informalexample> - <screen>ipfw -a list</screen> + <screen>&prompt.root; <userinput>ipfw -a list</userinput></screen> </informalexample> or in the short form <informalexample> - <screen>ipfw -a l</screen> + <screen>&prompt.root; <userinput>ipfw -a l</userinput></screen> </informalexample> You can also see the last time a chain entry was matched with <informalexample> - <screen>ipfw -at l</screen> + <screen>&prompt.root; <userinput>ipfw -at l</userinput></screen> </informalexample> </para> @@ -6430,11 +6523,9 @@ you. There is currently no support in the <command>ipfw</command> utility for loading multiple rules in the one command. The system I use is to use the command:</para> - <para> - <informalexample> - <screen>&prompt.root; ipfw list</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.root; <userinput>ipfw list</userinput></screen> + </informalexample> <para>to write a list of the current rules out to a file, and then use a text editor to prepend `<literal>ipfw @@ -6944,21 +7035,19 @@ <para>To find out if the kernel you are currently using supports a serial interface, type <informalexample> - <screen>&prompt.root; <userinput>dmesg | grep - sio<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>dmesg | grep sio<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the serial port, starting from zero. If you see output similar to the following <informalexample> - <screen> sio2 at 0x3e8-0x3ef irq 5 on isa sio2: type - 16550A</screen> + <screen>sio2 at 0x3e8-0x3ef irq 5 on isa +sio2: type 16550A</screen> </informalexample> then the kernel supports the port.</para> <para>To find out if the kernel supports a parallel interface, type <informalexample> - <screen>&prompt.root; <userinput>dmesg | grep - lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>dmesg | grep lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the parallel port, starting from zero. If you see output similar to the following @@ -7010,8 +7099,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput> ./MAKEDEV - <replaceable>port</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>./MAKEDEV <replaceable>port</replaceable></userinput></screen> </informalexample> where <replaceable>port</replaceable> is the device entry for the port you want to make. Use <literal>lpt0</literal> for the first parallel port, <literal>lpt1</literal> for the second, and @@ -7088,11 +7176,9 @@ <listitem> <para>If you want interrupt-driven mode, add the <literal>irq</literal> specifier: - <informalexample> - <screen>device lpt0 at isa? - port? tty irq <replaceable>N</replaceable> - vector lptintr</screen> - </informalexample> where <replaceable>N</replaceable> is the IRQ number for your + <programlisting> +device lpt0 at isa? port? tty irq <replaceable>N</replaceable> vector lptintr + </programlisting> where <replaceable>N</replaceable> is the IRQ number for your computer's parallel port. </para> </listitem> @@ -7100,11 +7186,9 @@ <listitem> <para>If you want polled mode, do not add the <literal>irq</literal> specifier: - <informalexample> - <screen>device lpt0 at isa? - port? tty vector lptintr - </screen> - </informalexample> + <programlisting> +device lpt0 at isa? port? tty vector lptintr + </programlisting> </para> </listitem> @@ -7130,8 +7214,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput>lptcontrol -i -u - <replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptcontrol -i -u <replaceable>N</replaceable></userinput></screen> </informalexample> to set interrupt-driven mode for <literal>lpt<replaceable>N</replaceable></literal>. </para> @@ -7140,8 +7223,7 @@ <listitem> <para>Type <informalexample> - <screen>&prompt.root; <userinput>lptcontrol -p -u - <replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptcontrol -p -u <replaceable>N</replaceable></userinput></screen> </informalexample> to set polled-mode for <literal>lpt<replaceable>N</replaceable></literal>.</para> </listitem> @@ -7168,11 +7250,14 @@ <para>For a PostScript (or other language-based) printer, we will need a more sophisticated test. A small PostScript program, such as the following, will suffice: - <informalexample> - <programlisting>%!PS 100 100 moveto 300 300 lineto stroke - 310 310 moveto /Helvetica findfont 12 scalefont setfont - (Is this thing working?) show showpage</programlisting> - </informalexample> + + <programlisting> +%!PS +100 100 moveto 300 300 lineto stroke +310 310 moveto /Helvetica findfont 12 scalefont setfont +(Is this thing working?) show +showpage + </programlisting> </para> <note> @@ -7211,8 +7296,7 @@ use <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.root; <userinput>lptest > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptest > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>N</replaceable> is the number of the parallel port, starting from zero. </para> @@ -7223,8 +7307,7 @@ other printer language, then send a small program to the printer. Type <informalexample> - <screen>&prompt.root; <userinput>cat > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>cat > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> Then, line by line, type the program <emphasis>carefully</emphasis> as you cannot edit a line once you have pressed RETURN @@ -7237,9 +7320,7 @@ <para> Alternatively, you can put the program in a file and type <informalexample> - <screen>&prompt.root; <userinput>cat - <replaceable>file</replaceable> > - /dev/lpt<replaceable>N</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>cat <replaceable>file</replaceable> > /dev/lpt<replaceable>N</replaceable></userinput></screen> </informalexample> where <replaceable>file</replaceable> is the name of the file containing the program you want to send to the printer.</para> @@ -7278,9 +7359,9 @@ <listitem> <para>Edit the file <filename>/etc/remote</filename>. Add the following entry: - <informalexample> - <screen><literal>printer:dv=/dev/<replaceable>port</replaceable>:br#<replaceable>bps-rate</replaceable>:pa=<replaceable>parity</replaceable></literal></screen> - </informalexample> where <replaceable>port</replaceable> is the device entry for the + <programlisting> +printer:dv=/dev/<replaceable>port</replaceable>:br#<replaceable>bps-rate</replaceable>:pa=<replaceable>parity</replaceable> + </programlisting> where <replaceable>port</replaceable> is the device entry for the serial port (<literal>ttyd0</literal>, <literal>ttyd1</literal>, etc.), <replaceable>bps-rate</replaceable> is the bits-per-second rate at which the printer communicates, and @@ -7291,9 +7372,9 @@ <para>Here is a sample entry for a printer connected via a serial line to the third serial port at 19200 bps with no parity: - <informalexample> - <programlisting>printer:dv=/dev/ttyd2:br#19200:pa=none</programlisting> - </informalexample> + <programlisting> +printer:dv=/dev/ttyd2:br#19200:pa=none + </programlisting> </para> </listitem> @@ -7301,7 +7382,7 @@ <para>Connect to the printer with <citerefentry> <refentrytitle>tip</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.root; tip printer</screen> + <screen>&prompt.root; <userinput>tip printer</userinput></screen> </informalexample> If this step does not work, edit the file <filename>/etc/remote</filename> again and try using @@ -7318,7 +7399,7 @@ use <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>. Type: <informalexample> - <screen>&prompt.user; lptest</screen> + <screen><prompt>~</prompt><userinput>$lptest</userinput></screen> </informalexample> </para> @@ -7340,7 +7421,7 @@ <para> Alternatively, you can put the program in a file and type <informalexample> - <screen><userinput>~><replaceable>file</replaceable></userinput></screen> + <screen><prompt>~</prompt><userinput>><replaceable>file</replaceable></userinput></screen> </informalexample> where <replaceable>file</replaceable> is the name of the file containing the program. After <citerefentry> @@ -7498,12 +7579,16 @@ <filename>/etc/printcap</filename> that defines two printers (a Diablo 630 line printer and a Panasonic KX-P4455 PostScript laser printer): - <informalexample> - <programlisting># # /etc/printcap for host rose # - rattan|line|diablo|lp|Diablo 630 Line Printer: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:</programlisting> - </informalexample> In this example, the first printer is named + + <programlisting> +# +# /etc/printcap for host rose +# +rattan|line|diablo|lp|Diablo 630 Line Printer: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4: + </programlisting> + In this example, the first printer is named <hostid>rattan</hostid> and has as aliases <emphasis remap=tt>line</emphasis>, <emphasis remap=tt>diablo</emphasis>, <emphasis @@ -7536,12 +7621,18 @@ printer in <filename>/etc/printcap</filename>. Here is the example <filename>/etc/printcap</filename> with <emphasis remap=tt>sh</emphasis> added: - <informalexample> - <programlisting># # /etc/printcap for host rose - no header - pages anywhere # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh: bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ :sh:</programlisting> - </informalexample> Note how we used the correct format: the + + <programlisting> +# +# /etc/printcap for host rose - no header pages anywhere +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh: + </programlisting> + Note how we used the correct format: the first line starts in the leftmost column, and subsequent lines are indented with a single TAB. Every line in an entry except the last ends in a backslash character.</para> @@ -7567,16 +7658,16 @@ <para>It is also customary to make the directory with a name that is identical to the name of the printer, as shown below: <informalexample> - <screen>&prompt.root; <userinput>mkdir - /var/spool/<replaceable>printer-name</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>mkdir /var/spool/<replaceable>printer-name</replaceable></userinput></screen> </informalexample> However, if you have a lot of printers on your network, you might want to put the spooling directories under a single directory that you reserve just for printing with LPD. We will do this for our two example printers <hostid>rattan</hostid> and <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.root; mkdir /var/spool/lpd mkdir /var/spool/lpd/rattan - mkdir /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>mkdir /var/spool/lpd</userinput> +&prompt.root; <userinput>mkdir /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>mkdir /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> @@ -7590,10 +7681,10 @@ <para> <informalexample> - <screen>&prompt.root; chown daemon.daemon /var/spool/lpd/rattan chown - daemon.daemon /var/spool/lpd/bamboo chmod 770 - /var/spool/lpd/rattan chmod 770 - /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/rattan</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> </note> @@ -7602,13 +7693,18 @@ using the <filename>/etc/printcap</filename> file. You specify the pathname of the spooling directory with the <emphasis remap=tt>sd</emphasis> capability: - <informalexample> - <programlisting># # /etc/printcap for host rose - added - spooling directories # rattan|line|diablo|lp|Diablo 630 - Line Printer:\ :sh:sd=/var/spool/lpd/rattan: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:</programlisting> - </informalexample> Note that the name of the printer starts in + + <programlisting> +# +# /etc/printcap for host rose - added spooling directories +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo: + </programlisting> + Note that the name of the printer starts in the first column but all other entries describing the printer should be indented with a tab and each line escaped with a backslash.</para> @@ -7640,15 +7736,19 @@ and <hostid>bamboo</hostid> is on a sixth serial port; here are the additions to <filename>/etc/printcap</filename>: - <informalexample> - <programlisting># # /etc/printcap for host rose - - identified what devices to use # - rattan|line|diablo|lp|Diablo 630 Line Printer:\ - :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host rose - identified what devices to use +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5: + </programlisting> </para> <para>If you do not specify the <emphasis remap=tt>lp</emphasis> @@ -7768,11 +7868,12 @@ we will set the TANDEM, ANYP, LITOUT, FLUSHO, and PASS8 flags. For the local mode bits, we will set the LITOUT and PASS8 flags: - <informalexample> - <screen>bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000c1:xs#0x820:</screen> - </informalexample> + + <programlisting> +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000c1:xs#0x820: + </programlisting> </para> </sect4> @@ -7811,15 +7912,21 @@ <filename>/usr/local/libexec/if-simple</filename> be a simple text filter. Put the following text into that file with your favorite text editor: + + <programlisting> +#!/bin/sh +# +# if-simple - Simple text input filter for lpd +# Installed in /usr/local/libexec/if-simple +# +# Simply copies stdin to stdout. Ignores all filter arguments. + +/bin/cat && exit 0 +exit 2 + </programlisting> + Make the file executable: <informalexample> - <programlisting>#!/bin/sh # # if-simple - Simple text input - filter for lpd # Installed in /usr/local/libexec/if-simple - # # Simply copies stdin to stdout. Ignores all filter - arguments. /bin/cat && exit 0 exit - 2</programlisting> - </informalexample> Make the file executable: - <informalexample> - <screen>&prompt.root; chmod 555 /usr/local/libexec/if-simple</screen> + <screen>&prompt.root; <userinput>chmod 555 /usr/local/libexec/if-simple</userinput></screen> </informalexample> </para> @@ -7828,16 +7935,20 @@ <filename>/etc/printcap</filename>. We will add it to the two printers we have so far in the example <filename>/etc/printcap</filename>: - <informalexample> - <programlisting># # /etc/printcap for host rose - added - text filter # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:\ - :if=/usr/local/libexec/if-simple:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host rose - added text filter +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:\ + :if=/usr/local/libexec/if-simple: + </programlisting> </para> </sect4> @@ -7866,8 +7977,7 @@ <para> Type: <informalexample> - <screen>&prompt.root; <userinput>lptest 20 5 | lpr - -P<replaceable>printer-name</replaceable></userinput></screen> + <screen>&prompt.root; <userinput>lptest 20 5 | lpr -P<replaceable>printer-name</replaceable></userinput></screen> </informalexample> where <emphasis remap=it>printer-name</emphasis> is a the name of a printer (or an alias) specified in <filename>/etc/printcap</filename>. @@ -7882,13 +7992,13 @@ the program. If you are using <citerefentry> <refentrytitle>lptest</refentrytitle></citerefentry>, then your results should look like the following:</para> - <para> - <informalexample> - <screen>!"#$%&'()*+,-./01234 "#$%&'()*+,-./012345 - #$%&'()*+,-./0123456 $%&'()*+,-./01234567 - %&'()*+,-./012345678</screen> - </informalexample> - </para> + <programlisting> +!"#$%&'()*+,-./01234 +"#$%&'()*+,-./012345 +#$%&'()*+,-./0123456 +$%&'()*+,-./01234567 +%&'()*+,-./012345678 + </programlisting> <para>To further test the printer, try downloading larger programs (for language-based printers) or running</para> @@ -7933,15 +8043,19 @@ <filename>/usr/local/libexec/if-simple</filename> prints a form feed after it sends the job to the printer: - <informalexample> - <programlisting>#!/bin/sh # # if-simple - Simple - text input filter for lpd # Installed in - /usr/local/libexec/if-simple # # Simply copies - stdin to stdout. Ignores all filter arguments. # - Writes a form feed character (\f) after printing - job. /bin/cat && printf "\f" && - exit 0 exit 2</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# if-simple - Simple text input filter for lpd +# Installed in /usr/local/libexec/if-simple +# +# Simply copies stdin to stdout. Ignores all filter arguments. +# Writes a form feed character (\f) after printing job. + +/bin/cat && printf "\f" && exit 0 +exit 2 + </programlisting> </para> </listitem> </varlistentry> @@ -7951,11 +8065,13 @@ <listitem> <para>You got the following on paper: - <informalexample> - <screen>!"#$%&'()*+,-./01234 + + <programlisting> +!"#$%&'()*+,-./01234 "#$%&'()*+,-./012345 - #$%&'()*+,-./0123456</screen> - </informalexample> You have become another victim of + #$%&'()*+,-./0123456 + </programlisting> + You have become another victim of the <emphasis>staircase effect</emphasis>, caused by conflicting interpretations of what characters should indicate a new-line. UNIX-style operating systems use @@ -7973,7 +8089,8 @@ carriage return is for: to move the location of the next character to print to the left edge of the paper.</para> - + + <!-- This para needs to be rewritten - Nik --> <para>Here is what FreeBSD wants your printer to do: <informalexample> <screen>Printer received CR Printer prints @@ -8035,20 +8152,19 @@ page of the job. It should work with nearly all Hewlett Packard printers.</para> - <para> - <informalexample> - <programlisting>#!/bin/sh # # hpif - Simple - text input filter for lpd for HP-PCL based - printers # Installed in - /usr/local/libexec/hpif # # Simply copies - stdin to stdout. Ignores all filter - arguments. # Tells printer to treat LF as - CR+LF. Writes a form feed character # after - printing job. printf "\033&k2G" - && cat && printf "\f" - && exit 0 exit 2</programlisting> - </informalexample> - </para> + <programlisting> +#!/bin/sh +# +# hpif - Simple text input filter for lpd for HP-PCL based printers +# Installed in /usr/local/libexec/hpif +# +# Simply copies stdin to stdout. Ignores all filter arguments. +# Tells printer to treat LF as CR+LF. Writes a form feed character +# after printing job. + +printf "\033&k2G" && cat && printf "\f" && exit 0 +exit 2 + </programlisting> <para>Here is an example <filename>/etc/printcap</filename> from a host @@ -8056,12 +8172,15 @@ to its first parallel port, a Hewlett Packard LaserJet 3Si named <hostid>teak</hostid>. It is using the above script as its text filter: - <informalexample> - <programlisting># # /etc/printcap for host - orchid # teak|hp|laserjet|Hewlett Packard - LaserJet 3Si:\ - :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ :if=/usr/local/libexec/hpif:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif: + </programlisting> </para> </listitem> @@ -8083,7 +8202,8 @@ being treated as CR characters to return the print location to the left edge of the paper, but not also down a line.</para> - + + <!-- Need to rewrite this para --> <para>Use the printer's configuration switches or control panel to enforce the following interpretation of LF and CR characters: @@ -8170,12 +8290,14 @@ <filename>/etc/printcap</filename> file. For example, here is the entry for <hostid>rattan</hostid>, with the <emphasis remap=tt>lf</emphasis> capability: - <informalexample> - <screen>rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ - :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple:\ - :lf=/var/log/rattan.log</screen> - </informalexample> Then, try printing again. Check + + <programlisting> +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple:\ + :lf=/var/log/rattan.log + </programlisting> + Then, try printing again. Check the log file (in our example, <filename>/var/log/rattan.log</filename>) to see any error messages that might appear. Based on the @@ -8261,23 +8383,21 @@ <para>To print files, type <informalexample> - <screen><userinput>lpr - <replaceable>filename...</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lpr <replaceable>filename</replaceable> <replaceable>...</replaceable></userinput></screen> </informalexample> This prints each of the listed files to the default printer. If you list no files, <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> reads data to print from standard input. For example, this command prints some important system files: <informalexample> - <screen>&prompt.user; lpr /etc/host.conf /etc/hosts.equiv</screen> + <screen>&prompt.user; <userinput>lpr /etc/host.conf /etc/hosts.equiv</userinput></screen> </informalexample> To select a specific printer, type <informalexample> - <screen>&prompt.user; <userinput>lpr -P <replaceable>printer-name</replaceable> - <replaceable>filename...</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lpr -P <replaceable>printer-name</replaceable> <replaceable>filename</replaceable> <replaceable>...</replaceable></userinput></screen> </informalexample> This example prints a long listing of the current directory to the printer named <hostid>rattan</hostid>: <informalexample> - <screen>&prompt.user; ls -l | lpr -P rattan</screen> + <screen>&prompt.user; <userinput>ls -l | lpr -P rattan</userinput></screen> </informalexample> Because no files were listed for the <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> @@ -8314,15 +8434,15 @@ specific printer, use the <option>-P</option> option. For example, the command <informalexample> - <screen>&prompt.user; lpq -P bamboo</screen> + <screen>&prompt.user; <userinput>lpq -P bamboo</userinput></screen> </informalexample> shows the queue for the printer named <hostid>bamboo</hostid>. Here is an example of the output of the <command>lpq</command> command: <informalexample> - <screen>bamboo is ready and printing Rank Owner Job Files - Total Size active kelly 9 /etc/host.conf, - /etc/hosts.equiv 88 bytes 2nd kelly 10 (standard - input) 1635 bytes 3rd mary 11 ... - 78519 bytes</screen> + <screen>bamboo is ready and printing +Rank Owner Job Files Total Size +active kelly 9 /etc/host.conf, /etc/hosts.equiv 88 bytes +2nd kelly 10 (standard input) 1635 bytes +3rd mary 11 ... 78519 bytes</screen> </informalexample> This shows three jobs in the queue for <hostid>bamboo</hostid>. The first job, submitted by user kelly, got assigned <emphasis>job number</emphasis> 9. Every @@ -8359,14 +8479,16 @@ also support a <option>-l</option> option to generate a detailed long listing. Here is an example of <command>lpq -l</command>: <informalexample> - <screen>waiting for bamboo to become ready (offline ?) kelly: - 1st [job 009rose] /etc/host.conf - 73 bytes /etc/hosts.equiv 15 bytes - kelly: 2nd [job 010rose] - (standard input) 1635 bytes mary: 3rd - [job 011rose] - /home/orchid/mary/research/venus/alpha-regio/mapping 78519 - bytes</screen> + <screen>waiting for bamboo to become ready (offline ?) +kelly: 1st [job 009rose] + /etc/host.conf 73 bytes + /etc/hosts.equiv 15 bytes + +kelly: 2nd [job 010rose] + (standard input) 1635 bytes + +mary: 3rd [job 011rose] + /home/orchid/mary/research/venus/alpha-regio/mapping 78519 bytes</screen> </informalexample> </para> @@ -8389,13 +8511,12 @@ <refentrytitle>lpq</refentrytitle></citerefentry> to find the job number. Then type <informalexample> - <screen>&prompt.user; <userinput>lprm - <replaceable>job-number</replaceable></userinput></screen> + <screen>&prompt.user; <userinput>lprm <replaceable>job-number</replaceable></userinput></screen> </informalexample> To remove the job from a specific printer, add the <option>-P</option> option. The following command removes job number 10 from the queue for the printer <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.user; lprm -P bamboo 10</screen> + <screen>&prompt.user; <userinput>lprm -P bamboo 10</userinput></screen> </informalexample> The <citerefentry> <refentrytitle>lprm</refentrytitle></citerefentry> command has a few shortcuts: @@ -8436,11 +8557,9 @@ For example, the following command removes all jobs for the current user in the queue for the printer named <hostid>rattan</hostid>:</para> - <para> - <informalexample> - <screen>&prompt.user; lprm -P rattan -</screen> - </informalexample> - </para> + <informalexample> + <screen>&prompt.user; <userinput>lprm -P rattan -</userinput></screen> + </informalexample> <note> <para>If you are working in a networked @@ -8452,13 +8571,19 @@ were submitted, even if the same printer is available from other hosts. The following command sequence demonstrates this: <informalexample> - <programlisting>&prompt.user; lpr -P rattan myfile &prompt.user; rlogin orchid - &prompt.user; lpq -P rattan Rank Owner Job Files Total - Size active seeyan 12 ... 49123 bytes 2nd kelly - 13 myfile 12 bytes &prompt.user; lprm -P rattan 13 rose: - Permission denied &prompt.user; logout &prompt.user; lprm -P rattan 13 - dfA013rose dequeued cfA013rose dequeued &prompt.user; - </programlisting> + <screen>&prompt.user; <userinput>lpr -P rattan myfile</userinput> +&prompt.user; <userinput>rlogin orchid</userinput> +&prompt.user; <userinput>lpq -P rattan</userinput> +Rank Owner Job Files Total Size +active seeyan 12 ... 49123 bytes +2nd kelly 13 myfile 12 bytes +&prompt.user; <userinput>lprm -P rattan 13</userinput> +rose: Permission denied +&prompt.user; <userinput>logout</userinput> +&prompt.user; <userinput>lprm -P rattan 13</userinput> +dfA013rose dequeued +cfA013rose dequeued + </screen> </informalexample> </para> </note> @@ -8493,7 +8618,7 @@ <filename>fish-report.dvi</filename> to the printer named <hostid>bamboo</hostid>: <informalexample> - <screen>&prompt.user; lpr -P bamboo -d fish-report.dvi</screen> + <screen>&prompt.user; <userinput>lpr -P bamboo -d fish-report.dvi</userinput></screen> </informalexample> These options apply to every file in the job, so you cannot mix (say) DVI and ditroff files together in a job. Instead, submit the files as separate jobs, using a different @@ -8613,8 +8738,7 @@ <refentrytitle>ls</refentrytitle></citerefentry> manual page on the default printer: <informalexample> - <screen>&prompt.user; zcat /usr/share/man/man1/ls.1.gz | troff -t -man | lpr - -t</screen> + <screen>&prompt.user; <userinput>zcat /usr/share/man/man1/ls.1.gz | troff -t -man | lpr -t</userinput></screen> </informalexample> The <citerefentry> <refentrytitle>zcat</refentrytitle></citerefentry> command uncompresses the source of the</para> @@ -8661,7 +8785,7 @@ <filename>parser.c</filename> followed by three copies of <filename>parser.h</filename> to the default printer: <informalexample> - <screen>&prompt.user; lpr -#3 parser.c parser.h</screen> + <screen>&prompt.user; <userinput>lpr -#3 parser.c parser.h</userinput></screen> </informalexample> </para> </listitem> @@ -9155,14 +9279,16 @@ and comparing that to the number of lines per page the printer supports. The text filter is started with the following argument list: - <informalexample> - <screen><command>[-c] -w<replaceable>width</replaceable> - -l<replaceable>length</replaceable> - -i<replaceable>indent</replaceable> -n - <replaceable>login</replaceable> -h - <replaceable>host</replaceable> - <replaceable>acct-file</replaceable></command></screen> - </informalexample> where + <cmdsynopsis> + <command>filter-name</command> + <arg>-c</arg> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + <arg choice="plain">-l<replaceable>length</replaceable></arg> + <arg choice="plain">-i<replaceable>indent</replaceable></arg> + <arg choice="plain">-n <replaceable>login</replaceable></arg> + <arg choice="plain">-h <replaceable>host</replaceable></arg> + <arg choice="plain"><replaceable>acct-file</replaceable></arg> + </cmdsynopsis> where <variablelist> <varlistentry><term><option>-c</option></term> <listitem> @@ -9245,12 +9371,17 @@ Conversion filters also need to do accounting, if you need printer accounting. Conversion filters are started with the following arguments: - <informalexample> - <screen><command>-x<replaceable>pixel-width</replaceable> -y<replaceable>pixel-height</replaceable> -n <replaceable>login</replaceable> -h <replaceable>host</replaceable> <replaceable>acct-file</replaceable></command></screen> - </informalexample> where <emphasis - remap=it>pixel-width</emphasis> is the value from the + <cmdsynopsis> + <command>filter-name</command> + <arg + choice="plain">-x<replaceable>pixel-width</replaceable></arg> + <arg choice="plain">-y<replaceable>pixel-height</replaceable></arg> + <arg choice="plain">-n <replaceable>login</replaceable></arg> + <arg choice="plain">-h <replaceable>host</replaceable></arg> + <arg choice="plain"><replaceable>acct-file</replaceable></arg> + </cmdsynopsis> where <replaceable>pixel-width</replaceable> is the value from the <emphasis remap=tt>px</emphasis> capability (default 0) - and <emphasis remap=it>pixel-height</emphasis> is the + and <replaceable>pixel-height</replaceable> is the value from the <emphasis remap=tt>py</emphasis> capability (default 0). </para> @@ -9263,10 +9394,12 @@ <xref linkend="printing-advanced-of" remap="Output Filters"> describe them. There are only two arguments to an output filter: - <informalexample> - <screen><command>-w<replaceable>width</replaceable> - -l<replaceable>length</replaceable></command></screen> - </informalexample> which are identical to the text filters + <cmdsynopsis> + <command>filter-name</command> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + + <arg choice="plain">-l<replaceable>length</replaceable></arg> + </cmdsynopsis> which are identical to the text filters <option>-w</option> and <option>-l</option> arguments.</para> </listitem> @@ -9365,9 +9498,9 @@ installed <command>lprps</command> from the ports collection, use the following in the serial PostScript printer's entry in <filename>/etc/printcap</filename>: - <informalexample> - <screen> :if=/usr/local/libexec/psif:</screen> - </informalexample> You should also specify the <emphasis + <programlisting> +:if=/usr/local/libexec/psif: + </programlisting> You should also specify the <emphasis remap=tt>rw</emphasis> capability; that tells LPD to open the printer in read-write mode.</para> @@ -9375,19 +9508,33 @@ cannot use two-way communication with the printer, which <command>lprps</command> needs), you can use the following shell script as the text filter: - <informalexample> - <programlisting>#!/bin/sh # # psif - Print PostScript or - plain text on a PostScript printer # Script version; NOT - the version that comes with lprps # Installed in - /usr/local/libexec/psif # read first_line - first_two_chars=`expr "$first_line" : '\(..\)'` if [ - "$first_two_chars" = "%!" ]; then # # PostScript job, print - it. # echo $first_line && cat && printf - "\004" && exit 0 exit 2 else # # Plain text, - convert it, then print it. # ( echo $first_line; cat ) | - /usr/local/bin/textps && printf "\004" && - exit 0 exit 2 fi</programlisting> - </informalexample> In the above script, <command>textps</command> is a program we installed + + <programlisting> +#!/bin/sh +# +# psif - Print PostScript or plain text on a PostScript printer +# Script version; NOT the version that comes with lprps +# Installed in /usr/local/libexec/psif +# + +read first_line +first_two_chars=`expr "$first_line" : '\(..\)'` + +if [ "$first_two_chars" = "%!" ]; then + # + # PostScript job, print it. + # + echo $first_line && cat && printf "\004" && exit 0 + exit 2 +else + # + # Plain text, convert it, then print it. + # + ( echo $first_line; cat ) | /usr/local/bin/textps && printf "\004" && exit 0 + exit 2 +fi + </programlisting> + In the above script, <command>textps</command> is a program we installed separately to convert plain text to PostScript. You can use any text-to-PostScript program you wish. The FreeBSD ports collection (see <xref linkend="ports" remap="The Ports @@ -9430,25 +9577,45 @@ <para><citerefentry> <refentrytitle>gs</refentrytitle></citerefentry> (Ghostscript) command. (Type <command>gs -h</command> to get a list of devices the current installation of Ghostscript supports.) - <informalexample> - <programlisting>#!/bin/sh # # ifhp - Print - Ghostscript-simulated PostScript on a DeskJet 500 # - Installed in /usr/local/libexec/hpif # # Treat LF as CR+LF: - # printf "\033&k2G" || exit 2 # # Read first two - characters of the file # read first_line - first_two_chars=`expr "$first_line" : '\(..\)'` if [ - "$first_two_chars" = "%!" ]; then # # It is PostScript; use - Ghostscript to scan-convert and print it # /usr/local/bin/gs - -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \ - && exit 0 else # # Plain text or HP/PCL, so just - print it directly; print a form # at the end to eject the - last page. # echo $first_line && cat && - printf "\f" && exit 0 fi exit 2</programlisting> - </informalexample> Finally, you need to notify LPD of the filter + + <programlisting> +#!/bin/sh +# +# ifhp - Print Ghostscript-simulated PostScript on a DeskJet 500 +# Installed in /usr/local/libexec/hpif + +# +# Treat LF as CR+LF: +# +printf "\033&k2G" || exit 2 + +# +# Read first two characters of the file +# +read first_line +first_two_chars=`expr "$first_line" : '\(..\)'` + +if [ "$first_two_chars" = "%!" ]; then + # + # It is PostScript; use Ghostscript to scan-convert and print it + # + /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \ + && exit 0 +else + # + # Plain text or HP/PCL, so just print it directly; print a form + # at the end to eject the last page. + # + echo $first_line && cat && printf "\f" && exit 0 +fi + +exit 2 + </programlisting> + Finally, you need to notify LPD of the filter via the <emphasis remap=tt>if</emphasis> capability: - <informalexample> - <screen> :if=/usr/local/libexec/hpif:</screen> - </informalexample> That is it. You can type <command>lpr plain.text</command> and <filename>lpr + <programlisting> +:if=/usr/local/libexec/hpif: + </programlisting> That is it. You can type <command>lpr plain.text</command> and <filename>lpr whatever.ps</filename> and both should print successfully.</para> @@ -9475,15 +9642,14 @@ directly until we convert the DVI file into PostScript. The command sequence goes like this: <informalexample> - <screen>&prompt.user; dvips seaweed-analysis.dvi - &prompt.user; lpr - seaweed-analysis.ps</screen> + <screen>&prompt.user; <userinput>dvips seaweed-analysis.dvi</userinput> +&prompt.user; <userinput>lpr seaweed-analysis.ps</userinput></screen> </informalexample> By installing a conversion filter for DVI files, we can skip the hand conversion step each time by having LPD do it for us. Now, each time we get a DVI file, we are just one step away from printing it: <informalexample> - <screen>&prompt.user; lpr -d seaweed-analysis.dvi</screen> + <screen>&prompt.user; <userinput>lpr -d seaweed-analysis.dvi</userinput></screen> </informalexample> We got LPD to do the DVI file conversion for us by specifying the <option>-d</option> option. Section <xref @@ -9514,15 +9680,68 @@ with, their capability entries for the <filename>/etc/printcap</filename> file, and how to invoke them with the <command>lpr</command> command: - <informalexample> - <programlisting> /etc/printcap File type - Capability lpr option ------------ ------------- - ---------- cifplot cf -c DVI - df -d plot gf -g ditroff - nf -n FORTRAN text rf -f troff - tf -t raster vf -v plain - text if none, -p, or -l</programlisting> - </informalexample> + + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>File type</entry> + <entry><filename>/etc/printcap</filename> + capability</entry> + <entry><command>lpr</command> option</entry> + </row> + </thead> + <tbody> + <row> + <entry>cifplot</entry> + <entry><literal>cf</literal></entry> + <entry><option>-c</option></entry> + </row> + + <row> + <entry>DVI</entry> + <entry><literal>df</literal></entry> + <entry><option>-d</option></entry> + </row> + + <row> + <entry>plot</entry> + <entry><literal>gf</literal></entry> + <entry><option>-g</option></entry> + </row> + + <row> + <entry>ditroff</entry> + <entry><literal>nf</literal></entry> + <entry><option>-n</option></entry> + </row> + + <row> + <entry>FORTRAN text</entry> + <entry><literal>rf</literal></entry> + <entry><option>-f</option></entry> + </row> + + <row> + <entry>troff</entry> + <entry><literal>rf</literal></entry> + <entry><option>-f</option></entry> + </row> + + <row> + <entry>raster</entry> + <entry><literal>vf</literal></entry> + <entry><option>-v</option></entry> + </row> + + <row> + <entry>plain text</entry> + <entry><literal>if</literal></entry> + <entry>none, <option>-p</option>, or <option>-l</option></entry> + </row> + </tbody> + </tgroup> + </informaltable> </para> <para>In our example, using <command>lpr -d</command> means the @@ -9561,26 +9780,37 @@ <filename>/etc/printcap</filename> file again, with the new <emphasis remap=tt>df</emphasis> capability for the printer <hostid>bamboo</hostid> - <informalexample> - <programlisting># # /etc/printcap for host rose - added df - filter for bamboo # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> The DVI filter is a shell script named + + <programlisting> +# +# /etc/printcap for host rose - added df filter for bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + The DVI filter is a shell script named <filename>/usr/local/libexec/psdf</filename>. Here is that script: - <informalexample> - <programlisting>#!bin/sh # # psdf - DVI to PostScript - printer filter # Installed in /usr/local/libexec/psdf # # - Invoked by lpd when user runs lpr -d # exec - /usr/local/bin/dvips -f | /usr/local/libexec/lprps - "$@"</programlisting> - </informalexample> This script runs <citerefentry> + + <programlisting> +#!bin/sh +# +# psdf - DVI to PostScript printer filter +# Installed in /usr/local/libexec/psdf +# +# Invoked by lpd when user runs lpr -d +# +exec /usr/local/bin/dvips -f | /usr/local/libexec/lprps "$@" + </programlisting> + This script runs <citerefentry> <refentrytitle>dvips</refentrytitle></citerefentry> in filter mode (the <option>-f</option> argument) on standard input, which is the job to print. It then starts the PostScript printer filter <command>lprps</command> (see section <xref linkend="printing-advanced-if-conversion" remap="Accommodating Plain Text Jobs on PostScript Printers">) with the arguments LPD passed to this script. @@ -9600,74 +9830,97 @@ <para>This example script is a raster (well, GIF file, actually) conversion filter for a Hewlett Packard LaserJet III-Si printer: - <informalexample> - <programlisting>#!/bin/sh # # hpvf - Convert GIF files into - HP/PCL, then print # Installed in /usr/local/libexec/hpvf - PATH=/usr/X11R6/bin:$PATH; export PATH giftopnm | ppmtopgm - | pgmtopbm | pbmtolj -resolution 300 \ && exit 0 \ - || exit 2</programlisting> - </informalexample> It works by converting the GIF file into a + + <programlisting> +#!/bin/sh +# +# hpvf - Convert GIF files into HP/PCL, then print +# Installed in /usr/local/libexec/hpvf + +PATH=/usr/X11R6/bin:$PATH; export PATH giftopnm | ppmtopgm | pgmtopbm | pbmtolj -resolution 300 \ + && exit 0 \ + || exit 2 + </programlisting> + It works by converting the GIF file into a portable anymap, converting that into a portable graymap, converting that into a portable bitmap, and converting that into LaserJet/PCL-compatible data.</para> <para>Here is the <filename>/etc/printcap</filename> file with an entry for a printer using the above filter: - <informalexample> - <programlisting># # /etc/printcap for host orchid # - teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/hpif:\ - :vf=/usr/local/libexec/hpvf:</programlisting> - </informalexample> + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sh:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif:\ + :vf=/usr/local/libexec/hpvf: + </programlisting> </para> <para>The following script is a conversion filter for troff data from the groff typesetting system for the PostScript printer named <hostid>bamboo</hostid>: - <informalexample> - <programlisting>#!/bin/sh # # pstf - Convert groff's troff - data into PS, then print. # Installed in - /usr/local/libexec/pstf # exec grops | - /usr/local/libexec/lprps "$@"</programlisting> - </informalexample> The above script makes use of <command>lprps</command> again to handle the communication + + <programlisting> +#!/bin/sh +# +# pstf - Convert groff's troff data into PS, then print. +# Installed in /usr/local/libexec/pstf +# +exec grops | /usr/local/libexec/lprps "$@" + </programlisting> + The above script makes use of <command>lprps</command> again to handle the communication with the printer. If the printer were on a parallel port, we would use this script instead: - <informalexample> - <programlisting>#!/bin/sh # # pstf - Convert groff's troff - data into PS, then print. # Installed in - /usr/local/libexec/pstf # exec grops</programlisting> - </informalexample> That is it. Here is the entry we need to + + <programlisting> +#!/bin/sh +# +# pstf - Convert groff's troff data into PS, then print. +# Installed in /usr/local/libexec/pstf +# +exec grops + </programlisting> + That is it. Here is the entry we need to add to <filename>/etc/printcap</filename> to enable the filter: - <informalexample> - <screen> :tf=/usr/local/libexec/pstf:</screen> - </informalexample> + <programlisting> +:tf=/usr/local/libexec/pstf: + </programlisting> </para> <para>Here is an example that might make old hands at FORTRAN blush. It is a FORTRAN-text filter for any printer that can directly print plain text. We will install it for the printer <hostid>teak</hostid>: - <informalexample> - <programlisting>#!/bin/sh # # hprf - FORTRAN text filter for - LaserJet 3si: # Installed in /usr/local/libexec/hprf # - printf "\033&k2G" && fpr && printf - "\f" && exit 0 exit 2</programlisting> - </informalexample> And we will add this line to the + + <programlisting> +#!/bin/sh +# +# hprf - FORTRAN text filter for LaserJet 3si: +# Installed in /usr/local/libexec/hprf +# + +printf "\033&k2G" && fpr && printf "\f" && exit 0 +exit 2 + </programlisting> + And we will add this line to the <filename>/etc/printcap</filename> for the printer <hostid>teak</hostid> to enable this filter: - <informalexample> - <screen> :rf=/usr/local/libexec/hprf:</screen> - </informalexample> + <programlisting> +:rf=/usr/local/libexec/hprf: + </programlisting> </para> <para>Here is one final, somewhat complex example. We will add a DVI filter to the LaserJet printer <hostid>teak</hostid> introduced earlier. First, the easy part: updating <filename>/etc/printcap</filename> with the location of the DVI filter: - <informalexample> - <screen> :df=/usr/local/libexec/hpdf:</screen> - </informalexample> + <programlisting> +:df=/usr/local/libexec/hpdf: + </programlisting> </para> <para>Now, for the hard part: making the filter. For that, we @@ -9713,29 +9966,68 @@ than under <filename>/tmp</filename>.</para> <para>Here, finally, is the filter: - <informalexample> - <programlisting>#!/bin/sh # # hpdf - Print DVI data on - HP/PCL printer # Installed in /usr/local/libexec/hpdf - PATH=/usr/local/bin:$PATH; export PATH # # Define a - function to clean up our temporary files. These exist # - in the current directory, which will be the spooling - directory # for the printer. # cleanup() { rm -f - hpdf$$.dvi } # # Define a function to handle fatal - errors: print the given message # and exit 2. Exiting - with 2 tells LPD to do not try to reprint the # job. # - fatal() { echo "$@" 1>&2 cleanup exit 2 } # # If - user removes the job, LPD will send SIGINT, so trap SIGINT - # (and a few other signals) to clean up after ourselves. - # trap cleanup 1 2 15 # # Make sure we are not colliding - with any existing files. # cleanup # # Link the DVI input - file to standard input (the file to print). # ln -s - /dev/fd/0 hpdf$$.dvi || fatal "Cannot symlink /dev/fd/0" # - # Make LF = CR+LF # printf "\033&k2G" || fatal - "Cannot initialize printer" # # Convert and print. - Return value from dvilj2p does not seem to be # reliable, - so we ignore it. # dvilj2p -M1 -q -e- dfhp$$.dvi # # - Clean up and exit # cleanup exit 0</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# hpdf - Print DVI data on HP/PCL printer +# Installed in /usr/local/libexec/hpdf + +PATH=/usr/local/bin:$PATH; export PATH + +# +# Define a function to clean up our temporary files. These exist +# in the current directory, which will be the spooling directory +# for the printer. +# +cleanup() { + rm -f hpdf$$.dvi +} + +# +# Define a function to handle fatal errors: print the given message +# and exit 2. Exiting with 2 tells LPD to do not try to reprint the +# job. +# +fatal() { + echo "$@" 1>&2 + cleanup + exit 2 +} + +# +# If user removes the job, LPD will send SIGINT, so trap SIGINT +# (and a few other signals) to clean up after ourselves. +# +trap cleanup 1 2 15 + +# +# Make sure we are not colliding with any existing files. +# +cleanup + +# +# Link the DVI input file to standard input (the file to print). +# +ln -s /dev/fd/0 hpdf$$.dvi || fatal "Cannot symlink /dev/fd/0" + +# +# Make LF = CR+LF +# +printf "\033&k2G" || fatal "Cannot initialize printer" + +# +# Convert and print. Return value from dvilj2p does not seem to be +# reliable, so we ignore it. +# +dvilj2p -M1 -q -e- dfhp$$.dvi + +# +# Clean up and exit +# +cleanup +exit 0 + </programlisting> </para> </sect4> @@ -9800,13 +10092,12 @@ <para>LPD does not pass the user's login or host to the filter, so it is not intended to do accounting. In fact, it gets only two arguments: - <informalexample> - <screen><command>-w<replaceable>width</replaceable> - -l<replaceable>length</replaceable></command></screen> - </informalexample> where <emphasis - remap=it>width</emphasis> is from the <emphasis - remap=tt>pw</emphasis> capability and <emphasis - remap=it>length</emphasis> is from the <emphasis + <cmdsynopsis> + <command>filter-name</command> + <arg choice="plain">-w<replaceable>width</replaceable></arg> + <arg choice="plain">-l<replaceable>length</replaceable></arg> + </cmdsynopsis> where <replaceable>width</replaceable> is from the <emphasis + remap=tt>pw</emphasis> capability and <replaceable>length</replaceable> is from the <emphasis remap=tt>pl</emphasis> capability for the printer in question.</para> </listitem> @@ -9938,12 +10229,17 @@ provide an output filter to send initialization strings to the printer. Here is an example output filter for Hewlett Packard PCL-compatible printers: - <informalexample> - <programlisting>#!/bin/sh # # hpof - Output filter for - Hewlett Packard PCL-compatible printers # Installed in - /usr/local/libexec/hpof printf "\033&k2G" || exit 2 exec - /usr/libexec/lpr/lpf</programlisting> - </informalexample> Specify the path to the output filter in the + + <programlisting> +#!/bin/sh +# +# hpof - Output filter for Hewlett Packard PCL-compatible printers +# Installed in /usr/local/libexec/hpof + +printf "\033&k2G" || exit 2 exec +/usr/libexec/lpr/lpf + </programlisting> + Specify the path to the output filter in the <emphasis remap=tt>of</emphasis> capability. See <xref linkend="printing-advanced-of" remap="Output Filters"> for more information.</para> @@ -9952,13 +10248,18 @@ for the printer <hostid>teak</hostid> that we introduced earlier; we enabled header pages and added the above output filter: - <informalexample> - <programlisting># # /etc/printcap for host orchid # - teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/hpif:\ :vf=/usr/local/libexec/hpvf:\ - :of=/usr/local/libexec/hpof:</programlisting> - </informalexample> Now, when users print jobs to <hostid>teak</hostid>, they get a header page with each + + <programlisting> +# +# /etc/printcap for host orchid +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/hpif:\ + :vf=/usr/local/libexec/hpvf:\ + :of=/usr/local/libexec/hpof: + </programlisting> + Now, when users print jobs to <hostid>teak</hostid>, they get a header page with each job. If users want to spend time searching for their printouts, they can suppress header pages by submitting the job with <command>lpr -h</command>; see <xref @@ -9985,25 +10286,55 @@ header</emphasis>, a full page of large letters identifying the user, host, and job. Here is an example (kelly printed the job named outline from host rose): - <informalexample> - <screen>k ll ll k l - l k l l k k eeee l - l y y k k e e l l y y k k - eeeeee l l y y kk k e l - l y y k k e e l l y yy k - k eeee lll lll yyy y y y y yyyy ll t - l i t l oooo u u ttttt l - ii n nnn eeee o o u u t l - i nn n e e o o u u t l - i n n eeeeee o o u u t l - i n n e o o u uu t t l i - n n e e oooo uuu u tt lll iii - n n eeee r rrr oooo ssss eeee rr r o - o s s e e r o o ss eeeeee r - o o ss e r o o s s e e r - oooo ssss eeee Job: outline Date: Sun Sep 17 - 11:04:58 1995</screen> - </informalexample> LPD appends a form feed after this text so + <programlisting> + k ll ll + k l l + k l l + k k eeee l l y y + k k e e l l y y + k k eeeeee l l y y + kk k e l l y y + k k e e l l y yy + k k eeee lll lll yyy y + y + y y + yyyy + + + ll + t l i + t l + oooo u u ttttt l ii n nnn eeee + o o u u t l i nn n e e + o o u u t l i n n eeeeee + o o u u t l i n n e + o o u uu t t l i n n e e + oooo uuu u tt lll iii n n eeee + + + + + + + + + + r rrr oooo ssss eeee + rr r o o s s e e + r o o ss eeeeee + r o o ss e + r o o s s e e + r oooo ssss eeee + + + + + + + + Job: outline + Date: Sun Sep 17 11:04:58 1995 + </programlisting> LPD appends a form feed after this text so the job starts on a new page (unless you have <emphasis remap=tt>sf</emphasis> (suppress form feeds) in the destination printer's entry in @@ -10013,10 +10344,9 @@ header</emphasis>; specify <literal>sb</literal> (short banner) in the <filename>/etc/printcap</filename> file. The header page will look like this: - <informalexample> - <screen>rose:kelly Job: outline Date: Sun Sep 17 11:07:51 - 1995</screen> - </informalexample> Also by default, LPD prints the header page + <programlisting> +rose:kelly Job: outline Date: Sun Sep 17 11:07:51 1995 + </programlisting> Also by default, LPD prints the header page first, then the job. To reverse that, specify <literal>hl</literal> (header last) in <filename>/etc/printcap</filename>.</para> @@ -10120,53 +10450,128 @@ <para>Let us explore this method. The following script takes three arguments (user login name, host name, and job name) and makes a simple PostScript header page: - <informalexample> - <programlisting>#!/bin/sh # # make-ps-header - make a - PostScript header page on stdout # Installed in - /usr/local/libexec/make-ps-header # # # These are - PostScript units (72 to the inch). Modify for A4 or # - whatever size paper you are using: # page_width=612 - page_height=792 border=72 # # Check arguments # if [ $# -ne - 3 ]; then echo "Usage: `basename $0` <user> - <host> <job>" 1>&2 exit 1 fi # # Save - these, mostly for readability in the PostScript, below. # - user=$1 host=$2 job=$3 date=`date` # # Send the PostScript - code to stdout. # exec cat <<EOF %!PS % % Make sure - we do not interfere with user's job that will follow % save - % % Make a thick, unpleasant border around the edge of the - paper. % $border $border moveto $page_width $border 2 mul - sub 0 rlineto 0 $page_height $border 2 mul sub rlineto - currentscreen 3 -1 roll pop 100 3 1 roll setscreen $border 2 - mul $page_width sub 0 rlineto closepath 0.8 setgray 10 - setlinewidth stroke 0 setgray % % Display user's login - name, nice and large and prominent % /Helvetica-Bold - findfont 64 scalefont setfont $page_width ($user) - stringwidth pop sub 2 div $page_height 200 sub moveto - ($user) show % % Now show the boring particulars % - /Helvetica findfont 14 scalefont setfont /y 200 def [ (Job:) - (Host:) (Date:) ] { 200 y moveto show /y y 18 sub def } - forall /Helvetica-Bold findfont 14 scalefont setfont /y 200 - def [ ($job) ($host) ($date) ] { 270 y moveto show /y y 18 - sub def } forall % % That is it % restore showpage - EOF</programlisting> - </informalexample> Now, each of the conversion filters and the + + <programlisting> +#!/bin/sh +# +# make-ps-header - make a PostScript header page on stdout +# Installed in /usr/local/libexec/make-ps-header +# + +# +# These are PostScript units (72 to the inch). Modify for A4 or +# whatever size paper you are using: +# +page_width=612 +page_height=792 +border=72 + +# +# Check arguments +# +if [ $# -ne 3 ]; then + echo "Usage: `basename $0` <user> <host> <job>" 1>&2 + exit 1 +fi + +# +# Save these, mostly for readability in the PostScript, below. +# +user=$1 +host=$2 +job=$3 +date=`date` + +# +# Send the PostScript code to stdout. +# +exec cat <<EOF +%!PS + +% +% Make sure we do not interfere with user's job that will follow +% +save + +% +% Make a thick, unpleasant border around the edge of the paper. +% +$border $border moveto +$page_width $border 2 mul sub 0 rlineto +0 $page_height $border 2 mul sub rlineto +currentscreen 3 -1 roll pop 100 3 1 roll setscreen +$border 2 mul $page_width sub 0 rlineto closepath +0.8 setgray 10 setlinewidth stroke 0 setgray + +% +% Display user's login name, nice and large and prominent +% +/Helvetica-Bold findfont 64 scalefont setfont +$page_width ($user) stringwidth pop sub 2 div $page_height 200 sub moveto +($user) show + +% +% Now show the boring particulars +% +/Helvetica findfont 14 scalefont setfont +/y 200 def +[ (Job:) (Host:) (Date:) ] { +200 y moveto show /y y 18 sub def } +forall + +/Helvetica-Bold findfont 14 scalefont setfont +/y 200 def +[ ($job) ($host) ($date) ] { + 270 y moveto show /y y 18 sub def +} forall + +% +% That is it +% +restore +showpage +EOF + </programlisting> + Now, each of the conversion filters and the text filter can call this script to first generate the header page, and then print the user's job. Here is the DVI conversion filter from earlier in this document, modified to make a header page: - <informalexample> - <programlisting>#!/bin/sh # # psdf - DVI to PostScript - printer filter # Installed in /usr/local/libexec/psdf # # - Invoked by lpd when user runs lpr -d # orig_args="$@" fail() - { echo "$@" 1>&2 exit 2 } while getopts "x:y:n:h:" - option; do case $option in x|y) ;; # Ignore n) - login=$OPTARG ;; h) host=$OPTARG ;; *) echo "LPD - started `basename $0` wrong." 1>&2 exit 2 ;; esac - done [ "$login" ] || fail "No login name" [ "$host" ] || - fail "No host name" ( /usr/local/libexec/make-ps-header - $login $host "DVI File" /usr/local/bin/dvips -f ) | eval - /usr/local/libexec/lprps $orig_args</programlisting> - </informalexample> Notice how the filter has to parse the + + <programlisting> +#!/bin/sh +# +# psdf - DVI to PostScript printer filter +# Installed in /usr/local/libexec/psdf +# +# Invoked by lpd when user runs lpr -d +# + +orig_args="$@" + +fail() { + echo "$@" 1>&2 + exit 2 +} + +while getopts "x:y:n:h:" option; do + case $option in + x|y) ;; # Ignore + n) login=$OPTARG ;; + h) host=$OPTARG ;; + *) echo "LPD started `basename $0` wrong." 1>&2 + exit 2 + ;; + esac +done + +[ "$login" ] || fail "No login name" +[ "$host" ] || fail "No host name" + +( /usr/local/libexec/make-ps-header $login $host "DVI File" + /usr/local/bin/dvips -f ) | eval /usr/local/libexec/lprps $orig_args + </programlisting> + Notice how the filter has to parse the argument list in order to determine the user and host name. The parsing for the other conversion filters is identical. The text filter takes a slightly different set of arguments, though (see @@ -10336,36 +10741,47 @@ remap="Enabling Header Pages">). It already had the entry for the printer <hostid>teak</hostid>; we have added entries for the two printers on the host rose: - <informalexample> - <programlisting># # /etc/printcap for host orchid - added - (remote) printers on rose # # # teak is local; it is - connected directly to orchid: # teak|hp|laserjet|Hewlett - Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ - :if=/usr/local/libexec/ifhp:\ :vf=/usr/local/libexec/vfhp:\ - :of=/usr/local/libexec/ofhp: # # rattan is connected to - rose; send jobs for rattan to rose: # - rattan|line|diablo|lp|Diablo 630 Line Printer:\ - :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: # # bamboo - is connected to rose as well: # - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ - :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:</programlisting> - </informalexample> Then, we just need to make spooling + + <programlisting> +# +# /etc/printcap for host orchid - added (remote) printers on rose +# + +# +# teak is local; it is connected directly to orchid: +# +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:\ + :if=/usr/local/libexec/ifhp:\ + :vf=/usr/local/libexec/vfhp:\ + :of=/usr/local/libexec/ofhp: + +# +# rattan is connected to rose; send jobs for rattan to rose: +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: + +# +# bamboo is connected to rose as well: +# +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo: + </programlisting> + Then, we just need to make spooling directories on orchid: + <informalexample> - <screen>&prompt.root; mkdir -p /var/spool/lpd/rattan /var/spool/lpd/bamboo - &prompt.root; chmod 770 /var/spool/lpd/rattan - /var/spool/lpd/bamboo &prompt.root; chown - daemon.daemon /var/spool/lpd/rattan - /var/spool/lpd/bamboo</screen> + <screen>&prompt.root; <userinput>mkdir -p /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chmod 770 /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput> +&prompt.root; <userinput>chown daemon.daemon /var/spool/lpd/rattan /var/spool/lpd/bamboo</userinput></screen> </informalexample> </para> <para>Now, users on orchid can print to <hostid>rattan</hostid> and <hostid>bamboo</hostid>. If, for example, a user on orchid typed <informalexample> - <screen>&prompt.user; lpr -P bamboo -d sushi-review.dvi</screen> + <screen>&prompt.user; <userinput>lpr -P bamboo -d sushi-review.dvi</userinput></screen> </informalexample> the LPD system on orchid would copy the job to the spooling directory <filename>/var/spool/lpd/bamboo</filename> and note that it was @@ -10410,33 +10826,45 @@ printers support two-way communication, and you might want to take advantage of that (to get printer status, perform accounting, etc.). - <informalexample> - <programlisting>#!/usr/bin/perl # # netprint - Text filter - for printer attached to network # Installed in - /usr/local/libexec/netprint # $#ARGV eq 1 || die "Usage: $0 - <printer-hostname> <port-number>"; $printer_host - = $ARGV[0]; $printer_port = $ARGV[1]; require - 'sys/socket.ph'; ($ignore, $ignore, $protocol) = - getprotobyname('tcp'); ($ignore, $ignore, $ignore, $ignore, - $address) = gethostbyname($printer_host); $sockaddr = - pack('S n a4 x8', &AF_INET, $printer_port, $address); - socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol) - || die "Can't create TCP/IP stream socket: $!"; - connect(PRINTER, $sockaddr) || die "Can't contact - $printer_host: $!"; while (<STDIN>) { print PRINTER; } - exit 0;</programlisting> - </informalexample> We can then use this script in various + + <programlisting> +#!/usr/bin/perl +# +# netprint - Text filter for printer attached to network +# Installed in /usr/local/libexec/netprint +# +$#ARGV eq 1 || die "Usage: $0 <printer-hostname> <port-number>"; + +$printer_host = $ARGV[0]; +$printer_port = $ARGV[1]; + +require 'sys/socket.ph'; + +($ignore, $ignore, $protocol) = getprotobyname('tcp'); +($ignore, $ignore, $ignore, $ignore, $address) + = gethostbyname($printer_host); + +$sockaddr = pack('S n a4 x8', &AF_INET, $printer_port, $address); + +socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol) + || die "Can't create TCP/IP stream socket: $!"; +connect(PRINTER, $sockaddr) || die "Can't contact $printer_host: $!"; +while (<STDIN>) { print PRINTER; } +exit 0; + </programlisting> + We can then use this script in various filters. Suppose we had a Diablo 750-N line printer connected to the network. The printer accepts data to print on port number 5100. The host name of the printer is scrivener. Here is the text filter for the printer: - <informalexample> - <programlisting>#!/bin/sh # # diablo-if-net - Text filter for - Diablo printer `scrivener' listening # on port 5100. - Installed in /usr/local/libexec/diablo-if-net # exec - /usr/libexec/lpr/lpf "$@" | /usr/local/libexec/netprint - scrivener 5100</programlisting> - </informalexample> + + <programlisting> +#!/bin/sh +# +# diablo-if-net - Text filter for Diablo printer `scrivener' listening +# on port 5100. Installed in /usr/local/libexec/diablo-if-net # exec +/usr/libexec/lpr/lpf "$@" | /usr/local/libexec/netprint scrivener 5100 + </programlisting> </para> </sect3> @@ -10488,41 +10916,51 @@ we will allow multiple copies, but the laser printer <hostid>bamboo</hostid>'s a bit more delicate, so we will disable multiple copies by adding the <emphasis remap=tt>sc</emphasis> capability: - <informalexample> - <programlisting># # /etc/printcap for host rose - restrict - multiple copies on bamboo # rattan|line|diablo|lp|Diablo 630 - Line Printer:\ :sh:sd=/var/spool/lpd/rattan:\ - :lp=/dev/lpt0:\ :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Now, we also need to add the <emphasis + + <programlisting> +# +# /etc/printcap for host rose - restrict multiple copies on bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Now, we also need to add the <emphasis remap=tt>sc</emphasis> capability on the host orchid's <filename>/etc/printcap</filename> (and while we are at it, let us disable multiple copies for the printer <hostid>teak</hostid>): - <informalexample> - <programlisting># # /etc/printcap for host orchid - no - multiple copies for local # printer teak or remote printer - bamboo teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ - :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:sc:\ - :if=/usr/local/libexec/ifhp:\ :vf=/usr/local/libexec/vfhp:\ - :of=/usr/local/libexec/ofhp: rattan|line|diablo|lp|Diablo - 630 Line Printer:\ - :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ - :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:sc:</programlisting> - </informalexample> By using the <emphasis remap=tt>sc</emphasis> + + <programlisting> +# +# /etc/printcap for host orchid - no multiple copies for local +# printer teak or remote printer bamboo +teak|hp|laserjet|Hewlett Packard LaserJet 3Si:\ + :lp=/dev/lpt0:sd=/var/spool/lpd/teak:mx#0:sc:\ + :if=/usr/local/libexec/ifhp:\ + :vf=/usr/local/libexec/vfhp:\ + :of=/usr/local/libexec/ofhp: + +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :lp=:rm=rose:rp=rattan:sd=/var/spool/lpd/rattan: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :lp=:rm=rose:rp=bamboo:sd=/var/spool/lpd/bamboo:sc: + </programlisting> + By using the <emphasis remap=tt>sc</emphasis> capability, we prevent the use of <command>lpr -#</command>, but that still does not prevent users from running <citerefentry> <refentrytitle>lpr</refentrytitle></citerefentry> multiple times, or from submitting the same file multiple times in one job like this: <informalexample> - <screen>&prompt.user; lpr forsale.sign forsale.sign forsale.sign - forsale.sign forsale.sign </screen> + <screen>&prompt.user; <userinput>lpr forsale.sign forsale.sign forsale.sign forsale.sign forsale.sign</userinput></screen> </informalexample> There are many ways to prevent this abuse (including ignoring it) which you are free to explore.</para> @@ -10556,17 +10994,23 @@ <para>For example, we will let anyone access the printer <hostid>rattan</hostid>, but only those in group <emphasis remap=tt>artists</emphasis> can use <hostid>bamboo</hostid>. Here is the familiar <filename>/etc/printcap</filename> for host rose: - <informalexample> - <programlisting># # /etc/printcap for host rose - restricted - group for bamboo # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: - bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript - v51.4:\ :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Let us leave the other example + + <programlisting> +# +# /etc/printcap for host rose - restricted group for bamboo +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Let us leave the other example <filename>/etc/printcap</filename> file (for the host orchid) alone. Of course, anyone on orchid can print to <hostid>bamboo</hostid>. It might be the case that we only allow certain logins on orchid anyway, and want them to have @@ -10608,18 +11052,30 @@ <para>Let us add limits to our example printers <hostid>rattan</hostid> and <hostid>bamboo</hostid>. Since those artists' PostScript files tend to be large, we will limit them to five megabytes. We will put no limit on the plain text line printer: - <informalexample> - <programlisting># # /etc/printcap for host rose # # # No - limit on job size: # rattan|line|diablo|lp|Diablo 630 Line - Printer:\ :sh:sd=/var/spool/lpd/rattan:\ :lp=/dev/lpt0:\ - :if=/usr/local/libexec/if-simple: # # Limit of five - megabytes: # bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ - :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</programlisting> - </informalexample> Again, the limits apply to the local users + + <programlisting> +# +# /etc/printcap for host rose +# + +# +# No limit on job size: +# +rattan|line|diablo|lp|Diablo 630 Line Printer:\ + :sh:sd=/var/spool/lpd/rattan:\ + :lp=/dev/lpt0:\ + :if=/usr/local/libexec/if-simple: + +# +# Limit of five megabytes: +# +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + Again, the limits apply to the local users only. If you have set up access to your printers remotely, remote users will not get those limits. You will need to specify the <emphasis remap=tt>mx</emphasis> capability in the @@ -10667,10 +11123,13 @@ <para>For example, here is the <filename>/etc/hosts.lpd</filename> file on the host rose: - <informalexample> - <programlisting>orchid violet - madrigal.fishbaum.de</programlisting> - </informalexample> This means rose will accept requests + + <programlisting> +orchid +violet +madrigal.fishbaum.de + </programlisting> + This means rose will accept requests from the hosts orchid, violet, and madrigal.fishbaum.de. If any other host tries to access rose's LPD, LPD will refuse them.</para> @@ -10701,21 +11160,20 @@ <hostid>bamboo</hostid>. We examine <filename>/etc/printcap</filename> to find the spooling directory for this printer; here is <hostid>bamboo</hostid>'s entry: - <informalexample> - <screen>bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 - PostScript v51.4:\ - :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ - :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:mx#5000:\ - :if=/usr/local/libexec/psif:\ - :df=/usr/local/libexec/psdf:</screen> - </informalexample> The spooling directory is the given + <programlisting> +bamboo|ps|PS|S|panasonic|Panasonic KX-P4455 PostScript v51.4:\ + :sh:sd=/var/spool/lpd/bamboo:sc:rg=artists:mx#5000:\ + :lp=/dev/ttyd5:fs#0x82000e1:xs#0x820:rw:mx#5000:\ + :if=/usr/local/libexec/psif:\ + :df=/usr/local/libexec/psdf: + </programlisting> + The spooling directory is the given in the <emphasis remap=tt>sd</emphasis> capability. We will make three megabytes (which is 6144 disk blocks) the amount of free disk space that must exist on the filesystem for LPD to accept remote jobs: <informalexample> - <screen>&prompt.root; echo 6144 > - /var/spool/lpd/bamboo/minfree</screen> + <screen>&prompt.root; <userinput>echo 6144 > /var/spool/lpd/bamboo/minfree</userinput></screen> </informalexample> </para> @@ -10852,10 +11310,14 @@ much paper will be used. After sending the file to the printer, it then writes an accounting entry in the accounting file. The entries look like this: - <informalexample> - <screen> 2.00 rose:andy 3.00 rose:kelly 3.00 orchid:mary - 5.00 orchid:mary 2.00 orchid:zhang</screen> - </informalexample> You should use a separate accounting file for + + <programlisting> +2.00 rose:andy +3.00 rose:kelly +3.00 orchid:mary +5.00 orchid:mary +2.00 orchid:zhang</programlisting> + You should use a separate accounting file for each printer, as <command>lpf</command> has no file locking logic built into it, and two <command>lpf</command>s might corrupt each other's entries if they were to write to the same file at the same time. A easy way