History log of /freebsd-10-stable/usr.sbin/lpr/common_source/common.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

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

# 251044 27-May-2013 gad

Change the closeallfds() routine to use closefrom() when it is
available (closefrom() was added to FreeBSD in 8.0-release).
The selection is made at compile-time, as I still compile a
FreeBSD-based version of lpr&friends on other platforms.

While testing I out that (at least on my system) lpd has been
closing 11095 fd's, when there are only 6 fd's open. The old
code took 120 times more clocktime than calling closefrom().
(although that was still less than 2/1000-ths of a second!)

Reviewed by: jilles
MFC after: 2 weeks


# 242091 25-Oct-2012 ed

Let lpr build with -Wmissing-variable-declarations.

Mark variables static where possible and place the uid/euid variables in
lp.h, so that we can compile-time enforce that these variables have the
same type.


# 241852 22-Oct-2012 eadler

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


# 238547 17-Jul-2012 jh

Make sure that arraysz is initialized to a value larger than zero.
arraysz could get initialized to zero on ZFS because ZFS reports
directory sizes differently compared to UFS.

PR: bin/169493
Tested by: swills
MFC after: 2 weeks


# 238546 17-Jul-2012 jh

Remove trailing whitespace.

MFC after: 2 weeks


# 235647 19-May-2012 gleb

Hide DIR definition by making it an opaque struct typedef.

Introduce dirfd() libc exported symbol replacing macro with same name,
preserve _dirfd() macro for internal use.

Replace dirp->dd_fd with dirfd() call. Avoid using dirfd as variable
name to prevent shadowing global symbol.

Sponsored by: Google Summer Of Code 2011


# 139464 30-Dec-2004 gad

Fix so all parts of lpd, lpc, lpq, and lprm will use the same algorithm
for calculating the job number for a job based on the control-file name.
We might receive cf-files named by other implementations of lpr, where
the job number shown by lpq would not match the job number that other
commands expected for the same name.

This also uses a newer algorithm for determining a job number, to avoid
problems caused when a control-file is named using an IP address, instead
of the hostname.

This also moved the declaration if isowner() from lp.h to rmjob.c. When I
went to change the parameters, I noticed that rmjob.c was the only source
file which uses it.

MFC after: 2 weeks


# 117592 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.
Also add blank lines where one (per file) was missing.

Reviewed by: First part noticed by bde, blank lines noticed by me
MFC after: 15 days


# 117541 14-Jul-2003 gad

Take advantage of the common_source/lp.cdefs.h file to change lpr
source to use __FBSDID() for setting rcsids. Also fix the format
of 'sccsid' lines to consistently match style(9) guidelines.

Reviewed by: discussed with bde and obrien
MFC after: 15 days


# 99845 11-Jul-2002 gad

Fix set_qstate() so it correctly checks for any error from chmod().
Note that set_qstate() is only called from several 'lpc' commands.

MFC after: 3 days


# 99844 11-Jul-2002 gad

Add a SQS_QCHANGED option to set_qstate(). This will soon be used by 'lpc'.

Reviewed by: freebsd-print@bostonradio.org
MFC after: 3 days


# 99842 11-Jul-2002 gad

Add two variables to struct jobqueue, and change the way that getq()
calculates how much space to get for that struct, so it will get the
right amount when new variables are added.

MFC after: 3 days


# 98154 13-Jun-2002 gad

Bah humbug. Fix another typo on the same comment line. It also had
an option-space instead of a space...

MFC after: 10 days


# 98153 13-Jun-2002 gad

Fix a typo in a comment from the previous commit. I had a bullet-character
instead of an asterisk.

Noticed by: keramida
MFC after: 10 days


# 98152 12-Jun-2002 gad

Almost complete rewrite of the lpc commands 'abort', 'enable', 'disable',
'restart', 'start', 'stop' and 'up'. These are commands which mainly
just alter the access bits on the lock-file of a queue, and they all
now use a central routine to do that. This reduces the amount of code
that is run as the priv userid, and eliminates a number of cases where
error messages were written while that priv uid was in effect.

As far as users are concerned, there should be no noticable difference
in the new versions. In case there *is*, the previous implementations
are still there as 'xabort', 'xenable', etc, so they are available for
instant fallback. If no one reports a problem after a few weeks, then
a later update will remove those x-commands.

Reviewed by: freebsd-audit and freebsd-print@bostonradio.org
MFC after: 10 days


# 97421 28-May-2002 alfred

Assume __STDC__, remove non-__STDC__ code.


# 95290 22-Apr-2002 gad

Add 'const' to some casts to fix two warnings that are printed by the
new gcc (on sparc64).

MFC after: 4 days


# 80172 22-Jul-2001 gad

Fix a few more minor compile-time warnings, mainly by using size_t where
appropriate, and using '("%lu", (unsigned long)asizeval)' when printing
something of type size_t.

MFC after: 1 week


# 79740 14-Jul-2001 gad

Replace three subtly-wrong calls to strncpy with calls to strlcpy, and
use (size_t) in a few places to avoid compile-time warnings on alpha.

MFC after: 1 week


# 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


# 78280 15-Jun-2001 gad

Rename global variable 'name' to 'progname', thus fixing a number of
warnings which come up for various routines that have a parameter which
is also called 'name'.

Reviewed by: freebsd-print@bostonradio.org
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


# 75253 06-Apr-2001 gad

Make sure the euid is restored in an obscure error situation.

Submitted by: J Wunsch <j@ida.interface-business.de> in freebsd-audit


# 68740 15-Nov-2000 gad

Reset the seteuid in a few obscure error situations.


# 68739 15-Nov-2000 gad

Just some style-related improvements.


# 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


# 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


# 59920 03-May-2000 wollman

Print files submitted at the same instant in deterministic order.

PR: 18361
Submitted by: Garance A Drosehn <gad@freefour.acs.rpi.edu>


# 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)


# 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...


# 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


# 27618 22-Jul-1997 imp

Use setuid/seteuid around dangerous operations. Also a few buffer
overflow patches that were "near" to where these operations are taking
place. The buffer overflows are from OpenBSD. The setuid/seteuid patches
are from NetBSD by way of OpenBSD (they changed them a little), at least from
my read of the tree.

This is the first of a series of OpenBSD lpr/et al merges. It (and them)
should be merged back into 2.2 and/or 2.1 (if requested) branches when they
have been shaken out in -current.
Obtained from: OpenBSD


# 27511 18-Jul-1997 imp

Add code to make sure that we don't overflow the buffer that we copy
the hostname into. In theory the bind library should do this, but
in practice the limites between system defines and bind defines make
an attack using this vector possible. These patches have been in
use on my systems for three months now, so I am fairly confident about
them. I plan on commiting this to 2.2 and 2.1 in the near future,
as well as many other patches of this nature.


# 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>


# 15031 03-Apr-1996 sef

Remove definitions and declarations for FS, FC, XS, XC variables, and
replace them with MS char* variable.

Reviewed by: rgrimes, joerg


# 8857 30-May-1995 rgrimes

Remove trailing whitespace.


# 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