The contents of the /etc/lpd.perms file are used to control
access to the lpd server
facilities. The model used for permission granting is similar
to packet filters. An incoming request is tested against a
list of rules, and the first match found determines the
action to be taken. The action is either ACCEPT or the request is granted, or REJECT and the request is denied. You
can also establish a default action.
The following is a sample lpd.perms file.
# allow root on server to control jobs
ACCEPT SERVICE=C SERVER REMOTEUSER=root
REJECT SERVICE=C
#
# allow same user on originating host to remove a job
ACCEPT SERVICE=M SAMEHOST SAMEUSER
# allow root on server to remove a job
ACCEPT SERVICE=M SERVER REMOTEUSER=root
REJECT SERVICE=M
# all other operations allowed
DEFAULT ACCEPT
Each line of the permissions file is a rule. A rule will
ACCEPT or REJECT a request if all of the patterns specified
in the rule match. If there is a match failure, the next rule
in sequence will be applied. If all of the rules are
exhausted, then the last specified default authorization will
be used.
The sense of a pattern match can be inverted using the NOT
keyword. For example, the rules with ACCEPT NOT REMOTEUSER=john,bill succeeds only
if the REMOTEUSER value is defined and is not john or bill.
Each entry in a rule is a keyword which has is assigned a
value or list of values followed by an optional set of
patterns that are matched against these values. The following
table is a summary of the available keywords.
Table 17-1. Permission Keywords and Purpose
Keyword
Match
DEFAULT
default result
SERVICE
Checking lpC, lpR,
lprM, lpQ, and Printing
USER
P (logname) field name
in print job control file.
REMOTEUSER
user name in request
from remote host.
HOST
DNS and IP address
information for the H (host) field name in print job
control file
REMOTEHOST
DNS and IP address
information for the connection from the remote host
making the request
IP
Alias for HOST
REMOTEIP
Alias for
REMOTEHOST
REMOTEPORT
Originating TCP/IP port
for the connection from the remote host making the
request
PORT
Alias for PORT
UNIXSOCKET
Connection is on a UNIX
socket, i.e. from localhost
SAMEUSER
USER and REMOTEUSER
matches
SAMEHOST
HOST and REMOTEHOST
matches
SERVER
request originates on
lpd server
FORWARD
destination of job is
not host
REMOTEGROUP
REMOTEUSER is in the
specified group or netgroup in the lpd server group database.
GROUP
USER is in the
specified group or netgroup in the lpd server group database.
The lpd server uses the
following algorithm to do permission checks.
The configuration information initially establishes
a default permission using the default_permission configuration value.
This is used if an explicit permission is not
determined by the other steps in this algorithm.
Each line of the permissions file is a lists of
tests (patterns) and a permission value that is used if
all of the tests (patterns) on the line are successful.
A DEFAULT line sets the default result if all lines
fail.
Each line is executed in sequence until a match is
found. The first matching line terminates the
permission checking and the corresponding permission
value is used.
Each keyword has a value (or set of values) that are
matched against a set of patterns. If the keyword does
not have a value (or the null
value) then the match will fail. Initially, all the
keywords have a null
value.
When a connection is received by the lpd server, REMOTEHOST and REMOTEPORT
are set to the the IP addresses and hostnames, and the
TCP/IP port of the host originating the IP address
respectively. REMOTEIP and IFHP are aliases for
REMOTEPORT and PORT is an alias for REMOTEPORT and are
provided for backwards compatibility with older
versions of LPRng. If the
connection was on a UNIX socket, then the UNIXSOCKET
flag is set. For example, a request originating from
10.0.0.2, port 1011 would set
REMOTEIP to 10.0.0.2 and PORT to 1011.
The REMOTEHOST value is set to the result of doing a
reverse DNS lookup on the REMOTEIP address. This value
is the list of names and ip
addresses in standard IP notation (nnn.nnn.nnn.nnn)
that are returned by the lookup. If the DNS lookup
fails then the REMOTEHOST value is set to the REMOTEIP
value. For example, lookup of 10.0.0.2 would result in
the names h2.private and patrick.private, and the only IP
address assigned to it was 10.0.0.2. The REMOTEHOST value would
then be the list h2.private,patrick.private,10.0.0.2.
The SERVICE value is set to X and then the permissions database is
scanned for a matching entry. The result is the
permission value of the first matching line or the
default permission. If the result is REJECT then the
connection is closed.
Next, a single line is read from the connection.
This line contains the request type, the print queue
name, and depending on the request type an optional
user name and options. The SERVICE value is set to R,Q,M, and C,
for a lpR, lpQ, lprM, and
lpc request respectively and
PRINTER to the print queue name.
If the request is for an lpc operation, the LPC value is set
to the name of the operation. For example, and lpc lpd operation
If the request contains a user name then REMOTEUSER
is assigned the user name.
If the request originates from the lpd server as determined by the
connection arriving from the localhost address or an address assigned
to one of the network interfaces for this host then the
SERVER value is set to true (or matches).
If the request is for an authenticated transfer,
(see Authentication and
Encryption ), then the authentication procedures
are carried out. After they have been performed, the
AUTH value is set to true, AUTHTYPE is set to the name
of the authentication method, AUTHUSER to the
authenticated identifier of the originator of the
request, and AUTHFROM to the authenticated identifier
of the originator of the connection.
Other matching keywords such as REMOTEGROUP use
values set at this time. These are discussed in the
next section.
The permission database is rescanned, this time to
see if there is permission to operate on the specified
spool queue. The permission database is first checked
to see if the requesting user has control (SERVICE=C)
permission. If they do, then they can perform any
operation on the spool queue. The scan is then repeated
for the actual request.
If there is no permission to perform the operation
then an error code and messages is returned on the
requesting connection.
If the operation is for a spool queue or server, no
other permissions checking is done. This includes the
lpq command, and most of the
lpc commands control queue
operations.
If the operation is for for individual jobs in a
spool queue, then the queue is scanned and job
information is extracted for each job in the queue. The
USER value is set to the job control file P line. The value of the H line in the control file is used to
perform a DNS lookup, and the HOST value is set to the
results of this lookup. IP is an alias for HOST, and is
retained for backwards compatibility.
The SAMEUSER value is set to true (or match) if the
REMOTEUSER value is identical to the USER value.
Similarly, SAMEHOST is set to true if the REMOTEHOST
value matches the HOST value. See the following
sections for other keywords such as GROUP.
The permission checking is done for each individual
job in a spool queue, and if it succeeds the action is
carried out on the job.
These checks are applied on the arrival of a job from an
external connection. Unfortunately, there are a set of
print spooler implementations that do not handle job
rejection due to lack of permissions. These printers will
continually and repeatedly attempt to send a job for which
there is no printing permission until the job is removed by
administrative action. To accommodate these printers, we
must accept jobs for printing and then dispose of them.
This is done by using the SERVICE=P (printing) checks.
These checks are performed after
the job has been accepted.
When a print spool is active and is printing or
forwarding jobs, before it processes a job it will read
the job control file and set the USER and HOST values as discussed in the
previous sections. It will also set the AUTH, AUTHUSER, and AUTHJOB values as well, if the job was
spooled by using an authenticated method.
The permissions database will be scanned and the
resulting permission determined. Note that the values
of the REMOTE keys are undefined, and tests using them
will have unpredictable effects.
If the job does not have permission to be printed,
it will normally be removed from the spool queue.
While this model is very simple it can handle a wide
range of situations. However, it is really based on the
simple trust that users will not impersonate other users or hosts. If
this is not the case, then more elaborate procedures based
on encryption and authentication are called for.
There is a problem with permissions checking for lpq (SERVICE=Q) requests. Since the
user name is not passed as part of the request, it is
impossible to use the REMOTEUSER clause to restrict lpq operations.
The SERVICE=R and SERVICE=P facilities are provided to handle
problems with print spoolers that do not recognize a lack of permission error code, and
will indefinitely retry sending a job to the lpd server. If this is the case, then the
SERVICE=R clause can be used to
accept jobs, and then the SERVICE=P clause will cause the lpd server to remove of the job when it
is scheduled for printing.