PR bin/56963 Mark Davies: inetd not configured for rpc Instead of using negative flags to turn on positive flags, set -DRPC in the makefile. Corrects a problem where the SunRPC code in parse.c was accidentally left disabled. This is a prime example of why we don't like negative flags...diff -r1.30 -r1.31 src/usr.sbin/inetd/Makefile
(dholland)
--- src/usr.sbin/inetd/Makefile 2021/10/12 19:08:04 1.30
+++ src/usr.sbin/inetd/Makefile 2022/08/10 03:35:38 1.31
@@ -1,30 +1,33 @@ | @@ -1,30 +1,33 @@ | |||
1 | # from: @(#)Makefile 8.1 (Berkeley) 6/6/93 | 1 | # from: @(#)Makefile 8.1 (Berkeley) 6/6/93 | |
2 | # $NetBSD: Makefile,v 1.30 2021/10/12 19:08:04 christos Exp $ | 2 | # $NetBSD: Makefile,v 1.31 2022/08/10 03:35:38 dholland Exp $ | |
3 | 3 | |||
4 | .include <bsd.own.mk> | 4 | .include <bsd.own.mk> | |
5 | 5 | |||
6 | USE_FORT?= yes # network server | 6 | USE_FORT?= yes # network server | |
7 | 7 | |||
8 | PROG= inetd | 8 | PROG= inetd | |
9 | SRCS= inetd.c parse.c parse_v2.c ratelimit.c | 9 | SRCS= inetd.c parse.c parse_v2.c ratelimit.c | |
10 | MAN= inetd.8 | 10 | MAN= inetd.8 | |
11 | MLINKS= inetd.8 inetd.conf.5 | 11 | MLINKS= inetd.8 inetd.conf.5 | |
12 | WARNS= 6 | 12 | WARNS= 6 | |
13 | #LINTFLAGS+= -T | 13 | #LINTFLAGS+= -T | |
14 | 14 | |||
15 | # Enables debug printouts when in debug mode | 15 | # Enables debug printouts when in debug mode | |
16 | CPPFLAGS+=-DDEBUG_ENABLE | 16 | CPPFLAGS+=-DDEBUG_ENABLE | |
17 | 17 | |||
18 | # Enables SunRPC support | |||
19 | CPPFLAGS+=-DRPC | |||
20 | ||||
18 | CPPFLAGS+=-DLIBWRAP | 21 | CPPFLAGS+=-DLIBWRAP | |
19 | # Use LIBWRAP_INTERNAL for libwrap checking of inetd's `internal' services. | 22 | # Use LIBWRAP_INTERNAL for libwrap checking of inetd's `internal' services. | |
20 | #CPPFLAGS+=-DLIBWRAP_INTERNAL | 23 | #CPPFLAGS+=-DLIBWRAP_INTERNAL | |
21 | LDADD+= -lwrap -lblocklist -lutil | 24 | LDADD+= -lwrap -lblocklist -lutil | |
22 | DPADD+= ${LIBWRAP} ${LIBBLOCKLIST} ${LIBUTIL} | 25 | DPADD+= ${LIBWRAP} ${LIBBLOCKLIST} ${LIBUTIL} | |
23 | 26 | |||
24 | .if (${USE_INET6} != "no") | 27 | .if (${USE_INET6} != "no") | |
25 | CPPFLAGS+=-DINET6 | 28 | CPPFLAGS+=-DINET6 | |
26 | .endif | 29 | .endif | |
27 | 30 | |||
28 | CPPFLAGS+=-DIPSEC | 31 | CPPFLAGS+=-DIPSEC | |
29 | SRCS+= ipsec.c | 32 | SRCS+= ipsec.c | |
30 | LDADD+= -lipsec | 33 | LDADD+= -lipsec |
--- src/usr.sbin/inetd/inetd.c 2021/10/17 04:14:49 1.139
+++ src/usr.sbin/inetd/inetd.c 2022/08/10 03:35:38 1.140
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: inetd.c,v 1.139 2021/10/17 04:14:49 ryo Exp $ */ | 1 | /* $NetBSD: inetd.c,v 1.140 2022/08/10 03:35:38 dholland Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center and by Matthias Scheler. | 9 | * NASA Ames Research Center and by Matthias Scheler. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -56,27 +56,27 @@ | @@ -56,27 +56,27 @@ | |||
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
59 | * SUCH DAMAGE. | 59 | * SUCH DAMAGE. | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | #include <sys/cdefs.h> | 62 | #include <sys/cdefs.h> | |
63 | #ifndef lint | 63 | #ifndef lint | |
64 | __COPYRIGHT("@(#) Copyright (c) 1983, 1991, 1993, 1994\ | 64 | __COPYRIGHT("@(#) Copyright (c) 1983, 1991, 1993, 1994\ | |
65 | The Regents of the University of California. All rights reserved."); | 65 | The Regents of the University of California. All rights reserved."); | |
66 | #if 0 | 66 | #if 0 | |
67 | static char sccsid[] = "@(#)inetd.c 8.4 (Berkeley) 4/13/94"; | 67 | static char sccsid[] = "@(#)inetd.c 8.4 (Berkeley) 4/13/94"; | |
68 | #else | 68 | #else | |
69 | __RCSID("$NetBSD: inetd.c,v 1.139 2021/10/17 04:14:49 ryo Exp $"); | 69 | __RCSID("$NetBSD: inetd.c,v 1.140 2022/08/10 03:35:38 dholland Exp $"); | |
70 | #endif | 70 | #endif | |
71 | #endif /* not lint */ | 71 | #endif /* not lint */ | |
72 | 72 | |||
73 | /* | 73 | /* | |
74 | * Inetd - Internet super-server | 74 | * Inetd - Internet super-server | |
75 | * | 75 | * | |
76 | * This program invokes all internet services as needed. Connection-oriented | 76 | * This program invokes all internet services as needed. Connection-oriented | |
77 | * services are invoked each time a connection is made, by creating a process. | 77 | * services are invoked each time a connection is made, by creating a process. | |
78 | * This process is passed the connection as file descriptor 0 and is expected | 78 | * This process is passed the connection as file descriptor 0 and is expected | |
79 | * to do a getpeername to find out the source host and port. | 79 | * to do a getpeername to find out the source host and port. | |
80 | * | 80 | * | |
81 | * Datagram oriented services are invoked when a datagram | 81 | * Datagram oriented services are invoked when a datagram | |
82 | * arrives; a process is created and passed a pending message | 82 | * arrives; a process is created and passed a pending message | |
@@ -183,31 +183,26 @@ __RCSID("$NetBSD: inetd.c,v 1.139 2021/1 | @@ -183,31 +183,26 @@ __RCSID("$NetBSD: inetd.c,v 1.139 2021/1 | |||
183 | * initgroups(name, specified group) | 183 | * initgroups(name, specified group) | |
184 | * | 184 | * | |
185 | */ | 185 | */ | |
186 | 186 | |||
187 | #include <sys/param.h> | 187 | #include <sys/param.h> | |
188 | #include <sys/stat.h> | 188 | #include <sys/stat.h> | |
189 | #include <sys/ioctl.h> | 189 | #include <sys/ioctl.h> | |
190 | #include <sys/wait.h> | 190 | #include <sys/wait.h> | |
191 | #include <sys/resource.h> | 191 | #include <sys/resource.h> | |
192 | #include <sys/event.h> | 192 | #include <sys/event.h> | |
193 | #include <sys/socket.h> | 193 | #include <sys/socket.h> | |
194 | #include <sys/queue.h> | 194 | #include <sys/queue.h> | |
195 | 195 | |||
196 | ||||
197 | #ifndef NO_RPC | |||
198 | #define RPC | |||
199 | #endif | |||
200 | ||||
201 | #include <net/if.h> | 196 | #include <net/if.h> | |
202 | 197 | |||
203 | #ifdef RPC | 198 | #ifdef RPC | |
204 | #include <rpc/rpc.h> | 199 | #include <rpc/rpc.h> | |
205 | #include <rpc/rpcb_clnt.h> | 200 | #include <rpc/rpcb_clnt.h> | |
206 | #include <netconfig.h> | 201 | #include <netconfig.h> | |
207 | #endif | 202 | #endif | |
208 | 203 | |||
209 | #include <ctype.h> | 204 | #include <ctype.h> | |
210 | #include <err.h> | 205 | #include <err.h> | |
211 | #include <errno.h> | 206 | #include <errno.h> | |
212 | #include <fcntl.h> | 207 | #include <fcntl.h> | |
213 | #include <glob.h> | 208 | #include <glob.h> |
--- src/usr.sbin/inetd/parse.c 2022/05/22 11:27:37 1.3
+++ src/usr.sbin/inetd/parse.c 2022/08/10 03:35:38 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: parse.c,v 1.3 2022/05/22 11:27:37 andvar Exp $ */ | 1 | /* $NetBSD: parse.c,v 1.4 2022/08/10 03:35:38 dholland Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center and by Matthias Scheler. | 9 | * NASA Ames Research Center and by Matthias Scheler. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -54,53 +54,57 @@ | @@ -54,53 +54,57 @@ | |||
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
59 | * SUCH DAMAGE. | 59 | * SUCH DAMAGE. | |
60 | */ | 60 | */ | |
61 | 61 | |||
62 | #include <sys/cdefs.h> | 62 | #include <sys/cdefs.h> | |
63 | #ifndef lint | 63 | #ifndef lint | |
64 | #if 0 | 64 | #if 0 | |
65 | static char sccsid[] = "@(#)inetd.c 8.4 (Berkeley) 4/13/94"; | 65 | static char sccsid[] = "@(#)inetd.c 8.4 (Berkeley) 4/13/94"; | |
66 | #else | 66 | #else | |
67 | __RCSID("$NetBSD: parse.c,v 1.3 2022/05/22 11:27:37 andvar Exp $"); | 67 | __RCSID("$NetBSD: parse.c,v 1.4 2022/08/10 03:35:38 dholland Exp $"); | |
68 | #endif | 68 | #endif | |
69 | #endif /* not lint */ | 69 | #endif /* not lint */ | |
70 | 70 | |||
71 | /* | 71 | /* | |
72 | * This file contains code and state for loading and managing servtabs. | 72 | * This file contains code and state for loading and managing servtabs. | |
73 | * The "positional" syntax parsing is performed in this file. See parse_v2.c | 73 | * The "positional" syntax parsing is performed in this file. See parse_v2.c | |
74 | * for "key-values" syntax parsing. | 74 | * for "key-values" syntax parsing. | |
75 | */ | 75 | */ | |
76 | 76 | |||
77 | #include <sys/param.h> | 77 | #include <sys/param.h> | |
78 | #include <sys/stat.h> | 78 | #include <sys/stat.h> | |
79 | #include <sys/socket.h> | 79 | #include <sys/socket.h> | |
80 | #include <sys/queue.h> | 80 | #include <sys/queue.h> | |
81 | 81 | |||
82 | #include <ctype.h> | 82 | #include <ctype.h> | |
83 | #include <err.h> | 83 | #include <err.h> | |
84 | #include <errno.h> | 84 | #include <errno.h> | |
85 | #include <fcntl.h> | 85 | #include <fcntl.h> | |
86 | #include <glob.h> | 86 | #include <glob.h> | |
87 | #include <libgen.h> | 87 | #include <libgen.h> | |
88 | #include <stdio.h> | 88 | #include <stdio.h> | |
89 | #include <stdlib.h> | 89 | #include <stdlib.h> | |
90 | #include <string.h> | 90 | #include <string.h> | |
91 | #include <syslog.h> | 91 | #include <syslog.h> | |
92 | #include <unistd.h> | 92 | #include <unistd.h> | |
93 | 93 | |||
94 | #ifdef RPC | |||
95 | #include <rpc/rpc.h> | |||
96 | #endif | |||
97 | ||||
94 | #include "inetd.h" | 98 | #include "inetd.h" | |
95 | 99 | |||
96 | static void config(void); | 100 | static void config(void); | |
97 | static void endconfig(void); | 101 | static void endconfig(void); | |
98 | static struct servtab *enter(struct servtab *); | 102 | static struct servtab *enter(struct servtab *); | |
99 | static struct servtab *getconfigent(char **); | 103 | static struct servtab *getconfigent(char **); | |
100 | #ifdef DEBUG_ENABLE | 104 | #ifdef DEBUG_ENABLE | |
101 | static void print_service(const char *, struct servtab *); | 105 | static void print_service(const char *, struct servtab *); | |
102 | #endif | 106 | #endif | |
103 | static struct servtab init_servtab(void); | 107 | static struct servtab init_servtab(void); | |
104 | static void include_configs(char *); | 108 | static void include_configs(char *); | |
105 | static int glob_error(const char *, int); | 109 | static int glob_error(const char *, int); | |
106 | static void read_glob_configs(char *); | 110 | static void read_glob_configs(char *); | |
@@ -311,27 +315,27 @@ config(void) | @@ -311,27 +315,27 @@ config(void) | |||
311 | SERV_FMT | 315 | SERV_FMT | |
312 | ": unknown service", | 316 | ": unknown service", | |
313 | SERV_PARAMS(sep)); | 317 | SERV_PARAMS(sep)); | |
314 | sep->se_checked = false; | 318 | sep->se_checked = false; | |
315 | continue; | 319 | continue; | |
316 | } | 320 | } | |
317 | sep->se_rpcprog = rp->r_number; | 321 | sep->se_rpcprog = rp->r_number; | |
318 | } | 322 | } | |
319 | if (sep->se_fd == -1 && !ISMUX(sep)) | 323 | if (sep->se_fd == -1 && !ISMUX(sep)) | |
320 | setup(sep); | 324 | setup(sep); | |
321 | if (sep->se_fd != -1) | 325 | if (sep->se_fd != -1) | |
322 | register_rpc(sep); | 326 | register_rpc(sep); | |
323 | } else | 327 | } else | |
324 | #endif | 328 | #endif /* RPC */ | |
325 | { | 329 | { | |
326 | if (sep->se_fd >= 0) | 330 | if (sep->se_fd >= 0) | |
327 | close_sep(sep); | 331 | close_sep(sep); | |
328 | if (sep->se_fd == -1 && !ISMUX(sep)) | 332 | if (sep->se_fd == -1 && !ISMUX(sep)) | |
329 | setup(sep); | 333 | setup(sep); | |
330 | } | 334 | } | |
331 | } | 335 | } | |
332 | } | 336 | } | |
333 | } | 337 | } | |
334 | endconfig(); | 338 | endconfig(); | |
335 | } | 339 | } | |
336 | 340 | |||
337 | static struct servtab * | 341 | static struct servtab * |