Commit graph

173 commits

Author SHA1 Message Date
Warner Losh 0b8224d1cc 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
2023-11-26 22:23:58 -07:00
Warner Losh 8a7b612037 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
2023-11-26 22:23:56 -07:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Mateusz Piotrowski 648b9ce80e inetd: Use the synopsis from the manual page
Also, document -s in the usage message.

MFC after:	7 days
2021-12-06 22:15:19 +01:00
Kyle Evans 1253835121 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
2021-02-12 13:36:38 -06:00
Kyle Evans 525c896ba8 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
2020-01-10 14:43:57 +00:00
Kyle Evans 36cac5570f 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
2020-01-10 14:40:04 +00:00
Ed Maste 9a3e2f583f 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
2020-01-03 15:29:32 +00:00
Kyle Evans 705d79b4bd 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.
2020-01-01 18:49:57 +00:00
Kyle Evans c8863d0590 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.
2020-01-01 04:29:08 +00:00
Kyle Evans c53b0f40f3 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
2020-01-01 04:22:04 +00:00
Kyle Evans d6272fce7c 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.
2020-01-01 03:59:54 +00:00
Kyle Evans a1cedb80c6 inetd: prefer strlcpy to strlen(3) check + strcpy(3), NFC
This is again functionally equivalent but more concise.
2019-12-31 04:53:50 +00:00
Kyle Evans f23df31975 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.
2019-12-31 04:00:24 +00:00
Kyle Evans f930f30f60 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
2019-12-30 15:54:36 +00:00
Pedro F. Giffuni 8a16b7a18f 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.
2017-11-20 19:49:47 +00:00
Hiroki Sato d31d87b0a7 Simplify a pipe for signal handling. 2017-03-20 17:57:24 +00:00
Warner Losh fbbd9655e5 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
2017-02-28 23:42:47 +00:00
Enji Cooper 484b700751 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
2017-01-14 10:20:38 +00:00
Enji Cooper 63eca8f1dd 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
2017-01-14 01:37:03 +00:00
Hiroki Sato 1232b86014 Fix build when WITHOUT_INET6 is defined. 2017-01-05 03:25:16 +00:00
Hiroki Sato 4909085f84 - Add static for symbols which need not to be exported.
- Clean up warnings to the WARNS=6 level.
2016-12-31 11:03:34 +00:00
Marcelo Araujo a1b422f4d6 Use MAX macro from sys/param.h.
MFC after:	2 weeks.
2016-05-02 01:43:22 +00:00
Baptiste Daroussin 02277afdb1 Use the SOCK_CLOEXEC flags in the socket(2) 'type' attribute instead of
calling fcntl(2)

MFC after:	1 week
2016-04-16 13:10:31 +00:00
Baptiste Daroussin 29808109ea Use pipe2(2) to directly set the close-on-exec flags directly
MFC after:	1 week
2016-04-16 12:42:01 +00:00
Hiroki Sato fb0e28f0e1 - 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
2015-09-19 23:48:06 +00:00
Hiroki Sato 157d2c3355 - 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
2015-09-19 23:27:22 +00:00
Eitan Adler d5792866b0 identd: restore memcpy
I should not be committing at 2:30am....

Reported by:	pluknet
2015-04-19 09:35:46 +00:00
Eitan Adler 7ebd5ed4d4 identd: also zero se_rpc_highvers
Reported by:	pluknet
2015-04-19 09:27:47 +00:00
Eitan Adler af5f5a398f 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
2015-04-19 09:07:57 +00:00
Alexander V. Chernikov 603eaf792b 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@
2014-11-09 21:33:01 +00:00
Andrey Zonov ec89b1f97c - 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
2013-01-20 19:44:33 +00:00
Xin LI 4f985ef6b9 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
2012-06-04 18:02:09 +00:00
Ed Schouten b3608ae18f 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.
2012-01-03 18:51:58 +00:00
Ed Schouten 9a958de54c ANSIfy some more tools in usr.sbin/.
Most of these tools build with WARNS=6, except for their use of K&R
function declarations.
2010-01-02 11:05:34 +00:00
Attilio Rao 7a7043c787 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
2009-11-25 15:12:24 +00:00
Xin LI 882284ccd1 Sync comment with actual configuration format. 2009-02-13 22:48:05 +00:00
George V. Neville-Neil 8409aedfa6 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
2007-07-01 12:08:08 +00:00
David Malone 7149ee1696 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>
2007-03-11 16:30:49 +00:00
Ruslan Ermilov 906c8a734c Removed T/TCP bits. 2006-09-14 08:36:53 +00:00
Xin LI b512f01068 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
2006-01-18 19:38:43 +00:00
Xin LI 4d115fef9e 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
2006-01-18 07:47:46 +00:00
Pawel Jakub Dawidek 8b28aef238 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
2005-09-16 11:24:28 +00:00
Pawel Jakub Dawidek f670195163 Use pidfile(3) in inetd(8). 2005-08-24 19:04:21 +00:00
Hajimu UMEMOTO 4f10131848 NI_WITHSCOPEID cleanup. Neither RFC 2553 nor RFC 3493 defines
NI_WITHSCOPEID, and our getaddrinfo(3) does nothing special
for it, now.
2005-05-13 16:31:11 +00:00
Stefan Farfeleder 80c4c0db4f Prefer C99's __func__ over GCC's __FUNCTION__.
Approved by:	dwmalone
2004-09-26 13:47:25 +00:00
Warner Losh 486c8cc4c6 Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived software
(with permission of addtional copyright holders where appropriate)
2004-08-07 04:28:56 +00:00
Brooks Davis 44501e8cfd 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
2004-04-20 23:34:39 +00:00
David Malone 48135410c1 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
2004-04-04 21:32:23 +00:00
David Malone bcd4c5746a 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
2004-03-22 12:01:23 +00:00