There is quite a bit of variation between the various releases but
I'll try where possible to offer solutions that are universally
applicable. Start `lpd' in your `/etc/rc' or `/etc/rc.local' (usually
in `/etc/rc.local' after you start `syslogd' (if you use `syslogd')).
Set the group fields of the file permissons/ownership as follows:
-rwxr-sr-- 1 root lp 37892 Nov 19 23:32 /etc/lpd
-rwxr-sr-x 1 root lp 21508 Nov 19 23:32 /usr/bin/lpc
-rwsr-sr-x 1 root lp 17412 Nov 19 23:32 /usr/bin/lpq
-rwxr-sr-x 1 root lp 17412 Nov 19 23:32 /usr/bin/lpr
-rwxr-sr-x 1 root lp 17412 Nov 19 23:32 /usr/bin/lprm
-rwxr-xr-x 1 root lp 2816 May 10 13:37 /usr/bin/lptest
...and for each of the spool directories listed in the sd fields of
/etc/printcap...
/var/spool/lpd:
total 5
drwxrwxr-x 2 root lp 1024 May 18 23:00 .
drwxr-xr-x 11 root root 1024 Feb 19 20:56 ..
-rw-rw-r-- 1 root lp 4 May 18 23:00 .seq
-rw-rw-r-- 1 root lp 18 May 18 23:00 lock
-rw-rw-r-- 1 root lp 25 May 18 23:00 status
Note these 3 files are created by lpr and lpd so if you've never run
these they will be absent. With some versions of the lpd package you
had to touch them into being or they would be created with the wrong
permissions but this bug seems to have been fixed.
In older versions the group id was `daemon' not `lp'. There's also a
named socket but `lpd' creates/deletes it as needed. Also you may find
the uid is sometimes set to `daemon' or `lp' rather than `root' but
this is of no consequence except on setuid binaries.
These permissions are the most pedantic so don't be surprised if
your system works with different permissions. On the other hand if lpd
is not working for you and you have different permissions please try
these before mailing us or posting to usenet. (This may sound obvious
but you'd be amazed how much mail I've had from people with the
permissions set wrong).
People tell me that `lpr' must be setuid(root) but I've not seen
evidence that this is really the case as long as the file permissions on
the spool queues are right. Still as far as I know `lpr' is designed to
be secure when installed setuid(root). This allows an alternative
(sloppy) approach: just make `lpr' and `lprm' setuid(root) then you can
almost forget the file permissions on the spool queues!
You're free to choose different directories for the executables on
your system (notably `lpc' is usually in `/etc' (or `/usr/sbin') even
though it has commands that are useful to non-root). Of course since
you are free to do this it implies the person who made up your
distribution was also free to do so, so be carefull to make sure you
delete old components when you install new ones.
The master lpd lock file is fixed at compile time to be
`/var/spool/lpd/lpd.lock' so you must have a `/var/spool/lpd directory'
even if you choose not to keep your spool queue there. In the older
binaries the lock file was `/usr/spool/lpd.lock' so this was not an
issue.
My advise is to keep your primary spool queue in `/usr/spool/lpd' and
make `/var' a symlink to `usr' or keep it in `/var/spool/lpd' and make
`/usr/spool' a symlink to `../var/spool'. This gives the greatest
compatibility with the pathnames that are compiled into the various
distributed binaries. Note that having a separate `/var' filesystem
avoids the problem of your `/usr' filesystem filling up as a result of
stuff in spool queues.
The main configuration file is `/etc/printcap'. Network printing also
uses `/etc/hosts.allow' and `/etc/hosts.lpd'.
By now everyone should have libraries and binaries that look for
config files in `/etc'. If you chose to keep your configs somewhere else
(`/conf' or `/usr/etc' for example) then `/etc' must contain a symlink
to the real file. If you still have a system which looks for files in
`/usr/etc' or `/etc/inet' your system is way out of date and you should
upgrade.
File: Printing-HOWTO.info, Node: lpd not working, Next: Where Do I Get A Printcap For Printer Model xxxxx?, Prev: lpd files and permissions, Up: LPR
lpd not working
===============
If `ps ax' does not reveal a `lpd' then you daemon has died (or was
never started) - usually a sign that it couldn't create its lockfile,
or was unable to find `/etc/services'. (This will happen if you tried
to start it before all your filesystems were mounted).
If `lpr' works only for root then you've probably got a permission
problem.
If you cant even `cat' files to the printer then you may be using
the wrong device name for the printer in `/etc/printcap' *Note Printer
device names:: or you may need to fiddle with `tunelp'. *Note hardware
and drivers::.
If you get "jobs queued, but cannot start daemon" or "lpc: connect:
No such file or directory" while `lpd' is running then you are having
trouble with the socket connection to `lpd'. "start" in the context of
this error really means "wake". This problem has come and gone
thoughout the history of Linux - I don't really understand this but it
stems from an erroneous interaction between the networking stuff and
"Unix domain" (non-network) sockets. Usually it has only shown up when
the network is incorrectly configured. If you're not really on a
network it is usually adequate just to have the following somewhere in
your startup.
ifconfig lo localhost
route add localhost
You'll also need to have the `/etc/hosts' file. There's no need to
run any daemons.
There is second and much more understandable way to produce this
error - use a mixture of components from different releases of lpd that
use different names for the Unix domain socket (new stuff uses
`/tmp/.printer', obsolete stuff `/dev/printer'). (For some time SLS was
released this way).
At the time of writing I am quite unable to reproduce this error - I
am using my debugged version of the net-2 lpd compiled with gcc-2.4.5
and libc-4.4.4 on kernel 0.99.14.
File: Printing-HOWTO.info, Node: Where Do I Get A Printcap For Printer Model xxxxx?, Next: The Semantics of /etc/printcap, Prev: lpd not working, Up: LPR
Where Do I Get A Printcap For Printer Model xxxxx?
This question is essentially meaningless so please don't ask it on
usenet *Note The Semantics of /etc/printcap::.
File: Printing-HOWTO.info, Node: The Semantics of /etc/printcap, Next: The Syntax of /etc/printcap, Prev: Where Do I Get A Printcap For Printer Model xxxxx?, Up: LPR
The Semantics of `/etc/printcap'
================================
Given the similarity in appearance and name between `/etc/termcap'
and `/etc/printcap' one could be forgiven for assuming that they
contain analogous infomation. This is not the case. Whereas
`/etc/termcap' contains informations about terminal *types* - (mostly
escape seqences) printcap contains information about *specific*
printers (like the directory that holds the spool queue, the device
name of the printer and what room it's in). The information about a
printer model's escape sequences and so on are held in the various
"filters" which are programs called by `lpd' to drive the printer.
`/etc/printcap' simply gives the locations of these filters. For
details RTFM(printcap). [Alternatively the net-HOWTO has a summary of
some of the more important fields.]
One last point - you should always specify `suppress header' `:sh:'
unless you have a *text* (not PostScript) printer and want banners. On
a text printer they are usually a waste of time and paper. On a
PostScript printer they usually stop your printer working. *Note
Burst/banner pages::.
File: Printing-HOWTO.info, Node: The Syntax of /etc/printcap, Next: An /etc/printcap gotcha, Prev: The Semantics of /etc/printcap, Up: LPR
The Syntax of `/etc/printcap'
=============================
Ideally RTFM(termcap) (yes, I said *termcap*) but since most people
don't have TFM(termcap) here are the essentials.
Lines starting with `#' are comments (as you might have guessed).
For each printer usable from the `lpr' command on your system there
is one logical line in the file. For the sake of readability each
logical line may be spread over several physical lines by making the
last character on all but the last physical line a backslash.
Each logical line has the following format:
NAME1|NAME2|NAME3:STRING_CAPABILITY=STRING:\
:NUMERIC_CAPABILITY#NUMBER:BOOLEAN_CAPABILITY:
The leading spaces and colon on the second line are for readability
only.
A printer can have as many names as you like but conventionally the
final name is used as a longhand description of the printer. (Still
people are free to say `lpr -P "grotty teletype in room 213"' if that's
the description you've given.) One of the names of your default printer
must be `lp'.
The list of capabilities can be as long as needed and the order is
not significant. Each "capability" is denoted by a two character code.
(The name "capability" comes form the file format's termcap heritage -
parameter or attribute would be a more sensible terms.) [Note from Ross
Biro: capabilities with 3 character names don't work properly which is
why the serial port stuff in the old binaries failed.] Capabilities
having string value and have a `=' delimiter between the capability
name and the value while those having a numeric value use a `#'
(actually they can use either a `#' or an `='). Boolean "capabilities"
are true if they appear in the list and false if they do not.
Special characters in a string value can be expressed using
backslash-escaped sequences as in C; in addition, `\E' stands for ESC.
`^' is also a kind of escape character; `^' followed by CHAR stands for
the control-equivalent of CHAR. Thus, `^a' stands for the character
control-a, just like `\001'. `\' and `^' themselves can be represented
as `\\' and `\^' respectively. `\:' for `:' seems to work but the
source code contains a warning that it can confuse the parser and