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

Refresh the patches

parent dde0b09d
--- a/inetd.8 --- a/inetd.8
+++ b/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 .Bd -unfilled -offset indent
service name service name
socket type socket type
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
wait/nowait[.max] wait/nowait[.max]
user[.group] or user[:group] user[.group] or user[:group]
server program 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 .Bd -unfilled -offset indent
service name/version service name/version
socket type socket type
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
wait/nowait[.max] wait/nowait[.max]
user[.group] or user[:group] user[.group] or user[:group]
server program server program
@@ -234,6 +234,30 @@ of @@ -235,6 +235,30 @@ of
is used to specify a socket in the is used to specify a socket in the
.Ux Ns -domain . .Ux Ns -domain .
.Pp .Pp
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
int se_rpcprog; /* rpc program number */ int se_rpcprog; /* rpc program number */
int se_rpcversl; /* rpc program lowest version */ int se_rpcversl; /* rpc program lowest version */
int se_rpcversh; /* rpc program highest version */ int se_rpcversh; /* rpc program highest version */
@@ -1240,6 +1242,8 @@ getconfigent(void) @@ -1115,6 +1117,8 @@ getconfigent(void)
{ {
struct servtab *sep, *tsep; struct servtab *sep, *tsep;
char *arg, *cp, *hostdelim, *s; char *arg, *cp, *hostdelim, *s;
...@@ -68,8 +68,8 @@ ...@@ -68,8 +68,8 @@
+ int val; + int val;
int argc; int argc;
sep = (struct servtab *) malloc(sizeof(struct servtab)); sep = calloc(1, sizeof(struct servtab));
@@ -1315,6 +1319,93 @@ more: @@ -1188,6 +1192,93 @@ more:
sep->se_proto = newstr(arg); sep->se_proto = newstr(arg);
......
--- a/inetd.c --- a/inetd.c
+++ b/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 *); struct servtab *enter(struct servtab *);
int matchconf(struct servtab *, struct servtab *); int matchconf(struct servtab *, struct servtab *);
int dg_broadcast(struct in_addr *in); int dg_broadcast(struct in_addr *in);
...@@ -8,13 +8,12 @@ ...@@ -8,13 +8,12 @@
#define NUMINT (sizeof(intab) / sizeof(struct inent)) #define NUMINT (sizeof(intab) / sizeof(struct inent))
char *CONFIG = _PATH_INETDCONF; 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 ch;
int readablen = 0, ch;
+ int keepenv = 0; + int keepenv = 0;
struct servtab *sep;
initsetproctitle(argc, argv, envp); initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dR:")) != -1) - while ((ch = getopt(argc, argv, "dR:")) != -1)
...@@ -29,7 +28,7 @@ ...@@ -29,7 +28,7 @@
case 'R': { /* invocation rate */ case 'R': { /* invocation rate */
char *p; char *p;
int val; 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 '?': case '?':
default: default:
fprintf(stderr, fprintf(stderr,
...@@ -47,7 +46,7 @@ ...@@ -47,7 +46,7 @@
uid = getuid(); uid = getuid();
if (uid != 0) if (uid != 0)
CONFIG = NULL; 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) if (!sep->se_wait && sep->se_socktype == SOCK_STREAM)
close(ctrl); close(ctrl);
} }
......
--- a/inetd.c --- a/inetd.c
+++ b/inetd.c +++ b/inetd.c
@@ -170,6 +170,7 @@ int lflag = 0; @@ -175,6 +175,7 @@ int lflag = 0;
#endif #endif
int debug = 0; int debug = 0;
+int global_queuelen = 128; +int global_queuelen = 128;
int nsock, maxsock; int maxsock;
fd_set *allsockp; int toomany = TOOMANY;
int allsockn; int timingout;
@@ -338,7 +339,7 @@ main(int argc, char *argv[], char *envp[ @@ -315,7 +316,7 @@ main(int argc, char *argv[], char *envp[
initsetproctitle(argc, argv, envp); initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dEilR:")) != -1) - while ((ch = getopt(argc, argv, "dEilR:")) != -1)
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
switch (ch) { switch (ch) {
case 'd': case 'd':
debug = 1; 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); progname);
exit(1); exit(1);
#endif #endif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
case 'R': { /* invocation rate */ case 'R': { /* invocation rate */
char *p; char *p;
int val; 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 '?': case '?':
default: default:
fprintf(stderr, fprintf(stderr,
...@@ -38,15 +38,15 @@ ...@@ -38,15 +38,15 @@
exit(1); exit(1);
} }
argc -= optind; 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; return;
} }
if (sep->se_socktype == SOCK_STREAM) if (sep->se_socktype == SOCK_STREAM)
- listen(sep->se_fd, 10); - listen(sep->se_fd, 10);
+ listen(sep->se_fd, global_queuelen); + listen(sep->se_fd, global_queuelen);
fd_grow(&allsockp, &allsockn, sep->se_fd); if (!sep->se_wait && sep->se_socktype == SOCK_STREAM) {
FD_SET(sep->se_fd, allsockp); event_set(&sep->se_event, sep->se_fd, EV_READ|EV_PERSIST,
--- a/inetd.8 --- a/inetd.8
+++ b/inetd.8 +++ b/inetd.8
@@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
.Op Fl R Ar rate .Op Fl R Ar rate
.Op Ar configuration_file .Op Ar configuration_file
.Sh DESCRIPTION .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 is silently not executed even if present in
.Pa /etc/inetd.conf .Pa /etc/inetd.conf
and instead libwrap is called directly by inetd. and instead libwrap is called directly by inetd.
......
--- a/inetd.c --- a/inetd.c
+++ b/inetd.c +++ b/inetd.c
@@ -161,6 +161,11 @@ @@ -169,6 +169,11 @@
#define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */
#define RETRYTIME (60*10) /* retry after bind or server fail */ #define RETRYTIME (60*10) /* retry after bind or server fail */
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
+#endif +#endif
+ +
int debug = 0; int debug = 0;
int nsock, maxsock; int maxsock;
fd_set *allsockp; int toomany = TOOMANY;
@@ -327,7 +332,7 @@ main(int argc, char *argv[], char *envp[ @@ -309,7 +314,7 @@ main(int argc, char *argv[], char *envp[
initsetproctitle(argc, argv, envp); initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dER:")) != -1) - while ((ch = getopt(argc, argv, "dER:")) != -1)
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
switch (ch) { switch (ch) {
case 'd': case 'd':
debug = 1; 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': case 'E':
keepenv = 1; keepenv = 1;
break; break;
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
case 'R': { /* invocation rate */ case 'R': { /* invocation rate */
char *p; char *p;
int val; 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 '?': case '?':
default: default:
fprintf(stderr, fprintf(stderr,
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
exit(1); exit(1);
} }
argc -= optind; 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) { if (pid == 0) {
+#ifdef LIBWRAP +#ifdef LIBWRAP
+ if (lflag && !sep->se_wait && !sep->se_bi && sep->se_socktype == SOCK_STREAM) { + if (lflag && !sep->se_wait && !sep->se_bi && sep->se_socktype == SOCK_STREAM) {
...@@ -118,10 +118,10 @@ ...@@ -118,10 +118,10 @@
.It Fl R Ar rate .It Fl R Ar rate
Specify 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. in one minute; the default is 256.
@@ -349,6 +357,23 @@ is reread. @@ -336,6 +344,23 @@ rereads its configuration file when it r
creates a file .Dv SIGHUP .
.Em /var/run/inetd.pid Services may be added, deleted or modified when the configuration file
that contains its process identifier. is reread.
+.Ss libwrap +.Ss libwrap
+Support for +Support for
+.Tn TCP +.Tn TCP
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
Examples might be Examples might be
.Dq tcp .Dq tcp
or 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. only IPv6 traffic will be routed to the server.
.El .El
.Sh SEE ALSO .Sh SEE ALSO
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
.Xr ftpd 8 , .Xr ftpd 8 ,
.Xr identd 8 , .Xr identd 8 ,
.Xr talkd 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 based services is modelled after that
provided by SunOS 4.1. provided by SunOS 4.1.
IPv6 support was added by the KAME project in 1999. IPv6 support was added by the KAME project in 1999.
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
This is largely because the This is largely because the
--- a/inetd.c --- a/inetd.c
+++ b/inetd.c +++ b/inetd.c
@@ -128,6 +128,7 @@ @@ -127,6 +127,7 @@
#include <sys/un.h> #include <sys/un.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/wait.h> #include <sys/wait.h>
...@@ -86,9 +86,9 @@ ...@@ -86,9 +86,9 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
@@ -146,11 +147,14 @@ @@ -147,14 +148,21 @@
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <limits.h>
#include <string.h> #include <string.h>
+#ifdef HAVE_SETUSERCONTEXT +#ifdef HAVE_SETUSERCONTEXT
#include <login_cap.h> #include <login_cap.h>
...@@ -99,25 +99,17 @@ ...@@ -99,25 +99,17 @@
#include <rpc/rpc.h> #include <rpc/rpc.h>
#include <rpc/pmap_clnt.h> #include <rpc/pmap_clnt.h>
-#include <rpcsvc/nfs_prot.h> -#include <rpcsvc/nfs_prot.h>
#include <event.h>
#include "pathnames.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 */ #define TOOMANY 256 /* don't start more than TOOMANY */
@@ -324,14 +328,11 @@ main(int argc, char *argv[]) @@ -342,8 +350,10 @@ 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[])
umask(022); umask(022);
if (debug == 0) { if (debug == 0) {
daemon(0, 0); daemon(0, 0);
...@@ -126,14 +118,11 @@ ...@@ -126,14 +118,11 @@
(void) setlogin(""); (void) setlogin("");
+#endif +#endif
} }
+ if (debug && uid == 0)
+ options |= SO_DEBUG;
if (uid == 0) { if (pledge("stdio rpath cpath getpw dns inet unix proc exec id", NULL) == -1)
gid_t gid = getgid(); @@ -384,6 +394,15 @@ main(int argc, char *argv[])
@@ -420,6 +425,15 @@ main(int argc, char *argv[])
sa.sa_handler = SIG_IGN; signal(SIGPIPE, SIG_IGN);
sigaction(SIGPIPE, &sa, &sapipe);
+ /* space for daemons to overwrite environment for ps */ + /* space for daemons to overwrite environment for ps */
+ { + {
...@@ -144,10 +133,10 @@ ...@@ -144,10 +133,10 @@
+ setenv("inetd_dummy", dummy, 1); + setenv("inetd_dummy", dummy, 1);
+ } + }
+ +
for (;;) { event_dispatch();
int n, ctrl = -1;
@@ -576,9 +590,6 @@ dg_badinput(struct sockaddr *sa) return (0);
@@ -476,9 +495,6 @@ dg_badinput(struct sockaddr *sa)
goto bad; goto bad;
} }
...@@ -157,7 +146,7 @@ ...@@ -157,7 +146,7 @@
return (0); return (0);
bad: bad:
@@ -588,6 +599,7 @@ bad: @@ -488,6 +504,7 @@ bad:
int int
dg_broadcast(struct in_addr *in) dg_broadcast(struct in_addr *in)
{ {
...@@ -165,7 +154,7 @@ ...@@ -165,7 +154,7 @@
struct ifaddrs *ifa, *ifap; struct ifaddrs *ifa, *ifap;
struct sockaddr_in *sin; 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); freeifaddrs(ifap);
...@@ -173,7 +162,7 @@ ...@@ -173,7 +162,7 @@
return (0); return (0);
} }
@@ -1852,7 +1865,7 @@ print_service(char *action, struct servt @@ -1690,7 +1708,7 @@ print_service(char *action, struct servt
fprintf(stderr, fprintf(stderr,
" wait.max=%d.%d user:group=%s:%s builtin=%lx server=%s\n", " wait.max=%d.%d user:group=%s:%s builtin=%lx server=%s\n",
sep->se_wait, sep->se_max, sep->se_user, sep->se_wait, sep->se_max, sep->se_user,
...@@ -182,7 +171,7 @@ ...@@ -182,7 +171,7 @@
(long)sep->se_bi, sep->se_server); (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) if (uid != pwd->pw_uid)
exit(1); exit(1);
} else { } else {
...@@ -190,7 +179,7 @@ ...@@ -190,7 +179,7 @@
tmpint = LOGIN_SETALL & tmpint = LOGIN_SETALL &
~(LOGIN_SETGROUP|LOGIN_SETLOGIN); ~(LOGIN_SETGROUP|LOGIN_SETLOGIN);
if (pwd->pw_uid) 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); sep->se_service, sep->se_proto);
exit(1); exit(1);
} }
......
...@@ -19,13 +19,12 @@ ...@@ -19,13 +19,12 @@
Internal services cannot be wrapped. When enabled, Internal services cannot be wrapped. When enabled,
--- a/inetd.c --- a/inetd.c
+++ b/inetd.c +++ b/inetd.c
@@ -328,11 +328,12 @@ main(int argc, char *argv[], char *envp[ @@ -311,10 +311,11 @@ main(int argc, char *argv[], char *envp[
fd_set *fdsrp = NULL; {
int readablen = 0, ch; int ch;
int keepenv = 0; int keepenv = 0;
+ int nodaemon = 0; + int nodaemon = 0;
struct servtab *sep;
initsetproctitle(argc, argv, envp); initsetproctitle(argc, argv, envp);
- while ((ch = getopt(argc, argv, "dElR:")) != -1) - while ((ch = getopt(argc, argv, "dElR:")) != -1)
...@@ -33,7 +32,7 @@ ...@@ -33,7 +32,7 @@
switch (ch) { switch (ch) {
case 'd': case 'd':
debug = 1; 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': case 'E':
keepenv = 1; keepenv = 1;
break; break;
...@@ -43,7 +42,7 @@ ...@@ -43,7 +42,7 @@
case 'l': case 'l':
#ifdef LIBWRAP #ifdef LIBWRAP
lflag = 1; 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 '?': case '?':
default: default:
fprintf(stderr, fprintf(stderr,
...@@ -52,7 +51,7 @@ ...@@ -52,7 +51,7 @@
exit(1); exit(1);
} }
argc -= optind; 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); umask(022);
if (debug == 0) { if (debug == 0) {
......
--- a/inetd.c --- a/inetd.c
+++ b/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; return;
} }
syslog(LOG_ERR, syslog(LOG_ERR,
......
--- a/inetd.c --- a/inetd.c
+++ b/inetd.c +++ b/inetd.c
@@ -317,12 +317,14 @@ fd_grow(fd_set **fdsp, int *bytes, int f @@ -301,10 +301,12 @@ void initring(void);
struct sigaction sa, sapipe; u_int32_t machtime(void);
int int
-main(int argc, char *argv[]) -main(int argc, char *argv[])
+main(int argc, char *argv[], char *envp[]) +main(int argc, char *argv[], char *envp[])
{ {
fd_set *fdsrp = NULL; int ch;
int readablen = 0, ch;
struct servtab *sep;
+ initsetproctitle(argc, argv, envp); + initsetproctitle(argc, argv, envp);
+ +
while ((ch = getopt(argc, argv, "dR:")) != -1) while ((ch = getopt(argc, argv, "dR:")) != -1)
......
--- a/inetd.8 --- a/inetd.8
+++ b/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 If you have only one server on
.Dq tcp6 , .Dq tcp6 ,
only IPv6 traffic will be routed to the server. only IPv6 traffic will be routed to the server.
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
.Xr fingerd 8 , .Xr fingerd 8 ,
--- a/inetd.c --- a/inetd.c
+++ b/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) { if (!port) {
/* XXX */
+ unsigned char *p; + unsigned char *p;
strncpy(protoname, sep->se_proto, (void)strlcpy(protoname, sep->se_proto,
sizeof(protoname)); sizeof(protoname));
- if (isdigit((unsigned char) - if (isdigit((unsigned char)
- protoname[strlen(protoname) - 1])) - protoname[strlen(protoname) - 1]))
- protoname[strlen(protoname) - 1] = '\0'; - protoname[strlen(protoname) - 1] = '\0';
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
sp = getservbyname(sep->se_service, sp = getservbyname(sep->se_service,
protoname); protoname);
if (sp == 0) { 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); sep->se_service, sep->se_proto);
return; return;
} }
...@@ -49,4 +49,4 @@ ...@@ -49,4 +49,4 @@
+ } + }
#define turnon(fd, opt) \ #define turnon(fd, opt) \
setsockopt(fd, SOL_SOCKET, opt, &on, sizeof (on)) 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