Commit Graph

54 Commits

Author SHA1 Message Date
garbled 2d58d3d4c7 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.
2006-01-18 23:17:38 +00:00
yamt ebd9a381a8 constify. 2005-12-02 11:33:39 +00:00
christos 04723c3ffc - WARNS = 4
- factor out commonly used code.
- constify
- use warn/warnx instead of printf
2005-11-28 03:26:06 +00:00
lukem 9b668c37e7 Ensure s is initialized before testing (none of the sockets may be ready
so it might not be setup).
Detected with gcc -Wuninitialized.
2005-06-02 05:57:03 +00:00
dsl 75ba9fc767 Add (unsigned char) cast to ctype functions
Some of this code could usefully be converted to use strtoul() and/or
some small helper functions.
2004-10-30 08:44:25 +00:00
itojun 686afb7f65 safer use of realloc 2003-10-16 06:22:09 +00:00
itojun 94a111ae53 safer realloc.
sizeof() for malloc was mistaken in socksetup().
2003-10-16 03:03:04 +00:00
itojun 67ad87844e plug memory leak. oenbsd-pr-3425 2003-09-01 00:21:08 +00:00
agc 326b2259b7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22366, verified by myself.
2003-08-07 11:25:11 +00:00
itojun 85da88227f use strlcpy/strlcat.
[fix off-by-one in displayq.c]
2003-05-17 20:46:42 +00:00
thorpej d2ed7ebdd1 * 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().
2002-10-26 01:46:31 +00:00
itojun c41e40e20e set IPV6_V6ONLY socket option for AF_INET6 socket, to avoid
complicated access control issue due to IPv4 mapped address.
2002-09-24 13:31:33 +00:00
lukem 1b2d905cd0 cast "%ld", xxx.tv_sec to a long 2002-09-20 04:12:42 +00:00
mycroft 59edfd2c03 Simplify the accept() code a little -- sockaddr_storage is fine for both
AF_LOCAL and AF_INET{,6}.
2002-09-19 20:35:56 +00:00
mycroft 4082cae6ac If we exit because the pid file is locked, syslog that. 2002-09-19 20:22:32 +00:00
mycroft e1a3e519ec select() -> poll(), nanosleep() 2002-09-19 20:08:58 +00:00
itojun 166e26e413 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.
2002-08-12 18:03:41 +00:00
grant cc65da74ac specify the reason when aborting with "Malformed from address",
suggested by Matt Green.
2002-08-11 07:04:00 +00:00
itojun 1917442aa9 die if fd_set overruns 2002-08-09 02:40:57 +00:00
wiz 895dc72a69 Unifdef __STDC__. Remove __P(). ANSIfy. 2002-07-14 15:27:58 +00:00
hubertf 534ff5d5e9 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
2002-07-09 01:12:35 +00:00
wiz b36c0a5406 deamon -> daemon 2002-01-21 14:42:26 +00:00
wiz 1fd7eeefcd "than" instead of "then". 2001-11-21 19:14:19 +00:00
mjl c903850da8 Replace 1 and 2 with STDOUT_FILENO and STDERR_FILENO.
ANSIfy and constify.
2001-10-09 02:15:37 +00:00
mjl 98e1bdc90d 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.
2001-08-11 01:04:57 +00:00
mrg e1633c19d7 printer of "" becomes the DEFLP (the default printer, "lp") 2001-06-25 15:29:12 +00:00
simonb a378517ea4 80 column police. 2001-03-28 03:17:41 +00:00
cgd 25bdbb661e convert to use getprogname() 2001-02-19 23:22:40 +00:00
itojun bcbf09100a listen to the port number specified on argument, as advertised
in document.  part of PR 12112 from feico@pasta.cs.uit.no.
2001-02-02 14:20:33 +00:00
itojun 78907e0169 don't give result of function directly into syslog, use "%s". 2000-10-03 13:54:31 +00:00
scw 5c0e061414 Free the bind-address list entries, as well as the list itself. 2000-10-03 13:28:27 +00:00
scw 97a603e5b0 Add a "-b" option to specify one or more local addresses to bind
to instead of the default INADDR_ANY.
2000-10-03 11:45:30 +00:00
mrg 3f207f4f5a - fix usage message to current reality.
- pull over "lpd [port]" code from freebsd's lpr code.
- use posix signal handling.
2000-04-10 08:09:33 +00:00
itojun 7b48263c7b (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.
2000-02-24 06:33:47 +00:00
itojun 33ba3a0f18 IPv6 support, using rcmd-family funciton added.
NetBSD PR: 9050
From: Feico Dillema
2000-01-27 05:39:50 +00:00
mjl 8515b446a0 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.
1999-12-23 02:10:07 +00:00
mrg 5b6d0e7e39 - 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.
1999-12-07 14:54:44 +00:00
lukem 786b86d71b use AF_LOCAL instead of AF_UNIX 1998-07-18 05:04:35 +00:00
mrg 32f519716b - 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
1998-07-06 06:56:06 +00:00
lukem fbafdc25f8 use memcmp/memset/memmove instead of bcmp/bzero/bcopy 1997-10-18 08:52:17 +00:00
mrg 38811f7fea document -d, -s. remove bogus #port. fix getopt(). 1997-10-09 07:58:39 +00:00
mrg fe7ed7ce37 - 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()
1997-10-05 15:11:58 +00:00
mrg e6a91a0997 merge 4.4 lite2 1997-10-05 11:52:17 +00:00
mikel fff865d146 use <sys/cdefs.h> __COPYRIGHT and __RCSID macros
include <arpa/inet.h> for inet_ntoa() prototype, nuke local declaration
1997-07-17 05:49:13 +00:00
mikel 3bf6872439 index array with int, not char 1997-07-10 06:26:44 +00:00
mrg 077acf5088 remove unsafe calls to strcpy(), strcat(), and sprintf(). some KNF. 1996-12-09 09:57:40 +00:00
perry d8e1329af8 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.
1996-09-21 15:57:21 +00:00
mrg d28f8743af Stylistic changes. 1996-04-24 14:54:06 +00:00
pk f54b84516b Add RCSIDs 1995-11-15 22:48:07 +00:00
hpeyerl 8e41ca8016 -- 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>
1995-10-03 15:02:17 +00:00