History log of /openbsd-current/usr.sbin/lpr/lpq/lpq.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.25 28-Dec-2022 jmc

spelling fixes; from paul tagliamonte
any parts of his diff not taken are noted on tech


# 1.24 04-Dec-2022 cheloha

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument. We can
handle this case with the "default" failure case with no loss of
legibility. Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@. With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.23 29-Feb-2016 jca

Move ckqueue() to common_source/common.c

Patch from Chris Bennett, ok tb@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.22 09-Feb-2015 deraadt

clean up flags++ instances around getopt()
ok florian


# 1.21 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.20 24-Nov-2013 deraadt

more ctype cleanups
checked by jca


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.19 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.18 26-May-2008 otto

cgetstr(3) can also return 2 so handle that. Also restructre things a bit
to get rid of the flag var. ok deraadt@ fgsch@


# 1.17 22-May-2008 otto

Comparing string literals does not work as the author expected.
From Adam Majer (debian maintaner); looks correct fgs@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.16 16-Feb-2007 jmc

sort options and sync usage(); from Igor Sobrado


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.15 03-Sep-2003 tedu

plug mem leaks, pr3425 from patrick latifi. ok deraadt@


# 1.14 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.13 08-Jun-2002 millert

Remove setuid root from lp*. lpr needs to be setuid daemon so the
files it creates are not owned by the user spooling them but the
others (lpc, lpq, lprm) can get away with setgid daemon. lpd runs
as user daemon for most things, only changing its uid to 0 for
things that must be done as root.

For the time being, don't require connections to come from a reserved
port since lpq/lpr/lprm can't acquire that w/o setuid root. In the
near future we will have a mechanism for select non-root processes
to grab reserved ports.

The upshot of this is that spool directories must be writable by
group daemon and the files within the spool dirs must be owned by
daemon.


# 1.12 20-May-2002 millert

Pull in useful bits from NetBSD and make our lp* easier to diff and
do some minor cleanup of my own:

o IPv6 support
o ANSI function headers
o use getopt()
o synce usage() with man pages
o passes -Wall on both 32bit and 64bit platforms
o add an option to set the max number of children lpd will fork off
o add an lpd option to bind to specific addresses instead of INADDR_ANY.
o allow user to specify how long to wait for a connection to remote servers
o more strlcpy() and snprintf() usage
o Use FOO_FILENO constants instead of hard-coding 0-2
o Add some keeps to man the page SYNOPSIS to avoid options being split


Revision tags: OPENBSD_3_1_BASE
# 1.11 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.10 06-Dec-2001 ericj

use err/warn and friends instead of printf/exit.
also, remove fatal2() which is just errx anyway.

millert@ ok


# 1.9 23-Nov-2001 deraadt

use the same siginterrupt() trick in lpc(1) as in timedc(1). we have to hack
a global into the other programs since they share some source.


Revision tags: OPENBSD_3_0_BASE
# 1.8 30-Aug-2001 millert

o kill register
o add const to rcsid and copyright strings
o placate -Wall


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.7 17-Jan-1997 millert

Add OpenBSD tags (was in wrong dir for previous commit)


# 1.6 26-Oct-1996 imp

getopt returns -1 on OpenBSD


Revision tags: OPENBSD_2_0_BASE
# 1.5 04-Jul-1996 tholo

Integrated 4.4Lite2 source
Fixed potential problem pointed out by bitblt


# 1.4 15-May-1996 pefo

previous fix of NULL check reversed


# 1.3 06-May-1996 pefo

Missing ' == NULL)' added...


# 1.2 04-May-1996 deraadt

correct -P, $PRINTER, and DEFLP interactions. bug reported by scott.burns@labatt.com


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.24 04-Dec-2022 cheloha

userspace: remove vestigial '?' cases from top-level getopt(3) loops

getopt(3) returns '?' when it encounters a flag not present in the in
the optstring or if a flag is missing its option argument. We can
handle this case with the "default" failure case with no loss of
legibility. Hence, remove all the redundant "case '?':" lines.

Prompted by dlg@. With help from dlg@ and millert@.

Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2

ok naddy@ millert@ dlg@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.23 29-Feb-2016 jca

Move ckqueue() to common_source/common.c

Patch from Chris Bennett, ok tb@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.22 09-Feb-2015 deraadt

clean up flags++ instances around getopt()
ok florian


# 1.21 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.20 24-Nov-2013 deraadt

more ctype cleanups
checked by jca


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.19 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.18 26-May-2008 otto

cgetstr(3) can also return 2 so handle that. Also restructre things a bit
to get rid of the flag var. ok deraadt@ fgsch@


# 1.17 22-May-2008 otto

Comparing string literals does not work as the author expected.
From Adam Majer (debian maintaner); looks correct fgs@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.16 16-Feb-2007 jmc

sort options and sync usage(); from Igor Sobrado


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.15 03-Sep-2003 tedu

plug mem leaks, pr3425 from patrick latifi. ok deraadt@


# 1.14 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.13 08-Jun-2002 millert

Remove setuid root from lp*. lpr needs to be setuid daemon so the
files it creates are not owned by the user spooling them but the
others (lpc, lpq, lprm) can get away with setgid daemon. lpd runs
as user daemon for most things, only changing its uid to 0 for
things that must be done as root.

For the time being, don't require connections to come from a reserved
port since lpq/lpr/lprm can't acquire that w/o setuid root. In the
near future we will have a mechanism for select non-root processes
to grab reserved ports.

