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

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


Revision tags: 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.65 26-Apr-2018 guenther

Use <fcntl.h> instead of <sys/file.h> for open() and friends.
Delete a bunch of unnecessary #includes and sort to match style(9)
while doing the above cleanup.

ok deraadt@ krw@


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

Move ckqueue() to common_source/common.c

Patch from Chris Bennett, ok tb@


Revision tags: OPENBSD_5_9_BASE
# 1.63 19-Dec-2015 mmcc

Remove NULL-check before free().


# 1.62 28-Oct-2015 millert

Remove support for lpd.pid file. OK deraadt@


# 1.61 27-Oct-2015 millert

Use AF_UNIX instead of AF_LOCAL.


# 1.60 11-Oct-2015 guenther

Userspace doesn't need to use SUN_LEN(): connect() and bind() must accept
sizeof(struct sockaddr_un), so do the simple, portable thing.
Also convert some strncpy() to strlcpy()

ok deraadt@


# 1.59 29-Sep-2015 millert

Replace call to __ivaliduser_sa() with a pared down version that
only checks the host name. This clears the way for removal of
__ivaliduser_sa() and __ivaliduser() from libc. OK deraadt@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.58 09-Feb-2015 deraadt

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


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


# 1.56 17-Oct-2014 deraadt

Remove chunk special-casing malloc(siz) for realloc(NULL, siz). Bit
tricky, but note the remembered size is in bss.


# 1.55 11-Oct-2014 doug

Userland reallocarray() audit.

Avoid potential integer overflow in the size argument of malloc() and
realloc() by using reallocarray() to avoid unchecked multiplication.

ok deraadt@ (had same diff in tree)


Revision tags: OPENBSD_5_6_BASE
# 1.54 12-Jul-2014 deraadt

The hosts.lpd file must exist, or no permission is granted. Change the
the log messages to clarify the reason for the failure to clarify the
condition.
ok guenther


# 1.53 20-Apr-2014 ajacoutot

Prevent lpd(8) from looking into hosts.equiv.
Access control is now done only using hosts.lpd.
See lpd(8) for more information about the format of this file.

"seems reasonable" tedu@
"looks good" deraadt@
ok sthen@


Revision tags: OPENBSD_5_5_BASE
# 1.52 24-Nov-2013 deraadt

more ctype cleanups
checked by jca


Revision tags: OPENBSD_5_4_BASE
# 1.51 11-Mar-2013 deraadt

handle ECONNABORTED errors from accept(). In many code blocks they can be
ignored silently and without aborting, much like EINTR and EWOULDBLOCK are.
ok's from various maintainers of these directories...


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
# 1.50 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.49 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.48 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_3_BASE
# 1.47 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_4_2_BASE
# 1.46 05-May-2007 stevesk

remove code for -W, argument now a no-op; ok millert@


# 1.45 01-May-2007 stevesk

remove #ifndef SUN_LEN; ok millert@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.44 07-Apr-2004 aaron

Remove those option letters from the getopt string which do not have a case
handler below. millert@ ok


Revision tags: OPENBSD_3_5_BASE
# 1.43 08-Nov-2003 jmc

typos from Jonathon Gray;


# 1.42 16-Oct-2003 itojun

safer realloc. deraadt ok


# 1.41 26-Sep-2003 pvalchev

realloc fixes; ok deraadt millert


Revision tags: OPENBSD_3_4_BASE
# 1.40 03-Sep-2003 tedu

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


# 1.39 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.38 06-Sep-2002 deraadt

use more socklen_t; pvalchev


# 1.37 23-Jun-2002 deraadt

uid_t and gid_t are unsigned


# 1.36 11-Jun-2002 millert

lprm needs to be setuid daemon after all


# 1.35 08-Jun-2002 millert

make this actually compile


# 1.34 08-Jun-2002 millert

Force lpd socket to be mode 0660, group daemon


# 1.33 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.32 28-May-2002 millert

Repair remote printing; maxfd was not set correctly for remote connections.


