History log of /freebsd-9.3-release/usr.sbin/lpr/lpd/printjob.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 229226 01-Jan-2012 dim

MFC r228664:

In usr.sbin/lpr/lpd/printjob.c, use the correct printf length modifiers
for off_t (aka int64_t).


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 216372 11-Dec-2010 joel

Remove the advertising clause from UCB copyrighted files in usr.sbin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change


# 211190 11-Aug-2010 gad

- Improve the wait4data() routine so it behaves better when checking
print-jobs which have last-modification times that are in the future.
This shouldn't happen, of course, but it can. And when it did happen,
the previous check could cause completely-spooled jobs to sit in the
queue for 20 minutes per job. The new code waits until the last-modify
time is not changing, instead of making decisions based on the specific
value of last-modify.

MFC after: 2 weeks


# 160147 06-Jul-2006 gad

Fix checking of the "lock" file in the spool directory for a queue,
so that the checking will wind up with the correct mode-bits in
the case where the initial open() of that lock file will create it.
Due to this bug, the first job ever sent to a queue could leave
that queue in a "printing is disabled" state.

PR: 93469
Submitted by: Michael Szklarski of kco.com.pl
MFC after: 1 week


# 139035 19-Dec-2004 gad

Call umask() before opening the lock-file for a queue, to make sure
the file will be created with the right access, if the call to open()
does create it. Also fix the other call to umask() to turn off
"write others", just as a matter of general safety.

PR: 74418
MFC after: 4 days


# 138939 16-Dec-2004 gad

When printing a data file received from some other host, check to make
sure the data file has been completely transfered before starting to
print it. This is needed because some implementations of lpr will send
the control-file for a print job before sending the matching data-files,
and that can cause problems if the receiving host is a busy print-server.

MFC after: 2 weeks


# 119192 21-Aug-2003 gad

Minimal update to make it easier to increase the buffer-size lpd uses
when reading/writing spool files. I intend to do a more elaborate
version, but I want to get this much in before 4.9-release. As written,
this results in no change to the object code.

Submitted by: John-Mark Gurney
Reviewed by: /sbin/md5
MFC after: 4 days


# 118881 13-Aug-2003 gad

Use STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO in a few more
places (replacing constants 0, 1 & 2).

Noticed by:
Reviewed by: md5
MFC after: 4 days


# 117587 14-Jul-2003 gad

Get the 'sccsid' lines even closer to correct style(9) form. The
'#ifdef lint/#endif' around the lines should not have been removed.

Reviewed by: noticed by bde
MFC after: 15 days


# 117554 14-Jul-2003 gad

More changes to use __FBSDID() for setting rcsids, and fix the
format of 'sccsid' lines so they consistently match style(9)
guidelines. Inspired by recent update to lpd.c by charnier.

Reviewed by: discussed on cvs-src & with bde and obrien
MFC after: 15 days


# 97793 04-Jun-2002 gad

Change some "process id" variables from 'int' to 'pid_t', renaming some
of them to keep better track of which-is-which (multiple variables were
named 'pid'). Moved a global pid-variable into the only routine that
used it. Net result: fixes two compile-time warnings...

MFC after: 2 weeks


# 97792 04-Jun-2002 gad

Cosmetic improvements to some of the syslog() calls in here (in some cases
simply getting the indentation right when the statement wraps).

MFC after: 2 weeks


# 97791 03-Jun-2002 gad

Fix all the 'return' statements in here to follow style(9).

MFC after: 2 weeks


# 97789 03-Jun-2002 gad

Avoid checking WIFEXITED and WTERMSIG in some error situations where the
value in wstatus is not related to the process that we care about.

MFC after: 2 weeks


# 97781 03-Jun-2002 gad

Stop using the depreciated 'union wait' definitions, moving to a more
standard handling of wait()-related routines.

Submitted by: mike
MFC after: 2 weeks


# 97421 28-May-2002 alfred

Assume __STDC__, remove non-__STDC__ code.


# 95293 22-Apr-2002 gad

Implement new printcap option of "rc" aka "remote.resend_copies".
This is a boolean option, and if it is specified in a print queue
for a remote host, it causes lpd to resend the data file for each
copy the user requested on 'lpr -#n'. This is useful for network
printers which accept lpd-style jobs, but which ignore the control
file (and thus they ignore any request for multiple copies).

PR: 25635
Reviewed by: short review on freebsd-audit
MFC after: 6 days


# 95069 19-Apr-2002 gad

Remove a safety-setting line which is unnecessary now that the previous
line is using strlcpy instead of strncpy.

MFC after: 4 days


# 95067 19-Apr-2002 gad

Add a little detail to the syslog-msg that comes up when lpd can not
execute a given filter.

MFC after: 4 days


# 94040 07-Apr-2002 gad

A variable had been unnecessarily assigned a bogus value because gcc was
"confused" about it being unassigned. In fact, gcc was right. Fix the
real problem by setting that variable before break-ing out of a select
statement so gcc is happy, and then remove the unnecessary assignment.

Reported by: a user wondering why lpd syslog-ed about "compiler confusion"
MFC after: 12 days


# 94038 07-Apr-2002 gad

Rename a variable from 'user' to 'userid' to avoid some compiler warnings.

MFC after: 12 days


# 94036 07-Apr-2002 gad

Rearrange all the error returns from sendfile() to make sure the original
input file and any temporary (filter) file are closed upon return, and
that is generally done at the end of the routine. This should make it
easier for a later update (not yet written) to implement a "resend_copies"
option.

MFC after: 12 days


# 94032 07-Apr-2002 gad

Re-arrange how output filters (of=) are handled for queues going to
remote machines. Now they really are handled *exactly* the same as
input filters (if=) for remote queues, except that they are started
with a different set of parameters. This should fix a few subtle
bugs in output-filter processing on such queues. It is a pretty
significant re-arranging of sendfile(), moving some of it to a new
execfilter() routine.

PR: 36552
Reviewed by: no screams from freebsd-audit
MFC after: 12 days


# 86935 26-Nov-2001 gad

Change the recently-added 'o'-processing so it maps to 'l' instead of 'f'.
'l' ("plain text which includes control characters") is somewhat more
appropriate for 'o' ("postscript files"), and in fact some printers treat
'l' as a request to print a postscript file.

MFC after: 1 week


# 83684 19-Sep-2001 gad

Add minimal support for "o"-type print-file actions in lpd control files.
This was described in the original RFC wrt lpr, but most lpr's do not
actually implement it. There is some indication that MacOS 10.1 will
be using this when sending postscript files to print servers (that is
what "o"-type was supposed to signify -- postscript files).

MFC after: 1 week


# 80230 23-Jul-2001 gad

Basically rewrite the dofork() routine, to add more error-checking and
correct the error-checking that was there. With the old code, an error
return from getpwuid(daemon_user) could turn the lpd process into a very
effective fork-bomb...

Reviewed by: freebsd-audit freebsd-print (a little...)
MFC after: 6 days


# 80133 22-Jul-2001 gad

Replace calls to strncpy with calls to strlcpy, and remove the extra step
needed to ensure that the result is null-terminated when using strncpy().

MFC after: 8 days


# 79739 14-Jul-2001 gad

Fix most of the warnings generated by compiling lpr with -Wnon-const-format,
often by just telling gcc that some internal routine is "__printflike"
(work done by Kris Kennaway <kris@FreeBSD.org>). Also fix the new warnings
which show up once gcc starts checking the "printf-like parameters" passed
to those routines.

MFC after: 1 week


# 79735 14-Jul-2001 gad

Change signal-handling to reset SIGCHLD to SIGDFLT instead of SIG_IGN.
This fixes a problem with using print filters (if=, of=, etc) that showed
up in -current around June 20th. That problem initially reported by
Georg-W Koltermann <gwk@sgi.com>, while most of the investigation that
led to this fix was done by Anton Berezin <tobez@FreeBSD.org>.

Reviewed by: freebsd-print@bostonradio.org
MFC after: 1 week


# 79452 09-Jul-2001 brian

Fix the type of the NULL arg to execl()

Idea from: Theo de Raadt <deraadt@openbsd.org>


# 78300 15-Jun-2001 gad

Rename a few global variables which hold hostname-related values to be
more sensible/understandable. 'from'->'from_host' 'host'->'local_host'
'fromb'->'frombuf' 'fromhost'->'origin_host' and a local-variable
named 'host'->'hostbuf'. This fixes some compile-time warnings about
local variables shadowing global variables.

Other than renaming variables, the only actual code changes are to call
strlcpy() instead of strncpy() when setting those (renamed) variables,
and that 'from_ip' is now a strdup()-created buffer instead of being a
static buffer compiled in as 1025 bytes.

Reviewed by: freebsd-print@bostonradio.org (an earlier version)
MFC after: 1 week


# 78146 12-Jun-2001 gad

Fix about 90-100 warnings one gets when trying to compile lpr&friends
with BDECFLAGS on, mainly by adding 'const' to parameters in a number
of routine declarations. While I'm at it, ANSI-fy all of the routine
declarations. The resulting object code is exactly the same after
this update as before it, with the exception of one unavoidable
change to lpd.o on freebsd/alpha.

Also added $FreeBSD$ line to lpc/extern.h lpc/lpc.h lptest/lptest.c

Reviewed by: /sbin/md5, and no feedback from freebsd-audit


# 74124 11-Mar-2001 gad

Improve a few error messages wrt if= filters on remote print queues.


# 68741 15-Nov-2000 gad

Make sure a few strings will have terminating null characters.
(most of the PR 16186 was already applied, except for these 2 lines)

PR: 16186
Submitted by: Przemyslaw Frasunek <venglin@lubi.FreeBSD.lublin.pl>


# 68734 14-Nov-2000 gad

Fix (style) some variable initializations.


# 68733 14-Nov-2000 gad

Change 'count' to a more descriptive 'jobcount', and fix the stupid
comments which claim this counter is counting "files", which it is not.


# 68732 14-Nov-2000 gad

Get rid of 'exit(-1)' calls. Exit codes are limited to 8 bits under most
Unixes, so -1 becomes 0xFF for 2's complement and 0xFE (?) for 1's
complement.

Reviewed by: bde@FreeBSD.org


# 68682 13-Nov-2000 gad

My previous commit removed a line it wasn't supposed to. Add it back.


# 68664 13-Nov-2000 gad

Replace call to mktemp() with mkstemp. Also move where that call is
done, so the correct directory is being checked. The mkstemp() call
is meant to create a temp file for stderrs when running filters. This
update also fixes log-file processing for remote (rm=) queues which
specify an input filter (if=). Before, filter-errs were thrown away.
Now they'll be copied to the queue's logfile (lf=).

Reviewed by: (a little) audit@FreeBSD.ORG & freebsd-print@bostonradio.org


# 68467 07-Nov-2000 gad

Fix 'printit()' to ignore some lines it doesn't recognize (most likely
coming from lprNG hosts), and print a more helpful error msg for others.


# 68401 06-Nov-2000 gad

Cosmetic change of a structure name.
Turn 'struct queue { q_time, q_name }' (loosely-speaking)
into 'struct jobqueue { job_time, job_cfname }'

Reviewed by: GAWollman


# 68379 06-Nov-2000 gad

Fix a format-code, thus getting rid of a compile-time warning msg.


# 68343 05-Nov-2000 gad

Fix potential problem processing jobs from hosts with >32 character hostnames.
This may fix a problem reported by Juha Ylitalo <juha.o.ylitalo@nokia.com>


# 68253 02-Nov-2000 gad

Implement new printcap options of sr= (aka stat.recv) and sr= (aka stat.send)
in lpd. Stat.recv is useful on a printserver, as something of a network
performance-monitoring tool. Stat.send is a minimal accounting record of
sorts for jobs going to tcp/ip based printers.

Reviewed by: freebsd-print@bostonradio.org


# 60871 24-May-2000 mpp

Re-implement my fix from rev 1.6 (same rev for both files being committed)
that was lost during the lite-2 merge. From the original commit message:

Initialize the group list so that any filter programs that are
run by lpd are not run with root's groups.


# 53956 30-Nov-1999 ache

Add support for pr's locale


# 50479 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 39084 11-Sep-1998 wollman

Fix additional warnings. Remove -Werror, since some people have complained
about it.

PR: 7886
Submitted by: Stefan Eggers <seggers@semyam.dinoco.de> (partially)


# 38470 21-Aug-1998 brian

Fix ``lp=port@machine'' syntax and mention it in printcap(5).


# 31492 02-Dec-1997 wollman

Mega lpd/lpd upgrade, part I:

- Get rid of a lot of the static variables which were shared by
many routines and programs in the suite.
- Create an abstract interface to the printcap database, so that
other retrieval and iteration mechanisms could be developed
(e.g., YP, Hesiod, or automatic retrieval from a trusted server).
- Give each capability a human-readable name in addition to the historic
two-character one.
- Otherwise generally clean up a lot of dark corners. Many still remain.
- When submitting jobs, use the official login name record (from getlogin())
if there is one, rather than reverse-mapping the uid.

More to come...


# 31020 07-Nov-1997 joerg

Argl! Who's got the pointy hat these days? Hand it over to me, ASAP!

When setting an alarm that didn't trigger, i gotta clear it again
before going on. Hmpf!


# 30407 14-Oct-1997 joerg

