History log of /freebsd-current/usr.sbin/inetd/builtins.c
Revision Date Author Comments
# 6addf2595 11-Apr-2024 Elyes Haouas <ehaouas@noos.fr>

inetd: Fix typos

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/882


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


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

inetd: prefer strtonum(3) to strspn(3)+atoi(3), NFC

strtonum(3) does effectively the same validation as we had, but it's 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.


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

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.

No functional change intended.


# 483825ed 26-Nov-2017 Xin LI <delphij@FreeBSD.org>

Don't assign rs as we will assign it later.

MFC after: 2 weeks


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


# f03ef840 10-May-2016 Baptiste Daroussin <bapt@FreeBSD.org>

Rename getline with get_line to avoid collision with getline(3)

When getline(3) in 2009 was added a _WITH_GETLINE guard has also been added.
This rename is made in preparation for the removal of this guard


# 902d9eaf 01-Sep-2012 Ed Schouten <ed@FreeBSD.org>

Rework all non-contributed files that use `struct timezone'.

This structure is not part of POSIX. According to POSIX, gettimeofday()
has the following prototype:

int gettimeofday(struct timeval *restrict tp, void *restrict tzp);

Also, POSIX states that gettimeofday() shall return 0 (as long as tzp is
not used). Remove dead error handling code. Also use NULL for a
nul-pointer instead of integer 0.

While there, change all pieces of code that only use tv_sec to use
time(3), as this provides less overhead.


# 3df5ecac 30-Dec-2011 Ulrich Spörlein <uqs@FreeBSD.org>

Spelling fixes for usr.sbin/


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


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

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


# 6a4d12ad 17-Apr-2006 David Malone <dwmalone@FreeBSD.org>

Update a couple of comments relating to RFCs.


# e90fa6a9 17-Apr-2006 David Malone <dwmalone@FreeBSD.org>

Port 37 (RFC 738) style times are supposed to be a 32 bit time since
1900 in network byte order. Use a uint32_t to calculate and send
the time, so that we don't need to know how big ints or longs are.

I used uint32_t instead of int in the patch, on the off chance
someone uses our inetd source on a system that doesnt 32 bit ints.

PR: 95290
Submitted by: Bruce Becker <hostmaster@whois.gts.net>
MFC after: 2 weeks


# ae5fafd8 22-Jul-2002 Tony Finch <fanf@FreeBSD.org>

Fix typo: corrisponds -> corresponds


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


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

Kill bad whitespace and do some style cleanups as a result of the protoize.


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

ANSI prototypes via protoize(1).


# 76183f34 26-Feb-2002 Dima Dorfman <dd@FreeBSD.org>

Introduce a version field to `struct xucred' in place of one of the
spares (the size of the field was changed from u_short to u_int to
reflect what it really ends up being). Accordingly, change users of
xucred to set and check this field as appropriate. In the kernel,
this is being done inside the new cru2x() routine which takes a
`struct ucred' and fills out a `struct xucred' according to the
former. This also has the pleasant sideaffect of removing some
duplicate code.

Reviewed by: rwatson


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


# aca66ea0 04-Jun-2001 David Malone <dwmalone@FreeBSD.org>

Correct a comment - the time service returns seconds since 1900 not 1970.

Submitted by: ru


# 9a0b3389 04-Jun-2001 David Malone <dwmalone@FreeBSD.org>

This patch cleans up the ident stuff in inetd. The code which has
been patched so many times it was a bit of a mess. There are style,
code and man page cleanups. The following are the functional changes:

The RFC only permits the returning of 4 possible error
codes, make sure we only return these (PR 27636).

Use MAXLOGNAME to determine the longest usernames.

Add a -i flag, which returns the uid instead of the username
(this is from a PR 25787, which also contained alot of the
cleanups in this patch).

PR: 25787, 27636
Partially Submitted by: Arne.Dag.Fidjestol@idi.ntnu.no
Reviewed by: Arne.Dag.Fidjestol@idi.ntnu.no, green
MFC after: 3 weeks


# d0847e93 26-May-2001 David Malone <dwmalone@FreeBSD.org>

Make dg_echo return up to the first 65536 bytes of a datagram.
The patch I used isn't quite the one Lars suggested, but the size
of the largest datagram you can recv isn't #defined anywhere, and
probably isn't even bounded for some protocols.

PR: 25050
Submitted by: Lars Eggert <larse@isi.edu>


# d517199f 28-Mar-2001 David Malone <dwmalone@FreeBSD.org>

Allow ident requests with trailing junk following the terminating "\n".

Reviewed by: ben
Approved by: green


# c0511d3b 18-Feb-2001 Brian Feldman <green@FreeBSD.org>

Switch to using a struct xucred instead of a struct xucred when not
actually in the kernel. This structure is a different size than
what is currently in -CURRENT, but should hopefully be the last time
any application breakage is caused there. As soon as any major
inconveniences are removed, the definition of the in-kernel struct
ucred should be conditionalized upon defined(_KERNEL).

This also changes struct export_args to remove dependency on the
constantly-changing struct ucred, as well as limiting the bounds
of the size fields to the correct size. This means: a) mountd and
friends won't break all the time, b) mountd and friends won't crash
the kernel all the time if they don't know what they're doing wrt
actual struct export_args layout.

Reviewed by: bde


# 38db6bf3 05-Dec-2000 David Malone <dwmalone@FreeBSD.org>

Add a -F option to the builtin ident service, which allows .fakeid files
to contain the name of other valid users.

PR: 22837
Submitted by: Andreas Gerstenberg <andy@andy.de>
Reviewed by: green
Reviewed by: sheldonh


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


# c4483bc0 02-Dec-2000 Brian Feldman <green@FreeBSD.org>

Make some style changes to the ident_stream() code.

Partially submitted by: alfred
Reviewed by: alfred


# 6fe761c7 24-Nov-2000 Brian Feldman <green@FreeBSD.org>

Security fix: correctly set groups according to the user. Previously,
root's groups' permissions were being used, so a user could read up to
16 (excluding initial whitespace) bytes of e.g. a wheel-accessible file.

Also, don't allow blocking on the opening of ~/.fakeid, so replace a fopen()
with open() and fdopen(). I knew I'd be going to hell for using C file
streams instead of POSIX syscalls...


# 957672f9 01-Oct-2000 David Malone <dwmalone@FreeBSD.org>

Stop internal ident service spinning until the timeout if the
connection goes away. Spotted by people on -STABLE about 2 weeks
ago.

Submitted by: Based on a patch by alfred and Maxime Henrion <mux@qualys.com>


# 7d37a2e6 12-Jul-2000 David Malone <dwmalone@FreeBSD.org>

Make builtin ident service work if the request arrives in more than
one packet. Also check that the whole request has been recieved
before processing it.

The patch isn't the exact one from the PR, but a slight varient
suggested by Brian.

PR: 16086
Submitted by: Hajimu UMEMOTO <ume@mahoroba.org>
Reviewed by: green


# 9e72c318 30-May-2000 Brian Feldman <green@FreeBSD.org>

Fix the ident server up more: use ssize_t/size_t/socklen_t/int all in the
proper places and make the fakeid parsing code a bit less stupid. Also,
remove an "Rflag" that snuck in there (-R wouldn't be accepted by it,
anyway).


# 1078172a 30-May-2000 John Baldwin <jhb@FreeBSD.org>

Fix a 64-bit'ism in the handling of the ident service. sysctlbyname() takes
a size_t as its 3rd argument, which is 64-bits on the alpha. The 'len'
variable used was a int, which is only 32-bits. Use size_t as the type
for 'len' to work-around this.


# a3ad0852 28-Mar-2000 Sheldon Hearn <sheldonh@FreeBSD.org>

Optimize those services that send only one block of data: use send(2)
with the MSG_EOF flag set instead of write(2).

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


# 7ef719fb 27-Mar-2000 Brian Feldman <green@FreeBSD.org>

Allow using "-d username" without "-r". Example:
auth stream tcp nowait root internal auth -d "Only fools trust ident"


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

Make inetd compilable without INET6.

Approved by: jkh

Submitted by: jhb


# a9a948a9 09-Mar-2000 Yoshinobu Inoue <shin@FreeBSD.org>

Fix addr length argument value passed to sendto().
Some inetd internal udp servers didn't worked with problem.
Also fix recvfrom() "fromlen" arg type from int * to socklen_t *.

Approved by: jkh

Submitted by: bde


# 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


# 5a5e442a 19-Jan-2000 Brian Feldman <green@FreeBSD.org>

I like base-36 better.


# 18338e9e 19-Jan-2000 Brian Feldman <green@FreeBSD.org>

Implement -g and -d options in my ident code. The -g flag uses a random
garbage value for the username (hex garbage, that is), and the -d flag
provides a default username for fallback purposes if the user cannot be
looked up. That is very useful for the case where inetd auth is
running on a NAT box.

While I'm here updating the manpage, clean up an English error and a
few small nits.


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

$Id$ -> $FreeBSD$


# 019893b4 26-Jul-1999 Brian Feldman <green@FreeBSD.org>

Here goes, the "clear up any possible confusion" commit.
I've taken time to write up comments for the ident code tonight,
so there should no longer be any confusion about the purpouse of
whatever is in there. Wow, me commenting code... who'd have thought
that would happen?

Reviewed by: DES


# ecf12be0 25-Jul-1999 Brian Feldman <green@FreeBSD.org>

More cleanups to ident_stream. Variables moved around, changed.
Got rid of an extra variable or two, while making corrections to
problems (that would probably not be a problem anyway, and worked.)

Partially Obtained from: David Malone <dwmalone@maths.tcd.ie>


# 2d878a19 24-Jul-1999 Brian Feldman <green@FreeBSD.org>

More cleanups, asprintf() usage (proper, as opposed to using snprintf()),
and addition of a -n .noident-checking flag.


# b52c43b3 24-Jul-1999 Brian Feldman <green@FreeBSD.org>

Clean up to match style(9) more closely. This should fix the problem of
people having ants in their pants ;)


# 9a16e31a 24-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Use comments to group functions by service more clearly. I've used the
excuse of providing the RFC numbers for the associated services.


# 6f426a27 23-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Style nits:
* Bring memory allocation failure handling in line with that of
the rest of the code.
* Nestle block curlies between case statements correctly.

I've left the in-block declarations alone, since style(9) says we should
conform to the existing style within the code, and inetd already does
this. I've left the asprintf()'s in there because that's how Brian wants
it.


# e1c77598 23-Jul-1999 Brian Feldman <green@FreeBSD.org>

Ahem. Put things back a bit. I declare variables in the scope they're
used! I don't declare every variable at the top of a function because
that wastes stack space. I've clarified the error a bit (for if asprintf()
filas.)


# 56658bf1 23-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Style cleanups for iderror() and ident_stream(). Looks like c++ hang-over.
;-)


# 3d1171b5 23-Jul-1999 Sheldon Hearn <sheldonh@FreeBSD.org>

Fix auth -t argument handling. It was broken for the "sec.usec" case.
Add a warning for bogus -t arguments for the (debug) case.


# e26aedfb 22-Jul-1999 Brian Feldman <green@FreeBSD.org>

Fixed a braino: lack of spaces in sscanf caused ident parsing to fail.
Sorry, guys.


# 202a2323 22-Jul-1999 Brian Feldman <green@FreeBSD.org>

"knobs are cheap". Here's a -t timeout option for the internal ident
service. It takes a number (w/ or w/out .usec) as an argument.


# 8391600e 22-Jul-1999 Brian Feldman <green@FreeBSD.org>

This commit encompasses the following changes to inetd:
1. Cleanups of ident_stream. "Evil" stdio is less used.
2. The BSD Copyright was added to the top of builtins.c.
3. As suggested, a timeout is now implemented in the ident
service. It defaults to 10 seconds. If enough people want
it, I'll make it configurable.

Suggested by: msmith


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