Next Previous Contents

11. Configuration File lpd.conf and Options

The values in the LPRng configuration file (default: /etc/lpd.conf) override the compile time default values for printcap options. See the Index To All The Configuration and Printcap Options for an index to a complete list of configuration options.

11.1 Configuration File Format

The LPRng distribution contains a template lpd.conf file which can be installed as /etc/lpd.conf. The configuration file has the following format:

# lpd.conf generated from  on Wed Apr  7 07:59:48 PDT 1999

#   The values in this file are the default values.
#   If you modify the file,  set the value to something other than the default
#   For example, '# default force_localhost' means the 'force_localhost' option
#    change this to 'force_localhost@' to have the opposite effect.

# Purpose: always print banner, ignore lpr -h option
#   default ab@
# change ---
ab
# Purpose: query accounting server when connected
#   default achk@
# Purpose: accounting at end (see also af, la, ar, as)
#   default ae=jobend $H $n $P $k $b $t
# Purpose: name of accounting file (see also la, ar)
#   default af=
...

The options are set exactly as for a printcap file, but do not require a leading colon (:).

To change the default value of an option, remove the comment character and edit the entry as shown in the above example.

To force the lpd server to use the new options, use the lpc reread command.

11.2 Configuration Information

In order to protect system security, the /etc/lpd.conf and /etc/printcap files should be read only.

For testing purposes when LPRng is compiled with the -DGET_ENV option LPRng uses the value of the LPD_CONF environment variable as the path to the lpd.conf file. This is a security loophole, and should not be used when running SETUID ROOT or as ROOT.

11.3 Configuration Options

The following variables are used to set default behavior for the LPRng software, or are commonly used for configuration of LPRng operations.

default_format

Default format for printing. Usually, default_format=f, but setting it to default_format=l will cause all files spooled by lpr to be spooled as binary files.

default_permission=ACCEPT

The default permissions to use when checking for printing or other permissions.

default_priority=A

The default priority for a print job.

default_remote_host=localhost

The default lpd server host.

default_tmp_dir=/tmp

The default directory for temporary files.

This option can be used to specify a default printer. If no value is given (default), the first printer in the printcap file will be used when no printer is specified.

domain_name=domain.name

You will only need to set this if LPRng can't determine your hosts domain name itself. This is usually a desperation option when DNS or some other database system is not available. The value of the $USER environment variable will be used as the return address.

11.4 The Record Queue Name qq and force_queuename flags

Options used:

The printcap information consists of the printer name and aliases; when a job is spooled to a printer alias, it is actually spooled to the main printer entry.

The qq use queuename option or its alias use_queuename tells LPRng to record the queue name that a job was queued to, and make it available to other software for processing. The force_queuename=... entry forces this name to be used. This capability has some interesting possibilities, as shown below.

pr1_landscape|pr1_portrait|pr_raw:lp=pr@host:qq

If a job is printed using lpr -Ppr1_landscape, then pr1_landscape will be recorded as the spool queue name by the LPRng software.

Later, when the job is processed by a filter, the filter will be invoked with a -Qpr1_landscape command line option. The filter can use the name of the queue to enable say, landscape, portrait, or raw orientations.

john|tom|frank:lp=pr@host:force_queuename=office

This printcap entry forces the queuename to be office; this information could be used by a central routing facility to process the information is a suitable manner.

11.5 The check_for_nonprintable Flag

Options used:

Normally, lpr checks an f format file for non-printable characters (i.e., escape characters) at the start of the print file. Disabling this check allows you to print executable files, etc., which can cause extreme abuse of your printer.

Disabling can be done on a single printcap basis, or you can do this on a global basis by modifying the configuration information (see lpd.conf).

The ml value specifies the number of characters that are to be checked. Clearly, if it is 0, none will be checked.

11.6 The rg Restrict Use to Group Members Option

Options used:

The rg value specifies a list of groups. If this value is present use of a printer or operation is restricted to only users in a particular group.

This was a wimpy attempt to do restrictions on print facilities. The -Ppr@host option overrides this check, unless the rg value is put in the LPRng defaults.

However, it does provide a simple tool to have clients do some form of permissions checking that only the lpd server could normally do.

