History log of /freebsd-head/usr.sbin/lpr/lpc/cmds.c
Revision Date Author Comments
872b698bd4a1bfc0bf008c09228e6fd238809c75 20-Nov-2017 pfg <pfg@FreeBSD.org> General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

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.
7e6cabd06e6caa6a02eeb86308dc0cb3f27e10da 28-Feb-2017 imp <imp@FreeBSD.org> Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96
00d578928eca75be320b36d37543a7e2a4f9fbdb 27-May-2016 grehan <grehan@FreeBSD.org> Create branch for bhyve graphics import.
c80a45c967a30b0e865e5e6c8f674b2d5566c50b 10-May-2016 bapt <bapt@FreeBSD.org> 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
eb1a5f8de9f7ea602c373a710f531abbf81141c4 21-Feb-2014 gjb <gjb@FreeBSD.org> Move ^/user/gjb/hacking/release-embedded up one directory, and remove
^/user/gjb/hacking since this is likely to be merged to head/ soon.

Sponsored by: The FreeBSD Foundation
6b01bbf146ab195243a8e7d43bb11f8835c76af8 27-Dec-2013 gjb <gjb@FreeBSD.org> Copy head@r259933 -> user/gjb/hacking/release-embedded for initial
inclusion of (at least) arm builds with the release.

Sponsored by: The FreeBSD Foundation
4bc19b04c5658de751c40ddf1399ab0dd1d895e7 22-Oct-2012 eadler <eadler@FreeBSD.org> 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
f897dd9a4be8dd80e43185edf0240b1566bd6e8d 30-Apr-2012 gad <gad@FreeBSD.org> Print out a warning message if a `lpc setstatus' is done when
the queue is not 'lpc stop'-ed. In that situation `lpq' will
not display the status message to the user, and the operator
may think the queue is already stopped when it is not.

MFC after: 3 weeks
5fb190b2b7edf0bf9cabd4a770e52a9d17b292ba 30-Apr-2012 gad <gad@FreeBSD.org> Catch the user-error when no queue name was specified on an
lpc-command which supports '-msg' (e.g.: setstatus). Print
out a helpful error message instead hitting a seg-fault.

MFC after: 3 weeks
716dc0a601e63e27f4d5fa9699d4a218d60e2557 13-Apr-2012 delphij <delphij@FreeBSD.org> The scandir(3) function expects fourth parameter, compar, be in type of:

int (*compar)(const struct dirent **, const struct dirent **)

The current code defines sortq() to accept two void *, then cast them
to const struct dirent **. Because the code does not really need this
cast, we can eliminate the casts by changing the function prototype
to match scandir(3) expectation.

MFC after: 1 month
09bba37b34a115e616e690de3923dc08dc8b9e9e 15-Feb-2012 kevlo <kevlo@FreeBSD.org> - Remove some unnecessary cast when assigning NULL to a handle.
- Silent a warning
415a3a9b966c1522657d435a1785904f41accc78 30-Dec-2011 uqs <uqs@FreeBSD.org> Spelling fixes for usr.sbin/
0b5bdd518a11b52d15aff2e28c8409db9a134c6d 11-Dec-2010 joel <joel@FreeBSD.org> 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
09f9c897d33c41618ada06fbbcf1a9b3812dee53 19-Oct-2010 jamie <jamie@FreeBSD.org> A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.
f1216d1f0ade038907195fc114b7e630623b402c 19-Mar-2010 delphij <delphij@FreeBSD.org> Create a custom branch where I will be able to do the merge.
19b6af98ec71398e77874582eb84ec5310c7156f 22-Nov-2008 dfr <dfr@FreeBSD.org> Clone Kip's Xen on stable/6 tree so that I can work on improving FreeBSD/amd64
performance in Xen's HVM mode.
cf5320822f93810742e3d4a1ac8202db8482e633 19-Oct-2008 lulf <lulf@FreeBSD.org> - Import the HEAD csup code which is the basis for the cvsmode work.
5ecf206bdeaff7188680193fa691cc07690809e6 14-Jul-2003 gad <gad@FreeBSD.org> More changes to use __FBSDID() for setting rcsids, and fix the
format of 'sccsid' lines so they consistently match style(9)
guidelines. Note that this means you will have to add '-a' to
the 'strings' command when searching for rcs ids, eg:
strings -a /usr/sbin/lpc | grep '$FreeBSD'

Reviewed by: discussed on cvs-src & with bde and obrien
MFC after: 15 days
f9c62a94d6f639cce594e8d4e6054f3e4790b19b 12-Jul-2002 gad <gad@FreeBSD.org> Call routine to free everything obtained when filling in 'struct printer'.

MFC after: 3 days
ee962e9598cd8f3308bf0825b779fa0b9b9b2730 02-Jul-2002 gad <gad@FreeBSD.org> Remove the backup-versions ("x*") of various lpc commands that were
recently rewritten. No one in -current has reported any problems with
the newer versions.

MFC after: 3 weeks
8da8ab73f43e5508fec262ba4a1d38aeaa8e55ef 16-Jun-2002 gad <gad@FreeBSD.org> Just rename two generic-queue init routines from 'init_*' to '*_gi'
("gi" short for 'generic init'...).

MFC after: 10 days
075d7239bd1571a0a5a991b23f18657c58988ded 16-Jun-2002 gad <gad@FreeBSD.org> Add a nearly complete rewrite of the lpc command 'down'. The only user-
visible change should be that more than one queue can now be specified,
if one uses the '-msg' parameter to separate the list of queues from the
status message to set.

The previous implementation of 'down' remains available as the command
'xdown', available for instant fallback if there seems to be anything
wrong with the new one. If no one reports a problem after a few weeks,
then a later update will remove 'xdown'.

Reviewed by: freebsd-print@bostonradio.org
MFC after: 10 days
d26b6e946e24570444b21b2e5d4b9747e297a200 15-Jun-2002 gad <gad@FreeBSD.org> Reorganize the way that arguments are processed in lpc's generic-queue
commands, to make things a little cleaner (mainly for a later update).

Reviewed by: freebsd-print@bostonradio.org
MFC after: 10 days
6bfe5682488b02e59b3b1254657a7bc8b9bb209b 15-Jun-2002 gad <gad@FreeBSD.org> Add a new command to 'lpc' called 'setstatus', which would be used to
change the status message of a print queue. This includes some minor
changes to the upstat() routine, so that error messages are not printed
while seteuid(priv-user).

Reviewed by: freebsd-audit and freebsd-print@bostonradio.org
MFC after: 10 days
1c055fbea9cfb02ca0226882de37e40e7f2039af 13-Jun-2002 gad <gad@FreeBSD.org> 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
3221843018420856d43b612319c6236f91198471 22-Apr-2002 gad <gad@FreeBSD.org> Add 'const' to some casts to fix two warnings that are printed by the
new gcc (on sparc64).

MFC after: 4 days
4d6b787d2daa6eb05c0f3526d65b0b92b1afa715 22-Apr-2002 des <des@FreeBSD.org> Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.
f06e6295c8dce22b1649c23d59705ab3fefdc9ce 28-Nov-2001 gad <gad@FreeBSD.org> My recent changes to add the ctl_renametf routine assumed that print job
control-files will always start with 'cfA*'. It turns out that some
implementations of lpd (such as solaris) may send a control file which
starts with 'cfB*', or really 'cf<anyLetter>*'. Although such filenames
are very odd, we did used to accept them. This changes ctl_renametf to
work correctly with them, and fixes up 'lpc clean' to match.

PR: bin/32183
MFC after: 10 days
28ccdf65058a921f0db4b4c374922ffcddf0e8bc 09-Oct-2001 gad <gad@FreeBSD.org> Fix minor compile-time warning that snunk in with changes to sortq() rtn.

MFC after: 4 days
1053a31527aa5f44fdc9da31c012291a4c06d118 27-Sep-2001 gad <gad@FreeBSD.org> Basically rewrite the sortq() routine which is used by 'lpc clean' and
'lpc tclean'. In some obscure cases, the previous version could cause a
valid user job to be removed (by 'clean'), due to invalid assumptions in
the sort routine. This was a rare problem, unless ctlinfo.c is compiled
with 'LEAVE_TMPCF_FILES' turned on (to check what that rtn was doing).

Reviewed by: Lack of outcry on -audit and freebsd-print@bostonradio.org
MFC after: 10 days
dea0eea19efa30f9411602f8f9e742fd9ffad88f 23-Jul-2001 gad <gad@FreeBSD.org> Get rid of a compile-time warning by casting to (size_t).

MFC after: 1 week
75f5203b04d78ac555161bc219da58cbfeffefbd 15-Jul-2001 gad <gad@FreeBSD.org> 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
a89ca1efdcee5122d5660c0173acb8a8d1d53225 25-Jun-2001 gad <gad@FreeBSD.org> Make 'lpc clean' somewhat safer. Add an 'lpc tclean' command, which allows
one to see what files would be removed *if* an 'lpc clean' is done. 'tclean'
will remove no files, and is therefore not a privileged command. Also, both
'lpc clean' and 'lpc tclean' will now look for 'core' files in spool directories
(but not remove them). They also print out an extra line of info when a
datafile to be removed is a symlink (from 'lpr -s'), saying what file it is
a symlink to.

The 'lpc clean' commands also now print out a summary line saying how many
queues were checked, how many files were removed (or "would be" removed, for
tclean), and how much disk space is involved. For the benefit of those who
have many print queues, 'lpc clean all' will only print out the names of print
queues where some "interesting" files were found, instead of printing out a
header-line for every queue in your printcap file.

Reviewed by: freebsd-print@bostonradio.org freebsd-audit@FreeBSD.org
MFC after: 2 weeks
d61428321f0ceb41de748a616b592b50195c51fb 12-Jun-2001 gad <gad@FreeBSD.org> 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
0a81eeee321ee06eb5c4bdecf10ccdf38411f692 06-Nov-2000 gad <gad@FreeBSD.org> 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
b42951578188c5aab5c9f8cbcde4a743f8092cdc 02-Apr-2000 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'ALSA'.
1a88679ae1b5d8f8d777508cfcb671d512e56bce 24-Jan-2000 dillon <dillon@FreeBSD.org> 'start' command was not reenabling printing.

PR: bin/15728
efabb9ccb197b05958967dd035c279ba3bc19cb0 28-Aug-1999 peter <peter@FreeBSD.org> $Id$ -> $FreeBSD$
aac5469d30c451307f3e3a8b2356165d289e444a 11-Sep-1998 wollman <wollman@FreeBSD.org> Fix additional warnings. Remove -Werror, since some people have complained
about it.

PR: 7886
Submitted by: Stefan Eggers <seggers@semyam.dinoco.de> (partially)
0506343883d62f6649f7bbaf1a436133cef6261d 11-Jan-1998 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'jb'.
7c6e96080c4fb49bf912942804477d202a53396c 10-Jan-1998 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'JB'.
bf21e6b4e0e85ae08cb5d1f2335da248f52e2d26 02-Dec-1997 wollman <wollman@FreeBSD.org> 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...
2f9d4f24114eb44bfde492debae4196f2127b888 29-Jul-1997 imp <imp@FreeBSD.org> 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
b1debf973d6a489bfe9c6511c94e356d6c024a47 29-Jul-1997 imp <imp@FreeBSD.org> 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
181a3aef05fad102fcb087cc47240b3a5d52298e 23-Jul-1997 imp <imp@FreeBSD.org> 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.
f080009db57e6a7b246a2ab15d8a73e4563931b4 23-Jul-1997 imp <imp@FreeBSD.org> 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
dc36a1d5ad68922d4425cce4fb05d82a4584ec17 13-May-1997 brian <brian@FreeBSD.org> Don't output extraneous tab

Submitted by: Garance A Drosehn <gad@eclipse.its.rpi.edu>
0bd4c187acf470a3fb00c2633c8b9e4f3d46cfaf 09-Feb-1997 imp <imp@FreeBSD.org> Buffer overflow from OpenBSD:
Rev 1.7 millert:
possible oflow
Obtained from: OpenBSD
354a4db3b5ff4e1a474ecd6a53a6b494699bb7e5 27-Oct-1996 imp <imp@FreeBSD.org> 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
914cbcef2ca2238d808f510c1a2f084eb37952b6 05-May-1996 joerg <joerg@FreeBSD.org> 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>
0291e848bc787305335af649ac14bc8fe5a19a49 05-May-1996 joerg <joerg@FreeBSD.org> Vendor-branch import of the 4.4BSD-Lite2 code for lpr. There are
several bugfixes in it that are worth considering.

Don't be alarmed about the import conflicts...

Obtained from: 4.4BSD-Lite2
86f1bc4514fdcfd255f37f3218fe234bdc3664fc 05-Nov-1995 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'LINUX'.
4f960dd75f181e9fa2edc44324f15f0ab5c64b37 30-May-1995 rgrimes <rgrimes@FreeBSD.org> Remove trailing whitespace.
2e14d9ebc3d3592c67bdf625af9ebe0dfc386653 14-Mar-1995 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'MATT_THOMAS'.
34cd81d75f398ee455e61969b118639dacbfd7a6 23-Sep-1994 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'MACKERRAS'.
e16baf7a5fe7ac1453381d0017ed1dcdeefbc995 07-Aug-1994 cvs2svn <cvs2svn@FreeBSD.org> This commit was manufactured by cvs2svn to create branch 'SUNRPC'.
862fdf11a2ede45dec0da01ed575525d79468981 26-May-1994 rgrimes <rgrimes@FreeBSD.org> BSD 4.4 Lite usr.sbin Sources