History log of /freebsd-current/usr.sbin/lpr/lpc/cmds.c
Revision Date Author Comments
# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# 8a7b6120 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.sbin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 1def31df 02-Mar-2023 Elyes Haouas <ehaouas@noos.fr>

lpr: Remove useless return at the end of void function

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656


# 04389c85 08-Aug-2021 Gordon Bergling <gbe@FreeBSD.org>

Fix some common typos in comments

- s/configuraiton/configuration/
- s/specifed/specified/
- s/compatiblity/compatibility/

MFC after: 5 days


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <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.


# fbbd9655 28-Feb-2017 Warner Losh <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


# a9c48188 10-May-2016 Baptiste Daroussin <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


# 1d1d4a47 21-Oct-2012 Eitan Adler <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


# 7574a1c1 29-Apr-2012 Garance A Drosehn <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


# aa318fd7 29-Apr-2012 Garance A Drosehn <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


# 2c81fb6a 13-Apr-2012 Xin LI <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


# 6e807fa6 14-Feb-2012 Kevin Lo <kevlo@FreeBSD.org>

- Remove some unnecessary cast when assigning NULL to a handle.
- Silent a warning


# 3df5ecac 30-Dec-2011 Ulrich Spörlein <uqs@FreeBSD.org>

Spelling fixes for usr.sbin/


# 914e11a7 11-Dec-2010 Joel Dahl <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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# c44a6dce 14-Jul-2003 Garance A Drosehn <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


# cc2b61b1 11-Jul-2002 Garance A Drosehn <gad@FreeBSD.org>

Call routine to free everything obtained when filling in 'struct printer'.

MFC after: 3 days


# c06ffb89 01-Jul-2002 Garance A Drosehn <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


# c9cb13a0 15-Jun-2002 Garance A Drosehn <gad@FreeBSD.org>

Just rename two generic-queue init routines from 'init_*' to '*_gi'
("gi" short for 'generic init'...).

MFC after: 10 days


# 5b1c34fb 15-Jun-2002 Garance A Drosehn <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


# e7f478b2 15-Jun-2002 Garance A Drosehn <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


# 54032d11 15-Jun-2002 Garance A Drosehn <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


# e8e715fa 12-Jun-2002 Garance A Drosehn <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


# f0baf665 22-Apr-2002 Garance A Drosehn <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


# d3974088 22-Apr-2002 Dag-Erling Smørgrav <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}/.


# 1fd731fa 27-Nov-2001 Garance A Drosehn <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


# 4f7f8234 08-Oct-2001 Garance A Drosehn <gad@FreeBSD.org>

Fix minor compile-time warning that snunk in with changes to sortq() rtn.

MFC after: 4 days


# ceeaedd3 27-Sep-2001 Garance A Drosehn <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


# 79c96a6c 22-Jul-2001 Garance A Drosehn <gad@FreeBSD.org>

Get rid of a compile-time warning by casting to (size_t).

MFC after: 1 week


# 6d39e1b7 14-Jul-2001 Garance A Drosehn <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


# 004c9c5d 24-Jun-2001 Garance A Drosehn <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


# ba7a1ad7 12-Jun-2001 Garance A Drosehn <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


# 30b4b758 06-Nov-2000 Garance A Drosehn <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


# 1bd87e1b 24-Jan-2000 Matthew Dillon <dillon@FreeBSD.org>

'start' command was not reenabling printing.

PR: bin/15728


# 97d92980 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 90cf373d 11-Sep-1998 Garrett 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)


# 4a1a0dbe 02-Dec-1997 Garrett 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...


# 6ee8b269 29-Jul-1997 Warner Losh <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


# 5f87a7b6 28-Jul-1997 Warner Losh <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


# f8eb25da 23-Jul-1997 Warner Losh <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.


# 360d4ad5 22-Jul-1997 Warner Losh <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


# 36abea5d 13-May-1997 Brian Somers <brian@FreeBSD.org>

Don't output extraneous tab

Submitted by: Garance A Drosehn <gad@eclipse.its.rpi.edu>


# 87751a84 08-Feb-1997 Warner Losh <imp@FreeBSD.org>

Buffer overflow from OpenBSD:
Rev 1.7 millert:
possible oflow
Obtained from: OpenBSD


# bc407914 26-Oct-1996 Warner Losh <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


# 5458e2f4 05-May-1996 Joerg Wunsch <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>


# 0b561052 05-May-1996 Joerg Wunsch <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


# 709e8f9a 29-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# dea673e9 25-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite usr.sbin Sources