/[base]/head/usr.sbin/lpr/common_source/common.c
ViewVC logotype

Log of /head/usr.sbin/lpr/common_source/common.c

Parent Directory Parent Directory | Revision Log Revision Log


Links to HEAD: (view) (download) (annotate)
Sticky Revision:

Revision 325966 - (view) (download) (annotate) - [select for diffs]
Modified Sat Nov 18 14:26:50 2017 UTC (6 years, 7 months ago) by pfg
File length: 22779 byte(s)
Diff to previous 314877
spdx: initial adoption of licensing ID tags.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133


Revision 314877 - (view) (download) (annotate) - [select for diffs]
Modified Tue Mar 7 19:30:22 2017 UTC (7 years, 3 months ago) by pfg
File length: 22734 byte(s)
Diff to previous 299357
lpr(1): small bounds check with reallocarray(3).

While here plug a memory leak upon error and postpose a multiplication
until after reallocation has succeded.

Hinted partially by:	OpenBSD
Reviewed by:		gad
MFC after:		2 weeks


Revision 299357 - (view) (download) (annotate) - [select for diffs]
Modified Tue May 10 11:17:19 2016 UTC (8 years, 1 month ago) by bapt
File length: 22706 byte(s)
Diff to previous 298886
Rename getline with get_line to avoid collision with getline(3)

When getline(3) in 2009 was added a _WITH_GETLINE guard has also been added.
This rename is made in preparation for the removal of this guard


Revision 298886 - (view) (download) (annotate) - [select for diffs]
Modified Sun May 1 16:41:25 2016 UTC (8 years, 2 months ago) by pfg
File length: 22704 byte(s)
Diff to previous 297795
usr.sbin: minor spelling fixes on comments.

No functional change.


Revision 297795 - (view) (download) (annotate) - [select for diffs]
Modified Sun Apr 10 23:47:40 2016 UTC (8 years, 2 months ago) by pfg
File length: 22703 byte(s)
Diff to previous 251044
lpr: replace 0 with NULL for pointers.

Found with devel/coccinelle.

Reviewed by:	gad


Revision 251044 - (view) (download) (annotate) - [select for diffs]
Modified Mon May 27 22:19:01 2013 UTC (11 years, 1 month ago) by gad
File length: 22697 byte(s)
Diff to previous 242091
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


Revision 242091 - (view) (download) (annotate) - [select for diffs]
Modified Thu Oct 25 20:16:38 2012 UTC (11 years, 8 months ago) by ed
File length: 22637 byte(s)
Diff to previous 241852
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.


Revision 241852 - (view) (download) (annotate) - [select for diffs]
Modified Mon Oct 22 03:31:22 2012 UTC (11 years, 8 months ago) by eadler
File length: 22662 byte(s)
Diff to previous 238547
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


Revision 238547 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jul 17 09:34:52 2012 UTC (11 years, 11 months ago) by jh
File length: 22700 byte(s)
Diff to previous 238546
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


Revision 238546 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jul 17 09:31:05 2012 UTC (11 years, 11 months ago) by jh
File length: 22665 byte(s)
Diff to previous 235647
Remove trailing whitespace.

MFC after:	2 weeks


Revision 235647 - (view) (download) (annotate) - [select for diffs]
Modified Sat May 19 12:44:27 2012 UTC (12 years, 1 month ago) by gleb
File length: 22670 byte(s)
Diff to previous 139464
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


Revision 139464 - (view) (download) (annotate) - [select for diffs]
Modified Fri Dec 31 00:36:28 2004 UTC (19 years, 6 months ago) by gad
File length: 22670 byte(s)
Diff to previous 117592
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


Revision 117592 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jul 14 20:20:58 2003 UTC (20 years, 11 months ago) by gad
File length: 20726 byte(s)
Diff to previous 117541
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


Revision 117541 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jul 14 05:15:21 2003 UTC (20 years, 11 months ago) by gad
File length: 20690 byte(s)
Diff to previous 99845
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


Revision 99845 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jul 12 01:37:06 2002 UTC (21 years, 11 months ago) by gad
File length: 20667 byte(s)
Diff to previous 99844
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


Revision 99844 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jul 12 01:31:46 2002 UTC (21 years, 11 months ago) by gad
File length: 20665 byte(s)
Diff to previous 99842
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


Revision 99842 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jul 12 01:22:57 2002 UTC (21 years, 11 months ago) by gad
File length: 20402 byte(s)
Diff to previous 98154
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


Revision 98154 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jun 13 02:37:50 2002 UTC (22 years ago) by gad
File length: 20293 byte(s)
Diff to previous 98153
Bah humbug.  Fix another typo on the same comment line.  It also had
an option-space instead of a space...

MFC after:	10 days


Revision 98153 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jun 13 02:32:42 2002 UTC (22 years ago) by gad
File length: 20293 byte(s)
Diff to previous 98152
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


Revision 98152 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jun 13 01:55:48 2002 UTC (22 years ago) by gad
File length: 20293 byte(s)
Diff to previous 97421
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


Revision 97421 - (view) (download) (annotate) - [select for diffs]
Modified Tue May 28 19:23:47 2002 UTC (22 years, 1 month ago) by alfred
File length: 16945 byte(s)
Diff to previous 95290
Assume __STDC__, remove non-__STDC__ code.


Revision 95290 - (view) (download) (annotate) - [select for diffs]
Modified Mon Apr 22 23:08:07 2002 UTC (22 years, 2 months ago) by gad
File length: 17147 byte(s)
Diff to previous 80172
Add 'const' to some casts to fix two warnings that are printed by the
new gcc (on sparc64).

MFC after:	4 days


Revision 80172 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jul 23 01:08:15 2001 UTC (22 years, 11 months ago) by gad
File length: 17133 byte(s)
Diff to previous 79740
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


Revision 79740 - (view) (download) (annotate) - [select for diffs]
Modified Sun Jul 15 00:57:18 2001 UTC (22 years, 11 months ago) by gad
File length: 17055 byte(s)
Diff to previous 78300
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


Revision 78300 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jun 15 22:03:07 2001 UTC (23 years ago) by gad
File length: 17086 byte(s)
Diff to previous 78280
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


Revision 78280 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jun 15 16:28:37 2001 UTC (23 years ago) by gad
File length: 17010 byte(s)
Diff to previous 78146
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


Revision 78146 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jun 12 16:38:20 2001 UTC (23 years ago) by gad
File length: 17002 byte(s)
Diff to previous 75253
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


Revision 75253 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 6 02:14:39 2001 UTC (23 years, 3 months ago) by gad
File length: 17125 byte(s)
Diff to previous 68740
Make sure the euid is restored in an obscure error situation.

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


Revision 68740 - (view) (download) (annotate) - [select for diffs]
Modified Wed Nov 15 04:10:59 2000 UTC (23 years, 7 months ago) by gad
File length: 17095 byte(s)
Diff to previous 68739
Reset the seteuid in a few obscure error situations.


Revision 68739 - (view) (download) (annotate) - [select for diffs]
Modified Wed Nov 15 03:35:09 2000 UTC (23 years, 7 months ago) by gad
File length: 17059 byte(s)
Diff to previous 68401
Just some style-related improvements.


Revision 68401 - (view) (download) (annotate) - [select for diffs]
Modified Mon Nov 6 19:36:38 2000 UTC (23 years, 8 months ago) by gad
File length: 17004 byte(s)
Diff to previous 68253
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


Revision 68253 - (view) (download) (annotate) - [select for diffs]
Modified Thu Nov 2 19:22:06 2000 UTC (23 years, 8 months ago) by gad
File length: 16932 byte(s)
Diff to previous 59920
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


Revision 59920 - (view) (download) (annotate) - [select for diffs]
Modified Wed May 3 14:56:20 2000 UTC (24 years, 2 months ago) by wollman
File length: 7791 byte(s)
Diff to previous 50479
Print files submitted at the same instant in deterministic order.

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


Revision 50479 - (view) (download) (annotate) - [select for diffs]
Modified Sat Aug 28 01:35:59 1999 UTC (24 years, 10 months ago) by peter
File length: 7271 byte(s)
Diff to previous 39084
$Id$ -> $FreeBSD$


Revision 39084 - (view) (download) (annotate) - [select for diffs]
Modified Fri Sep 11 18:49:33 1998 UTC (25 years, 9 months ago) by wollman
File length: 7315 byte(s)
Diff to previous 31492
Fix additional warnings.  Remove -Werror, since some people have complained
about it.

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


Revision 31492 - (view) (download) (annotate) - [select for diffs]
Modified Tue Dec 2 20:46:22 1997 UTC (26 years, 7 months ago) by wollman
File length: 7261 byte(s)
Diff to previous 30407
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...


Revision 30407 - (view) (download) (annotate) - [select for diffs]
Modified Tue Oct 14 16:01:02 1997 UTC (26 years, 8 months ago) by joerg
File length: 10364 byte(s)
Diff to previous 27757
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?


Revision 27757 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jul 29 13:24:01 1997 UTC (26 years, 11 months ago) by imp
File length: 10324 byte(s)
Diff to previous 27748
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


Revision 27748 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jul 29 04:17:19 1997 UTC (26 years, 11 months ago) by imp
File length: 10313 byte(s)
Diff to previous 27618
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


Revision 27618 - (view) (download) (annotate) - [select for diffs]
Modified Wed Jul 23 00:49:46 1997 UTC (26 years, 11 months ago) by imp
File length: 10261 byte(s)
Diff to previous 27511
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


Revision 27511 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jul 18 18:52:53 1997 UTC (26 years, 11 months ago) by imp
File length: 10140 byte(s)
Diff to previous 15648
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.


Revision 15648 - (view) (download) (annotate) - [select for diffs]
Modified Sun May 5 22:40:51 1996 UTC (28 years, 2 months ago) by joerg
File length: 10076 byte(s)
Diff to previous 15031
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>


Revision 15031 - (view) (download) (annotate) - [select for diffs]
Modified Wed Apr 3 22:46:59 1996 UTC (28 years, 3 months ago) by sef
File length: 9512 byte(s)
Diff to previous 8857
Remove definitions and declarations for FS, FC, XS, XC variables, and
replace them with MS char* variable.

Reviewed by:	rgrimes, joerg


Revision 8857 - (view) (download) (annotate) - [select for diffs]
Modified Tue May 30 03:57:47 1995 UTC (29 years, 1 month ago) by rgrimes
File length: 9659 byte(s)
Diff to previous 1554
Remove trailing whitespace.


Revision 1554 - (view) (download) (annotate) - [select for diffs]
Modified Thu May 26 05:23:31 1994 UTC (30 years, 1 month ago) by rgrimes
File length: 9660 byte(s)
Copied from: vendor/CSRG/dist/usr.sbin/lpr/common_source/common.c revision 1553
Diff to previous 1553
This commit was generated by cvs2svn to compensate for changes in r1553,
which included commits to RCS files with non-trunk default branches.


Revision 1553 - (view) (download) (annotate) - [select for diffs]
Added Thu May 26 05:23:31 1994 UTC (30 years, 1 month ago) by rgrimes
Original Path: vendor/CSRG/dist/usr.sbin/lpr/common_source/common.c
File length: 9660 byte(s)
BSD 4.4 Lite usr.sbin Sources


This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

  Diffs between and
  Type of Diff should be a

  ViewVC Help
Powered by ViewVC 1.1.27