11.7 The fx Allowed Formats Option

Options used:

The fx option restricts the formats supported by a spool queue. The lpr program uses these to check if a requested format is supported. By default, all formats are supported.

11.8 Fixing Bad Control Files and Metacharacters

Options used:

RFC1179 defines a simple protocol and standard for print jobs to be interchanged between print spooling systems. Unfortunately, there were some major mistakes in not specifying the exact form that text would take when placed in the control file.

In addition, there are some simple coding errors that have been made, but due to their wide distribution in major vendors software, need to be accommodated. See reverse_lpq_format for an example.

By default, LPRng will brutally convert a non-conforming RFC1179 control file into one that is acceptible to most, if not all, existing RFC1179 implementation.

In order to prevent problems with LPRng ruthlessly purges all characters but upper and lower case letters, spaces, tabs, and -_.@/:()=,+-% from the control file, replacing suspicious characters with '_'.

For some installations, the default set of safe characters may be overly restrictive. For example, vintage software may generate files with # characters in the J line of the control file. The replacement of this character may cause other things to stop working.

The safe_chars option allows the user to specify an additional set of safe characters in the lpd.conf configuration file(s). For example, safe_chars=#" would allow the # and " characters to appear in the control file.

In addition, LPRng will ruthlessly regenerate control file entries and data file names so that they are compliant with all known RFC1179 implementations.

11.9 Using the bk Option and Control File Filters

Options:

One of the more serious problems is when a print spooler (LPR) program does not generate print jobs in a manner compatible with a remote system.

While LPRng performs checks for improper implementations of RFC1179, it will try to accept a job even under the most severe abuse of the protocol. However, other spoolers are not so forgiving.

Some spoolers require that the contents of the control file be in exactly the order that the original 1988 BSD LPR software generated them. While some entries can be missing, all the entries present in the file must be in an explicit order.

The bk (Berkeley LPD compatible control file) option causes LPR and LPD to reformat the control file, removing objectionable entries. The control file of a job being sent to a remote printer will have its control file entries restricted to letters in (and the same order) as HPJCLIMWT1234.

However, there are some very odd commercial implementations that require more information than is present. To assist with this, the control_filter option can be used. This specifies a program that will process the control file before it is sent to a remote destination. See Filters for details on filter operation, and Control Filters for details on the point during job processing when the control_filter is used.

The control_filter program is run with the standard set of filter options. STDIN is attached to the control file and the STDOUT will be used as the control file value sent to the remote host.

The control_filter can rewrite the control file. The only restriction is that it cannot modify the names or delete datafiles. Here is a small snip of PERL code that shows how to rewrite the control file:

# you need to get PERL to do a 'dup' call on FD 0
$status = 0;
@cf_lines = <STDIN>;
# mess about with the control file
foreach $line (@cf_lines) {
   # or whatever you want
   print STDOUT $line;
} 
exit $status;

The exit code of the control_filter is used to determine whether to proceed in processing. See Errorcodes for details.

11.10 Maximum Copies

Options used:

The mc value specifies the maximum number of copies of a job that can be printed on a printer using the lpr -Knn or lpr -#nn option.

11.11 The minfree Minimum Spool Queue Space Option

Options used:

If this value is non-zero, then the lpd receiving server checks to see that there is the specified number of Kbytes of file space available before accepting a job.

11.12 Debugging

Options used:

The LPRng software has a very powerful debugging capability. Since most printing problems occur on remote systems where it is impossible to run debuggers, and since most systems do not do core dumps of SETUID ROOT programs, the LPRng software provides a very verbose set of log file trace messages.

First, serious errors or other information are logged using the syslog() facilities. If these are not present on a system, then the messages are logged to the device specified by syslog_device.

For client programs, the debugging options are specified on the command line and output is directed to STDERR. For the lpd server, debugging commands can be specified on the command line OR as the db=options printcap value. Output is directed to the log file (lf option value, default log).

A typical debug entry has the format 2,network+1,database. This sets the general debugging level to 2, network debugging to 1 and the database debugging level to the default. The following debugging options and levels are supported.

The full_time flag forces the logging and other information which has timestamps to have a full (year, month, day, etc.) timestamp. The ms_time_resolution flag forces millisecond time resolution in the time stamp. The use_date flag forces a date value to be placed in a control file if there is none.

The use_info_cache (default ON) causes lpd to cache printcap and configuration information. This is desirable except when trying to change values in printcap files and test the results. By using use_info_cache@ in the configuration information, you can get immediate responses. Also, see lpc reread for another method.

11.13 LPD Specific

Options used:

These options are usually LPD specific. For example, the ipv6 specifies that the IPV6 protocol, rather than IPV4 will be used. In future versions, this may not be necessary.

The lockfile specifies the location of the lock file used by the lpd server.

The spool_dir_perms and spool_file_perms (default 0700 and 0600 respectively) values are the (numeric) permissions for the spool directory and spool files.

The spread_jobs option is obsolete. The spread_jobs option was a desperation fix to handle difficulties with the arrival of a large number of jobs with the same or close job number. The LPD server would fork children, each of whom tried to lock the job files. The spread value randomly chose a new number in the range about the original job number. However, it is still preserved for legacy systems which still have problems with file locking.

The report_server_as option allows an administrator to masquerade a server with another name. This could be useful if various load sharing activities are being carried out, or if there are problems reconfiguring DNS to cause the correct server name to be reported.

11.14 Legacy Compatibility

The following arguments have been provided for compatibility with legacy systems.

The allow_duplicate_args Option

Options used:

Some users would like duplicate LPR and LPRM command line arguments to override earlier ones, i.e. - lpr -a x -a y should be equivalent to lpr -a y

The allow_duplicate_args option allows the various client programs to have duplicate arguments. The last specified argument on the command line will override previous values.

The class_in_status Options

Options used:

Setting the class_in_status option causes the class name rather than priority to be displayed in the status information.

The reverse_lpq_format Option

Options used:

Various Solaris and other System V implementations support an RFC1179 interface to remote printers. Unfortunately, there is a problem in that when they send a status request, the status format is reversed. That is, when LONG status format is wanted, they send SHORT, and vice versa.

The reverse_lpq_format= specifies a list of printers or IP addresses for which the lpd server will return LONG status when SHORT is requested, and vice versa. For example:

reverse_lpq_format=*.eng.com,130.192.0.0/16

will cause hosts whose Fully Qualified Domain Name (FQDN) ends in eng.com or from subnet 130.192.0.0 to have reversed status returned.

The return_short_status and short_status_length Options

Options used:

In order to be compatible with non-LPRng client programs, some administrators would like lpd to return a short or brief status to normal status queries.

The return_short_status= specifies a list of printers or IP addresses for which the lpd server will return an abbreviated status when LONG status is requested. For example:

return_short_status=*.eng.com,130.192.0.0/16
short_status_length#3

will cause hosts whose Fully Qualified Domain Name (FQDN) ends in eng.com or from subnet 130.192.0.0 to get only 3 lines of detailed status returned.

The force_lpq_status Options

Options used:

In order to be compatible with non-LPRng client programs which are totally unpredictable, this allows the administrator to specify the format for LPQ status when requests arrrive.

The force_lpq_status= specifies a list of formats and printers or IP addresses for which the lpd server will return status in the sepcified format. The entry has the format KEY=list;KEY=list... where KEY is s for short and l for long format, and list is a list of hosts or IP addresses. For example:

force_lpq_status=s=pc*.eng.com,130.192.12.0/24,l=sun*.eng.com

will cause hosts whose Fully Qualified Domain Name (FQDN) matches pc*eng.com or from subnet 130.192.12.0 to get short status returned and hosts which match sun*.eng.com get long status.

The ignore_requested_user_priority and force_fqdn_host Options

Options used:

Some students... um... users... will request a high priority for their job in order to jump the queue of waiting jobs. This option will cause the lpd server to ignore the requested user priority. However, the topq operation will still be effective.

Similarly, some print spoolers do not put a FQDN host name in their control file. The force_fqdn_hostname flag will cause lpd to put a FQDN host name in.

The lpr_bsd Options

This will force the lpr -m (send mail to user) option not to take an arguement, as in the BSD lpr.


Next Previous Contents