# 1.31 22-May-2002 millert

unlink lpd.pid if killed by a signal


# 1.30 22-May-2002 millert

Use O_EXLOCK in open() instead of flock() to eliminate a potential locking
race on the pid file.


# 1.29 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.28 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.27 21-Jan-2002 deraadt

s/deamon/daemon/


# 1.26 07-Jan-2002 millert

Revert local changes that should not have been committed


# 1.25 07-Jan-2002 millert

To disable a SIGCHLD signal handler use SIG_DFL, *not* SIG_IGN
which now has a different meaning.


# 1.24 06-Dec-2001 ericj

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

millert@ ok


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


# 1.22 19-Nov-2001 deraadt

only slight fixes needed in signal handlers


Revision tags: OPENBSD_3_0_BASE
# 1.21 05-Sep-2001 deraadt

do not select(20, ...)


# 1.20 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.19 30-Aug-2001 millert

When using dup2() to make a socket be stdout, first check that it
is not already stdout (fd 1). Otherwise we end up closing stdout
which is not the intention. Also use STDOUT_FILENO instead of 1.
From a conversation with huntting@glarp.com.


# 1.18 30-Aug-2001 millert

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


# 1.17 22-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'


Revision tags: 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.16 03-Aug-1998 millert

Set SO_REUSEADDR on printer/tcp service (port 515); csapuntz@clearviewtech.com


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.15 04-Aug-1997 deraadt

save errno in sigchld handlers


# 1.14 19-Jul-1997 deraadt

Wall cleanup; people running lpd should test!


Revision tags: OPENBSD_2_1_BASE
# 1.13 17-Jan-1997 millert

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


# 1.12 20-Dec-1996 deraadt

initialize name; is this the right hack?


# 1.11 03-Nov-1996 millert

Improve portability by using ANSI/POSIX interfaces when possible.


# 1.10 26-Oct-1996 deraadt

we are so ftp bounce paranoid, we checked twice!


Revision tags: OPENBSD_2_0_BASE
# 1.9 21-Sep-1996 deraadt

doh


# 1.8 21-Sep-1996 deraadt

i so rarely forget htons & friends; this time i did -- warner caught me


# 1.7 21-Sep-1996 deraadt

oflow protection, ftp bounce protection, dns spoof protection


# 1.6 07-Aug-1996 deraadt

ftp bounce protection


# 1.5 04-Jul-1996 tholo

Fix bogon in import


# 1.4 04-Jul-1996 tholo

Integrated 4.4Lite2 source
Fixed potential problem pointed out by bitblt


# 1.3 05-May-1996 deraadt

headers


# 1.2 01-May-1996 deraadt

save some bytes of disk


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.65 26-Apr-2018 guenther

Use <fcntl.h> instead of <sys/file.h> for open() and friends.
Delete a bunch of unnecessary #includes and sort to match style(9)
while doing the above cleanup.

ok deraadt@ krw@


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

Move ckqueue() to common_source/common.c

Patch from Chris Bennett, ok tb@


Revision tags: OPENBSD_5_9_BASE
# 1.63 19-Dec-2015 mmcc

Remove NULL-check before free().


# 1.62 28-Oct-2015 millert

Remove support for lpd.pid file. OK deraadt@


# 1.61 27-Oct-2015 millert

Use AF_UNIX instead of AF_LOCAL.


# 1.60 11-Oct-2015 guenther

Userspace doesn't need to use SUN_LEN(): connect() and bind() must accept
sizeof(struct sockaddr_un), so do the simple, portable thing.
Also convert some strncpy() to strlcpy()

ok deraadt@


# 1.59 29-Sep-2015 millert

Replace call to __ivaliduser_sa() with a pared down version that
only checks the host name. This clears the way for removal of
__ivaliduser_sa() and __ivaliduser() from libc. OK deraadt@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.58 09-Feb-2015 deraadt

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


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


# 1.56 17-Oct-2014 deraadt

