Home | History | Annotate | Download | only in lpd
History log of /src/usr.sbin/lpr/lpd/lpd.c
RevisionDateAuthorComments
 1.60  26-Apr-2023  kre Us daemons don't need no unions - just wait, the easy way.
 1.59  08-Apr-2022  andvar fix various typos, mainly in comments, but also log messages, docs, game text.
 1.58  04-May-2017  sevan Drop main() prototype.
 1.57  09-Nov-2011  is branches: 1.57.30;
If hosts.lpd contains '+', don't insist on reverse DNS == forward DNS.
 1.56  30-Aug-2011  joerg branches: 1.56.2;
static, __printflike, __dead
 1.55  21-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.54  18-Jan-2006  garbled branches: 1.54.20;
If we set SIGCHLD to SIG_IGN then any wait()'s on the child processes will
return -1. This causes filters to fail because we get a value for
child_pid we weren't expecting. Set SIGCHLD to SIG_DFL instead to clear
the reapchild setting when forking the child lpd.
 1.53  02-Dec-2005  yamt constify.
 1.52  28-Nov-2005  christos - WARNS = 4
- factor out commonly used code.
- constify
- use warn/warnx instead of printf
 1.51  02-Jun-2005  lukem Ensure s is initialized before testing (none of the sockets may be ready
so it might not be setup).
Detected with gcc -Wuninitialized.
 1.50  30-Oct-2004  dsl branches: 1.50.2;
Add (unsigned char) cast to ctype functions
Some of this code could usefully be converted to use strtoul() and/or
some small helper functions.
 1.49  16-Oct-2003  itojun safer use of realloc
 1.48  16-Oct-2003  itojun safer realloc.
sizeof() for malloc was mistaken in socksetup().
 1.47  01-Sep-2003  itojun plug memory leak. oenbsd-pr-3425
 1.46  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.45  17-May-2003  itojun use strlcpy/strlcat.
[fix off-by-one in displayq.c]
 1.44  26-Oct-2002  thorpej * Use STDOUT_FILENO instead of 1.
* Pass the file descriptor to request_init() (libwrap) so that
it can actually do something useful later in fromhost().
 1.43  24-Sep-2002  itojun set IPV6_V6ONLY socket option for AF_INET6 socket, to avoid
complicated access control issue due to IPv4 mapped address.
 1.42  20-Sep-2002  lukem cast "%ld", xxx.tv_sec to a long
 1.41  19-Sep-2002  mycroft Simplify the accept() code a little -- sockaddr_storage is fine for both
AF_LOCAL and AF_INET{,6}.
 1.40  19-Sep-2002  mycroft If we exit because the pid file is locked, syslog that.
 1.39  19-Sep-2002  mycroft select() -> poll(), nanosleep()
 1.38  12-Aug-2002  itojun add libwrap support for lpd (you need to pass all tests to print,
so you will want "+" in hosts.lpd then restrict by hosts.allow/deny).
setsockopt(SO_REUSEPORT) while i'm here.
 1.37  11-Aug-2002  grant specify the reason when aborting with "Malformed from address",
suggested by Matt Green.
 1.36  09-Aug-2002  itojun die if fd_set overruns
 1.35  14-Jul-2002  wiz Unifdef __STDC__. Remove __P(). ANSIfy.
 1.34  09-Jul-2002  hubertf This fixes various little problems in the lpd source.

lpd.c bogus 'c' option in getopt option string

printjob.c spelling "prstatic inter" -> "printer"
finish ANSIfication

recvjob.c finish ANSIfication

Patch contributed by Brian Ginsbach <ginsbach@cray.com> in PR 17520
 1.33  21-Jan-2002  wiz branches: 1.33.2;
deamon -> daemon
 1.32  21-Nov-2001  wiz "than" instead of "then".
 1.31  09-Oct-2001  mjl Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.
