Commit de48914c authored by Marco d'Itri's avatar Marco d'Itri

Refresh the patches

parent dde0b09d
--- a/inetd.8
+++ b/inetd.8
@@ -107,7 +107,7 @@ The fields of the configuration file are
@@ -108,7 +108,7 @@ The fields of the configuration file are
.Bd -unfilled -offset indent
service name
socket type
......@@ -9,7 +9,7 @@
wait/nowait[.max]
user[.group] or user[:group]
server program
@@ -119,7 +119,7 @@ based service, the entry would contain t
@@ -120,7 +120,7 @@ based service, the entry would contain t
.Bd -unfilled -offset indent
service name/version
socket type
......@@ -18,7 +18,7 @@
wait/nowait[.max]
user[.group] or user[:group]
server program
@@ -234,6 +234,30 @@ of
@@ -235,6 +235,30 @@ of
is used to specify a socket in the
.Ux Ns -domain .
.Pp
......@@ -60,7 +60,7 @@
int se_rpcprog; /* rpc program number */
int se_rpcversl; /* rpc program lowest version */
int se_rpcversh; /* rpc program highest version */
@@ -1240,6 +1242,8 @@ getconfigent(void)
@@ -1115,6 +1117,8 @@ getconfigent(void)
{
struct servtab *sep, *tsep;
char *arg, *cp, *hostdelim, *s;
......@@ -68,8 +68,8 @@
+ int val;
int argc;
sep = (struct servtab *) malloc(sizeof(struct servtab));
@@ -1315,6 +1319,93 @@ more:
sep = calloc(1, sizeof(struct servtab));
@@ -1188,6 +1192,93 @@ more:
sep->se_proto = newstr(arg);
......
--- a/inetd.c
+++ b/inetd.c
@@ -290,6 +290,7 @@ int bump_nofile(void);
@@ -291,6 +291,7 @@ int bump_nofile(void);
struct servtab *enter(struct servtab *);
int matchconf(struct servtab *, struct servtab *);
int dg_broadcast(struct in_addr *in);
......@@ -8,13 +8,12 @@
#define NUMINT (sizeof(intab) / sizeof(struct inent))
char *CONFIG = _PATH_INETDCONF;
@@ -321,15 +322,19 @@ main(int argc, char *argv[], char *envp[
@@ -304,14 +305,18 @@ int
main(int argc, char *argv[], char *envp[])
{
fd_set *fdsrp = NULL;
int readablen = 0, ch;
int ch;
+ int keepenv = 0;
struct servtab *sep;
initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dR:")) != -1)
......@@ -29,7 +28,7 @@
case 'R': { /* invocation rate */
char *p;
int val;
@@ -347,12 +352,16 @@ main(int argc, char *argv[], char *envp[
@@ -329,12 +334,16 @@ main(int argc, char *argv[], char *envp[
case '?':
default:
fprintf(stderr,
......@@ -47,7 +46,7 @@
uid = getuid();
if (uid != 0)
CONFIG = NULL;
@@ -2052,3 +2061,45 @@ spawn(struct servtab *sep, int ctrl)
@@ -1905,3 +1914,45 @@ spawn(int ctrl, short events, void *xsep
if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
close(ctrl);
}
......
--- a/inetd.c
+++ b/inetd.c
@@ -170,6 +170,7 @@ int lflag = 0;
@@ -175,6 +175,7 @@ int lflag = 0;
#endif
int debug = 0;
+int global_queuelen = 128;
int nsock, maxsock;
fd_set *allsockp;
int allsockn;
@@ -338,7 +339,7 @@ main(int argc, char *argv[], char *envp[
int maxsock;
int toomany = TOOMANY;
int timingout;
@@ -315,7 +316,7 @@ main(int argc, char *argv[], char *envp[
initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dEilR:")) != -1)
......@@ -17,7 +17,7 @@
switch (ch) {
case 'd':
debug = 1;
@@ -358,6 +359,11 @@ main(int argc, char *argv[], char *envp[
@@ -335,6 +336,11 @@ main(int argc, char *argv[], char *envp[
progname);
exit(1);
#endif
......@@ -29,7 +29,7 @@
case 'R': { /* invocation rate */
char *p;
int val;
@@ -375,7 +381,7 @@ main(int argc, char *argv[], char *envp[
@@ -352,7 +358,7 @@ main(int argc, char *argv[], char *envp[
case '?':
default:
fprintf(stderr,
......@@ -38,15 +38,15 @@
exit(1);
}
argc -= optind;
@@ -1060,7 +1066,7 @@ setsockopt(fd, SOL_SOCKET, opt, &on, siz
@@ -932,7 +938,7 @@ setsockopt(fd, SOL_SOCKET, opt, &on, siz
return;
}
if (sep->se_socktype == SOCK_STREAM)
- listen(sep->se_fd, 10);
+ listen(sep->se_fd, global_queuelen);
fd_grow(&allsockp, &allsockn, sep->se_fd);
FD_SET(sep->se_fd, allsockp);
if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
event_set(&sep->se_event, sep->se_fd, EV_READ|EV_PERSIST,
--- a/inetd.8
+++ b/inetd.8
@@ -41,6 +41,7 @@
......@@ -57,7 +57,7 @@
.Op Fl R Ar rate
.Op Ar configuration_file
.Sh DESCRIPTION
@@ -81,6 +82,10 @@ Internal services cannot be wrapped. Wh
@@ -77,6 +78,10 @@ Internal services cannot be wrapped. Wh
is silently not executed even if present in
.Pa /etc/inetd.conf
and instead libwrap is called directly by inetd.
......
--- a/inetd.c
+++ b/inetd.c
@@ -161,6 +161,11 @@
@@ -169,6 +169,11 @@
#define CNT_INTVL 60 /* servers in CNT_INTVL sec. */
#define RETRYTIME (60*10) /* retry after bind or server fail */
......@@ -10,10 +10,10 @@
+#endif
+
int debug = 0;
int nsock, maxsock;
fd_set *allsockp;
@@ -327,7 +332,7 @@ main(int argc, char *argv[], char *envp[
int maxsock;
int toomany = TOOMANY;
@@ -309,7 +314,7 @@ main(int argc, char *argv[], char *envp[
initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dER:")) != -1)
......@@ -21,7 +21,7 @@
switch (ch) {
case 'd':
debug = 1;
@@ -335,6 +340,15 @@ main(int argc, char *argv[], char *envp[
@@ -317,6 +322,15 @@ main(int argc, char *argv[], char *envp[
case 'E':
keepenv = 1;
break;
......@@ -37,7 +37,7 @@
case 'R': { /* invocation rate */
char *p;
int val;
@@ -352,7 +366,7 @@ main(int argc, char *argv[], char *envp[
@@ -334,7 +348,7 @@ main(int argc, char *argv[], char *envp[
case '?':
default:
fprintf(stderr,
......@@ -46,9 +46,9 @@
exit(1);
}
argc -= optind;
@@ -1947,6 +1961,47 @@ spawn(struct servtab *sep, int ctrl)
@@ -1800,6 +1814,47 @@ spawn(int ctrl, short events, void *xsep
event_del(&sep->se_event);
}
sigprocmask(SIG_SETMASK, &emptymask, NULL);
if (pid == 0) {
+#ifdef LIBWRAP
+ if (lflag && !sep->se_wait && !sep->se_bi && sep->se_socktype == SOCK_STREAM) {
......@@ -118,10 +118,10 @@
.It Fl R Ar rate
Specify the maximum number of times a service can be invoked
in one minute; the default is 256.
@@ -349,6 +357,23 @@ is reread.
creates a file
.Em /var/run/inetd.pid
that contains its process identifier.
@@ -336,6 +344,23 @@ rereads its configuration file when it r
.Dv SIGHUP .
Services may be added, deleted or modified when the configuration file
is reread.
+.Ss libwrap
+Support for
+.Tn TCP
......
......@@ -42,7 +42,7 @@
Examples might be
.Dq tcp
or
@@ -368,9 +366,7 @@ If you have only one server on
@@ -364,9 +362,7 @@ If you have only one server on
only IPv6 traffic will be routed to the server.
.El
.Sh SEE ALSO
......@@ -52,7 +52,7 @@
.Xr ftpd 8 ,
.Xr identd 8 ,
.Xr talkd 8
@@ -383,7 +379,23 @@ Support for Sun-RPC
@@ -379,7 +375,23 @@ Support for Sun-RPC
based services is modelled after that
provided by SunOS 4.1.
IPv6 support was added by the KAME project in 1999.
......@@ -78,7 +78,7 @@
This is largely because the
--- a/inetd.c
+++ b/inetd.c
@@ -128,6 +128,7 @@
@@ -127,6 +127,7 @@
#include <sys/un.h>
#include <sys/file.h>
#include <sys/wait.h>
......@@ -86,9 +86,9 @@
#include <sys/time.h>
#include <sys/resource.h>
@@ -146,11 +147,14 @@
#include <stdlib.h>
@@ -147,14 +148,21 @@
#include <unistd.h>
#include <limits.h>
#include <string.h>
+#ifdef HAVE_SETUSERCONTEXT
#include <login_cap.h>
......@@ -99,25 +99,17 @@
#include <rpc/rpc.h>
#include <rpc/pmap_clnt.h>
-#include <rpcsvc/nfs_prot.h>
#include <event.h>
#include "pathnames.h"
+#ifndef HAVE_PLEDGE
+#define pledge(a, b) (0)
+#endif
+
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define TOOMANY 256 /* don't start more than TOOMANY */
@@ -324,14 +328,11 @@ main(int argc, char *argv[])
fd_set *fdsrp = NULL;
int readablen = 0, ch;
struct servtab *sep;
- extern char *optarg;
- extern int optind;
while ((ch = getopt(argc, argv, "dR:")) != -1)
switch (ch) {
case 'd':
debug = 1;
- options |= SO_DEBUG;
break;
case 'R': { /* invocation rate */
char *p;
@@ -373,9 +374,13 @@ main(int argc, char *argv[])
@@ -342,8 +350,10 @@ main(int argc, char *argv[])
umask(022);
if (debug == 0) {
daemon(0, 0);
......@@ -126,14 +118,11 @@
(void) setlogin("");
+#endif
}
+ if (debug && uid == 0)
+ options |= SO_DEBUG;
if (uid == 0) {
gid_t gid = getgid();
@@ -420,6 +425,15 @@ main(int argc, char *argv[])
sa.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sa, &sapipe);
if (pledge("stdio rpath cpath getpw dns inet unix proc exec id", NULL) == -1)
@@ -384,6 +394,15 @@ main(int argc, char *argv[])
signal(SIGPIPE, SIG_IGN);
+ /* space for daemons to overwrite environment for ps */
+ {
......@@ -144,10 +133,10 @@
+ setenv("inetd_dummy", dummy, 1);
+ }
+
for (;;) {
int n, ctrl = -1;
event_dispatch();
@@ -576,9 +590,6 @@ dg_badinput(struct sockaddr *sa)
return (0);
@@ -476,9 +495,6 @@ dg_badinput(struct sockaddr *sa)
goto bad;
}
......@@ -157,7 +146,7 @@
return (0);
bad:
@@ -588,6 +599,7 @@ bad:
@@ -488,6 +504,7 @@ bad:
int
dg_broadcast(struct in_addr *in)
{
......@@ -165,7 +154,7 @@
struct ifaddrs *ifa, *ifap;
struct sockaddr_in *sin;
@@ -604,6 +616,7 @@ dg_broadcast(struct in_addr *in)
@@ -504,6 +521,7 @@ dg_broadcast(struct in_addr *in)
}
}
freeifaddrs(ifap);
......@@ -173,7 +162,7 @@
return (0);
}
@@ -1852,7 +1865,7 @@ print_service(char *action, struct servt
@@ -1690,7 +1708,7 @@ print_service(char *action, struct servt
fprintf(stderr,
" wait.max=%d.%d user:group=%s:%s builtin=%lx server=%s\n",
sep->se_wait, sep->se_max, sep->se_user,
......@@ -182,7 +171,7 @@
(long)sep->se_bi, sep->se_server);
}
@@ -1960,6 +1973,7 @@ spawn(struct servtab *sep, int ctrl)
@@ -1799,6 +1817,7 @@ spawn(int ctrl, short events, void *xsep
if (uid != pwd->pw_uid)
exit(1);
} else {
......@@ -190,7 +179,7 @@
tmpint = LOGIN_SETALL &
~(LOGIN_SETGROUP|LOGIN_SETLOGIN);
if (pwd->pw_uid)
@@ -1975,6 +1989,53 @@ spawn(struct servtab *sep, int ctrl)
@@ -1814,6 +1833,53 @@ spawn(int ctrl, short events, void *xsep
sep->se_service, sep->se_proto);
exit(1);
}
......
......@@ -19,13 +19,12 @@
Internal services cannot be wrapped. When enabled,
--- a/inetd.c
+++ b/inetd.c
@@ -328,11 +328,12 @@ main(int argc, char *argv[], char *envp[
fd_set *fdsrp = NULL;
int readablen = 0, ch;
@@ -311,10 +311,11 @@ main(int argc, char *argv[], char *envp[
{
int ch;
int keepenv = 0;
+ int nodaemon = 0;
struct servtab *sep;
initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dElR:")) != -1)
......@@ -33,7 +32,7 @@
switch (ch) {
case 'd':
debug = 1;
@@ -340,6 +341,9 @@ main(int argc, char *argv[], char *envp[
@@ -322,6 +323,9 @@ main(int argc, char *argv[], char *envp[
case 'E':
keepenv = 1;
break;
......@@ -43,7 +42,7 @@
case 'l':
#ifdef LIBWRAP
lflag = 1;
@@ -366,7 +370,7 @@ main(int argc, char *argv[], char *envp[
@@ -348,7 +352,7 @@ main(int argc, char *argv[], char *envp[
case '?':
default:
fprintf(stderr,
......@@ -52,7 +51,7 @@
exit(1);
}
argc -= optind;
@@ -392,7 +396,11 @@ main(int argc, char *argv[], char *envp[
@@ -374,7 +378,11 @@ main(int argc, char *argv[], char *envp[
umask(022);
if (debug == 0) {
......
--- a/inetd.c
+++ b/inetd.c
@@ -1944,8 +1944,9 @@ spawn(struct servtab *sep, int ctrl)
@@ -1793,8 +1793,9 @@ spawn(int ctrl, short events, void *xsep
return;
}
syslog(LOG_ERR,
......
--- a/inetd.c
+++ b/inetd.c
@@ -317,12 +317,14 @@ fd_grow(fd_set **fdsp, int *bytes, int f
struct sigaction sa, sapipe;
@@ -301,10 +301,12 @@ void initring(void);
u_int32_t machtime(void);
int
-main(int argc, char *argv[])
+main(int argc, char *argv[], char *envp[])
{
fd_set *fdsrp = NULL;
int readablen = 0, ch;
struct servtab *sep;
int ch;
+ initsetproctitle(argc, argv, envp);
+
while ((ch = getopt(argc, argv, "dR:")) != -1)
......
--- a/inetd.8
+++ b/inetd.8
@@ -405,6 +405,11 @@ and IPv6 traffic will go to server on
@@ -401,6 +401,11 @@ and IPv6 traffic will go to server on
If you have only one server on
.Dq tcp6 ,
only IPv6 traffic will be routed to the server.
......@@ -14,13 +14,13 @@
.Xr fingerd 8 ,
--- a/inetd.c
+++ b/inetd.c
@@ -816,11 +816,15 @@ doconfig(void)
@@ -703,11 +703,15 @@ config(int sig, short event, void *arg)
1, USHRT_MAX, NULL));
if (!port) {
/* XXX */
+ unsigned char *p;
strncpy(protoname, sep->se_proto,
sizeof(protoname));
(void)strlcpy(protoname, sep->se_proto,
sizeof(protoname));
- if (isdigit((unsigned char)
- protoname[strlen(protoname) - 1]))
- protoname[strlen(protoname) - 1] = '\0';
......@@ -33,7 +33,7 @@
sp = getservbyname(sep->se_service,
protoname);
if (sp == 0) {
@@ -1015,6 +1019,16 @@ setup(struct servtab *sep)
@@ -883,6 +887,16 @@ setup(struct servtab *sep)
sep->se_service, sep->se_proto);
return;
}
......@@ -49,4 +49,4 @@
+ }
#define turnon(fd, opt) \
setsockopt(fd, SOL_SOCKET, opt, &on, sizeof (on))
if (strncmp(sep->se_proto, "tcp", 3) == 0 && (options & SO_DEBUG) &&
if (strncmp(sep->se_proto, "tcp", 3) == 0 && debug &&
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment