Home | History | Annotate | Download | only in lpd
History log of /src/usr.sbin/lpr/lpd/printjob.c
RevisionDateAuthorComments
 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

RSS XML Feed