[Midnightbsd-cvs] src [10741] trunk/usr.sbin/inetd: sync with freebsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jun 9 18:10:16 EDT 2018
Revision: 10741
http://svnweb.midnightbsd.org/src/?rev=10741
Author: laffer1
Date: 2018-06-09 18:10:16 -0400 (Sat, 09 Jun 2018)
Log Message:
-----------
sync with freebsd
Modified Paths:
--------------
trunk/usr.sbin/inetd/Makefile
trunk/usr.sbin/inetd/builtins.c
trunk/usr.sbin/inetd/inetd.8
trunk/usr.sbin/inetd/inetd.c
trunk/usr.sbin/inetd/inetd.h
trunk/usr.sbin/inetd/pathnames.h
Property Changed:
----------------
trunk/usr.sbin/inetd/inetd.8
Modified: trunk/usr.sbin/inetd/Makefile
===================================================================
--- trunk/usr.sbin/inetd/Makefile 2018-06-09 22:09:38 UTC (rev 10740)
+++ trunk/usr.sbin/inetd/Makefile 2018-06-09 22:10:16 UTC (rev 10741)
@@ -1,5 +1,6 @@
+# $MidnightBSD$
# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD: src/usr.sbin/inetd/Makefile,v 1.37 2007/07/05 08:56:46 bz Exp $
+# $FreeBSD: stable/10/usr.sbin/inetd/Makefile 313206 2017-02-04 15:52:08Z ngie $
.include <bsd.own.mk>
@@ -8,7 +9,7 @@
MLINKS= inetd.8 inetd.conf.5
SRCS= inetd.c builtins.c
-WARNS?= 2
+WARNS?= 3
CFLAGS+= -DLOGIN_CAP
#CFLAGS+= -DSANITY_CHECK
@@ -16,9 +17,15 @@
CFLAGS+= -DINET6
.endif
-DPADD= ${LIBUTIL} ${LIBWRAP}
-LDADD= -lutil -lwrap
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
+.if ${MK_TCP_WRAPPERS} != "no"
+CFLAGS+= -DLIBWRAP
+DPADD+= ${LIBWRAP}
+LDADD+= -lwrap
+.endif
+
# XXX for src/release/picobsd
.if !defined(RELEASE_CRUNCH)
CFLAGS+= -DIPSEC
Modified: trunk/usr.sbin/inetd/builtins.c
===================================================================
--- trunk/usr.sbin/inetd/builtins.c 2018-06-09 22:09:38 UTC (rev 10740)
+++ trunk/usr.sbin/inetd/builtins.c 2018-06-09 22:10:16 UTC (rev 10741)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1983, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/inetd/builtins.c,v 1.45 2006/04/17 19:55:25 dwmalone Exp $");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/inetd/builtins.c 326761 2017-12-11 05:10:11Z delphij $");
#include <sys/filio.h>
#include <sys/ioccom.h>
@@ -167,10 +168,8 @@
inetd_setproctitle(sep->se_service, s);
- if (!endring) {
+ if (!endring)
initring();
- rs = ring;
- }
text[LINESIZ] = '\r';
text[LINESIZ + 1] = '\n';
@@ -691,15 +690,9 @@
uint32_t
machtime(void)
{
- struct timeval tv;
- if (gettimeofday(&tv, (struct timezone *)NULL) < 0) {
- if (debug)
- warnx("unable to get time of day");
- return (0L);
- }
#define OFFSET ((uint32_t)25567 * 24*60*60)
- return (htonl((uint32_t)(tv.tv_sec + OFFSET)));
+ return (htonl((uint32_t)(time(NULL) + OFFSET)));
#undef OFFSET
}
@@ -745,7 +738,7 @@
#define MAX_SERV_LEN (256+2) /* 2 bytes for \r\n */
#define strwrite(fd, buf) (void) write(fd, buf, sizeof(buf)-1)
-static int /* # of characters upto \r,\n or \0 */
+static int /* # of characters up to \r,\n or \0 */
getline(int fd, char *buf, int len)
{
int count = 0, n;
Modified: trunk/usr.sbin/inetd/inetd.8
===================================================================
--- trunk/usr.sbin/inetd/inetd.8 2018-06-09 22:09:38 UTC (rev 10740)
+++ trunk/usr.sbin/inetd/inetd.8 2018-06-09 22:10:16 UTC (rev 10741)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1985, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)inetd.8 8.3 (Berkeley) 4/13/94
-.\" $FreeBSD: src/usr.sbin/inetd/inetd.8,v 1.84 2006/09/14 08:36:53 ru Exp $
+.\" $FreeBSD: stable/10/usr.sbin/inetd/inetd.8 175254 2008-01-12 21:09:48Z maxim $
.\"
-.Dd September 14, 2006
+.Dd January 12, 2008
.Dt INETD 8
.Os
.Sh NAME
@@ -177,6 +178,7 @@
service-name/version
socket-type
rpc/protocol
+{wait|nowait}[/max-child[/max-connections-per-ip-per-minute[/max-child-per-ip]]]
user[:group][/login-class]
server-program
server-program-arguments
Property changes on: trunk/usr.sbin/inetd/inetd.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/inetd/inetd.c
===================================================================
--- trunk/usr.sbin/inetd/inetd.c 2018-06-09 22:09:38 UTC (rev 10740)
+++ trunk/usr.sbin/inetd/inetd.c 2018-06-09 22:10:16 UTC (rev 10741)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -40,7 +41,7 @@
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.sbin/inetd/inetd.c,v 1.136 2007/07/01 12:08:08 gnn Exp $");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/inetd/inetd.c 313206 2017-02-04 15:52:08Z ngie $");
/*
* Inetd - Internet super-server
@@ -71,7 +72,7 @@
* socket type stream/dgram/raw/rdm/seqpacket
* protocol tcp[4][6][/faith], udp[4][6], unix
* wait/nowait single-threaded/multi-threaded
- * user user to run daemon as
+ * user[:group][/login-class] user/group/login-class to run daemon as
* server program full path name
* server program arguments maximum of MAXARGS (20)
*
@@ -95,7 +96,7 @@
* socket type stream/dgram/raw/rdm/seqpacket
* protocol rpc/tcp[4][6], rpc/udp[4][6]
* wait/nowait single-threaded/multi-threaded
- * user user to run daemon as
+ * user[:group][/login-class] user/group/login-class to run daemon as
* server program full path name
* server program arguments maximum of MAXARGS
*
@@ -110,6 +111,7 @@
*/
#include <sys/param.h>
#include <sys/ioctl.h>
+#include <sys/mman.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -137,7 +139,9 @@
#include <string.h>
#include <sysexits.h>
#include <syslog.h>
+#ifdef LIBWRAP
#include <tcpd.h>
+#endif
#include <unistd.h>
#include "inetd.h"
@@ -296,6 +300,7 @@
return 0; /* success */
}
+#ifdef LIBWRAP
static sa_family_t
whichaf(struct request_info *req)
{
@@ -309,6 +314,7 @@
return AF_INET;
return sa->sa_family;
}
+#endif
int
main(int argc, char **argv)
@@ -323,19 +329,12 @@
#ifdef LOGIN_CAP
login_cap_t *lc = NULL;
#endif
+#ifdef LIBWRAP
struct request_info req;
int denied;
char *service = NULL;
- union {
- struct sockaddr peer_un;
- struct sockaddr_in peer_un4;
- struct sockaddr_in6 peer_un6;
- struct sockaddr_storage peer_max;
- } p_un;
-#define peer p_un.peer_un
-#define peer4 p_un.peer_un4
-#define peer6 p_un.peer_un6
-#define peermax p_un.peer_max
+#endif
+ struct sockaddr_storage peer;
int i;
struct addrinfo hints, *res;
const char *servname;
@@ -497,6 +496,9 @@
}
}
+ if (madvise(NULL, 0, MADV_PROTECT) != 0)
+ syslog(LOG_WARNING, "madvise() failed: %s", strerror(errno));
+
for (i = 0; i < PERIPSIZE; ++i)
LIST_INIT(&proctable[i]);
@@ -544,15 +546,10 @@
(void)setenv("inetd_dummy", dummy, 1);
}
- if (pipe(signalpipe) != 0) {
+ if (pipe2(signalpipe, O_CLOEXEC) != 0) {
syslog(LOG_ERR, "pipe: %m");
exit(EX_OSERR);
}
- if (fcntl(signalpipe[0], F_SETFD, FD_CLOEXEC) < 0 ||
- fcntl(signalpipe[1], F_SETFD, FD_CLOEXEC) < 0) {
- syslog(LOG_ERR, "signalpipe: fcntl (F_SETFD, FD_CLOEXEC): %m");
- exit(EX_OSERR);
- }
FD_SET(signalpipe[0], &allsock);
#ifdef SANITY_CHECK
nsock++;
@@ -652,24 +649,24 @@
} else
ctrl = sep->se_fd;
if (dolog && !ISWRAP(sep)) {
- char pname[INET6_ADDRSTRLEN] = "unknown";
+ char pname[NI_MAXHOST] = "unknown";
socklen_t sl;
- sl = sizeof peermax;
+ sl = sizeof(peer);
if (getpeername(ctrl, (struct sockaddr *)
- &peermax, &sl)) {
- sl = sizeof peermax;
+ &peer, &sl)) {
+ sl = sizeof(peer);
if (recvfrom(ctrl, buf, sizeof(buf),
MSG_PEEK,
- (struct sockaddr *)&peermax,
+ (struct sockaddr *)&peer,
&sl) >= 0) {
- getnameinfo((struct sockaddr *)&peermax,
- peer.sa_len,
+ getnameinfo((struct sockaddr *)&peer,
+ peer.ss_len,
pname, sizeof(pname),
NULL, 0, NI_NUMERICHOST);
}
} else {
- getnameinfo((struct sockaddr *)&peermax,
- peer.sa_len,
+ getnameinfo((struct sockaddr *)&peer,
+ peer.ss_len,
pname, sizeof(pname),
NULL, 0, NI_NUMERICHOST);
}
@@ -684,11 +681,11 @@
*/
if (dofork) {
if (sep->se_count++ == 0)
- (void)gettimeofday(&sep->se_time, (struct timezone *)NULL);
+ (void)clock_gettime(CLOCK_MONOTONIC_FAST, &sep->se_time);
else if (toomany > 0 && sep->se_count >= toomany) {
- struct timeval now;
+ struct timespec now;
- (void)gettimeofday(&now, (struct timezone *)NULL);
+ (void)clock_gettime(CLOCK_MONOTONIC_FAST, &now);
if (now.tv_sec - sep->se_time.tv_sec >
CNT_INTVL) {
sep->se_time = now;
@@ -746,6 +743,7 @@
_exit(0);
}
}
+#ifdef LIBWRAP
if (ISWRAP(sep)) {
inetd_setproctitle("wrapping", ctrl);
service = sep->se_server_name ?
@@ -774,6 +772,7 @@
(whichaf(&req) == AF_INET6) ? "6" : "");
}
}
+#endif
if (sep->se_bi) {
(*sep->se_bi->bi_fn)(ctrl, sep);
} else {
@@ -1261,7 +1260,9 @@
{
int on = 1;
- if ((sep->se_fd = socket(sep->se_family, sep->se_socktype, 0)) < 0) {
+ /* Set all listening sockets to close-on-exec. */
+ if ((sep->se_fd = socket(sep->se_family,
+ sep->se_socktype | SOCK_CLOEXEC, 0)) < 0) {
if (debug)
warn("socket failed on %s/%s",
sep->se_service, sep->se_proto);
@@ -1269,13 +1270,6 @@
sep->se_service, sep->se_proto);
return;
}
- /* Set all listening sockets to close-on-exec. */
- if (fcntl(sep->se_fd, F_SETFD, FD_CLOEXEC) < 0) {
- syslog(LOG_ERR, "%s/%s: fcntl (F_SETFD, FD_CLOEXEC): %m",
- sep->se_service, sep->se_proto);
- close(sep->se_fd);
- return;
- }
#define turnon(fd, opt) \
setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
if (strcmp(sep->se_proto, "tcp") == 0 && (options & SO_DEBUG) &&
@@ -1393,8 +1387,7 @@
#ifdef IPSEC
void
-ipsecsetup(sep)
- struct servtab *sep;
+ipsecsetup(struct servtab *sep)
{
char *buf;
char *policy_in = NULL;
@@ -1758,10 +1751,8 @@
strlen(sep->se_proto) + 1 - 4);
sep->se_rpc = 1;
sep->se_rpc_prog = sep->se_rpc_lowvers =
- sep->se_rpc_lowvers = 0;
- memcpy(&sep->se_ctrladdr4, bind_sa4,
- sizeof(sep->se_ctrladdr4));
- if ((versp = rindex(sep->se_service, '/'))) {
+ sep->se_rpc_highvers = 0;
+ if ((versp = strrchr(sep->se_service, '/'))) {
*versp++ = '\0';
switch (sscanf(versp, "%u-%u",
&sep->se_rpc_lowvers,
@@ -1933,7 +1924,7 @@
} else
sep->se_group = NULL;
sep->se_server = newstr(sskip(&cp));
- if ((sep->se_server_name = rindex(sep->se_server, '/')))
+ if ((sep->se_server_name = strrchr(sep->se_server, '/')))
sep->se_server_name++;
if (strcmp(sep->se_server, "internal") == 0) {
struct biltin *bi;
@@ -2105,7 +2096,7 @@
{
socklen_t size;
struct sockaddr_storage ss;
- char buf[80], pbuf[INET6_ADDRSTRLEN];
+ char buf[80], pbuf[NI_MAXHOST];
size = sizeof(ss);
if (getpeername(s, (struct sockaddr *)&ss, &size) == 0) {
@@ -2121,7 +2112,7 @@
check_loop(const struct sockaddr *sa, const struct servtab *sep)
{
struct servtab *se2;
- char pname[INET6_ADDRSTRLEN];
+ char pname[NI_MAXHOST];
for (se2 = servtab; se2; se2 = se2->se_next) {
if (!se2->se_bi || se2->se_socktype != SOCK_DGRAM)
@@ -2135,8 +2126,8 @@
continue;
#ifdef INET6
case AF_INET6:
- if (((const struct sockaddr_in *)sa)->sin_port ==
- se2->se_ctrladdr4.sin_port)
+ if (((const struct sockaddr_in6 *)sa)->sin6_port ==
+ se2->se_ctrladdr6.sin6_port)
goto isloop;
continue;
#endif
@@ -2335,7 +2326,7 @@
}
}
if ((cnt * 60) / (CHTSIZE * CHTGRAN) > sep->se_maxcpm) {
- char pname[INET6_ADDRSTRLEN];
+ char pname[NI_MAXHOST];
getnameinfo((struct sockaddr *)&rss,
((struct sockaddr *)&rss)->sa_len,
Modified: trunk/usr.sbin/inetd/inetd.h
===================================================================
--- trunk/usr.sbin/inetd/inetd.h 2018-06-09 22:09:38 UTC (rev 10740)
+++ trunk/usr.sbin/inetd/inetd.h 2018-06-09 22:10:16 UTC (rev 10741)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/usr.sbin/inetd/inetd.h,v 1.17 2006/09/14 08:36:53 ru Exp $
+ * $FreeBSD: stable/10/usr.sbin/inetd/inetd.h 236572 2012-06-04 18:02:09Z delphij $
*/
#include <sys/time.h>
@@ -109,7 +110,7 @@
u_int se_rpc_lowvers; /* RPC low version */
u_int se_rpc_highvers; /* RPC high version */
int se_count; /* number started since se_time */
- struct timeval se_time; /* start of se_count */
+ struct timespec se_time; /* start of se_count */
struct servtab *se_next;
struct se_flags {
u_int se_nomapped : 1;
Modified: trunk/usr.sbin/inetd/pathnames.h
===================================================================
--- trunk/usr.sbin/inetd/pathnames.h 2018-06-09 22:09:38 UTC (rev 10740)
+++ trunk/usr.sbin/inetd/pathnames.h 2018-06-09 22:10:16 UTC (rev 10741)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
More information about the Midnightbsd-cvs
mailing list