ANSIfy and constify.
 1.30  11-Aug-2001  mjl Add -W parameter to lpd to disable check for a reserved port,
this is needed to get Win2k print to a NetBSD box. Heavily
inspired by FreeBSD.
 1.29  25-Jun-2001  mrg printer of "" becomes the DEFLP (the default printer, "lp")
 1.28  28-Mar-2001  simonb 80 column police.
 1.27  19-Feb-2001  cgd convert to use getprogname()
 1.26  02-Feb-2001  itojun listen to the port number specified on argument, as advertised
in document. part of PR 12112 from feico@pasta.cs.uit.no.
 1.25  03-Oct-2000  itojun don't give result of function directly into syslog, use "%s".
 1.24  03-Oct-2000  scw Free the bind-address list entries, as well as the list itself.
 1.23  03-Oct-2000  scw Add a "-b" option to specify one or more local addresses to bind
to instead of the default INADDR_ANY.
 1.22  10-Apr-2000  mrg branches: 1.22.4;
- fix usage message to current reality.
- pull over "lpd [port]" code from freebsd's lpr code.
- use posix signal handling.
 1.21  24-Feb-2000  itojun (rcmd.c) to make Zoularis happier, pass sa_len separately from sockaddrs.
this changes function prototype for __ivalid*.
This commit breaks binary compatibility for __ivalid*. I believe this can be
forgiven due to the following:
- this is not really exported function. no function prototype is in headers.
function name starts with underbars. No third-party applications are
expected to use it.
- the function was introduced very recently, when rcmd.c was made IPv6-ready.
- the only customer in NetBSD tree is lpd.

(lpd.c) sync with rcmd.c change.
 1.20  27-Jan-2000  itojun IPv6 support, using rcmd-family funciton added.
NetBSD PR: 9050
From: Feico Dillema
 1.19  23-Dec-1999  mjl Fix null terminating the wrong buffer curtesy of similar variables
mixed up. Seemed to never have any ill effect, but then...
Noted by Tetsuya Furukawa in FreeBSD PR/15604.
 1.18  07-Dec-1999  mrg - add timeouts to displayq(), rmremote(), sendfile() and response(),
and use these timeout in the lpq, lpd and lprm programs.

these stop hung remote printers that accept tcp connections but do
not process jobs from hanging the whole system and letting the sysadmin
have a clue about what is going on with this rogue printer.

