Commit Graph

71 Commits

Author SHA1 Message Date
Pedro F. Giffuni
7162347871 lpr: replace setpgrp(2) with setpgid(2).
setpgid(2) is more portable than setpgrp(2).
The BSD variant of setpgrp is a wrapper for
setpgid(2) anyways.

MFC after:	5 weeks
2014-09-18 17:01:45 +00:00
Eitan Adler
1d1d4a4727 Check the return error of set[ug]id. While this can never fail in the
current version of FreeBSD, this isn't guarenteed by the API.  Custom
security modules, or future implementations of the setuid and setgid
may fail.

PR:		bin/172289
PR:		bin/172290
PR:		bin/172291
Submittud by:	Erik Cederstrand <erik@cederstrand.dk>
Discussed by:	freebsd-security
Approved by:	cperciva
MFC after:	1 week
2012-10-22 03:31:22 +00:00
Kevin Lo
3dedcef753 Remove unused values 2012-09-11 07:54:41 +00:00
Ulrich Spörlein
3df5ecac8c Spelling fixes for usr.sbin/ 2011-12-30 10:58:14 +00:00
Dimitry Andric
97fbdc11ea In usr.sbin/lpr/lpd/printjob.c, use the correct printf length modifiers
for off_t (aka int64_t).

MFC after:	1 week
2011-12-17 22:05:28 +00:00
Joel Dahl
914e11a72b 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
2010-12-11 09:38:12 +00:00
Garance A Drosehn
422605a3b9 - 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
2010-08-11 19:32:49 +00:00
Garance A Drosehn
ae39ffc92e 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
2006-07-07 01:12:26 +00:00
Garance A Drosehn
a6ed151d3c 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
2004-12-19 05:14:29 +00:00
Garance A Drosehn
bea5945e6f 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
2004-12-17 01:54:50 +00:00
Garance A Drosehn
0de95e161e 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
2003-08-21 03:43:48 +00:00
Garance A Drosehn
53953407b6 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
2003-08-13 20:31:33 +00:00
Garance A Drosehn
a6381ce166 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
2003-07-14 19:59:33 +00:00
Garance A Drosehn
055c90456e 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
2003-07-14 15:54:41 +00:00
Garance A Drosehn
5e127035e4 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
2002-06-04 03:40:24 +00:00
Garance A Drosehn
0dcfaee0af 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
2002-06-04 02:48:12 +00:00
Garance A Drosehn
609614565f Fix all the 'return' statements in here to follow style(9).
MFC after:	2 weeks
2002-06-04 01:28:15 +00:00
Garance A Drosehn
4a13c4d9ee 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
2002-06-04 01:16:13 +00:00
Garance A Drosehn
0760287064 Stop using the depreciated 'union wait' definitions, moving to a more
standard handling of wait()-related routines.

Submitted by:	mike
MFC after:	2 weeks
2002-06-03 20:47:01 +00:00
Alfred Perlstein
16d8455dcc Assume __STDC__, remove non-__STDC__ code. 2002-05-28 19:23:47 +00:00
Garance A Drosehn
98f6cc5401 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
2002-04-23 00:06:10 +00:00
Garance A Drosehn
fc7477304d Remove a safety-setting line which is unnecessary now that the previous
line is using strlcpy instead of strncpy.

MFC after:	4 days
2002-04-19 18:46:10 +00:00
Garance A Drosehn
150508c64d Add a little detail to the syslog-msg that comes up when lpd can not
execute a given filter.

MFC after:	4 days
2002-04-19 18:28:35 +00:00
Garance A Drosehn
50cf7393cb 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
2002-04-07 08:12:39 +00:00
Garance A Drosehn
6710feea89 Rename a variable from 'user' to 'userid' to avoid some compiler warnings.
MFC after:	12 days
2002-04-07 08:01:42 +00:00
Garance A Drosehn
57d49eaa35 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
2002-04-07 07:48:32 +00:00
Garance A Drosehn
197ccef0c9 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
2002-04-07 05:37:27 +00:00
Garance A Drosehn
21ecfd4a44 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
2001-11-27 01:32:25 +00:00
Garance A Drosehn
626fb2a6fa 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
2001-09-20 01:04:50 +00:00
Garance A Drosehn
ad5fdfbda1 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
2001-07-23 23:13:39 +00:00
Garance A Drosehn
5d7321f61d 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
2001-07-22 07:25:27 +00:00
Garance A Drosehn
6d39e1b726 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
2001-07-15 00:09:46 +00:00
Garance A Drosehn
bfb9fa63fc 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
2001-07-14 21:49:17 +00:00
Brian Somers
7bc6d0158f Fix the type of the NULL arg to execl()
Idea from: Theo de Raadt <deraadt@openbsd.org>
2001-07-09 09:24:06 +00:00
Garance A Drosehn
cc3fd56f96 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
2001-06-15 22:03:07 +00:00
Garance A Drosehn
ba7a1ad76a 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
2001-06-12 16:38:20 +00:00
Garance A Drosehn
28b051021a Improve a few error messages wrt if= filters on remote print queues. 2001-03-12 00:22:03 +00:00
Garance A Drosehn
59a09735ef 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>
2000-11-15 04:57:22 +00:00
Garance A Drosehn
aa538512da Fix (style) some variable initializations. 2000-11-14 22:03:59 +00:00
Garance A Drosehn
a480d5f20e Change 'count' to a more descriptive 'jobcount', and fix the stupid
comments which claim this counter is counting "files", which it is not.
2000-11-14 21:44:47 +00:00
Garance A Drosehn
a4803ea103 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
2000-11-14 21:32:52 +00:00
Garance A Drosehn
c61c5210be My previous commit removed a line it wasn't supposed to. Add it back. 2000-11-13 16:21:24 +00:00
Garance A Drosehn
ca52ea3cc8 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
2000-11-13 05:44:50 +00:00
Garance A Drosehn
cdd8df463b 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.
2000-11-08 00:52:11 +00:00
Garance A Drosehn
30b4b758aa 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
2000-11-06 19:36:38 +00:00
Garance A Drosehn
7c17eaa6a8 Fix a format-code, thus getting rid of a compile-time warning msg. 2000-11-06 04:11:56 +00:00
Garance A Drosehn
19d0f858b4 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>
2000-11-05 03:24:26 +00:00
Garance A Drosehn
6522ebec87 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
2000-11-02 19:22:06 +00:00
Mike Pritchard
50545e9e59 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.
2000-05-24 11:38:50 +00:00
Andrey A. Chernov
d3d56c3d4c Add support for pr's locale 1999-11-30 16:15:22 +00:00