Improve my hack from rev 1.6 of displayq.c, and make the TCP
connection timeout controllable by a new printcap(5) capability named
`ct' (connectiom timeout), defaulting to 120 seconds (which is the
default TCP connection timeout).

Would anybody see a problem with merging all this into RELENG_2_2?


# 27757 29-Jul-1997 imp

Two minor, pedantic fixes from bde for my last pedantic fixes, plus
the following from recent OpenBSD changes. These changes (and all
I've made) should be merged back into 2.2 when they are vetted in
-current.

common.c:
OpenBSD 1.7: mickey: #if __STDC__ --> #ifdef __STDC__

displayq.c:
OpenBSD 1.8: deraadt: 1 byte oflows; millert

rmjob.c:
OpenBSD 1.8: deraadt: 1 byte oflows; millert

cmds.c:
OpenBSD 1.9: grr: restore traditional "all" keyword option - see lpc(8)
[[ This makes lpc status all work again -- imp ]]

printjob.c:
OpenBSD 1.17: deraadt: use sendmail -t
OpenBSD 1.16: mickey: #if __STDC__ --> #ifdef __STDC__
OpenBSD 1.15: deraadt: 1 byte oflow; Don.Lewis@tsc.tdk.com

recvjob.c:
OpenBSD 1.11: mickey: #if __STDC__ --> #ifdef __STDC__

lpr.c:
OpenBSD 1.19: mickey: #if __STDC__ --> #ifdef __STDC__

Obtained from: OpenBSD


# 27748 29-Jul-1997 imp

Fix boatloads of buffer overflows from the OpenBSD tree.
Be pedantic about always using sizeof(blah) vs sizeof (blah) or sizeof blah.
Obtained from:OpenBSD


# 27635 23-Jul-1997 imp

index -> strchr and rindex -> strrchr to reduce the number of gratuitous
diffes with NetBSD/OpenBSD. These changes seem to predate the NetBSD/OpenBSD
split, so it is hard to give proper credit for them.
Obtained from: OpenBSD.


# 24831 12-Apr-1997 brian

Support input and output filters with remote printing.
Output filters are executed on a per-file basis as it's
necessary to supply the file size to the "other side".


# 19202 27-Oct-1996 imp

lpc/cmds.c:
From NetBSD via OpenBSD to fix NetBSD PR #506
More descriptive message for printer status
(OpenBSD: 1.2)

Various warnings cleaned up (OpenBSD: 1.4)

lpc/lpc.c:
Various warnings cleaned up (OpenBSD: 1.3)

lpd/lpd.c:
Remove trailing blank lines (OpenBSD: 1.2)

Potential umask problem with creating /dev/printer
(OpenBSD: 1.4 and 1.5)

Ftp bounce attack (untested on FreeBSD)
(OpenBSD: 1.6, 1.8, 1.9)
Fencepost in strncpy
(OpenBSD: 1.6)

lpd/printjob.c:
Fix from freebsd for waiting for an exiting filter, that
appears not in the FreeBSD CVS tree.
(OpenBSD: 1.6)

lpd/recvjob.c:
Buffer overflow protection: use strncpy rather than strcpy.
(OpenBSD: 1.3)

lpr/lpr.c:
NetBSD change of return type for main()
(OpenBSD: 1.2)

Restrict time running as root
(OpenBSD: 1.7)

Use getcwd rather than getwd (from NetBSD)

Use snprintf rather than sprintf
(OpenBSD: 1.8)

Minor tweak to end of loop and buffer overflow sanity. card()
overflow already in FreeBSD
(OpenBSD: 1.9)

lptest/lptest.c:
void -> int return type of main, from NetBSD via OpenBSD
(OpenBSD: 1.2)

pac/pac.c:
void -> int return type of main, from NetBSD via OpenBSD
(OpenBSD: 1.3)

Obtained from: OpenBSD


# 18569 29-Sep-1996 bde

Close files up to getdtablesize(), instead of up to NOFILE.

lpd was one of 3 programs in /usr/src that (mis)used NOFILE.


# 15703 09-May-1996 joerg

Cleanup.

The removed files are no longer needed, they are actually labelled as
``Use only if you are not 4.4BSD''. (Yeah, the ol' crufty printcap.c
is really gone!)

Properly declare all external objects in files ending in .h, as
opposed to embed them into files ending in .c.


# 15648 05-May-1996 joerg

Pull a bunch of fixes from the 4.4BSD-Lite2 branch. It's really
surprising how many trivial errors there have been... :-)

Some more cleanup is needed, but i'd like to separate the Lite2 changes
from other work, that's why this goes into a different commit.

People with serial printers should see whether i have broken the stty-
style printcap options (i hope not).

Inspired by: Sergey Shkonda <serg@bcs1.bcs.zaporizhzhe.ua>


# 15032 03-Apr-1996 sef

Makefile: Add new modes.c file to list of objects.
printjob.c: Use termios instead of sgtty structs and ioctls; remove
support for fs/fc/xs/xc capabilities, and replace them with the ms
capability (stty-like words, instead of octal bit patterns).
modes.c: Modified from stty's file, parses comma-seperated list of
tty modes (e.g., "cs8,-paren,-opost").

Reviewed by: rgrimes, joerg


# 10530 02-Sep-1995 mpp

Initialize the group list so that any filter programs that are
run by lpd are not run with root's groups.


# 9821 31-Jul-1995 wpaul

The other day someone brought me an old Apple Laserwriter II with a serial
interface set at 57600 baud, and I found out the hard way that lpd doesn't
know about speeds greater than 38400, even though <sys/ttydev.h> also
permits 57600 and 115200 baud. Fix this by adding B57600 and B115200 to the
'bauds' table. (The Apple printer worked properly once I did this, BTW. :)


# 8857 30-May-1995 rgrimes

Remove trailing whitespace.


# 8094 27-Apr-1995 jkh

Close PR:
>Number: 368
>Category: bin
>Synopsis: Lpd doesn't log errors after failed exec
>Description:

If an exec done by lpd fails, nothing is sent to the system log
indicating what went wrong. This is because lpd closes all of
the file descriptors before doing the exec, thus closing the syslog
file descriptor in the process.
[Fix applied]
Submitted by: pritc003@maroon.tc.umn.edu


# 5445 08-Jan-1995 joerg

Use the "-F" option to /bin/pr now that we have it (thanks to Posix).
This helps for printers that tend to get out of sync. (For the
cautious folks: we used to have it in 1.1.5, too. But GNU pr used
"-f" for it.)


# 1554 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1553,
which included commits to RCS files with non-trunk default branches.


# 1553 26-May-1994 rgrimes

BSD 4.4 Lite usr.sbin Sources