- add a -r flag to lpd to allow `of' filters for remote jobs.

i know there are ways around this, but i just don't care.

- add a -f flag to lpf to add missing carriage returns.

useful when printing UNIX files to an, eg, LaserWriter that wants CR's
as well as LF's in raw text. stair-stepped text is no fun.

- implement child process accounting: we just have a limit on the number
of children we can have (settable by the sysadmin), and we sleep when
this number is reached. this can reduce malicious not-so-malicious
attacks on the print server by a rogue remote client..

- use setproctitle() where appropriate so the sysadmin has a clue about
what each of the lpd's here are doing.

this was useful to help diagnose a problem (that the above child process
accounting change reduces the lossages of) where a rogue client was
attempting "lpq" operations on one stuck queue in rapid succession,
causing the lpd server to be extremely slow, due to the large number
of lpd processes running.


i have been running these changes in production for about a year.
 1.17  18-Jul-1998  lukem branches: 1.17.6;
use AF_LOCAL instead of AF_UNIX
 1.16  06-Jul-1998  mrg - use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
 1.15  18-Oct-1997  lukem use memcmp/memset/memmove instead of bcmp/bzero/bcopy
 1.14  09-Oct-1997  mrg document -d, -s. remove bogus #port. fix getopt().
 1.13  05-Oct-1997  mrg - WARNS?=1
- be safe with unlinking files (from freebsd)
- remove register
- clean up $NetBSD$'s.
- use inet_ntoa() in one place (from openbsd)
- nul terminate after a bunch of strncpy()'s
- #ifdef __STDC__ rather than #if (from freebsd)
- be safe with a bunch of string operations (from freebsd)
- use warn()/err() over home grown versions (some from freebsd)
- rename warn() to nodaemon() to remove conflict with above
- check errno from failed kill(2) against ESRCH (from freebsd)
- use getopt() rather than home grown versions (from freebsd)
- clean up a bunch of man pages (some from freebsd)
- check for hostname spoof (from freebsd)
- use POSIX wait() interfaces
- use sysconf(_SC_OPEN_MAX) in preference to NOFILE (from freebsd)
- deal with fork() failure
- index/rindex -> strchr/strrchr (some from freebsd)
- add B57600 and B115200 speeds (from freebsd)
- some KNF
- be safe with files passed in over the network (some from freebsd)
- check return value of malloc(), calloc() and strdup()
 1.12  05-Oct-1997  mrg merge 4.4 lite2
 1.11  17-Jul-1997  mikel use <sys/cdefs.h> __COPYRIGHT and __RCSID macros
include <arpa/inet.h> for inet_ntoa() prototype, nuke local declaration
 1.10  10-Jul-1997  mikel index array with int, not char
 1.9  09-Dec-1996  mrg remove unsafe calls to strcpy(), strcat(), and sprintf(). some KNF.
 1.8  21-Sep-1996  perry close out pr 2771, which added a -s ("secure") flag to lpd -- makes
lpd run in a mode where the it listens only to the local unix domain
socket and not to the network. Changes are similar but not identical
to the supplied patches.
 1.7  24-Apr-1996  mrg branches: 1.7.4;
Stylistic changes.
 1.6  15-Nov-1995  pk Add RCSIDs
 1.5  03-Oct-1995  hpeyerl -- convert sgtty to termios. From: Scott Bartram <scottb@iis.net>
-- Use seteuid() to only give lpr, lprm, lpq and lpc root when they
need it from matthew green <mrg@mame.mu.oz.au>
 1.4  18-May-1994  cgd clean up that import. no rcsids yet.
 1.3  10-Nov-1993  cgd bzero structs before using; fix from theo
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  05-Oct-1997  mrg lite-2
 1.1.1.2  18-May-1994  cgd lpr from 4.4-Lite
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.4.1  26-Jan-1997  rat Update from trunk. Fixes security bugs.
 1.17.6.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.22.4.3  24-Sep-2002  itojun usr.sbin/lpr/lpd/lpd.c 1.43 via patch

Set IPV6_BINDV6ONLY socket option for AF_INET6 socket, to avoid
complicated access control issue due to IPv4 mapped address.

(itojun)
 1.22.4.2  26-Oct-2001  jhawk Pull up revision 1.29 (requested by mrg):
Use DEFLP ("lp") for printer when printer is zero-length.
 1.22.4.1  03-Oct-2000  itojun pullup: part of 1.24 -> 1.25 (approved by releng-1-5)
(this may not raise a real issue)

> don't give result of function directly into syslog, use "%s".
 1.33.2.2  21-Oct-2003  jmc Using hand patch from Havard (requested by thorpej in ticket #946)

* Use STDOUT_FILENO instead of 1.
* Pass the file descriptor to request_init() (libwrap) so that
it can actually do something useful later in fromhost().
 1.33.2.1  02-Oct-2002  lukem Pull up revision 1.43 (via patch) (requested by itojun in ticket #857):
set IPV6_V6ONLY socket option for AF_INET6 socket, to avoid
complicated access control issue due to IPv4 mapped address.
 1.50.2.1  15-Jun-2005  snj Pull up revision 1.51 (requested by lukem in ticket #416):
Ensure s is initialized before testing (none of the sockets may be ready
so it might not be setup).
Detected with gcc -Wuninitialized.
 1.54.20.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.56.2.1  10-Nov-2011  yamt sync with head
 1.57.30.1  11-May-2017  pgoyette Sync with HEAD

RSS XML Feed