History log of /freebsd-current/usr.sbin/inetd/inetd.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/


# 648b9ce8 06-Dec-2021 Mateusz Piotrowski <0mp@FreeBSD.org>

inetd: Use the synopsis from the manual page

Also, document -s in the usage message.

MFC after: 7 days


# 12538351 12-Feb-2021 Kyle Evans <kevans@FreeBSD.org>

inetd: fix unix sockaddr's length assignment

unsz was always exactly '1' here due to an unfortunate mispositioning
of closing parenthesis. While it's generally irrelevant because bind(2)
is passed the (accurate) sep->se_ctrladdr_size instead, it's not very
helpful for anything locally that wants to use it rather than assuming
that sep->se_ctrladdr_size perfectly fits the end of sun_path.

Just drop unsz entirely and use the result of SUN_LEN() for it.

MFC-after: 3 days


# 525c896b 10-Jan-2020 Kyle Evans <kevans@FreeBSD.org>

inetd: two more nits

Use __COPYRIGHT for copyright to simply either embed it via .ident or have
it properly marked __unused

Move an ipsec reference to IPSEC


# 36cac557 10-Jan-2020 Kyle Evans <kevans@FreeBSD.org>

inetd: free WITHOUT_INET6_SUPPORT build of warnings

If inetd is compiled without inet6 support, we need to error out on
rpc+inet6 services rather than attempting to call into rpc bits with an
uninitialized netid.

v4bind is only used with INET6 support, so move it under the proper #ifdefs
with v6bind.

Reported by: Pavel Timofeev <timp87 gmail com>
MFC after: 3 days


# 9a3e2f58 03-Jan-2020 Ed Maste <emaste@FreeBSD.org>

inetd: fix WITHOUT_TCP_WRAPPERS build after r356248

After increasing WARNS, building WITHOUT_TCP_WRAPPERS failed because of
some unused variables.

Reported by: Cirrus-CI (against my WIP branch)
MFC with: r356248
Sponsored by: The FreeBSD Foundation


# 705d79b4 01-Jan-2020 Kyle Evans <kevans@FreeBSD.org>

inetd: final round of trivial cleanup, NFC

Highlights:
- Use MAX() for maxsock raising; small readability improvement IMO
- malloc(3) + memset(3) -> calloc(3) where appropriate
- stop casting the return value of malloc(3)
- mallloc(3) -> reallocarray(3) where appropriate

A future change may enter capability mode when forking for some of the
built-in handlers.


# c8863d05 31-Dec-2019 Kyle Evans <kevans@FreeBSD.org>

inetd: convert remaining bzero(3) to memset(3), NFC

This change is purely in the name of noise reduction from static analyzers
that want to complain that bzero(3) is obsolete in favor of memset(3).

With this, clang-analyze at least is now noise free. WARNS= 6 also appears
to have been OK for some time now, so drop the current setting and opt for
the default.


# c53b0f40 31-Dec-2019 Kyle Evans <kevans@FreeBSD.org>

inetd: track all child pids, regardless of maxchild spec

Currently, child pids are only tracked if maxchildren is specified. As a
consequence, without a maxchild limit we do not get a notice in syslog on
children aborting abnormally. This turns out to be a great debugging aide at
times.

Children are now tracked in a LIST; the management interface is decidedly
less painful when there's no upper bound on the number of entries we may
have at the cost of one small allocation per connection.

PR: 70335


# d6272fce 31-Dec-2019 Kyle Evans <kevans@FreeBSD.org>

inetd: add some macros for checking child limits, NFC

The main point here is capturing the maxchild > 0 check. A future change to
inetd will start tracking all of the child pids so that it can give proper
and consistent notification of process exit/signalling.


# a1cedb80 30-Dec-2019 Kyle Evans <kevans@FreeBSD.org>

inetd: prefer strlcpy to strlen(3) check + strcpy(3), NFC

This is again functionally equivalent but more concise.


# f23df319 30-Dec-2019 Kyle Evans <kevans@FreeBSD.org>

inetd: knock out some clang analyze warnings

chargen_dg: clang-analyze is convinced that endring could be non-NULL at
entry, and thus wants to assume that rs == NULL. Just independently
initialize rs if it's NULL to appease the analyzer.

getconfigent: policy leaks on return

free_connlist: reorganize the loop to make it clear that we're not going to
access `conn` after it's been freed.

cpmip/hashval: left-shifts performed will result in UB as we take
signed 0xABC3D20F and left shift it by 5.


# f930f30f 30-Dec-2019 Kyle Evans <kevans@FreeBSD.org>

inetd: don't leak `policy` on return

sep->se_policy gets a strdup'd version of policy, so we don't need it to
stick around afterwards.

While here, remove a couple of NULL checks prior to free(policy).

CID: 1006865
MFC after: 3 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.


# d31d87b0 20-Mar-2017 Hiroki Sato <hrs@FreeBSD.org>

Simplify a pipe for signal handling.


# 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


# 484b7007 14-Jan-2017 Enji Cooper <ngie@FreeBSD.org>

Fix up r312105

- Only #include tcpd.h when LIBWRAP is true to avoid header include errors
- Only define whichaf when LIBWRAP is true to avoid -Wunused warning and
to avoid issues with structs being defined that should only be defined
when tcpd.h is included.

MFC after: 2 weeks
X-MFC with: r312105
Pointyhat to: ngie
Reported by: gcc tinderbox
Sponsored by: Dell EMC Isilon


# 63eca8f1 13-Jan-2017 Enji Cooper <ngie@FreeBSD.org>

Conditionalize libwrap support into inetd based on MK_TCP_WRAPPERS

This will allow inetd to stand by itself without libwrap.

MFC after: 2 weeks
Relnotes: yes
Reviewed by: hrs (earlier version)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D9056


# 1232b860 04-Jan-2017 Hiroki Sato <hrs@FreeBSD.org>

Fix build when WITHOUT_INET6 is defined.


# 4909085f 31-Dec-2016 Hiroki Sato <hrs@FreeBSD.org>

- Add static for symbols which need not to be exported.
- Clean up warnings to the WARNS=6 level.


# a1b422f4 01-May-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use MAX macro from sys/param.h.

MFC after: 2 weeks.


# 02277afd 16-Apr-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Use the SOCK_CLOEXEC flags in the socket(2) 'type' attribute instead of
calling fcntl(2)

MFC after: 1 week


# 29808109 15-Apr-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Use pipe2(2) to directly set the close-on-exec flags directly

MFC after: 1 week


# fb0e28f0 19-Sep-2015 Hiroki Sato <hrs@FreeBSD.org>

- Remove unused union p_un.

- Use NI_MAXHOST-long buffer for getnameinfo().
Although INET6_ADDRSTRLEN was designed to hold the longest
IPv6 address in IPv4-mapped address format a long time ago,
getnameinfo() can return scope identifier in addition to it.

MFC after: 1 day


# 157d2c33 19-Sep-2015 Hiroki Sato <hrs@FreeBSD.org>

- Fix a crash on a rpc entry when an IPv6 address is explicitly specified
in -a flag.

- Fix a bug that sockaddr_in was used where sockaddr_in6 should have
been used. This was not actually harmful because offsetof(struct
sockaddr_in, sin_port) is equal to offsetof(struct sockaddr_in6,
sin6_port).

MFC after: 1 day


# d5792866 19-Apr-2015 Eitan Adler <eadler@FreeBSD.org>

identd: restore memcpy
I should not be committing at 2:30am....

Reported by: pluknet


# 7ebd5ed4 19-Apr-2015 Eitan Adler <eadler@FreeBSD.org>

identd: also zero se_rpc_highvers

Reported by: pluknet


# af5f5a39 19-Apr-2015 Eitan Adler <eadler@FreeBSD.org>

identd: remove redundant zeroing
se_rpc_lowvers was set to 0 twice, so remove one of them
I can not find any other variable which they may have been a typo of.

Reported by: gcc5.1


# 603eaf79 09-Nov-2014 Alexander V. Chernikov <melifaro@FreeBSD.org>

Renove faith(4) and faithd(8) from base. It looks like industry
have chosen different (and more traditional) stateless/statuful
NAT64 as translation mechanism. Last non-trivial commits to both
faith(4) and faithd(8) happened more than 12 years ago, so I assume
it is time to drop RFC3142 in FreeBSD.

No objections from: net@


# ec89b1f9 20-Jan-2013 Andrey Zonov <zont@FreeBSD.org>

- Force inetd to have listen queue size to be set to the value of
kern.ipc.somaxconn instead of hardcoded value 64.

Submitted by: Andrey Ignatov <rdna@rdna.ru>
MFC after: 2 weeks


# 4f985ef6 04-Jun-2012 Xin LI <delphij@FreeBSD.org>

Replace the use of wall clock time with monotonically increasing
clock. In general, gettimeofday() is not appropriate interface
when accounting for elasped time because it can go backward, in
which case the policy code could errornously consider the limit
as exceeded.

MFC after: 1 week
Reported by: Mahesh Arumugam
Submitted by: Dorr H. Clark via gnn
Sponsored by: Citrix / NetScaler


# b3608ae1 03-Jan-2012 Ed Schouten <ed@FreeBSD.org>

Replace index() and rindex() calls with strchr() and strrchr().

The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.


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


# 9a958de5 02-Jan-2010 Ed Schouten <ed@FreeBSD.org>

ANSIfy some more tools in usr.sbin/.

Most of these tools build with WARNS=6, except for their use of K&R
function declarations.


# acd3c015 19-Dec-2009 Attilio Rao <attilio@FreeBSD.org>

MFC r199804:
Avoid sshd, crond, inetd and syslogd to be killed in an high-pressure
swapping environment.

Sponsored by: Sandvine Incorporated


# 7a7043c7 25-Nov-2009 Attilio Rao <attilio@FreeBSD.org>

Avoid sshd, cron, syslogd and inetd to be killed under high-pressure swap
environments.
Please note that this can't be done while such processes run in jails.

Note: in future it would be interesting to find a way to do that
selectively for any desired proccess (choosen by user himself), probabilly
via a ptrace interface or whatever.

Obtained from: Sandvine Incorporated
Reviewed by: emaste, arch@
Sponsored by: Sandvine Incorporated
MFC: 1 month


# 882284cc 13-Feb-2009 Xin LI <delphij@FreeBSD.org>

Sync comment with actual configuration format.


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

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


# 8409aedf 30-Jun-2007 George V. Neville-Neil <gnn@FreeBSD.org>

Commit IPv6 support for FAST_IPSEC to the tree.
This commit includes all remaining changes for the time being including
user space updates.

Submitted by: bz
Approved by: re


# 7149ee16 11-Mar-2007 David Malone <dwmalone@FreeBSD.org>

Don't try to apply connection-per-ip rate limiting to unix domain
sockets. Instead of rejecting all unix domain connections when the
-C flag is given, allow them instead. Aragon tested an earlier
version of the patch.

PR: 109315
MFC after: 2 weeks
Tested-by: Aragon Gouveia <aragon@phat.za.net>


# 906c8a73 14-Sep-2006 Ruslan Ermilov <ru@FreeBSD.org>

Removed T/TCP bits.


# b512f010 18-Jan-2006 Xin LI <delphij@FreeBSD.org>

Revert previous commit for now, which seems to have (re)introduced some
old bugs, as well as some unwanted side effects. I will do more
investigation and fix these issues first.

Pointed out by: dwmalone


# 4d115fef 18-Jan-2006 Xin LI <delphij@FreeBSD.org>

Improves and cleanups over inetd(8):

- Teach inetd(8) about kqueue, originally implemented by jmg@[1].
- Use new C99 style function prototypes instead of K&Rs.
- Raise WARNS from 2 to 6

Glanced at by: ru
MFC After: 2 weeks

[1] http://people.freebsd.org/~jmg/inetd.kq.patch,
http://people.freebsd.org/~jmg/inetd.kq.html


# 8b28aef2 16-Sep-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Pidfiles should be created with permission preventing users from opening
them for reading. When user can open file for reading, he can also
flock(2) it, which can lead to confusions.

Pointed out by: green


# f6701951 24-Aug-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Use pidfile(3) in inetd(8).


# 4f101318 13-May-2005 Hajimu UMEMOTO <ume@FreeBSD.org>

NI_WITHSCOPEID cleanup. Neither RFC 2553 nor RFC 3493 defines
NI_WITHSCOPEID, and our getaddrinfo(3) does nothing special
for it, now.


# 80c4c0db 26-Sep-2004 Stefan Farfeleder <stefanf@FreeBSD.org>

Prefer C99's __func__ over GCC's __FUNCTION__.

Approved by: dwmalone


# 486c8cc4 06-Aug-2004 Warner Losh <imp@FreeBSD.org>

Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived software
(with permission of addtional copyright holders where appropriate)


# 44501e8c 20-Apr-2004 Brooks Davis <brooks@FreeBSD.org>

Remove the requirement that the "discard" service be defined in the
services database. Now only services that are actually used need to be
defined.

Submitted by: ume


# 48135410 04-Apr-2004 David Malone <dwmalone@FreeBSD.org>

The list of (key,value) pairs to request_init is terminated by a 0 key,
not NULL.

Submitted by: Stefan Farfeleder <stefan@fafoe.narf.at>
MFC after: 3 days


# bcd4c574 21-Mar-2004 David Malone <dwmalone@FreeBSD.org>

On startup, warn if inetd's config file doesn't exist. This isn't
exactly the same as patch from the PR, which also exited if the
config file was missing. I didn't use Jeff's patch because I was
worried that some people might start inetd, create the config file
and then HUP inetd.

PR: 60806
Submitted by: Jeff Ito <jeffi@rcn.com>
MFC after: 2 weeks


# e2c61774 30-Oct-2003 Peter Wemm <peter@FreeBSD.org>

Rather than use the gcc -fno-builtin-log flag, just rename the 'int log'
variable.


# 47f07761 26-Oct-2003 Hajimu UMEMOTO <ume@FreeBSD.org>

Since semantic of IPV6_PKTINFO was changed in RFC3542, we need to
use IPV6_RECVPKTINFO instead.

Reported by: someone (I had removed the mail wrongly, sorry)


# 3bda2f43 25-Oct-2003 Peter Wemm <peter@FreeBSD.org>

Use -fno-builtin-log so gcc doesn't get ideas about using a math function
to log data. Clean up an unused variable that was hidden by the WARNS?=2
being commented out. Uncomment it now that it compiles cleanly again.


# d2be82da 15-Jul-2003 David Malone <dwmalone@FreeBSD.org>

Get the connections per minute calculation right. By good fortune
(or possibly testing) the previous formula worked for the default
constants compiled into inetd, but if you recompiled with different
values of CHTSIZE and CHTGRAN the calculation might not have worked.

PR: 54354
Submitted by: Claus Assmann <ca@sendmail.org>
Submitted by: Jose Marcio Martins da Cruz <Jose-Marcio.Martins@ensmp.fr>
MFC after: 5 days


# cbdbb725 23-Feb-2003 David Malone <dwmalone@FreeBSD.org>

Under some unusual conditions, inetd can leak a open file discriptor
into a child process. Rather than closing the discriptors manually,
mark all discriptors as close-on-exec.

PR: 47694
Submitted by: Max Okumoto <okumoto@ucsd.edu>
Obtained from: NetBSD
MFC after: 2 weeks


# c40f2eef 23-Feb-2003 David Malone <dwmalone@FreeBSD.org>

After calling login_getclass, be sure to call login_close so that
we don't leak memory. Only one of these two cases (reconfig) actually
causes a leak because the other is usually followed by an exec.

PR: 46845
Reviewed by: David Wang <dsw@juniper.net>
MFC after: 2 weeks


# 6431ecd0 13-Feb-2003 Hajimu UMEMOTO <ume@FreeBSD.org>

The tcp_wrappers function `fromhost()' can fail. In such
cases, the `struct sockaddr' will not be allocated.

Reported by: nectar
MFC after: 2 days


# 42c0e331 15-Jan-2003 Robert Watson <rwatson@FreeBSD.org>

Using LOGIN_SETALL &~LOGIN_SETMAC to avoid setting the MAC label improperly,
rather than specifically setting the process priority and resource class;
otherwise, we improperly set other aspects of the login class. We have
a bit more to do here, but the proper fix will probably involve breaking
out MAC labels from the login class at some point, as well as further
clarifying the logic here.

Pointed out by: kuriyama, max


# 15e90ad4 08-Jan-2003 Robert Watson <rwatson@FreeBSD.org>

For now, set only the resource limits and process priority associated
with a class, rather than all aspects of the class when switching
classes for an inetd service. Because we hard-code /daemon in the
current inetd implementation, using SETALL has unfortunate side-effects
involving the MAC code, and potentially other credential related
settings in the future. This change maintains the DoS-resistent
aspects of the class behavior, which is all that is promised in the
inetd man page.

A larger set of diffs providing more pluggability and configurability
was deferred for this more simple approach in the short term.

Reviewed by: ache
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories


# cd9a4d5d 27-Oct-2002 Garrett Wollman <wollman@FreeBSD.org>

Add used #include <limits.h>.


# 7718f45c 04-Sep-2002 David Malone <dwmalone@FreeBSD.org>

When printing the wait status, break it down into a signal and a exit status.

PR: 41912
Submitted by: Aaron Smith <aaron@mutex.org>
MFC after: 2 weeks


# 85d28cb4 04-Sep-2002 David Malone <dwmalone@FreeBSD.org>

Swap sense of no_v[46]bind variables and rename as v[46]bind_ok -
this avoids some double negatives which are a bit difficult to
parse.

Always tread v[46]bind{,_ok} as booleans.


# 6d4129d2 04-Sep-2002 David Malone <dwmalone@FreeBSD.org>

Fix parsing of unix domain entries after addition of IPv6 RPC support.

PR: 40771
Submitted by: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>


# 60c1ef97 02-Sep-2002 David Malone <dwmalone@FreeBSD.org>

Don't initialise policy, v4bind and v6bind where the variables are
declared - it was bad style and caused a bug. v[46]bind need to be
reset whenever we go to the "more:" label.

Jean-Luc and I came up with this patch independently, so it had
better be right!

PR: 40771
Submitted by: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>


# d0c55c69 02-Sep-2002 David Malone <dwmalone@FreeBSD.org>

tpc -> tcp in an error message.

PR: 40771
Submitted by: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>


# fa11816b 02-Sep-2002 David Malone <dwmalone@FreeBSD.org>

Clear up a few warnings (unused variable, rpc versions are usigned so use %u,
rename a parameter to avoid shadowing a global).

MFC after: 1 month


# 09b1c357 07-Aug-2002 Hajimu UMEMOTO <ume@FreeBSD.org>

Add capability for limiting the maximum number of simultaneous
invocations of each service from a single IP address.

Requested by: matusita
Reviewed by: dwmalone
Tested by: matusita on snapshots.jp.FreeBSD.org
MFC after: 2 weeks


# fc99a00c 22-Jul-2002 Hajimu UMEMOTO <ume@FreeBSD.org>

use IPV6_V6ONLY instead of non standard IPV6_BINDV6ONLY.

MFC after: 1 week


# d14ca883 15-Jul-2002 Alfred Perlstein <alfred@FreeBSD.org>

add support for rpc IPv6 (rpc/udp/46 ...)

Submitted by: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>


# 0ec563a5 22-Jun-2002 Juli Mallett <jmallett@FreeBSD.org>

Replace the SWAP(var0,var1) macro with SWAP(type,var0,var1) and use it as
is appropriate to avoid using typeof/__typeof__. It is worth noting that
SWAP() is only ever used to swap pointer values so 'void *' assumptions would
have been acceptable, but I'd gladly pay you tuesday for a cheeseburger^W
cleaner interface today.

Poked into submission by: bde


# d3a4920c 22-Jun-2002 Juli Mallett <jmallett@FreeBSD.org>

Unused macro.


# 35ea3970 21-Jun-2002 Juli Mallett <jmallett@FreeBSD.org>

__FBSDID() strategic insertion.


# edb616bb 21-Jun-2002 Juli Mallett <jmallett@FreeBSD.org>

Kill __P, yuck.


# 2306f8e9 21-Jun-2002 Juli Mallett <jmallett@FreeBSD.org>

Mark unused variables __unused.

Built standalone, inetd(8) is WARNS=5 clean, WARNS=6 if you ignore %m fits.


# 0e23eb87 21-Jun-2002 Juli Mallett <jmallett@FreeBSD.org>

Use __typeof__ instead of typeof.


# 081713dc 21-Jun-2002 Juli Mallett <jmallett@FreeBSD.org>

ANSI prototypes via protoize(1).


# 24aaa74c 25-May-2002 John W. De Boskey <jwd@FreeBSD.org>

Log invalid config entries. Make the -d option actually log to
the terminal(-d fix from dwmalone).

Approved by: dwmalone
MFC after: 2 weeks


# 89511d9d 08-May-2002 Hajimu UMEMOTO <ume@FreeBSD.org>

Make compilable without -DINET6.


# 7f59d20d 08-May-2002 Hajimu UMEMOTO <ume@FreeBSD.org>

Log address family of a connection.

Requested by: matusita
Reviewed by: matusita


# 20e1eb21 17-Jul-2001 David Malone <dwmalone@FreeBSD.org>

o Remove old setproctitle.
o Mark unused variables.
o Set WARNS?=2
o Results in no code changes.

Submitted by: Mike Barcroft <mike@q9media.com>


# b585f768 24-Jun-2001 David Malone <dwmalone@FreeBSD.org>

Fix most of the warnings given by WARNS=2.


# 1c8d1174 16-Jun-2001 David Malone <dwmalone@FreeBSD.org>

Give inetd the ability to manage unix domain sockets. Details of
how to use this feature are in the man page. This is based on work
by Lyndon Nerenberg.

(The only difficult part about this patch is the fact that you
can't fchown a unix domain socket, which means the sockets must be
put in a secure directory).

Reviewed by: dillon


# d57dbd16 06-Jun-2001 David Malone <dwmalone@FreeBSD.org>

Get rid of se_ctladdrinitok, which doesn't do anything and seemes
to have been accidently imported when ipv6 support was added to
inetd.

Approved by: ume


# a07ae7a1 31-May-2001 Hajimu UMEMOTO <ume@FreeBSD.org>

Recently, other BSDs had faith support in inetd. Though our inetd has
it already, their syntax is not compatible with ours. It will confuse
users. So, we have compatibility with their syntex.

Approved by: dwmalone
Obtained from: NetBSD


# 1c3b5f22 22-Jan-2001 David Malone <dwmalone@FreeBSD.org>

Various cleanups of inetd: Avoid shadowing variables, use socklen_t
instead of ints, don't cast to char *, clear up some remote name
handling code which had become a little odd.

Should result in no functional changes.


# 6ef18ba8 22-Jan-2001 David Malone <dwmalone@FreeBSD.org>

Don't mention /etc/protocols in inetd documentation or comments, as inetd
doesn't actually use it.

PR: 24307
Submitted by: opentrax@email.com


# 13f1579a 03-Dec-2000 David Malone <dwmalone@FreeBSD.org>

Tidy up some prototypes:
make sure there is exactly one prototype for each function,
use K&R style definitions everywhere to match dominant style,
make flag_signal take an int to avoid problems if we have
ANSI prototypes and K&R definitions.


# caf60155 24-Oct-2000 David Malone <dwmalone@FreeBSD.org>

Fix two typos in comments.

PR: 22268
Submitted by: Daniel S. Lewart <d-lewart@uiuc.edu>


# f27a3b3e 21-Oct-2000 David Malone <dwmalone@FreeBSD.org>

Don't leak a file discriptor if a service we've called accept() for
loops.

Submitted by: Ian Dowse <iedowse@maths.tcd.ie>


# 00205ff6 01-Oct-2000 David Malone <dwmalone@FreeBSD.org>

Make reconfiguring an external service as builtin service work.

PR: 21650
Submitted by: ben
Tested by: dan@ducky.nz.freebsd.org


# 1b65d153 03-Aug-2000 David Malone <dwmalone@FreeBSD.org>

Explain "-c" option more exactly and state the default in the man
page.

Add ability to run "inetd -R 0" to disable the default connection
per minute limit of 256 connections. Document this in man page.

Don't use maxchild as a boolean - instead check if it is greater
than zero.

Reviewed by: sheldonh
Based on a patch by: Alexander Langer <alex@big.endian.de>


# 8acc3828 31-Jul-2000 David Malone <dwmalone@FreeBSD.org>

Sleep for a second after tcp wrappers rejects a connection, so we
don't traumatise the parent inetd.

Requested by: wietse@porcupine.org
Approved by: markm


# 612c5899 02-Apr-2000 Hajimu UMEMOTO <ume@FreeBSD.org>

Make sure to use IPv4 mapped IPv6 address when mapped address is
requested in /etc/inetd.conf.

Reviewed by: shin


# 1a0760dd 11-Mar-2000 Yoshinobu Inoue <shin@FreeBSD.org>

Make inetd compilable without INET6.

Approved by: jkh

Submitted by: jhb


# 58af74e6 21-Feb-2000 Yoshinobu Inoue <shin@FreeBSD.org>

Fix broken inet logging when wrapping options are not specified.

Approved by: jkh

Submitted by: Ben Smithurst <ben@scientia.demon.co.uk>


# ef9c54c7 03-Feb-2000 Yoshinobu Inoue <shin@FreeBSD.org>

Fix inetd wrong AF check for RPC services

Incorrect Address Family check is done for RPC services, and
fail to initialize it.
The error check is replaced to new one, which checks if IPv4
bind is enabled or not. (It is disabled when IPv6 numeric
addr is specified for -a bind address option.)

An review reqeust is once sent to des, but he quit MAINTAINER.

Approved by: jkh


# 49de1b57 28-Jan-2000 Yoshinobu Inoue <shin@FreeBSD.org>

Fix inconsistent debug output. (syslog -> warnx)

Specified by: sheldonh

Reviewed by: des


# f669e3af 27-Jan-2000 Yoshinobu Inoue <shin@FreeBSD.org>

Avoid verbose error messages when ipsec initialization for sockets failed
usually, and print it only when debug is enabled.
(This always happens when kernel is configured without IPSEC option.)


# 0cac72f4 25-Jan-2000 Yoshinobu Inoue <shin@FreeBSD.org>

several tcp apps IPv6 update
-inetd
-rshd
-rlogind
-telnetd
-rsh
-rlogin

Reviewed by: freebsd-arch, cvs-committers
Obtained from: KAME project


# e2b7d857 23-Jan-2000 Philippe Charnier <charnier@FreeBSD.org>

Do not dot terminate sentences inside FILES section. Lowercase
inside error messages.


# 0b8c4709 16-Nov-1999 Peter Wemm <peter@FreeBSD.org>

Put the listening socket into non-blocking mode before doing an
accept(2). This is a not really problem on -current as the accept race
is fixed, however it is a MFC candidate for -stable.

This could possibly be slightly more efficient and leave the listening
socket permanently in non-blocking mode, but I wasn't certain that I
could catch all the stream/wait (not nowait) mode implications.


# 42474ae3 13-Oct-1999 Philippe Charnier <charnier@FreeBSD.org>

