summaryrefslogtreecommitdiff
path: root/networking/inetd.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-11 23:26:13 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-11 23:26:13 +0000
commitf8138d1f91c913166bffb0077a0fe06831a77ecf (patch)
treead67c96ccbbce0620186dd2926451f69c0831f0f /networking/inetd.c
parent4fa5e8b455c732db3176c7dbd58dec63d38f4273 (diff)
downloadbusybox-w32-f8138d1f91c913166bffb0077a0fe06831a77ecf.tar.gz
busybox-w32-f8138d1f91c913166bffb0077a0fe06831a77ecf.tar.bz2
busybox-w32-f8138d1f91c913166bffb0077a0fe06831a77ecf.zip
fakeinetd: attempted ipv6-ization (and it's done)
but entire applet can be orders of magnitude smaller if written as an inetd service. So did that (#ifdef'ed out entire old version). inetd version is less than 10% of old one! function old new delta packed_usage 22083 22105 +22 nobodystr 4 - -4 bind_ip_address 4 - -4 ident_substr 20 - -20 chmatch 22 - -22 movefd 25 - -25 skipchars 49 - -49 handlexitsigs 51 - -51 replyError 70 - -70 .rodata 158120 158024 -96 deleteConn 102 - -102 G 524 388 -136 conns 560 - -560 fakeidentd_main 1457 143 -1314 ------------------------------------------------------------------------------ (add/remove: 0/10 grow/shrink: 1/3 up/down: 22/-2453) Total: -2431 bytes
Diffstat (limited to 'networking/inetd.c')
-rw-r--r--networking/inetd.c49
1 files changed, 38 insertions, 11 deletions
diff --git a/networking/inetd.c b/networking/inetd.c
index 75665ba3e..93c16bf60 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -23,7 +23,7 @@
23 * may be used to endorse or promote products derived from this software 23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission. 24 * without specific prior written permission.
25 * 25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
@@ -36,8 +36,7 @@
36 * SUCH DAMAGE. 36 * SUCH DAMAGE.
37 */ 37 */
38 38
39/* 39/* Inetd - Internet super-server
40 * Inetd - Internet super-server
41 * 40 *
42 * This program invokes all internet services as needed. 41 * This program invokes all internet services as needed.
43 * connection-oriented services are invoked each time a 42 * connection-oriented services are invoked each time a
@@ -50,14 +49,14 @@
50 * arrives; a process is created and passed a pending message 49 * arrives; a process is created and passed a pending message
51 * on file descriptor 0. Datagram servers may either connect 50 * on file descriptor 0. Datagram servers may either connect
52 * to their peer, freeing up the original socket for inetd 51 * to their peer, freeing up the original socket for inetd
53 * to receive further messages on, or ``take over the socket'', 52 * to receive further messages on, or "take over the socket",
54 * processing all arriving datagrams and, eventually, timing 53 * processing all arriving datagrams and, eventually, timing
55 * out. The first type of server is said to be ``multi-threaded''; 54 * out. The first type of server is said to be "multi-threaded";
56 * the second type of server ``single-threaded''. 55 * the second type of server "single-threaded".
57 * 56 *
58 * Inetd uses a configuration file which is read at startup 57 * Inetd uses a configuration file which is read at startup
59 * and, possibly, at some later time in response to a hangup signal. 58 * and, possibly, at some later time in response to a hangup signal.
60 * The configuration file is ``free format'' with fields given in the 59 * The configuration file is "free format" with fields given in the
61 * order shown below. Continuation lines for an entry must begin with 60 * order shown below. Continuation lines for an entry must begin with
62 * a space or tab. All fields must be present in each entry. 61 * a space or tab. All fields must be present in each entry.
63 * 62 *
@@ -105,8 +104,37 @@
105 * Comment lines are indicated by a `#' in column 1. 104 * Comment lines are indicated by a `#' in column 1.
106 */ 105 */
107 106
108/* 107/* inetd rules for passing file descriptors to children
109 * Here's the scoop concerning the user[.:]group feature: 108 * (http://www.freebsd.org/cgi/man.cgi?query=inetd):
109 *
110 * The wait/nowait entry specifies whether the server that is invoked by
111 * inetd will take over the socket associated with the service access point,
112 * and thus whether inetd should wait for the server to exit before listen-
113 * ing for new service requests. Datagram servers must use "wait", as
114 * they are always invoked with the original datagram socket bound to the
115 * specified service address. These servers must read at least one datagram
116 * from the socket before exiting. If a datagram server connects to its
117 * peer, freeing the socket so inetd can receive further messages on the
118 * socket, it is said to be a "multi-threaded" server; it should read one
119 * datagram from the socket and create a new socket connected to the peer.
120 * It should fork, and the parent should then exit to allow inetd to check
121 * for new service requests to spawn new servers. Datagram servers which
122 * process all incoming datagrams on a socket and eventually time out are
123 * said to be "single-threaded". The comsat(8), (biff(1)) and talkd(8)
124 * utilities are both examples of the latter type of datagram server. The
125 * tftpd(8) utility is an example of a multi-threaded datagram server.
126 *
127 * Servers using stream sockets generally are multi-threaded and use the
128 * "nowait" entry. Connection requests for these services are accepted by
129 * inetd, and the server is given only the newly-accepted socket connected
130 * to a client of the service. Most stream-based services operate in this
131 * manner. Stream-based servers that use "wait" are started with the lis-
132 * tening service socket, and must accept at least one connection request
133 * before exiting. Such a server would normally accept and process incoming
134 * connection requests until a timeout.
135 */
136
137/* Here's the scoop concerning the user[.:]group feature:
110 * 138 *
111 * 1) set-group-option off. 139 * 1) set-group-option off.
112 * 140 *
@@ -125,7 +153,6 @@
125 * b) other: setgid(specified group) 153 * b) other: setgid(specified group)
126 * initgroups(name, specified group) 154 * initgroups(name, specified group)
127 * setuid() 155 * setuid()
128 *
129 */ 156 */
130 157
131#include "busybox.h" 158#include "busybox.h"
@@ -161,7 +188,7 @@
161#endif 188#endif
162 189
163/* Reserve some descriptors, 3 stdio + at least: 1 log, 1 conf. file */ 190/* Reserve some descriptors, 3 stdio + at least: 1 log, 1 conf. file */
164#define FD_MARGIN (8) 191#define FD_MARGIN 8
165static rlim_t rlim_ofile_cur = OPEN_MAX; 192static rlim_t rlim_ofile_cur = OPEN_MAX;
166static struct rlimit rlim_ofile; 193static struct rlimit rlim_ofile;
167 194