Home | History | Annotate | only in /src/usr.sbin/lpr/lpd
History log of /src/usr.sbin/lpr/lpd
RevisionDateAuthorComments
 1.19 07-Mar-2021  christos Add blocklist support to libwrap which enables all programs using libwrap
to block access from hosts we deny. (libwrap support from Greg A. Woods)
 1.18 10-Jan-2005  lukem Only compile in IPv6 support if ${USE_INET6} != "no"

MKINET6 is for providing IPv6 infrastructure.
USE_INET6 is for compiling IPv6 support into the programs (needs MKINET6).
 1.17 19-Oct-2003  lukem #define _PATH_BIN_RCMD in common_source/pathnames.h rather than using
wacky Makefile rules to compile rcmd.c
 1.16 18-Sep-2002  lukem use NETBSDSRCDIR as appropriate
 1.15 12-Aug-2002  itojun add libwrap support for lpd (you need to pass all tests to print,
so you will want "+" in hosts.lpd then restrict by hosts.allow/deny).
setsockopt(SO_REUSEPORT) while i'm here.
 1.14 05-Jun-2000  mycroft branches: 1.14.4;
Get rid of the stupid hack that makes this lose when ${CC} is more than one word.
 1.13 31-May-2000  enami Just remove the first word so that rcmd.c compiles even if the command line
contains same substrings with the name of compiler.
 1.12 30-May-2000  itojun usr.sbin/lpr/lpd now compiles lib/libc/net/rcmd.c on its own, to avoid
use of non-exported function __ivaliduser{,_sa}().

we cannot make __ivaliduser{,_sa}() static yet, since doing that would choke
compiled lpd binaries. we should do it on next libc major version bump.
added a memo on lib/libc/shlib_version.
 1.11 10-Oct-1997  lukem branches: 1.11.10;
only compile common_source/* once (25% faster), remove unused printcap.c
 1.10 08-May-1997  gwr Back out the .PATH.c changes. The .depend problem (and others)
will be fixed using the new .NOPATH make feature instead.
 1.9 06-May-1997  gwr Use .PATH.c: ...
 1.8 15-Nov-1995  pk Add RCSIDs
 1.7 03-Oct-1995  hpeyerl -- convert sgtty to termios. From: Scott Bartram <scottb@iis.net>
-- Use seteuid() to only give lpr, lprm, lpq and lpc root when they
need it from matthew green <mrg@mame.mu.oz.au>
 1.6 22-Dec-1994  cgd specify man pages the new way.
 1.5 18-May-1994  cgd clean up that import. no rcsids yet.
 1.4 28-Jan-1994  cgd don't need -lutil
 1.3 30-Jul-1993  mycroft Add RCS identifiers.
 1.2 15-Jun-1993  mycroft And just one more.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 18-May-1994  cgd lpr from 4.4-Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.14.4.1 21-Oct-2003  jmc Using hand patch from Havard (requested by thorpej in ticket #946)

* Use STDOUT_FILENO instead of 1.
* Pass the file descriptor to request_init() (libwrap) so that
it can actually do something useful later in fromhost().
 1.12 30-Aug-2011  joerg static, __printflike, __dead
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.10 14-Jul-2002  wiz Unifdef __STDC__. Remove __P(). ANSIfy.
 1.9 24-Feb-2000  itojun (rcmd.c) to make Zoularis happier, pass sa_len separately from sockaddrs.
this changes function prototype for __ivalid*.
This commit breaks binary compatibility for __ivalid*. I believe this can be
forgiven due to the following:
- this is not really exported function. no function prototype is in headers.
function name starts with underbars. No third-party applications are
expected to use it.
- the function was introduced very recently, when rcmd.c was made IPv6-ready.
- the only customer in NetBSD tree is lpd.

(lpd.c) sync with rcmd.c change.
 1.8 27-Jan-2000  itojun IPv6 support, using rcmd-family funciton added.
NetBSD PR: 9050
From: Feico Dillema
 1.7 05-Oct-1997  mrg - WARNS?=1
- be safe with unlinking files (from freebsd)
- remove register
- clean up $NetBSD$'s.
- use inet_ntoa() in one place (from openbsd)
- nul terminate after a bunch of strncpy()'s
- #ifdef __STDC__ rather than #if (from freebsd)
- be safe with a bunch of string operations (from freebsd)
- use warn()/err() over home grown versions (some from freebsd)
- rename warn() to nodaemon() to remove conflict with above
- check errno from failed kill(2) against ESRCH (from freebsd)
- use getopt() rather than home grown versions (from freebsd)
- clean up a bunch of man pages (some from freebsd)
- check for hostname spoof (from freebsd)
- use POSIX wait() interfaces
- use sysconf(_SC_OPEN_MAX) in preference to NOFILE (from freebsd)
- deal with fork() failure
- index/rindex -> strchr/strrchr (some from freebsd)
- add B57600 and B115200 speeds (from freebsd)
- some KNF
- be safe with files passed in over the network (some from freebsd)
- check return value of malloc(), calloc() and strdup()
 1.6 10-Jul-1997  veego Add #include <stdio.h> for struct FILE.
 1.5 10-Jul-1997  mikel add prototypes for ksearch(), msearch(), and __ivaliduser()
 1.4 15-Nov-1995  pk Add RCSIDs
 1.3 05-Oct-1995  mycroft Fix type errors.
 1.2 03-Oct-1995  hpeyerl -- convert sgtty to termios. From: Scott Bartram <scottb@iis.net>
-- Use seteuid() to only give lpr, lprm, lpq and lpc root when they
need it from matthew green <mrg@mame.mu.oz.au>
 1.1 18-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 18-May-1994  cgd lpr from 4.4-Lite
 1.7 28-Nov-2005  christos - WARNS = 4
- factor out commonly used code.
- constify
- use warn/warnx instead of printf
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.5 14-Jul-2002  wiz Unifdef __STDC__. Remove __P(). ANSIfy.
 1.4 09-Oct-2001  mjl Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.
ANSIfy and constify.
 1.3 20-Oct-1997  scottr Add support for DTR/CTS flow control, from Bill Studenmund.
 1.2 17-Jul-1997  mikel use <sys/cdefs.h> __RCSID macro, add prototype for local c_key function
 1.1 03-Oct-1995  hpeyerl -- convert sgtty to termios. From: Scott Bartram <scottb@iis.net>
-- Use seteuid() to only give lpr, lprm, lpq and lpc root when they
need it from matthew green <mrg@mame.mu.oz.au>
 1.36 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.35 09-Nov-2011  wiz Use Sq, and remove trailing whitespace.
 1.34 09-Nov-2011  is If hosts.lpd contains '+', don't insist on reverse DNS == forward DNS.
 1.33 22-Jan-2006  wiz branches: 1.33.42;
New sentence, new line. Bump date for previous. Properly case PostScript.
 1.32 20-Jan-2006  garbled Add control file documentation for 'o' handling, and fix the
documentation on the DVI handling, the correct letter is 'd' not 'r'.
 1.31 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.30 15-Mar-2003  wiz IPv4/IPv6, not IPV4/IPV6.
 1.29 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.28 06-Jan-2003  wiz Stanford, not Standford. From Chad Loder.
 1.27 03-Sep-2002  abs When -r is given actually pass the file through of, and also enable if.
 1.26 12-Aug-2002  wiz Minor mdoc nit.
 1.25 12-Aug-2002  itojun add libwrap support for lpd (you need to pass all tests to print,
so you will want "+" in hosts.lpd then restrict by hosts.allow/deny).
setsockopt(SO_REUSEPORT) while i'm here.
 1.24 31-Jul-2002  jschauma Fix typo pointed out by haes at shrubbery dot net in PR bin/17396
"filter to be use" -> "filter to be used"
 1.23 08-Feb-2002  ross branches: 1.23.2;
Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.22 19-Jan-2002  wiz Convert .Xr to non-existing program to Ic.
 1.21 11-Aug-2001  mjl Add -W parameter to lpd to disable check for a reserved port,
this is needed to get Win2k print to a NetBSD box. Heavily
inspired by FreeBSD.
 1.20 05-Apr-2001  wiz Improve markup, and add sections to xrefs, as well as the obligatory
whitespace fixes.
 1.19 07-Nov-2000  lukem fix up various .Nm abuses:
- keep the case consistent between the actual name and what's referenced.
e.g, if it's `foo', don't use '.Nm Foo' at the start of a sentence.
- remove unnecessary `.Nm foo' after the first occurrence (except for
using `.Nm ""' if there's stuff following, or for the 2nd and so on
occurrences in a SYNOPSIS
- use Sx, Ic, Li, Em, Sq, and Xr as appropriate
 1.18 03-Oct-2000  scw Add a "-b" option to specify one or more local addresses to bind
to instead of the default INADDR_ANY.
 1.17 10-Apr-2000  mrg branches: 1.17.4;
- fix usage message to current reality.
- pull over "lpd [port]" code from freebsd's lpr code.
- use posix signal handling.
 1.16 11-Dec-1999  mrg xref setsockopt (from freebsd) and hosts.equiv.
 1.15 10-Dec-1999  mrg tsk. tsk. document new features i added.
 1.14 22-Mar-1999  garbled branches: 1.14.6;
More and more .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Many more to
come.
 1.13 07-Mar-1999  mycroft Clean up SYNOPSIS formatting.
 1.12 28-Apr-1998  fair Change occurrences of "UNIX" to .Ux or .At as appropriate.
 1.11 09-Oct-1997  mrg document -d, -s. remove bogus #port. fix getopt().
 1.10 05-Oct-1997  mrg - WARNS?=1
- be safe with unlinking files (from freebsd)
- remove register
- clean up $NetBSD$'s.
- use inet_ntoa() in one place (from openbsd)
- nul terminate after a bunch of strncpy()'s
- #ifdef __STDC__ rather than #if (from freebsd)
- be safe with a bunch of string operations (from freebsd)
- use warn()/err() over home grown versions (some from freebsd)
- rename warn() to nodaemon() to remove conflict with above
- check errno from failed kill(2) against ESRCH (from freebsd)
- use getopt() rather than home grown versions (from freebsd)
- clean up a bunch of man pages (some from freebsd)
- check for hostname spoof (from freebsd)
- use POSIX wait() interfaces
- use sysconf(_SC_OPEN_MAX) in preference to NOFILE (from freebsd)
- deal with fork() failure
- index/rindex -> strchr/strrchr (some from freebsd)
- add B57600 and B115200 speeds (from freebsd)
- some KNF
- be safe with files passed in over the network (some from freebsd)
- check return value of malloc(), calloc() and strdup()
 1.9 16-Jul-1997  mikel xref pac(8) not nonexistent pac(1), sort xrefs
 1.8 09-Jul-1997  jtc Changed /var/spool/* to /var/spool/output/*, to be consistant with reality.
 1.7 21-Sep-1996  perry close out pr 2771, which added a -s ("secure") flag to lpd -- makes
lpd run in a mode where the it listens only to the local unix domain
socket and not to the network. Changes are similar but not identical
to the supplied patches.
 1.6 16-Jun-1996  pk `/dev/printer' => `/var/run/printer' (PR#2552).
Also, change `.Os 4.2' => `.Os 4.4' (this man page is from 4.4 lite), and
for now, refer to the "BSD 4.3 Line printer manual", because that is what
we now have in lpr/SMM.doc (SMM.doc needs updating too).
 1.5 15-Nov-1995  pk branches: 1.5.4;
Add RCSIDs
 1.4 18-May-1994  cgd clean up that import. no rcsids yet.
 1.3 14-Jan-1994  jtc Fix spelling errors
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 18-May-1994  cgd lpr from 4.4-Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.2 26-Jan-1997  rat Update from trunk. Fixes security bugs.
 1.5.4.1 14-Nov-1996  thorpej Pull up from trunk:

> revision 1.6
> date: 1996/06/16 22:36:59; author: pk; state: Exp; lines: +4 -4
> `/dev/printer' => `/var/run/printer' (PR#2552).
> Also, change `.Os 4.2' => `.Os 4.4' (this man page is from 4.4 lite), and
> for now, refer to the "BSD 4.3 Line printer manual", because that is what
> we now have in lpr/SMM.doc (SMM.doc needs updating too).
 1.14.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.17.4.3 15-Dec-2002  he Pull up revision 1.27 (via patch, requested by abs):
When ``-r'' is given, actually pass the file through ``of'' and
also enable ``if''.
 1.17.4.2 08-Oct-2001  he Apply patch (requested by msaitoh):
Add missing command name.
 1.17.4.1 26-Apr-2001  he Pull up revisions 1.19-1.20 (via patch, requested by wiz):
Cleanup Nm uses, add sections to cross references, and whitespace
fixes, and other fixes.
 1.23.2.2 21-Oct-2003  jmc Using hand patch from Havard (requested by thorpej in ticket #946)

* Use STDOUT_FILENO instead of 1.
* Pass the file descriptor to request_init() (libwrap) so that
it can actually do something useful later in fromhost().
 1.23.2.1 07-Dec-2002  he Pull up revision 1.27 (via patch, requested by abs in ticket #906):
When ``-r'' is given, actually pass the file through ``of'',
and also enable ``if''.
 1.33.42.1 10-Nov-2011  yamt sync with head
 1.60 26-Apr-2023  kre Us daemons don't need no unions - just wait, the easy way.
 1.59 08-Apr-2022  andvar fix various typos, mainly in comments, but also log messages, docs, game text.
 1.58 04-May-2017  sevan Drop main() prototype.
 1.57 09-Nov-2011  is branches: 1.57.30;
If hosts.lpd contains '+', don't insist on reverse DNS == forward DNS.
 1.56 30-Aug-2011  joerg branches: 1.56.2;
static, __printflike, __dead
 1.55 21-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.54 18-Jan-2006  garbled branches: 1.54.20;
If we set SIGCHLD to SIG_IGN then any wait()'s on the child processes will
return -1. This causes filters to fail because we get a value for
child_pid we weren't expecting. Set SIGCHLD to SIG_DFL instead to clear
the reapchild setting when forking the child lpd.
 1.53 02-Dec-2005  yamt constify.
 1.52 28-Nov-2005  christos - WARNS = 4
- factor out commonly used code.
- constify
- use warn/warnx instead of printf
 1.51 02-Jun-2005  lukem Ensure s is initialized before testing (none of the sockets may be ready
so it might not be setup).
Detected with gcc -Wuninitialized.
 1.50 30-Oct-2004  dsl branches: 1.50.2;
Add (unsigned char) cast to ctype functions
Some of this code could usefully be converted to use strtoul() and/or
some small helper functions.
 1.49 16-Oct-2003  itojun safer use of realloc
 1.48 16-Oct-2003  itojun safer realloc.
sizeof() for malloc was mistaken in socksetup().
 1.47 01-Sep-2003  itojun plug memory leak. oenbsd-pr-3425
 1.46 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.45 17-May-2003  itojun use strlcpy/strlcat.
[fix off-by-one in displayq.c]
 1.44 26-Oct-2002  thorpej * Use STDOUT_FILENO instead of 1.
* Pass the file descriptor to request_init() (libwrap) so that
it can actually do something useful later in fromhost().
 1.43 24-Sep-2002  itojun set IPV6_V6ONLY socket option for AF_INET6 socket, to avoid
complicated access control issue due to IPv4 mapped address.
 1.42 20-Sep-2002  lukem cast "%ld", xxx.tv_sec to a long
 1.41 19-Sep-2002  mycroft Simplify the accept() code a little -- sockaddr_storage is fine for both
AF_LOCAL and AF_INET{,6}.
 1.40 19-Sep-2002  mycroft If we exit because the pid file is locked, syslog that.
 1.39 19-Sep-2002  mycroft select() -> poll(), nanosleep()
 1.38 12-Aug-2002  itojun add libwrap support for lpd (you need to pass all tests to print,
so you will want "+" in hosts.lpd then restrict by hosts.allow/deny).
setsockopt(SO_REUSEPORT) while i'm here.
 1.37 11-Aug-2002  grant specify the reason when aborting with "Malformed from address",
suggested by Matt Green.
 1.36 09-Aug-2002  itojun die if fd_set overruns
 1.35 14-Jul-2002  wiz Unifdef __STDC__. Remove __P(). ANSIfy.
 1.34 09-Jul-2002  hubertf This fixes various little problems in the lpd source.

lpd.c bogus 'c' option in getopt option string

printjob.c spelling "prstatic inter" -> "printer"
finish ANSIfication

recvjob.c finish ANSIfication

Patch contributed by Brian Ginsbach <ginsbach@cray.com> in PR 17520
 1.33 21-Jan-2002  wiz branches: 1.33.2;
deamon -> daemon
 1.32 21-Nov-2001  wiz "than" instead of "then".
 1.31 09-Oct-2001  mjl Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.
ANSIfy and constify.
 1.30 11-Aug-2001  mjl Add -W parameter to lpd to disable check for a reserved port,
this is needed to get Win2k print to a NetBSD box. Heavily
inspired by FreeBSD.
 1.29 25-Jun-2001  mrg printer of "" becomes the DEFLP (the default printer, "lp")
 1.28 28-Mar-2001  simonb 80 column police.
 1.27 19-Feb-2001  cgd convert to use getprogname()
 1.26 02-Feb-2001  itojun listen to the port number specified on argument, as advertised
in document. part of PR 12112 from feico@pasta.cs.uit.no.
 1.25 03-Oct-2000  itojun don't give result of function directly into syslog, use "%s".
 1.24 03-Oct-2000  scw Free the bind-address list entries, as well as the list itself.
 1.23 03-Oct-2000  scw Add a "-b" option to specify one or more local addresses to bind
to instead of the default INADDR_ANY.
 1.22 10-Apr-2000  mrg branches: 1.22.4;
- fix usage message to current reality.
- pull over "lpd [port]" code from freebsd's lpr code.
- use posix signal handling.
 1.21 24-Feb-2000  itojun (rcmd.c) to make Zoularis happier, pass sa_len separately from sockaddrs.
this changes function prototype for __ivalid*.
This commit breaks binary compatibility for __ivalid*. I believe this can be
forgiven due to the following:
- this is not really exported function. no function prototype is in headers.
function name starts with underbars. No third-party applications are
expected to use it.
- the function was introduced very recently, when rcmd.c was made IPv6-ready.
- the only customer in NetBSD tree is lpd.

(lpd.c) sync with rcmd.c change.
 1.20 27-Jan-2000  itojun IPv6 support, using rcmd-family funciton added.
NetBSD PR: 9050
From: Feico Dillema
 1.19 23-Dec-1999  mjl Fix null terminating the wrong buffer curtesy of similar variables
mixed up. Seemed to never have any ill effect, but then...
Noted by Tetsuya Furukawa in FreeBSD PR/15604.
 1.18 07-Dec-1999  mrg - add timeouts to displayq(), rmremote(), sendfile() and response(),
and use these timeout in the lpq, lpd and lprm programs.

these stop hung remote printers that accept tcp connections but do
not process jobs from hanging the whole system and letting the sysadmin
have a clue about what is going on with this rogue printer.

- add a -r flag to lpd to allow `of' filters for remote jobs.

i know there are ways around this, but i just don't care.

- add a -f flag to lpf to add missing carriage returns.

useful when printing UNIX files to an, eg, LaserWriter that wants CR's
as well as LF's in raw text. stair-stepped text is no fun.

- implement child process accounting: we just have a limit on the number
of children we can have (settable by the sysadmin), and we sleep when
this number is reached. this can reduce malicious not-so-malicious
attacks on the print server by a rogue remote client..

- use setproctitle() where appropriate so the sysadmin has a clue about
what each of the lpd's here are doing.

this was useful to help diagnose a problem (that the above child process
accounting change reduces the lossages of) where a rogue client was
attempting "lpq" operations on one stuck queue in rapid succession,
causing the lpd server to be extremely slow, due to the large number
of lpd processes running.


i have been running these changes in production for about a year.
 1.17 18-Jul-1998  lukem branches: 1.17.6;
use AF_LOCAL instead of AF_UNIX
 1.16 06-Jul-1998  mrg - use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
 1.15 18-Oct-1997  lukem use memcmp/memset/memmove instead of bcmp/bzero/bcopy
 1.14 09-Oct-1997  mrg document -d, -s. remove bogus #port. fix getopt().
 1.13 05-Oct-1997  mrg - WARNS?=1
- be safe with unlinking files (from freebsd)
- remove register
- clean up $NetBSD$'s.
- use inet_ntoa() in one place (from openbsd)
- nul terminate after a bunch of strncpy()'s
- #ifdef __STDC__ rather than #if (from freebsd)
- be safe with a bunch of string operations (from freebsd)
- use warn()/err() over home grown versions (some from freebsd)
- rename warn() to nodaemon() to remove conflict with above
- check errno from failed kill(2) against ESRCH (from freebsd)
- use getopt() rather than home grown versions (from freebsd)
- clean up a bunch of man pages (some from freebsd)
- check for hostname spoof (from freebsd)
- use POSIX wait() interfaces
- use sysconf(_SC_OPEN_MAX) in preference to NOFILE (from freebsd)
- deal with fork() failure
- index/rindex -> strchr/strrchr (some from freebsd)
- add B57600 and B115200 speeds (from freebsd)
- some KNF
- be safe with files passed in over the network (some from freebsd)
- check return value of malloc(), calloc() and strdup()
 1.12 05-Oct-1997  mrg merge 4.4 lite2
 1.11 17-Jul-1997  mikel use <sys/cdefs.h> __COPYRIGHT and __RCSID macros
include <arpa/inet.h> for inet_ntoa() prototype, nuke local declaration
 1.10 10-Jul-1997  mikel index array with int, not char
 1.9 09-Dec-1996  mrg remove unsafe calls to strcpy(), strcat(), and sprintf(). some KNF.
 1.8 21-Sep-1996  perry close out pr 2771, which added a -s ("secure") flag to lpd -- makes
lpd run in a mode where the it listens only to the local unix domain
socket and not to the network. Changes are similar but not identical
to the supplied patches.
 1.7 24-Apr-1996  mrg branches: 1.7.4;
Stylistic changes.
 1.6 15-Nov-1995  pk Add RCSIDs
 1.5 03-Oct-1995  hpeyerl -- convert sgtty to termios. From: Scott Bartram <scottb@iis.net>
-- Use seteuid() to only give lpr, lprm, lpq and lpc root when they
need it from matthew green <mrg@mame.mu.oz.au>
 1.4 18-May-1994  cgd clean up that import. no rcsids yet.
 1.3 10-Nov-1993  cgd bzero structs before using; fix from theo
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 05-Oct-1997  mrg lite-2
 1.1.1.2 18-May-1994  cgd lpr from 4.4-Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.4.1 26-Jan-1997  rat Update from trunk. Fixes security bugs.
 1.17.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.22.4.3 24-Sep-2002  itojun usr.sbin/lpr/lpd/lpd.c 1.43 via patch

Set IPV6_BINDV6ONLY socket option for AF_INET6 socket, to avoid
complicated access control issue due to IPv4 mapped address.

(itojun)
 1.22.4.2 26-Oct-2001  jhawk Pull up revision 1.29 (requested by mrg):
Use DEFLP ("lp") for printer when printer is zero-length.
 1.22.4.1 03-Oct-2000  itojun pullup: part of 1.24 -> 1.25 (approved by releng-1-5)
(this may not raise a real issue)

> don't give result of function directly into syslog, use "%s".
 1.33.2.2 21-Oct-2003  jmc Using hand patch from Havard (requested by thorpej in ticket #946)

* Use STDOUT_FILENO instead of 1.
* Pass the file descriptor to request_init() (libwrap) so that
it can actually do something useful later in fromhost().
 1.33.2.1 02-Oct-2002  lukem Pull up revision 1.43 (via patch) (requested by itojun in ticket #857):
set IPV6_V6ONLY socket option for AF_INET6 socket, to avoid
complicated access control issue due to IPv4 mapped address.
 1.50.2.1 15-Jun-2005  snj Pull up revision 1.51 (requested by lukem in ticket #416):
Ensure s is initialized before testing (none of the sockets may be ready
so it might not be setup).
Detected with gcc -Wuninitialized.
 1.54.20.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.56.2.1 10-Nov-2011  yamt sync with head
 1.57.30.1 11-May-2017  pgoyette Sync with HEAD
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.6 09-Oct-2001  mjl Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.
ANSIfy and constify.
 1.5 17-Jul-1997  mikel use <sys/cdefs.h> __RCSID macro
 1.4 15-Nov-1995  pk Add RCSIDs
 1.3 18-May-1994  cgd clean up that import. no rcsids yet.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 18-May-1994  cgd lpr from 4.4-Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7 22-Oct-2006  christos use c99 initializers
 1.6 28-Nov-2005  christos - WARNS = 4
- factor out commonly used code.
- constify
- use warn/warnx instead of printf
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.4 09-Oct-2001  mjl Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.
ANSIfy and constify.
 1.3 20-Oct-1997  scottr Add support for DTR/CTS flow control, from Bill Studenmund.
 1.2 17-Jul-1997  mikel use <sys/cdefs.h> __RCSID macro
 1.1 03-Oct-1995  hpeyerl -- convert sgtty to termios. From: Scott Bartram <scottb@iis.net>
-- Use seteuid() to only give lpr, lprm, lpq and lpc root when they
need it from matthew green <mrg@mame.mu.oz.au>
 1.57 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.56 30-Aug-2011  joerg branches: 1.56.42;
static, __printflike, __dead
 1.55 13-Jul-2009  roy Rename internal getline() function to get_line() so it does
conflict with the soon to be added getline(3) libc function.
 1.54 21-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.53 07-May-2008  christos branches: 1.53.2;
patch from Dennis den Brok for foomatic
 1.52 03-Mar-2008  lukem branches: 1.52.2;
Use mkstemp(3) (in a hokey manner) instead of mktemp(3).

XXX: still not 100% "safe", except that we're in a protected directory.
XXX: arguably we should keep the fds open and fdopen(3) dup()s,
XXX: but we're in a protected directory so it shouldn't matter.
 1.51 16-Feb-2008  matt branches: 1.51.2;
scnkey is const char [][HEIGHT], not char [][HEIGHT]
 1.50 11-May-2006  mrg branches: 1.50.10;
end the argument list to exec*(3) with a NULL instead of a bare '0', as
the latter isn't a pointer context in these varargs functions.
 1.49 17-Mar-2006  christos Appease Coverity CID 2580 [not a bug]
 1.48 20-Jan-2006  christos Instead of dealing with port@host in many places, do it where it is needed.
It reduces code and complexity and at the same time allows as to use symbolic
ports instead of just numeric everywhere.
 1.47 19-Jan-2006  garbled Fix PR bin/30272 Lpd would create the tempfile "remotexxxxx" and send
that, but then fill out the control file with the "df" filename. Fix by
sending the remote file with the "df" filename, as suggested by Robert
Vargason on tech-userlevel. lpd -r now works properly with an if (input
filter)
 1.46 17-Jan-2006  garbled Update a comment regarding control file WRT "o"
 1.45 17-Jan-2006  garbled Fix PR bin/14247
This PR claims that MacOSX 10.1 cannot print postscript files to a NetBSD
lpd because the mac will tag the file with an "o" for postscript, which
we do not handle. Rather than simply mapping o -> f as was done in the
PR, or mapping o -> l as was done in FreeBSD, I have implemented full
support for the "o" option. If a postscript filter does not exist in the
printcap file however, it will default to "l" handling.

With this change, you can now specify a "pf" or postscript filter in your
printcap, and have it handle postscript files sent to it with "lpr -o".

The "o" format in lpd is specified in RFC1179 as being a valid format flag.
 1.44 04-Jan-2006  garbled Address PR bin/12112
Lpd has the ability to start on a port other than "printer" but has no
way to connect to a remote lpd on that port. This change adds the
ability to specify port@host in the rm element of printcap(5). Tested to
work with both a standard lpd setup and one running on special ports.
 1.43 28-Nov-2005  christos - WARNS = 4
- factor out commonly used code.
- constify
- use warn/warnx instead of printf
 1.42 27-Nov-2005  jdolecek the mktemp() use here is not OK, adjust comment
 1.41 30-Oct-2004  dsl Add (unsigned char) cast to ctype functions
Some of this code could usefully be converted to use strtoul() and/or
some small helper functions.
 1.40 26-Aug-2004  wiz Avoid printing a useless \0. From SHIMIZU Ryo in PR 26766.
 1.39 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.38 17-May-2003  itojun use strlcpy/strlcat.
[fix off-by-one in displayq.c]
 1.37 26-Oct-2002  thorpej Rather than relying on pure luck to get the log file on STDERR_FILENO,
explictly dup2 the log file dscriptor to STDERR_FILENO and close the
original.
 1.36 04-Sep-2002  abs Add back __attribute__() data for pstatus() removed by error in last commit.
Noted by wiz.
 1.35 03-Sep-2002  abs When -r is given actually pass the file through of, and also enable if.
 1.34 14-Jul-2002  wiz Unifdef __STDC__. Remove __P(). ANSIfy.
 1.33 09-Jul-2002  hubertf This fixes various little problems in the lpd source.

lpd.c bogus 'c' option in getopt option string

printjob.c spelling "prstatic inter" -> "printer"
finish ANSIfication

recvjob.c finish ANSIfication

Patch contributed by Brian Ginsbach <ginsbach@cray.com> in PR 17520
 1.32 08-Jun-2002  itojun avoid hardcoded octals. openbsd
 1.31 21-Jan-2002  wiz branches: 1.31.2;
deamon -> daemon
 1.30 09-Oct-2001  mjl Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.
ANSIfy and constify.
 1.29 24-Sep-2001  wiz va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.28 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.27 25-Jun-2001  mrg use DEFLP instead of "lp".
 1.26 05-Jan-2001  lukem use %ll_ instead of the less standard %q_
 1.25 11-Oct-2000  is More format string cleanups by sommerfeld.
 1.24 26-Sep-2000  itojun syslog() string format hole.
http://www.securityfocus.com/templates/archive.pike?start=2000-09-24&fromthread=0&mid=85023&list=1&end=2000-09-30&threads=0&
 1.23 24-Aug-2000  itohy Don't pass null pointer to syslog.

lpd[6813]: mail sent to user itohy about job foo.ps on printer lp ((null))
^^^^^^
 1.22 11-Dec-1999  mrg branches: 1.22.4;
- use symbolic names for mode bits
- use _exit() where we should
- fix spelling mistake
- use vasprintf() in pstatus()
all from freebsd.
 1.21 07-Dec-1999  mrg - add timeouts to displayq(), rmremote(), sendfile() and response(),
and use these timeout in the lpq, lpd and lprm programs.

these stop hung remote printers that accept tcp connections but do
not process jobs from hanging the whole system and letting the sysadmin
have a clue about what is going on with this rogue printer.

- add a -r flag to lpd to allow `of' filters for remote jobs.

i know there are ways around this, but i just don't care.

- add a -f flag to lpf to add missing carriage returns.

useful when printing UNIX files to an, eg, LaserWriter that wants CR's
as well as LF's in raw text. stair-stepped text is no fun.

- implement child process accounting: we just have a limit on the number
of children we can have (settable by the sysadmin), and we sleep when
this number is reached. this can reduce malicious not-so-malicious
attacks on the print server by a rogue remote client..

- use setproctitle() where appropriate so the sysadmin has a clue about
what each of the lpd's here are doing.

this was useful to help diagnose a problem (that the above child process
accounting change reduces the lossages of) where a rogue client was
attempting "lpq" operations on one stuck queue in rapid succession,
causing the lpd server to be extremely slow, due to the large number
of lpd processes running.


i have been running these changes in production for about a year.
 1.20 26-Sep-1999  mrg delint and other cleanups.
 1.19 06-Jul-1998  mrg branches: 1.19.2; 1.19.4;
- use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
 1.18 19-Oct-1997  mycroft Use S_IS*(), not S_IF*.
 1.17 05-Oct-1997  mrg fix alpha compile warnings.
 1.16 05-Oct-1997  mrg - WARNS?=1
- be safe with unlinking files (from freebsd)
- remove register
- clean up $NetBSD$'s.
- use inet_ntoa() in one place (from openbsd)
- nul terminate after a bunch of strncpy()'s
- #ifdef __STDC__ rather than #if (from freebsd)
- be safe with a bunch of string operations (from freebsd)
- use warn()/err() over home grown versions (some from freebsd)
- rename warn() to nodaemon() to remove conflict with above
- check errno from failed kill(2) against ESRCH (from freebsd)
- use getopt() rather than home grown versions (from freebsd)
- clean up a bunch of man pages (some from freebsd)
- check for hostname spoof (from freebsd)
- use POSIX wait() interfaces
- use sysconf(_SC_OPEN_MAX) in preference to NOFILE (from freebsd)
- deal with fork() failure
- index/rindex -> strchr/strrchr (some from freebsd)
- add B57600 and B115200 speeds (from freebsd)
- some KNF
- be safe with files passed in over the network (some from freebsd)
- check return value of malloc(), calloc() and strdup()
 1.15 05-Oct-1997  mrg merge 4.4 lite2
 1.14 17-Jul-1997  mikel use <sys/cdefs.h> __COPYRIGHT and __RCSID macros
garbage-collect old set_ttyflags() and ctime() declarations
 1.13 10-Jul-1997  mikel fix printf formats and implicit comparisons (gcc -Wall)
 1.12 22-Mar-1997  lukem use O_EXCL with O_CREAT when making the tempfile
 1.11 09-Dec-1996  mrg remove unsafe calls to strcpy(), strcat(), and sprintf(). some KNF.
 1.10 30-Jun-1996  jtc Changed to not use a compiled in table of baud rates. Evidently
there are some PC/Mac oriented devices that use non-standard speeds,
furthermore that's just not the way we do things anymore.

"Bad" baud rates are no longer caught with their own error message,
but the condition will still be diagnosed when the tcsetattr() fails.
 1.9 30-Apr-1996  jtc branches: 1.9.4;
Use XS, not XC, flags when setting tty flags.
From Brook Milligan <brook@trillium.nmsu.edu>.
 1.8 15-Nov-1995  pk Add RCSIDs
 1.7 03-Oct-1995  hpeyerl -- convert sgtty to termios. From: Scott Bartram <scottb@iis.net>
-- Use seteuid() to only give lpr, lprm, lpq and lpc root when they
need it from matthew green <mrg@mame.mu.oz.au>
 1.6 14-Apr-1995  mycroft Reset group list before execing child, as pointed out by Mike Pritchard.
 1.5 18-May-1994  cgd clean up that import. no rcsids yet.
 1.4 27-Mar-1994  cgd off_t exp.
 1.3 07-Mar-1994  cgd fix from John F. Woods <jfw@ksr.com>: don't clobber page width specified
in printcap file.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 05-Oct-1997  mrg lite-2
 1.1.1.2 18-May-1994  cgd lpr from 4.4-Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.4.4 26-Jan-1997  rat Update from trunk. Fixes security bugs.
 1.9.4.3 12-Jul-1996  jtc pull up baud rate change anyway; turns out this is very useful to mac folks
 1.9.4.2 30-Jun-1996  jtc Revert last checkin, it wasn't supposed to go to the release branch
 1.9.4.1 30-Jun-1996  jtc Changed to not use a compiled in table of baud rates. Evidently
there are some PC/Mac oriented devices that use non-standard speeds,
furthermore that's just not the way we do things anymore.

"Bad" baud rates are no longer caught with their own error message,
but the condition will still be diagnosed when the tcsetattr() fails.
 1.19.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.2.2 19-Oct-2000  he Pull up revision 1.25 (via patch, requested by he):
Format string cleanup.
 1.19.2.1 04-Oct-2000  he Pull up revisions 1.23-1.24 (requested by sommerfeld):
Fix potential syslog() format string hole.
 1.22.4.3 15-Dec-2002  he Pull up revision 1.35-1.36 (via patch, requested by abs):
When ``-r'' is given, actually pass the file through ``of'' and
also enable ``if''.
 1.22.4.2 17-Oct-2000  tv Pullup usr.sbin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.22.4.1 28-Sep-2000  itojun pullup 1.23 -> 1.24 (approved by releng-1-5)

> syslog() string format hole.
> http://www.securityfocus.com/templates/archive.pike?start=2000-09-24&fromthread=0&mid=85023&list=1&end=2000-09-30&threads=0&
 1.31.2.2 07-Dec-2002  he Pull up revision 1.37 (requested by thorpej in ticket #947):
Rather than relying on pure luck to get the log file on
STDERR_FILENO, explicitly dup2 the log file descriptor to
STDERR_FILENO and close the original.
 1.31.2.1 07-Dec-2002  he Pull up revisions 1.35-1.36 (via patch, requested by abs in ticket #906):
When ``-r'' is given, actually pass the file through ``of'',
and also enable ``if''.
 1.50.10.1 23-Mar-2008  matt sync with HEAD
 1.51.2.1 24-Mar-2008  keiichi sync with head.
 1.52.2.1 18-May-2008  yamt sync with head.
 1.53.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.56.42.1 10-Jun-2019  christos Sync with HEAD
 1.26 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.25 27-Dec-2019  msaitoh s/transfered/transferred/
 1.24 14-Oct-2015  christos branches: 1.24.16;
this is syslog-like
 1.23 30-Aug-2011  joerg static, __printflike, __dead
 1.22 18-Jan-2009  lukem fix -Wsign-compare issues
 1.21 21-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.20 28-Nov-2005  christos branches: 1.20.20;
- WARNS = 4
- factor out commonly used code.
- constify
- use warn/warnx instead of printf
 1.19 21-Apr-2004  christos Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.17 26-Oct-2002  thorpej Rather than relying on pure luck to get the log file on STDERR_FILENO,
explictly dup2 the log file dscriptor to STDERR_FILENO and close the
original.
 1.16 14-Jul-2002  wiz Unifdef __STDC__. Remove __P(). ANSIfy.
 1.15 09-Jul-2002  hubertf This fixes various little problems in the lpd source.

lpd.c bogus 'c' option in getopt option string

printjob.c spelling "prstatic inter" -> "printer"
finish ANSIfication

recvjob.c finish ANSIfication

Patch contributed by Brian Ginsbach <ginsbach@cray.com> in PR 17520
 1.14 04-Dec-2001  christos branches: 1.14.2;
Make sure that the we have a valid pathname. [We did the check too late,
and we had a buffer overflow]. Bug found by Sebastian Krahmer of SuSE,
fix inspired by patch 008 for OpenBSD-3.0.
 1.13 09-Oct-2001  mjl Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.
ANSIfy and constify.
 1.12 11-Oct-2000  is More format string cleanups by sommerfeld.
 1.11 05-Oct-1997  mrg branches: 1.11.4; 1.11.12;
in rcleanup() don't unlink() the dfname if it contains a /. noted
by matt power <mhpower@mit.edu>.
 1.10 05-Oct-1997  mrg - WARNS?=1
- be safe with unlinking files (from freebsd)
- remove register
- clean up $NetBSD$'s.
- use inet_ntoa() in one place (from openbsd)
- nul terminate after a bunch of strncpy()'s
- #ifdef __STDC__ rather than #if (from freebsd)
- be safe with a bunch of string operations (from freebsd)
- use warn()/err() over home grown versions (some from freebsd)
- rename warn() to nodaemon() to remove conflict with above
- check errno from failed kill(2) against ESRCH (from freebsd)
- use getopt() rather than home grown versions (from freebsd)
- clean up a bunch of man pages (some from freebsd)
- check for hostname spoof (from freebsd)
- use POSIX wait() interfaces
- use sysconf(_SC_OPEN_MAX) in preference to NOFILE (from freebsd)
- deal with fork() failure
- index/rindex -> strchr/strrchr (some from freebsd)
- add B57600 and B115200 speeds (from freebsd)
- some KNF
- be safe with files passed in over the network (some from freebsd)
- check return value of malloc(), calloc() and strdup()
 1.9 05-Oct-1997  mrg merge 4.4 lite2
 1.8 17-Jul-1997  mikel use <sys/cdefs.h> __RCSID macro
 1.7 09-Dec-1996  mrg remove unsafe calls to strcpy(), strcat(), and sprintf(). some KNF.
 1.6 15-Nov-1995  pk branches: 1.6.4;
Add RCSIDs
 1.5 11-Dec-1994  pk Correct character array declaration (bug-report bin608).
 1.4 18-May-1994  cgd clean up that import. no rcsids yet.
 1.3 21-Apr-1994  cgd header file foo
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 05-Oct-1997  mrg lite-2
 1.1.1.2 18-May-1994  cgd lpr from 4.4-Lite
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.4.1 26-Jan-1997  rat Update from trunk. Fixes security bugs.
 1.11.12.1 17-Oct-2000  tv Pullup usr.sbin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.11.4.1 19-Oct-2000  he Pull up revision 1.12 (requested by he):
Format string cleanup.
 1.14.2.1 07-Dec-2002  he Pull up revision 1.17 (requested by thorpej in ticket #947):
Rather than relying on pure luck to get the log file on
STDERR_FILENO, explicitly dup2 the log file descriptor to
STDERR_FILENO and close the original.
 1.20.20.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.24.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.11 14-Jul-2002  wiz Unifdef __STDC__. Remove __P(). ANSIfy.
 1.10 05-Oct-1997  mrg - WARNS?=1
- be safe with unlinking files (from freebsd)
- remove register
- clean up $NetBSD$'s.
- use inet_ntoa() in one place (from openbsd)
- nul terminate after a bunch of strncpy()'s
- #ifdef __STDC__ rather than #if (from freebsd)
- be safe with a bunch of string operations (from freebsd)
- use warn()/err() over home grown versions (some from freebsd)
- rename warn() to nodaemon() to remove conflict with above
- check errno from failed kill(2) against ESRCH (from freebsd)
- use getopt() rather than home grown versions (from freebsd)
- clean up a bunch of man pages (some from freebsd)
- check for hostname spoof (from freebsd)
- use POSIX wait() interfaces
- use sysconf(_SC_OPEN_MAX) in preference to NOFILE (from freebsd)
- deal with fork() failure
- index/rindex -> strchr/strrchr (some from freebsd)
- add B57600 and B115200 speeds (from freebsd)
- some KNF
- be safe with files passed in over the network (some from freebsd)
- check return value of malloc(), calloc() and strdup()
 1.9 15-Nov-1995  pk Add RCSIDs
 1.8 05-Oct-1995  mycroft Update from kernel source.
 1.7 05-Oct-1995  mycroft Fix typos.
 1.6 05-Oct-1995  mycroft Fix various parity and character size bugs from the termios transition.
 1.5 05-Oct-1995  mycroft Fix a couple of things broken in the termios transition.
 1.4 05-Oct-1995  mycroft Fix type errors.
 1.3 05-Oct-1995  mycroft Fix typo in previous.
 1.2 05-Oct-1995  mycroft Change to use SET(), CLR(), and ISSET() macros.
 1.1 03-Oct-1995  hpeyerl -- convert sgtty to termios. From: Scott Bartram <scottb@iis.net>
-- Use seteuid() to only give lpr, lprm, lpq and lpc root when they
need it from matthew green <mrg@mame.mu.oz.au>

RSS XML Feed