Do not dot or \n terminate syslog string.


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

$Id$ -> $FreeBSD$


# daae1387 26-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Bring two wayward memory allocation failure messages in line with
those featured in the rest of the code.


# fc2cff31 23-Jul-1999 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't match up TCP services with UDP sockets.


# f6389f4b 22-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Relegate the diagnostic descriptor counter to the -DSANITY_CHECK case.


# db6da755 22-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Remove unnecessary macro introduced in previous commit.

Also, the previous commit failed to reference:

PR: 12731
Submitted by: dwmalone@maths.tcd.ie (David "Inetd" Malone)


# 0a418352 22-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Don't leak pipe descriptor to daemons on execv().


# dd09a74d 22-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Signal handlers should use _exit(2) and not exit(3).


# 5ff3afce 22-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Move code for all builtin services from inetd.c to builtins.c, including
the Green Piece. :-)

In future, new builtin services are less likely to need to touch the
already tangled inetd.c .


# a9ed85ec 21-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Fix for the hosts_options(5) spawn option.

Restore default SIGHUP, SIGCHLD and SIGALRM handlers in forked inetd
processes. This happens to work around the fact that hosts_access()
doesn't (but should) set SIG_IGN as the handler for SIGCHLD while it
handles the spawn option, but it would make sense even if that were
not true.

This does not address the leaking descriptors issue discussed on the
same PR.

PR: 12731
Reviewed by: des
Submitted by: David Malone <dwmalone@maths.tcd.ie>


# 6134dbe0 20-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Fix horribly broken comment. The submitter of the associated code sent
me the right comment and I bastardized it. :-(


# b81a43e2 15-Jul-1999 Brian Feldman <green@FreeBSD.org>

By popular demand, ident_stream now takes arguments. Ex:
# This enables the old, fake ident service.
auth stream tcp nowait root internal
# This enables the new, real ident service.
auth stream tcp nowait root internal auth -r
# This enables ~/.fakeid support, too.
auth stream tcp nowait root internal auth -r -f


# d33eb4c8 14-Jul-1999 Brian Feldman <green@FreeBSD.org>

This is the working internal ident service. Turn it on by setting
the make variable REAL_IDENT, and ~/.fakeid support can be added
with FAKEID set. Note that the default behavior is the same as
the old behavior.


# 49906707 09-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Use the proctitle to indicate that we're busy wrapping a request for a
service. Inetd already uses the process title to indicate that a request
for an internal service is being serviced, so this addition is fairly
orthogonal.

Submitted by: David Malone <dwmalone@maths.tcd.ie>


# 10d03f50 09-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Allow internal and external wrapping to be enabled independantly of
each other. Instead of allowing the -w option to be specified twice,
we now take -w (wrap external) and -W (wrap internal).

Discussed with: markm


# eb0fde47 02-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Allow service alias names from /etc/services to be used when specifying
internal services in inetd.conf .

The inetd(8) manpage used to say that the official name of a service
_must_ be used, yet inetd itself was hardcoded to used a service alias for
the auth service, namely ident!

Rather than change inetd.conf and break existing configurations on next
upgrade, we now allow service aliases as well as official names. This
allows the software to work as expected and still support existing
configurations.

This should not breaking existing wrapped configurations either and the
inetd(8) manpage already states that it is the service name specified in
inetd.conf that is used for calls to hosts_access(3).

PR: 11796
Reported by: Alex Charalabidis <alex@wnm.net>
Approved by: des


# 1efeefd5 30-Jun-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Ommitted in previous commit message:

Submitted by: David Malone <dwmalone@maths.tcd.ie>


# c48c2d6d 30-Jun-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Enable wrapping for dgram services and fix logging so that -l really
does log all connections.


# 9735000d 28-Jun-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Sync usage() with the manpage.

Approved by: mpp


# 8d0fe869 28-Jun-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Fix broken logic: (!wrap || log) -> (!wrap && log) .

Reported by: David Malone <dwmalone@maths.tcd.ie>


# 54f5ebed 27-Jun-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Add command-line option (-w), specified once to enable wrapping and
twice to enable wrapping for internal wrapping as well. If the option is
not specified wrapping is turned off so that inetd will behave exactly
as it used to before TCP Wrappers was imported.

Change etc/defaults/rc.conf so as to encourage wrapping on new systems.

Clarify the use of TCP Wrappers in the IMPLEMENTATION NOTES of the
manual page.

Approved by: jkh


# 7aad1732 21-Jun-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Fix handling of maximum children and connections per minute.

Submitted by: David Malone <dwmalone@maths.tcd.ie>


# 1181cf3c 17-Jun-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Various fixes for inetd's TCP Wrappers support:

1) Handle forking and non-forking internal services correctly.
Turn on wrapping for internal services because it works now.
2) Preserve server names for each service on HUP.
3) Honour hosts_options(5) severity option.
4) Add IMPLEMENTATION NOTES section to clarify TCP Wrappers
usage and limitations.

This change may cause previously allowed builtin services (e.g. daytime)
to be denied in existing configurations.

PR: 12097
Reviewed by: markm
1)
Reported by: Pierre Beyssac <pb@fasterix.freenix.org>
2)
Submitted by: Masachika ISHIZUKA <ishizuka@ish.org>
3)
Submitted by: David Malone <dwmalone@maths.tcd.ie>


# b180b6de 10-May-1999 Dag-Erling Smørgrav <des@FreeBSD.org>

Don't stop listening to the signal pipe just because you don't have
anything else to do.

PR: 10468, 11594


# d06590a5 11-Apr-1999 Mark Murray <markm@FreeBSD.org>

Fix the "internal" wrapping as well as a nasty bug involving
the daemon name vs the path. Also fix some warnings and improve
the wrapper section of the man page.

Nice debugging work by: Sheldon Hearn


# 9980037e 28-Mar-1999 Mark Murray <markm@FreeBSD.org>

Now inetd(8) has direct support for tcp_wrappers! Not working at the
moment is support for the internal serfvices, so these are not
enabled. Volunteers welcome!


# 552b1ded 05-Jan-1999 Daniel O'Callaghan <danny@FreeBSD.org>

Make machtime() function unsigned long instead of long.
Reviewed by: phk


# 87cef388 02-Jan-1999 Dag-Erling Smørgrav <des@FreeBSD.org>

Style cleanups.

Requested by: bde


# e20e25db 28-Dec-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

Back out rev. 1.42 and 1.43. Apply Graham Wheeler's signal handling patch.

Reviewed by: jkh & eivind
Submitted by: Graham Wheeler <gram@cdsec.com>
PR: bin/8183


# 73df45e2 15-Dec-1998 Matthew Dillon <dillon@FreeBSD.org>

Remove signal mask prior to calling exec


# 5177c293 11-Dec-1998 Matthew Dillon <dillon@FreeBSD.org>

Reviewed by: freebsd-current

Fix signal/library corruption by blocking all signals except during
select(). The reported corruption was with reentrancy in the malloc lib.


# 3c97a31c 04-Nov-1998 Poul-Henning Kamp <phk@FreeBSD.org>

Add an "internal" driver for the "ident" protocol (tcp/113).

It will return "ERROR:HIDDEN-USER" for all requests.

To use it add:
ident stream tcp nowait root internal
to inetd.conf


# 4b82d708 17-Aug-1998 John Birrell <jb@FreeBSD.org>

Bruce says that %p is intended to format void pointers only. So use a void *
cast. There are pointers and then there are _pointers_. One day I'll
figure out which are which. 8-)


# 44ab8b53 17-Aug-1998 John Birrell <jb@FreeBSD.org>

Remove a cast and print the pointer value with %p instead of %x.


# a07f318f 24-Jul-1998 Andrey A. Chernov <ache@FreeBSD.org>

Add (struct timezone *) cast to NULL for K&R


# 19ce9446 23-Jul-1998 Andrey A. Chernov <ache@FreeBSD.org>

Use NULL as gettimeofday arg instead of 0 cast
Add missing arg to error diagnostic
Print yet one arg of error diagnostic


# d4676e5a 22-Jul-1998 Poul-Henning Kamp <phk@FreeBSD.org>

last patch misapplied.


# 02c589d9 21-Jul-1998 Poul-Henning Kamp <phk@FreeBSD.org>

This may apply to all known versions of inetd.

For a tcp/nowait connection, inetd invokes accept(2) for
each pending connection; this call returns a file descriptor
associated with the new connection.

Twelve years ago, code was added to inetd to detect "failing
servers". The heuristic that identifies a failing server is
one that has been invoked a large number of times over some
specified interval (e.g., more than 128 ftp services started
in 60 seconds may flag the ftp service as "failing"). These
compile-time constants vary depending on vendor.

The problem is that, when a failing server is detected, the
code neglects to close the file descriptor returned by the
accept(2).

Security-Implications:
I suppose someone with ample free time could orchestrate an
attack buy pummeling services until the inetd process finally
runs out of file descriptors thus rendering inetd useless to
any new connections that require a new descriptor.

PR: 7286
Reviewed by: phk
Submitted by: Jeff Forys <jeff@forys.cranbury.nj.us>


# c6c38f1d 14-May-1998 Guido van Rooij <guido@FreeBSD.org>

On request of Garrett, ad a way to specify that a service should be
reachable via T/TCP
Reviewed by: Garrett Wollman


# 65434143 10-May-1998 Bruce Evans <bde@FreeBSD.org>

Fixed gross errors in previous commit. `sapipe' was used uninitialized
to attempt to unblock SIGCHLD, but we actually want to unignore SIGPIPE.

Obtained from: OpenBSD

Finished conversion from sigvec to sigaction (don't assume that sa_mask
is a scalar...). Didn't convert from sigblock to sigprocmask. Didn't
fix missing error checking for sigaction...


# e523d5ae 08-May-1998 Guido van Rooij <guido@FreeBSD.org>

Unblock SIGPIPE before execv(); convert from sigvec to sigaction
Obtained from: OpenBSD


# 34b32a7c 07-May-1998 Guido van Rooij <guido@FreeBSD.org>

Redo tcpmux stuff. tcpmux handling is now performed after inetd
forks. Furthermore, invalid input for tcpmux does not lead to
an exiting inetd.
This patch is recommended for people running tcpmux (which is NOT
enabled by default)


# ffb7094e 24-Feb-1998 Paul Traina <pst@FreeBSD.org>

Make maxchild and max child-per-minute default values configurable from
the command line or Makefile.


# 3e2e58f1 29-Oct-1997 Dima Ruban <dima@FreeBSD.org>

Add possibility to specify maximum number of connections per minute
for a given IP address.
This should be very effective against DoS attacks.


# b34683ca 28-Oct-1997 Andrey A. Chernov <ache@FreeBSD.org>

Implement group part now, final syntax is:
user[:group][/login-class]


# 186a5319 27-Oct-1997 Andrey A. Chernov <ache@FreeBSD.org>

Implement login classes sepcification as user[/loginclass]

By default inetd run things with the same limits as from /etc/rc
(daemon class) to not break anything as in good old days.


# c1a2e93e 19-Sep-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3).


# 83eea896 29-Aug-1997 Warner Losh <imp@FreeBSD.org>

Remove and odd sleep found by David Holland and posted to -security.
Reviewed by: Theo de Raadt (who put it into OpenBSD)
Submitted by: David Holland <dholland@eecs.harvard.edu>


# 5d0bfe39 10-May-1997 David Nugent <davidn@FreeBSD.org>

login_getclass() -> login_getpwclass().


# aeb83a46 28-Apr-1997 Garrett Wollman <wollman@FreeBSD.org>

Condition SO_PRIVSTATE twiddling on the definedness of SO_PRIVSTATE.
(This was done as a #ifdef to keep source compatibility between 2.2 and 3.0.)


# 6c3f552a 30-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 476602a9 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# fb425165 05-Feb-1997 Julian Elischer <julian@FreeBSD.org>

The "-a" option for inetd specifies a specific IP address for the
server to bind to. This works until you send it a SIGHUP with a
new service defined ... the new service is bound to INADDR_ANY.

This patch fixes this bug (in both RELENG_2_2 and -current).

This is a 2.2 candidate..(i.e. pure bug fix)

Submitted by: Archie Cobbs (archie@whistle.com)


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# fbc2342c 12-Jan-1997 Peter Wemm <peter@FreeBSD.org>

Implement minimal login class support (ie: does a setusercontext()).
Enabled by defining LOGIN_CAP in Makefile, on by default.


# 0661be0b 10-Nov-1996 Julian Elischer <julian@FreeBSD.org>

Reviewed by: Bill fenner
Submitted by: Archie Cobbs (Archie@whistle.com)

Changes to allow inted to control the number of servers to
start on each service. This is a defence against a denial of service attack
in which the system is made unusable by
an external party. It also allows the behaviour of
small memory systems to be more accuratly predicted, by
bounding the extent to which processes can multiply.


# 6467602b 10-Nov-1996 Julian Elischer <julian@FreeBSD.org>

Reviewed by: Bill fenner
Submitted by: Archie Cobbs (archie@whistle.com)

changes to make inetd compile cleaner under -Wall


# 9e375707 31-Oct-1996 Alexander Langer <alex@FreeBSD.org>

Fix incorrect length argument to memset() function. Closes PR#1937.

Submitted by: Archie Cobbs <archie@whistle.com>


# d4788da6 28-Oct-1996 Joerg Wunsch <joerg@FreeBSD.org>

Do not modify a malloc()ed pointer; instead, use memmove().

Detected by: phkmalloc - AJ :)


# 7356460f 09-Aug-1996 Julian Elischer <julian@FreeBSD.org>

Reviewed by: various
Submitted by: archie@whistle.com

changes to allow inetd to bind to a single interface
for more complicated options see xinetd in ports.

Obtained from: whistle.com


# e2894535 17-Jul-1996 David Greenman <dg@FreeBSD.org>

Increased listen() queue-depth limit to 64.


# e50d7759 07-Feb-1996 Garrett Wollman <wollman@FreeBSD.org>

Call setsockopt(SO_PRIVSTATE) to renounce SS_PRIV on all the sockets
we create. (Nothing being called from inetd should use it anyway,
but you can never be too careful.)

Translate the man page back into -mdoc.


# c1283020 01-Jan-1996 Peter Wemm <peter@FreeBSD.org>

Make inetd use setproctitle from libutil instead of it's own version.

The old code can probably still be compiled with #define OLD_SETPROCTITLE


# 84c60f0d 03-Nov-1995 Peter Wemm <peter@FreeBSD.org>

Workaround for the setlogin()-in-same-session-as-inetd bug.

This causes:
1: inetd to clear it's getlogin() name at startup (in case the sysadmin
logged in and su'ed to root and restarted inetd)
2: inetd to start each spawned process in it's own session.
3: inetd to call setlogin() on non-root processes (eg: uucp for uucico)
4: log failures more extensively

This means that root spawned processes from inetd remain responsible for
setting their login name if they change their uid. (eg: rshd, login, etc).

If they do not do so, it is safer for them to have no "login name" than a
wrong one (like "root") because the getlogin() system call is documented
as "secure" on 4.4BSD. inetd when started from /etc/rc would have no login
name anyway, so this isn't really a change - it's making it consistant with
the bootup state...

The setsid() change *may* cause something to break that is doing a setsid()
itself and checking the result - it will fail now because it's already been
done. The consensis seems to be that this is unlikely. David G. thinks
this is acceptable as it is cleaner from an architectural point of view.


# 32b505b2 30-Oct-1995 Adam David <adam@FreeBSD.org>

Implement simple quoting for command args.
Previously "abc xyz" became 2 args split at the space.


# 9fe96cbb 12-Oct-1995 Garrett Wollman <wollman@FreeBSD.org>

Record PID in /var/run/inetd.pid and document same.


# d3628763 11-Jun-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Merge RELENG_2_0_5 into HEAD


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

Remove trailing whitespace.


# 71704f34 21-Dec-1994 Garrett Wollman <wollman@FreeBSD.org>

Disable UDP service looping attack.


# bee39b42 11-Sep-1994 Geoff Rehmet <csgr@FreeBSD.org>

- increase TOOMANY, in line with 1.x
- add logging option from 1.x


# 55b91f3a 11-Sep-1994 Geoff Rehmet <csgr@FreeBSD.org>

Bring in handling of RPC services from 1.x
(Guess who forgot to replace his inetd until today ;-)


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

BSD 4.4 Lite usr.sbin Sources