Remove chunk special-casing malloc(siz) for realloc(NULL, siz). Bit
tricky, but note the remembered size is in bss.


# 1.55 11-Oct-2014 doug

Userland reallocarray() audit.

Avoid potential integer overflow in the size argument of malloc() and
realloc() by using reallocarray() to avoid unchecked multiplication.

ok deraadt@ (had same diff in tree)


Revision tags: OPENBSD_5_6_BASE
# 1.54 12-Jul-2014 deraadt

The hosts.lpd file must exist, or no permission is granted. Change the
the log messages to clarify the reason for the failure to clarify the
condition.
ok guenther


# 1.53 20-Apr-2014 ajacoutot

Prevent lpd(8) from looking into hosts.equiv.
Access control is now done only using hosts.lpd.
See lpd(8) for more information about the format of this file.

"seems reasonable" tedu@
"looks good" deraadt@
ok sthen@


Revision tags: OPENBSD_5_5_BASE
# 1.52 24-Nov-2013 deraadt

more ctype cleanups
checked by jca


Revision tags: OPENBSD_5_4_BASE
# 1.51 11-Mar-2013 deraadt

handle ECONNABORTED errors from accept(). In many code blocks they can be
ignored silently and without aborting, much like EINTR and EWOULDBLOCK are.
ok's from various maintainers of these directories...


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
# 1.50 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.49 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.48 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_3_BASE
# 1.47 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_4_2_BASE
# 1.46 05-May-2007 stevesk

remove code for -W, argument now a no-op; ok millert@


# 1.45 01-May-2007 stevesk

remove #ifndef SUN_LEN; ok millert@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.44 07-Apr-2004 aaron

Remove those option letters from the getopt string which do not have a case
handler below. millert@ ok


Revision tags: OPENBSD_3_5_BASE
# 1.43 08-Nov-2003 jmc

typos from Jonathon Gray;


# 1.42 16-Oct-2003 itojun

safer realloc. deraadt ok


# 1.41 26-Sep-2003 pvalchev

realloc fixes; ok deraadt millert


Revision tags: OPENBSD_3_4_BASE
# 1.40 03-Sep-2003 tedu

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


# 1.39 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.38 06-Sep-2002 deraadt

use more socklen_t; pvalchev


# 1.37 23-Jun-2002 deraadt

uid_t and gid_t are unsigned


# 1.36 11-Jun-2002 millert

lprm needs to be setuid daemon after all


# 1.35 08-Jun-2002 millert

make this actually compile


# 1.34 08-Jun-2002 millert

Force lpd socket to be mode 0660, group daemon


# 1.33 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.32 28-May-2002 millert

Repair remote printing; maxfd was not set correctly for remote connections.


# 1.31 22-May-2002 millert

unlink lpd.pid if killed by a signal


# 1.30 22-May-2002 millert

Use O_EXLOCK in open() instead of flock() to eliminate a potential locking
race on the pid file.


# 1.29 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.28 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.27 21-Jan-2002 deraadt

s/deamon/daemon/


# 1.26 07-Jan-2002 millert

Revert local changes that should not have been committed


# 1.25 07-Jan-2002 millert

To disable a SIGCHLD signal handler use SIG_DFL, *not* SIG_IGN
which now has a different meaning.


# 1.24 06-Dec-2001 ericj

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

millert@ ok


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


# 1.22 19-Nov-2001 deraadt

only slight fixes needed in signal handlers


Revision tags: OPENBSD_3_0_BASE
# 1.21 05-Sep-2001 deraadt

do not select(20, ...)


# 1.20 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.19 30-Aug-2001 millert

When using dup2() to make a socket be stdout, first check that it
is not already stdout (fd 1). Otherwise we end up closing stdout
which is not the intention. Also use STDOUT_FILENO instead of 1.
From a conversation with huntting@glarp.com.


# 1.18 30-Aug-2001 millert

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


# 1.17 22-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'


Revision tags: 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.16 03-Aug-1998 millert

Set SO_REUSEADDR on printer/tcp service (port 515); csapuntz@clearviewtech.com


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.15 04-Aug-1997 deraadt

save errno in sigchld handlers


# 1.14 19-Jul-1997 deraadt

Wall cleanup; people running lpd should test!


Revision tags: OPENBSD_2_1_BASE
# 1.13 17-Jan-1997 millert

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


# 1.12 20-Dec-1996 deraadt

initialize name; is this the right hack?


# 1.11 03-Nov-1996 millert

Improve portability by using ANSI/POSIX interfaces when possible.


# 1.10 26-Oct-1996 deraadt

we are so ftp bounce paranoid, we checked twice!


Revision tags: OPENBSD_2_0_BASE
# 1.9 21-Sep-1996 deraadt

doh


# 1.8 21-Sep-1996 deraadt

i so rarely forget htons & friends; this time i did -- warner caught me


# 1.7 21-Sep-1996 deraadt

oflow protection, ftp bounce protection, dns spoof protection


# 1.6 07-Aug-1996 deraadt

ftp bounce protection


# 1.5 04-Jul-1996 tholo

Fix bogon in import


# 1.4 04-Jul-1996 tholo

Integrated 4.4Lite2 source
Fixed potential problem pointed out by bitblt


# 1.3 05-May-1996 deraadt

headers


# 1.2 01-May-1996 deraadt

save some bytes of disk


# 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.64 29-Feb-2016 jca

Move ckqueue() to common_source/common.c

Patch from Chris Bennett, ok tb@


Revision tags: OPENBSD_5_9_BASE
# 1.63 19-Dec-2015 mmcc

Remove NULL-check before free().


# 1.62 28-Oct-2015 millert

Remove support for lpd.pid file. OK deraadt@


# 1.61 27-Oct-2015 millert

Use AF_UNIX instead of AF_LOCAL.


# 1.60 11-Oct-2015 guenther

Userspace doesn't need to use SUN_LEN(): connect() and bind() must accept
sizeof(struct sockaddr_un), so do the simple, portable thing.
Also convert some strncpy() to strlcpy()

ok deraadt@


# 1.59 29-Sep-2015 millert

Replace call to __ivaliduser_sa() with a pared down version that
only checks the host name. This clears the way for removal of
__ivaliduser_sa() and __ivaliduser() from libc. OK deraadt@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.58 09-Feb-2015 deraadt

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


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


# 1.56 17-Oct-2014 deraadt

Remove chunk special-casing malloc(siz) for realloc(NULL, siz). Bit
tricky, but note the remembered size is in bss.


# 1.55 11-Oct-2014 doug

Userland reallocarray() audit.

Avoid potential integer overflow in the size argument of malloc() and
realloc() by using reallocarray() to avoid unchecked multiplication.

ok deraadt@ (had same diff in tree)


Revision tags: OPENBSD_5_6_BASE
# 1.54 12-Jul-2014 deraadt

The hosts.lpd file must exist, or no permission is granted. Change the
the log messages to clarify the reason for the failure to clarify the
condition.
ok guenther


# 1.53 20-Apr-2014 ajacoutot

Prevent lpd(8) from looking into hosts.equiv.
Access control is now done only using hosts.lpd.
See lpd(8) for more information about the format of this file.

"seems reasonable" tedu@
"looks good" deraadt@
ok sthen@


Revision tags: OPENBSD_5_5_BASE
# 1.52 24-Nov-2013 deraadt

more ctype cleanups
checked by jca


Revision tags: OPENBSD_5_4_BASE
# 1.51 11-Mar-2013 deraadt

handle ECONNABORTED errors from accept(). In many code blocks they can be
ignored silently and without aborting, much like EINTR and EWOULDBLOCK are.
ok's from various maintainers of these directories...


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
# 1.50 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.49 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.48 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_3_BASE
# 1.47 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


Revision tags: OPENBSD_4_2_BASE
# 1.46 05-May-2007 stevesk

remove code for -W, argument now a no-op; ok millert@


# 1.45 01-May-2007 stevesk

remove #ifndef SUN_LEN; ok millert@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.44 07-Apr-2004 aaron

Remove those option letters from the getopt string which do not have a case
handler below. millert@ ok


Revision tags: OPENBSD_3_5_BASE
# 1.43 08-Nov-2003 jmc

typos from Jonathon Gray;


# 1.42 16-Oct-2003 itojun

safer realloc. deraadt ok


# 1.41 26-Sep-2003 pvalchev

realloc fixes; ok deraadt millert


Revision tags: OPENBSD_3_4_BASE
# 1.40 03-Sep-2003 tedu

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


# 1.39 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.38 06-Sep-2002 deraadt

use more socklen_t; pvalchev


# 1.37 23-Jun-2002 deraadt

uid_t and gid_t are unsigned


# 1.36 11-Jun-2002 millert

lprm needs to be setuid daemon after all


# 1.35 08-Jun-2002 millert

make this actually compile


# 1.34 08-Jun-2002 millert

Force lpd socket to be mode 0660, group daemon


# 1.33 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.32 28-May-2002 millert

Repair remote printing; maxfd was not set correctly for remote connections.


# 1.31 22-May-2002 millert

unlink lpd.pid if killed by a signal


# 1.30 22-May-2002 millert

Use O_EXLOCK in open() instead of flock() to eliminate a potential locking
race on the pid file.


# 1.29 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.28 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.27 21-Jan-2002 deraadt

s/deamon/daemon/


# 1.26 07-Jan-2002 millert

Revert local changes that should not have been committed


# 1.25 07-Jan-2002 millert

To disable a SIGCHLD signal handler use SIG_DFL, *not* SIG_IGN
which now has a different meaning.


# 1.24 06-Dec-2001 ericj

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

millert@ ok


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


# 1.22 19-Nov-2001 deraadt

only slight fixes needed in signal handlers


Revision tags: OPENBSD_3_0_BASE
# 1.21 05-Sep-2001 deraadt

do not select(20, ...)


# 1.20 04-Sep-2001 millert

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.


# 1.19 30-Aug-2001 millert

When using dup2() to make a socket be stdout, first check that it
is not already stdout (fd 1). Otherwise we end up closing stdout
which is not the intention. Also use STDOUT_FILENO instead of 1.
From a conversation with huntting@glarp.com.


# 1.18 30-Aug-2001 millert

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


# 1.17 22-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'


Revision tags: 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.16 03-Aug-1998 millert

Set SO_REUSEADDR on printer/tcp service (port 515); csapuntz@clearviewtech.com


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.15 04-Aug-1997 deraadt

save errno in sigchld handlers


# 1.14 19-Jul-1997 deraadt

Wall cleanup; people running lpd should test!


Revision tags: OPENBSD_2_1_BASE
# 1.13 17-Jan-1997 millert

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


# 1.12 20-Dec-1996 deraadt

initialize name; is this the right hack?


# 1.11 03-Nov-1996 millert

Improve portability by using ANSI/POSIX interfaces when possible.


# 1.10 26-Oct-1996 deraadt

we are so ftp bounce paranoid, we checked twice!


Revision tags: OPENBSD_2_0_BASE
# 1.9 21-Sep-1996 deraadt

doh


# 1.8 21-Sep-1996 deraadt

i so rarely forget htons & friends; this time i did -- warner caught me


# 1.7 21-Sep-1996 deraadt

oflow protection, ftp bounce protection, dns spoof protection


# 1.6 07-Aug-1996 deraadt

ftp bounce protection


# 1.5 04-Jul-1996 tholo

Fix bogon in import


# 1.4 04-Jul-1996 tholo

Integrated 4.4Lite2 source
Fixed potential problem pointed out by bitblt


# 1.3 05-May-1996 deraadt

headers


# 1.2 01-May-1996 deraadt

save some bytes of disk


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision