summaryrefslogtreecommitdiffstats
path: root/usr.sbin/inetd
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-09-19 06:27:30 +0000
committercharnier <charnier@FreeBSD.org>1997-09-19 06:27:30 +0000
commite9cad8594ecde5c524e5aa90a7b69513faa56123 (patch)
tree6e1749663964b8ec44b12cc8ba18efd9534e2857 /usr.sbin/inetd
parent7220eb2a3ed5eb140e2432de82e7de6f9d2ed57d (diff)
downloadFreeBSD-src-e9cad8594ecde5c524e5aa90a7b69513faa56123.zip
FreeBSD-src-e9cad8594ecde5c524e5aa90a7b69513faa56123.tar.gz
Use err(3).
Diffstat (limited to 'usr.sbin/inetd')
-rw-r--r--usr.sbin/inetd/inetd.853
-rw-r--r--usr.sbin/inetd/inetd.c46
2 files changed, 49 insertions, 50 deletions
diff --git a/usr.sbin/inetd/inetd.8 b/usr.sbin/inetd/inetd.8
index fed25f1..ae7664a 100644
--- a/usr.sbin/inetd/inetd.8
+++ b/usr.sbin/inetd/inetd.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)inetd.8 8.3 (Berkeley) 4/13/94
-.\" $Id$
+.\" $Id: inetd.8,v 1.13 1997/02/22 16:05:51 peter Exp $
.\"
.Dd February 7, 1996
.Dt INETD 8
@@ -49,7 +49,7 @@
.Op Ar configuration file
.Sh DESCRIPTION
The
-.Nm inetd
+.Nm
program
should be run at boot time by
.Pa /etc/rc
@@ -63,22 +63,21 @@ The server program is invoked with the service socket
as its standard input, output and error descriptors.
After the program is
finished,
-.Nm inetd
+.Nm
continues to listen on the socket (except in some cases which
will be described below). Essentially,
-.Nm inetd
+.Nm
allows running one daemon to invoke several others,
reducing load on the system.
.Pp
-The options available for
-.Nm inetd:
-.Bl -tag -compact -width Rratexxx
+The following options are available:
+.Bl -tag -width indent
.It Fl d
-Turns on debugging.
+Turn on debugging.
.It Fl l
-Turns on logging.
+Turn on logging.
.It Fl R Ar rate
-Specifies the maximum number of times a service can be invoked
+Specify the maximum number of times a service can be invoked
in one minute; the default is 256.
.It Fl a
Specify a specific IP address to bind to.
@@ -87,7 +86,7 @@ Specify an alternate file in which to store the process ID.
.El
.Pp
Upon execution,
-.Nm inetd
+.Nm
reads its configuration information from a configuration
file which, by default, is
.Pa /etc/inetd.conf .
@@ -121,7 +120,7 @@ server program arguments
.Ed
.Pp
There are two types of services that
-.Nm inetd
+.Nm
can start: standard and TCPMUX.
A standard service has a well-known port assigned to it;
it may be a service that implements an official Internet standard or is a
@@ -131,7 +130,7 @@ As described in
TCPMUX services are nonstandard services that do not have a
well-known port assigned to them.
They are invoked from
-.Nm inetd
+.Nm
when a program connects to the
.Dq tcpmux
well-known port and specifies
@@ -207,9 +206,11 @@ TCPMUX services must use
.Pp
The
.Em wait/nowait
-entry specifies whether the server that is invoked by inetd will take over
+entry specifies whether the server that is invoked by
+.Nm
+will take over
the socket associated with the service access point, and thus whether
-.Nm inetd
+.Nm
should wait for the server to exit before listening for new service
requests.
Datagram servers must use
@@ -220,7 +221,7 @@ These servers must read at least one datagram from the socket
before exiting.
If a datagram server connects
to its peer, freeing the socket so
-.Nm inetd
+.Nm
can received further messages on the socket, it is said to be
a
.Dq multi-threaded
@@ -229,7 +230,7 @@ it should read one datagram from the socket and create a new socket
connected to the peer.
It should fork, and the parent should then exit
to allow
-.Nm inetd
+.Nm
to check for new service requests to spawn new servers.
Datagram servers which process all incoming datagrams
on a socket and eventually time out are said to be
@@ -280,9 +281,9 @@ The
.Em server-program
entry should contain the pathname of the program which is to be
executed by
-.Nm inetd
+.Nm
when a request is found on its socket. If
-.Nm inetd
+.Nm
provides this service internally, this entry should
be
.Dq internal .
@@ -297,7 +298,7 @@ word
should take the place of this entry.
.Pp
The
-.Nm inetd
+.Nm
program
provides several
.Dq trivial
@@ -324,14 +325,14 @@ document.
When given the
.Fl l
option
-.Nm Inetd
+.Nm
will log an entry to syslog each time an
.Xr accept 2
is made, which notes the
service selected and the IP-number of the remote requestor.
.Pp
The
-.Nm inetd
+.Nm
program
rereads its configuration file when it receives a hangup signal,
.Dv SIGHUP .
@@ -356,7 +357,7 @@ the selected protocol begins; otherwise the connection is closed.''
The program is passed the TCP connection as file descriptors 0 and 1.
.Pp
If the TCPMUX service name begins with a ``+'',
-.Nm inetd
+.Nm
returns the positive reply for the program.
This allows you to invoke programs that use stdin/stdout
without putting any special server code in them.
@@ -364,7 +365,7 @@ without putting any special server code in them.
The special service name
.Dq help
causes
-.Nm inetd
+.Nm
to list TCPMUX services in
.Pa inetd.conf .
.Sh "FILES"
@@ -391,7 +392,7 @@ rstatd/1-3 dgram rpc/udp wait root /usr/libexec/rpc.rstatd rpc.rstatd
.Ed
.Sh "ERROR MESSAGES"
The
-.Nm inetd
+.Nm
server
logs error messages using
.Xr syslog 3 .
@@ -444,7 +445,7 @@ exists in the
.Xr passwd 5
database. The first message
occurs when
-.Nm inetd
+.Nm
(re)reads the configuration file. The second message occurs when the
service is invoked.
.Pp
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 1a7396bc..680ef8e 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -32,15 +32,17 @@
*/
#ifndef lint
-static char copyright[] __attribute__ ((unused)) =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1991, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-/* from: @(#)inetd.c 8.4 (Berkeley) 4/13/94"; */
-static char inetd_c_rcsid[] __attribute__ ((unused)) =
- "$Id: inetd.c,v 1.24 1997/05/10 18:59:11 davidn Exp $";
+#if 0
+static char sccsid[] = "@(#)from: inetd.c 8.4 (Berkeley) 4/13/94";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/*
@@ -115,6 +117,7 @@ static char inetd_c_rcsid[] __attribute__ ((unused)) =
#include <rpc/pmap_clnt.h>
#include <errno.h>
+#include <err.h>
#include <fcntl.h>
#include <netdb.h>
#include <pwd.h>
@@ -397,13 +400,12 @@ main(argc, argv, envp)
if (sep->se_fd != -1 && FD_ISSET(sep->se_fd, &readable)) {
n--;
if (debug)
- fprintf(stderr, "someone wants %s\n",
- sep->se_service);
+ warnx("someone wants %s", sep->se_service);
if (sep->se_accept && sep->se_socktype == SOCK_STREAM) {
ctrl = accept(sep->se_fd, (struct sockaddr *)0,
(int *)0);
if (debug)
- fprintf(stderr, "accept, ctrl %d\n", ctrl);
+ warnx("accept, ctrl %d", ctrl);
if (ctrl < 0) {
if (errno != EINTR)
syslog(LOG_WARNING,
@@ -485,8 +487,7 @@ main(argc, argv, envp)
if (pid == 0) {
if (dofork) {
if (debug)
- fprintf(stderr, "+ Closing from %d\n",
- maxsock);
+ warnx("+ closing from %d", maxsock);
for (tmpint = maxsock; tmpint > 2; tmpint--)
if (tmpint != ctrl)
(void) close(tmpint);
@@ -496,8 +497,8 @@ main(argc, argv, envp)
/* NOTREACHED */
} else {
if (debug)
- fprintf(stderr, "%d execl %s\n",
- getpid(), sep->se_server);
+ warnx("%d execl %s",
+ getpid(), sep->se_server);
dup2(ctrl, 0);
close(ctrl);
dup2(0, 1);
@@ -609,8 +610,7 @@ reapchild(signo)
if (pid <= 0)
break;
if (debug)
- fprintf(stderr, "%d reaped, status %#x\n",
- pid, status);
+ warnx("%d reaped, status %#x", pid, status);
for (sep = servtab; sep; sep = sep->se_next) {
for (k = 0; k < sep->se_numchild; k++)
if (sep->se_pids[k] == pid)
@@ -811,9 +811,8 @@ setup(sep)
if ((sep->se_fd = socket(AF_INET, sep->se_socktype, 0)) < 0) {
if (debug)
- fprintf(stderr, "socket failed on %s/%s: %s\n",
- sep->se_service, sep->se_proto,
- strerror(errno));
+ warn("socket failed on %s/%s",
+ sep->se_service, sep->se_proto);
syslog(LOG_ERR, "%s/%s: socket: %m",
sep->se_service, sep->se_proto);
return;
@@ -833,9 +832,8 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
if (bind(sep->se_fd, (struct sockaddr *)&sep->se_ctrladdr,
sizeof (sep->se_ctrladdr)) < 0) {
if (debug)
- fprintf(stderr, "bind failed on %s/%s: %s\n",
- sep->se_service, sep->se_proto,
- strerror(errno));
+ warn("bind failed on %s/%s",
+ sep->se_service, sep->se_proto);
syslog(LOG_ERR, "%s/%s: bind: %m",
sep->se_service, sep->se_proto);
(void) close(sep->se_fd);
@@ -872,7 +870,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
listen(sep->se_fd, 64);
enable(sep);
if (debug) {
- fprintf(stderr, "registered %s on %d\n",
+ warnx("registered %s on %d",
sep->se_server, sep->se_fd);
}
}
@@ -919,7 +917,7 @@ void
enable(struct servtab *sep)
{
if (debug)
- fprintf(stderr,
+ warnx(
"enabling %s, fd %d", sep->se_service, sep->se_fd);
#ifdef SANITY_CHECK
if (sep->se_fd < 0) {
@@ -948,7 +946,7 @@ void
disable(struct servtab *sep)
{
if (debug)
- fprintf(stderr,
+ warnx(
"disabling %s, fd %d", sep->se_service, sep->se_fd);
#ifdef SANITY_CHECK
if (sep->se_fd < 0) {
@@ -1516,7 +1514,7 @@ machtime()
if (gettimeofday(&tv, (struct timezone *)0) < 0) {
if (debug)
- fprintf(stderr, "Unable to get time of day\n");
+ warnx("unable to get time of day");
return (0L);
}
#define OFFSET ((u_long)25567 * 24*60*60)
@@ -1666,7 +1664,7 @@ tcpmux(s)
service[len] = '\0';
if (debug)
- fprintf(stderr, "tcpmux: someone wants %s\n", service);
+ warnx("tcpmux: someone wants %s", service);
/*
* Help is a required command, and lists available services,
OpenPOWER on IntegriCloud