The upshot of this is that spool directories must be writable by
group daemon and the files within the spool dirs must be owned by
daemon.


# 1.12 20-May-2002 millert

Pull in useful bits from NetBSD and make our lp* easier to diff and
do some minor cleanup of my own:

o IPv6 support
o ANSI function headers
o use getopt()
o synce usage() with man pages
o passes -Wall on both 32bit and 64bit platforms
o add an option to set the max number of children lpd will fork off
o add an lpd option to bind to specific addresses instead of INADDR_ANY.
o allow user to specify how long to wait for a connection to remote servers
o more strlcpy() and snprintf() usage
o Use FOO_FILENO constants instead of hard-coding 0-2
o Add some keeps to man the page SYNOPSIS to avoid options being split


Revision tags: OPENBSD_3_1_BASE
# 1.11 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.10 06-Dec-2001 ericj

use err/warn and friends instead of printf/exit.
also, remove fatal2() which is just errx anyway.

millert@ ok


# 1.9 23-Nov-2001 deraadt

use the same siginterrupt() trick in lpc(1) as in timedc(1). we have to hack
a global into the other programs since they share some source.


Revision tags: OPENBSD_3_0_BASE
# 1.8 30-Aug-2001 millert

o kill register
o add const to rcsid and copyright strings
o placate -Wall


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.7 17-Jan-1997 millert

Add OpenBSD tags (was in wrong dir for previous commit)


# 1.6 26-Oct-1996 imp

getopt returns -1 on OpenBSD


Revision tags: OPENBSD_2_0_BASE
# 1.5 04-Jul-1996 tholo

Integrated 4.4Lite2 source
Fixed potential problem pointed out by bitblt


# 1.4 15-May-1996 pefo

previous fix of NULL check reversed


# 1.3 06-May-1996 pefo

Missing ' == NULL)' added...


# 1.2 04-May-1996 deraadt

correct -P, $PRINTER, and DEFLP interactions. bug reported by scott.burns@labatt.com


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 29-Feb-2016 jca

Move ckqueue() to common_source/common.c

Patch from Chris Bennett, ok tb@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.22 09-Feb-2015 deraadt

clean up flags++ instances around getopt()
ok florian


# 1.21 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE
# 1.20 24-Nov-2013 deraadt

more ctype cleanups
checked by jca


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.19 27-Oct-2009 deraadt

rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable). these days, people use source. these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.18 26-May-2008 otto

cgetstr(3) can also return 2 so handle that. Also restructre things a bit
to get rid of the flag var. ok deraadt@ fgsch@


# 1.17 22-May-2008 otto

Comparing string literals does not work as the author expected.
From Adam Majer (debian maintaner); looks correct fgs@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.16 16-Feb-2007 jmc

sort options and sync usage(); from Igor Sobrado


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.15 03-Sep-2003 tedu

plug mem leaks, pr3425 from patrick latifi. ok deraadt@


# 1.14 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.13 08-Jun-2002 millert

Remove setuid root from lp*. lpr needs to be setuid daemon so the
files it creates are not owned by the user spooling them but the
others (lpc, lpq, lprm) can get away with setgid daemon. lpd runs
as user daemon for most things, only changing its uid to 0 for
things that must be done as root.

For the time being, don't require connections to come from a reserved
port since lpq/lpr/lprm can't acquire that w/o setuid root. In the
near future we will have a mechanism for select non-root processes
to grab reserved ports.

The upshot of this is that spool directories must be writable by
group daemon and the files within the spool dirs must be owned by
daemon.


# 1.12 20-May-2002 millert

Pull in useful bits from NetBSD and make our lp* easier to diff and
do some minor cleanup of my own:

o IPv6 support
o ANSI function headers
o use getopt()
o synce usage() with man pages
o passes -Wall on both 32bit and 64bit platforms
o add an option to set the max number of children lpd will fork off
o add an lpd option to bind to specific addresses instead of INADDR_ANY.
o allow user to specify how long to wait for a connection to remote servers
o more strlcpy() and snprintf() usage
o Use FOO_FILENO constants instead of hard-coding 0-2
o Add some keeps to man the page SYNOPSIS to avoid options being split


Revision tags: OPENBSD_3_1_BASE
# 1.11 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.10 06-Dec-2001 ericj

use err/warn and friends instead of printf/exit.
also, remove fatal2() which is just errx anyway.

millert@ ok


# 1.9 23-Nov-2001 deraadt

use the same siginterrupt() trick in lpc(1) as in timedc(1). we have to hack
a global into the other programs since they share some source.


Revision tags: OPENBSD_3_0_BASE
# 1.8 30-Aug-2001 millert

o kill register
o add const to rcsid and copyright strings
o placate -Wall


Revision tags: OPENBSD_2_1_BASE OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.7 17-Jan-1997 millert

Add OpenBSD tags (was in wrong dir for previous commit)


# 1.6 26-Oct-1996 imp

getopt returns -1 on OpenBSD


Revision tags: OPENBSD_2_0_BASE
# 1.5 04-Jul-1996 tholo

Integrated 4.4Lite2 source
Fixed potential problem pointed out by bitblt


# 1.4 15-May-1996 pefo

previous fix of NULL check reversed


# 1.3 06-May-1996 pefo

Missing ' == NULL)' added...


# 1.2 04-May-1996 deraadt

correct -P, $PRINTER, and DEFLP interactions. bug reported by scott.burns@labatt.com


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision