diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-14 14:46:18 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-14 14:46:18 +0000 |
commit | d1a6e8d320633d5981a1dc7866d8e06aaad34dc1 (patch) | |
tree | 2887b7334b7f3345a37f631807dc62f3b3d48acc | |
parent | d97c9244b18dbfc373465a111c9a17a28e84477d (diff) | |
download | busybox-w32-d1a6e8d320633d5981a1dc7866d8e06aaad34dc1.tar.gz busybox-w32-d1a6e8d320633d5981a1dc7866d8e06aaad34dc1.tar.bz2 busybox-w32-d1a6e8d320633d5981a1dc7866d8e06aaad34dc1.zip |
inetd: preparatory patch, no code changes
-rw-r--r-- | networking/inetd.c | 127 |
1 files changed, 64 insertions, 63 deletions
diff --git a/networking/inetd.c b/networking/inetd.c index 01f38ad60..3cf7b2d3b 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -159,15 +159,15 @@ | |||
159 | #include <syslog.h> | 159 | #include <syslog.h> |
160 | #include <sys/un.h> | 160 | #include <sys/un.h> |
161 | 161 | ||
162 | //#define CONFIG_FEATURE_INETD_RPC | 162 | //#define ENABLE_FEATURE_INETD_RPC 1 |
163 | //#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO | 163 | //#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_ECHO 1 |
164 | //#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD | 164 | //#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD 1 |
165 | //#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME | 165 | //#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_TIME 1 |
166 | //#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME | 166 | //#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME 1 |
167 | //#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN | 167 | //#define ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN 1 |
168 | //#define CONFIG_FEATURE_IPV6 | 168 | //#define ENABLE_FEATURE_IPV6 1 |
169 | 169 | ||
170 | #ifdef CONFIG_FEATURE_INETD_RPC | 170 | #if ENABLE_FEATURE_INETD_RPC |
171 | #include <rpc/rpc.h> | 171 | #include <rpc/rpc.h> |
172 | #include <rpc/pmap_clnt.h> | 172 | #include <rpc/pmap_clnt.h> |
173 | #endif | 173 | #endif |
@@ -194,17 +194,17 @@ static struct rlimit rlim_ofile; | |||
194 | 194 | ||
195 | 195 | ||
196 | /* Check unsupporting builtin */ | 196 | /* Check unsupporting builtin */ |
197 | #if defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO || \ | 197 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_ECHO || \ |
198 | defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD || \ | 198 | ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD || \ |
199 | defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME || \ | 199 | ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_TIME || \ |
200 | defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME || \ | 200 | ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME || \ |
201 | defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN | 201 | ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN |
202 | # define INETD_FEATURE_ENABLED | 202 | # define INETD_FEATURE_ENABLED |
203 | #endif | 203 | #endif |
204 | 204 | ||
205 | #if defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO || \ | 205 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_ECHO || \ |
206 | defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD || \ | 206 | ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD || \ |
207 | defined CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN | 207 | ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN |
208 | # define INETD_SETPROCTITLE | 208 | # define INETD_SETPROCTITLE |
209 | #endif | 209 | #endif |
210 | 210 | ||
@@ -214,7 +214,7 @@ typedef struct servtab { | |||
214 | int se_socktype; /* type of socket to use */ | 214 | int se_socktype; /* type of socket to use */ |
215 | int se_family; /* address family */ | 215 | int se_family; /* address family */ |
216 | char *se_proto; /* protocol used */ | 216 | char *se_proto; /* protocol used */ |
217 | #ifdef CONFIG_FEATURE_INETD_RPC | 217 | #if ENABLE_FEATURE_INETD_RPC |
218 | int se_rpcprog; /* rpc program number */ | 218 | int se_rpcprog; /* rpc program number */ |
219 | int se_rpcversl; /* rpc program lowest version */ | 219 | int se_rpcversl; /* rpc program lowest version */ |
220 | int se_rpcversh; /* rpc program highest version */ | 220 | int se_rpcversh; /* rpc program highest version */ |
@@ -236,7 +236,7 @@ typedef struct servtab { | |||
236 | union { | 236 | union { |
237 | struct sockaddr se_un_ctrladdr; | 237 | struct sockaddr se_un_ctrladdr; |
238 | struct sockaddr_in se_un_ctrladdr_in; | 238 | struct sockaddr_in se_un_ctrladdr_in; |
239 | #ifdef CONFIG_FEATURE_IPV6 | 239 | #if ENABLE_FEATURE_IPV6 |
240 | struct sockaddr_in6 se_un_ctrladdr_in6; | 240 | struct sockaddr_in6 se_un_ctrladdr_in6; |
241 | #endif | 241 | #endif |
242 | struct sockaddr_un se_un_ctrladdr_un; | 242 | struct sockaddr_un se_un_ctrladdr_un; |
@@ -264,53 +264,53 @@ struct builtin { | |||
264 | }; | 264 | }; |
265 | 265 | ||
266 | /* Echo received data */ | 266 | /* Echo received data */ |
267 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO | 267 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_ECHO |
268 | static void echo_stream(int, servtab_t *); | 268 | static void echo_stream(int, servtab_t *); |
269 | static void echo_dg(int, servtab_t *); | 269 | static void echo_dg(int, servtab_t *); |
270 | #endif | 270 | #endif |
271 | /* Internet /dev/null */ | 271 | /* Internet /dev/null */ |
272 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD | 272 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD |
273 | static void discard_stream(int, servtab_t *); | 273 | static void discard_stream(int, servtab_t *); |
274 | static void discard_dg(int, servtab_t *); | 274 | static void discard_dg(int, servtab_t *); |
275 | #endif | 275 | #endif |
276 | /* Return 32 bit time since 1900 */ | 276 | /* Return 32 bit time since 1900 */ |
277 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME | 277 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_TIME |
278 | static void machtime_stream(int, servtab_t *); | 278 | static void machtime_stream(int, servtab_t *); |
279 | static void machtime_dg(int, servtab_t *); | 279 | static void machtime_dg(int, servtab_t *); |
280 | #endif | 280 | #endif |
281 | /* Return human-readable time */ | 281 | /* Return human-readable time */ |
282 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME | 282 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME |
283 | static void daytime_stream(int, servtab_t *); | 283 | static void daytime_stream(int, servtab_t *); |
284 | static void daytime_dg(int, servtab_t *); | 284 | static void daytime_dg(int, servtab_t *); |
285 | #endif | 285 | #endif |
286 | /* Familiar character generator */ | 286 | /* Familiar character generator */ |
287 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN | 287 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN |
288 | static void chargen_stream(int, servtab_t *); | 288 | static void chargen_stream(int, servtab_t *); |
289 | static void chargen_dg(int, servtab_t *); | 289 | static void chargen_dg(int, servtab_t *); |
290 | #endif | 290 | #endif |
291 | 291 | ||
292 | static const struct builtin builtins[] = { | 292 | static const struct builtin builtins[] = { |
293 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO | 293 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_ECHO |
294 | /* Echo received data */ | 294 | /* Echo received data */ |
295 | {"echo", SOCK_STREAM, 1, 0, echo_stream,}, | 295 | {"echo", SOCK_STREAM, 1, 0, echo_stream,}, |
296 | {"echo", SOCK_DGRAM, 0, 0, echo_dg,}, | 296 | {"echo", SOCK_DGRAM, 0, 0, echo_dg,}, |
297 | #endif | 297 | #endif |
298 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD | 298 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD |
299 | /* Internet /dev/null */ | 299 | /* Internet /dev/null */ |
300 | {"discard", SOCK_STREAM, 1, 0, discard_stream,}, | 300 | {"discard", SOCK_STREAM, 1, 0, discard_stream,}, |
301 | {"discard", SOCK_DGRAM, 0, 0, discard_dg,}, | 301 | {"discard", SOCK_DGRAM, 0, 0, discard_dg,}, |
302 | #endif | 302 | #endif |
303 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME | 303 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_TIME |
304 | /* Return 32 bit time since 1900 */ | 304 | /* Return 32 bit time since 1900 */ |
305 | {"time", SOCK_STREAM, 0, 0, machtime_stream,}, | 305 | {"time", SOCK_STREAM, 0, 0, machtime_stream,}, |
306 | {"time", SOCK_DGRAM, 0, 0, machtime_dg,}, | 306 | {"time", SOCK_DGRAM, 0, 0, machtime_dg,}, |
307 | #endif | 307 | #endif |
308 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME | 308 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME |
309 | /* Return human-readable time */ | 309 | /* Return human-readable time */ |
310 | {"daytime", SOCK_STREAM, 0, 0, daytime_stream,}, | 310 | {"daytime", SOCK_STREAM, 0, 0, daytime_stream,}, |
311 | {"daytime", SOCK_DGRAM, 0, 0, daytime_dg,}, | 311 | {"daytime", SOCK_DGRAM, 0, 0, daytime_dg,}, |
312 | #endif | 312 | #endif |
313 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN | 313 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN |
314 | /* Familiar character generator */ | 314 | /* Familiar character generator */ |
315 | {"chargen", SOCK_STREAM, 1, 0, chargen_stream,}, | 315 | {"chargen", SOCK_STREAM, 1, 0, chargen_stream,}, |
316 | {"chargen", SOCK_DGRAM, 0, 0, chargen_dg,}, | 316 | {"chargen", SOCK_DGRAM, 0, 0, chargen_dg,}, |
@@ -364,7 +364,7 @@ static void endconfig(void) | |||
364 | defhost = 0; | 364 | defhost = 0; |
365 | } | 365 | } |
366 | 366 | ||
367 | #ifdef CONFIG_FEATURE_INETD_RPC | 367 | #if ENABLE_FEATURE_INETD_RPC |
368 | static void register_rpc(servtab_t *sep) | 368 | static void register_rpc(servtab_t *sep) |
369 | { | 369 | { |
370 | int n; | 370 | int n; |
@@ -401,7 +401,7 @@ static void unregister_rpc(servtab_t *sep) | |||
401 | bb_error_msg("pmap_unset(%u, %u)", sep->se_rpcprog, n); | 401 | bb_error_msg("pmap_unset(%u, %u)", sep->se_rpcprog, n); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | #endif /* CONFIG_FEATURE_INETD_RPC */ | 404 | #endif /* FEATURE_INETD_RPC */ |
405 | 405 | ||
406 | static void freeconfig(servtab_t *cp) | 406 | static void freeconfig(servtab_t *cp) |
407 | { | 407 | { |
@@ -417,13 +417,13 @@ static void freeconfig(servtab_t *cp) | |||
417 | free(cp->se_argv[i]); | 417 | free(cp->se_argv[i]); |
418 | } | 418 | } |
419 | 419 | ||
420 | static int bump_nofile (void) | 420 | static int bump_nofile(void) |
421 | { | 421 | { |
422 | #define FD_CHUNK 32 | 422 | #define FD_CHUNK 32 |
423 | 423 | ||
424 | struct rlimit rl; | 424 | struct rlimit rl; |
425 | 425 | ||
426 | if (getrlimit (RLIMIT_NOFILE, &rl) < 0) { | 426 | if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { |
427 | bb_perror_msg("getrlimit"); | 427 | bb_perror_msg("getrlimit"); |
428 | return -1; | 428 | return -1; |
429 | } | 429 | } |
@@ -456,7 +456,7 @@ static void setup(servtab_t *sep) | |||
456 | if (setsockopt_reuseaddr(sep->se_fd) < 0) | 456 | if (setsockopt_reuseaddr(sep->se_fd) < 0) |
457 | bb_perror_msg("setsockopt(SO_REUSEADDR)"); | 457 | bb_perror_msg("setsockopt(SO_REUSEADDR)"); |
458 | 458 | ||
459 | #ifdef CONFIG_FEATURE_INETD_RPC | 459 | #if ENABLE_FEATURE_INETD_RPC |
460 | if (isrpcservice(sep)) { | 460 | if (isrpcservice(sep)) { |
461 | struct passwd *pwd; | 461 | struct passwd *pwd; |
462 | 462 | ||
@@ -577,7 +577,7 @@ static servtab_t *dupconfig(servtab_t *sep) | |||
577 | newtab->se_socktype = sep->se_socktype; | 577 | newtab->se_socktype = sep->se_socktype; |
578 | newtab->se_family = sep->se_family; | 578 | newtab->se_family = sep->se_family; |
579 | newtab->se_proto = xstrdup(sep->se_proto); | 579 | newtab->se_proto = xstrdup(sep->se_proto); |
580 | #ifdef CONFIG_FEATURE_INETD_RPC | 580 | #if ENABLE_FEATURE_INETD_RPC |
581 | newtab->se_rpcprog = sep->se_rpcprog; | 581 | newtab->se_rpcprog = sep->se_rpcprog; |
582 | newtab->se_rpcversl = sep->se_rpcversl; | 582 | newtab->se_rpcversl = sep->se_rpcversl; |
583 | newtab->se_rpcversh = sep->se_rpcversh; | 583 | newtab->se_rpcversh = sep->se_rpcversh; |
@@ -669,13 +669,13 @@ static servtab_t *getconfigent(void) | |||
669 | } else { | 669 | } else { |
670 | sep->se_family = AF_INET; | 670 | sep->se_family = AF_INET; |
671 | if (sep->se_proto[strlen(sep->se_proto) - 1] == '6') | 671 | if (sep->se_proto[strlen(sep->se_proto) - 1] == '6') |
672 | #ifdef CONFIG_FEATURE_IPV6 | 672 | #if ENABLE_FEATURE_IPV6 |
673 | sep->se_family = AF_INET6; | 673 | sep->se_family = AF_INET6; |
674 | #else | 674 | #else |
675 | bb_error_msg("%s: IPV6 not supported", sep->se_proto); | 675 | bb_error_msg("%s: IPV6 not supported", sep->se_proto); |
676 | #endif | 676 | #endif |
677 | if (strncmp(sep->se_proto, "rpc/", 4) == 0) { | 677 | if (strncmp(sep->se_proto, "rpc/", 4) == 0) { |
678 | #ifdef CONFIG_FEATURE_INETD_RPC | 678 | #if ENABLE_FEATURE_INETD_RPC |
679 | char *p, *ccp; | 679 | char *p, *ccp; |
680 | long l; | 680 | long l; |
681 | 681 | ||
@@ -872,7 +872,7 @@ static servtab_t *enter(servtab_t *cp) | |||
872 | sep = new_servtab(); | 872 | sep = new_servtab(); |
873 | *sep = *cp; | 873 | *sep = *cp; |
874 | sep->se_fd = -1; | 874 | sep->se_fd = -1; |
875 | #ifdef CONFIG_FEATURE_INETD_RPC | 875 | #if ENABLE_FEATURE_INETD_RPC |
876 | sep->se_rpcprog = -1; | 876 | sep->se_rpcprog = -1; |
877 | #endif | 877 | #endif |
878 | Block_Using_Signals(omask); | 878 | Block_Using_Signals(omask); |
@@ -906,7 +906,7 @@ static int matchconf(servtab_t *old, servtab_t *new) | |||
906 | sizeof(new->se_ctrladdr_in.sin_addr)) != 0) | 906 | sizeof(new->se_ctrladdr_in.sin_addr)) != 0) |
907 | return 0; | 907 | return 0; |
908 | 908 | ||
909 | #ifdef CONFIG_FEATURE_IPV6 | 909 | #if ENABLE_FEATURE_IPV6 |
910 | if (old->se_family == AF_INET6 && new->se_family == AF_INET6 && | 910 | if (old->se_family == AF_INET6 && new->se_family == AF_INET6 && |
911 | memcmp(&old->se_ctrladdr_in6.sin6_addr, | 911 | memcmp(&old->se_ctrladdr_in6.sin6_addr, |
912 | &new->se_ctrladdr_in6.sin6_addr, | 912 | &new->se_ctrladdr_in6.sin6_addr, |
@@ -961,7 +961,7 @@ static void config(int sig ATTRIBUTE_UNUSED) | |||
961 | SWAP(char *, sep->se_argv[i], cp->se_argv[i]); | 961 | SWAP(char *, sep->se_argv[i], cp->se_argv[i]); |
962 | #undef SWAP | 962 | #undef SWAP |
963 | 963 | ||
964 | #ifdef CONFIG_FEATURE_INETD_RPC | 964 | #if ENABLE_FEATURE_INETD_RPC |
965 | if (isrpcservice(sep)) | 965 | if (isrpcservice(sep)) |
966 | unregister_rpc(sep); | 966 | unregister_rpc(sep); |
967 | sep->se_rpcversl = cp->se_rpcversl; | 967 | sep->se_rpcversl = cp->se_rpcversl; |
@@ -992,7 +992,7 @@ static void config(int sig ATTRIBUTE_UNUSED) | |||
992 | /* se_ctrladdr_in was set in getconfigent */ | 992 | /* se_ctrladdr_in was set in getconfigent */ |
993 | sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in; | 993 | sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in; |
994 | 994 | ||
995 | #ifdef CONFIG_FEATURE_INETD_RPC | 995 | #if ENABLE_FEATURE_INETD_RPC |
996 | if (isrpcservice(sep)) { | 996 | if (isrpcservice(sep)) { |
997 | struct rpcent *rp; | 997 | struct rpcent *rp; |
998 | // FIXME: atoi_or_else(str, 0) would be handy here | 998 | // FIXME: atoi_or_else(str, 0) would be handy here |
@@ -1039,13 +1039,13 @@ static void config(int sig ATTRIBUTE_UNUSED) | |||
1039 | setup(sep); | 1039 | setup(sep); |
1040 | } | 1040 | } |
1041 | break; | 1041 | break; |
1042 | #ifdef CONFIG_FEATURE_IPV6 | 1042 | #if ENABLE_FEATURE_IPV6 |
1043 | case AF_INET6: | 1043 | case AF_INET6: |
1044 | sep->se_ctrladdr_in6.sin6_family = AF_INET6; | 1044 | sep->se_ctrladdr_in6.sin6_family = AF_INET6; |
1045 | /* se_ctrladdr_in was set in getconfigent */ | 1045 | /* se_ctrladdr_in was set in getconfigent */ |
1046 | sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in6; | 1046 | sep->se_ctrladdr_size = sizeof sep->se_ctrladdr_in6; |
1047 | 1047 | ||
1048 | #ifdef CONFIG_FEATURE_INETD_RPC | 1048 | #if ENABLE_FEATURE_INETD_RPC |
1049 | if (isrpcservice(sep)) { | 1049 | if (isrpcservice(sep)) { |
1050 | struct rpcent *rp; | 1050 | struct rpcent *rp; |
1051 | 1051 | ||
@@ -1092,7 +1092,7 @@ static void config(int sig ATTRIBUTE_UNUSED) | |||
1092 | setup(sep); | 1092 | setup(sep); |
1093 | } | 1093 | } |
1094 | break; | 1094 | break; |
1095 | #endif /* CONFIG_FEATURE_IPV6 */ | 1095 | #endif /* FEATURE_IPV6 */ |
1096 | } | 1096 | } |
1097 | serv_unknown: | 1097 | serv_unknown: |
1098 | if (cp->se_next != NULL) { | 1098 | if (cp->se_next != NULL) { |
@@ -1122,7 +1122,7 @@ static void config(int sig ATTRIBUTE_UNUSED) | |||
1122 | nsock--; | 1122 | nsock--; |
1123 | (void) close(sep->se_fd); | 1123 | (void) close(sep->se_fd); |
1124 | } | 1124 | } |
1125 | #ifdef CONFIG_FEATURE_INETD_RPC | 1125 | #if ENABLE_FEATURE_INETD_RPC |
1126 | if (isrpcservice(sep)) | 1126 | if (isrpcservice(sep)) |
1127 | unregister_rpc(sep); | 1127 | unregister_rpc(sep); |
1128 | #endif | 1128 | #endif |
@@ -1171,11 +1171,11 @@ static void retry(int sig ATTRIBUTE_UNUSED) | |||
1171 | switch (sep->se_family) { | 1171 | switch (sep->se_family) { |
1172 | case AF_UNIX: | 1172 | case AF_UNIX: |
1173 | case AF_INET: | 1173 | case AF_INET: |
1174 | #ifdef CONFIG_FEATURE_IPV6 | 1174 | #if ENABLE_FEATURE_IPV6 |
1175 | case AF_INET6: | 1175 | case AF_INET6: |
1176 | #endif | 1176 | #endif |
1177 | setup(sep); | 1177 | setup(sep); |
1178 | #ifdef CONFIG_FEATURE_INETD_RPC | 1178 | #if ENABLE_FEATURE_INETD_RPC |
1179 | if (sep->se_fd != -1 && isrpcservice(sep)) | 1179 | if (sep->se_fd != -1 && isrpcservice(sep)) |
1180 | register_rpc(sep); | 1180 | register_rpc(sep); |
1181 | #endif | 1181 | #endif |
@@ -1199,10 +1199,10 @@ static void goaway(int sig ATTRIBUTE_UNUSED) | |||
1199 | (void) unlink(sep->se_service); | 1199 | (void) unlink(sep->se_service); |
1200 | break; | 1200 | break; |
1201 | case AF_INET: | 1201 | case AF_INET: |
1202 | #ifdef CONFIG_FEATURE_IPV6 | 1202 | #if ENABLE_FEATURE_IPV6 |
1203 | case AF_INET6: | 1203 | case AF_INET6: |
1204 | #endif | 1204 | #endif |
1205 | #ifdef CONFIG_FEATURE_INETD_RPC | 1205 | #if ENABLE_FEATURE_INETD_RPC |
1206 | if (sep->se_wait == 1 && isrpcservice(sep)) | 1206 | if (sep->se_wait == 1 && isrpcservice(sep)) |
1207 | unregister_rpc(sep); /* XXX signal race */ | 1207 | unregister_rpc(sep); /* XXX signal race */ |
1208 | #endif | 1208 | #endif |
@@ -1526,9 +1526,9 @@ do_exit1: | |||
1526 | */ | 1526 | */ |
1527 | #define BUFSIZE 4096 | 1527 | #define BUFSIZE 4096 |
1528 | 1528 | ||
1529 | #if defined(CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO) || \ | 1529 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_ECHO || \ |
1530 | defined(CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN) || \ | 1530 | ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN || \ |
1531 | defined(CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME) | 1531 | ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME |
1532 | static int dg_badinput(struct sockaddr_in *dg_sin) | 1532 | static int dg_badinput(struct sockaddr_in *dg_sin) |
1533 | { | 1533 | { |
1534 | if (ntohs(dg_sin->sin_port) < IPPORT_RESERVED) | 1534 | if (ntohs(dg_sin->sin_port) < IPPORT_RESERVED) |
@@ -1540,7 +1540,7 @@ static int dg_badinput(struct sockaddr_in *dg_sin) | |||
1540 | } | 1540 | } |
1541 | #endif | 1541 | #endif |
1542 | 1542 | ||
1543 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO | 1543 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_ECHO |
1544 | /* Echo service -- echo data back */ | 1544 | /* Echo service -- echo data back */ |
1545 | /* ARGSUSED */ | 1545 | /* ARGSUSED */ |
1546 | static void | 1546 | static void |
@@ -1578,9 +1578,9 @@ echo_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED) | |||
1578 | return; | 1578 | return; |
1579 | (void) sendto(s, buffer, i, 0, &sa, sizeof(sa)); | 1579 | (void) sendto(s, buffer, i, 0, &sa, sizeof(sa)); |
1580 | } | 1580 | } |
1581 | #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO */ | 1581 | #endif /* FEATURE_INETD_SUPPORT_BUILTIN_ECHO */ |
1582 | 1582 | ||
1583 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD | 1583 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD |
1584 | /* Discard service -- ignore data */ | 1584 | /* Discard service -- ignore data */ |
1585 | /* ARGSUSED */ | 1585 | /* ARGSUSED */ |
1586 | static void | 1586 | static void |
@@ -1605,10 +1605,10 @@ discard_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED) | |||
1605 | 1605 | ||
1606 | (void) read(s, buffer, sizeof(buffer)); | 1606 | (void) read(s, buffer, sizeof(buffer)); |
1607 | } | 1607 | } |
1608 | #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD */ | 1608 | #endif /* FEATURE_INETD_SUPPORT_BUILTIN_DISCARD */ |
1609 | 1609 | ||
1610 | 1610 | ||
1611 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN | 1611 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN |
1612 | #define LINESIZ 72 | 1612 | #define LINESIZ 72 |
1613 | static char ring[128]; | 1613 | static char ring[128]; |
1614 | static char *endring; | 1614 | static char *endring; |
@@ -1695,10 +1695,10 @@ chargen_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED) | |||
1695 | text[LINESIZ + 1] = '\n'; | 1695 | text[LINESIZ + 1] = '\n'; |
1696 | (void) sendto(s, text, sizeof(text), 0, &sa, sizeof(sa)); | 1696 | (void) sendto(s, text, sizeof(text), 0, &sa, sizeof(sa)); |
1697 | } | 1697 | } |
1698 | #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN */ | 1698 | #endif /* FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN */ |
1699 | 1699 | ||
1700 | 1700 | ||
1701 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME | 1701 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_TIME |
1702 | /* | 1702 | /* |
1703 | * Return a machine readable date and time, in the form of the | 1703 | * Return a machine readable date and time, in the form of the |
1704 | * number of seconds since midnight, Jan 1, 1900. Since gettimeofday | 1704 | * number of seconds since midnight, Jan 1, 1900. Since gettimeofday |
@@ -1749,19 +1749,20 @@ machtime_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED) | |||
1749 | result = machtime(); | 1749 | result = machtime(); |
1750 | (void) sendto(s, (char *) &result, sizeof(result), 0, &sa, sizeof(sa)); | 1750 | (void) sendto(s, (char *) &result, sizeof(result), 0, &sa, sizeof(sa)); |
1751 | } | 1751 | } |
1752 | #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME */ | 1752 | #endif /* FEATURE_INETD_SUPPORT_BUILTIN_TIME */ |
1753 | 1753 | ||
1754 | 1754 | ||
1755 | #ifdef CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME | 1755 | #if ENABLE_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME |
1756 | /* Return human-readable time of day */ | 1756 | /* Return human-readable time of day */ |
1757 | /* ARGSUSED */ | 1757 | /* ARGSUSED */ |
1758 | static void daytime_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED) | 1758 | static void daytime_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED) |
1759 | { | 1759 | { |
1760 | char buffer[256]; | 1760 | char buffer[32]; |
1761 | time_t t; | 1761 | time_t t; |
1762 | 1762 | ||
1763 | t = time(NULL); | 1763 | t = time(NULL); |
1764 | 1764 | ||
1765 | // fdprintf instead? | ||
1765 | (void) sprintf(buffer, "%.24s\r\n", ctime(&t)); | 1766 | (void) sprintf(buffer, "%.24s\r\n", ctime(&t)); |
1766 | (void) write(s, buffer, strlen(buffer)); | 1767 | (void) write(s, buffer, strlen(buffer)); |
1767 | } | 1768 | } |
@@ -1787,4 +1788,4 @@ daytime_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED) | |||
1787 | (void) sprintf(buffer, "%.24s\r\n", ctime(&t)); | 1788 | (void) sprintf(buffer, "%.24s\r\n", ctime(&t)); |
1788 | (void) sendto(s, buffer, strlen(buffer), 0, &sa, sizeof(sa)); | 1789 | (void) sendto(s, buffer, strlen(buffer), 0, &sa, sizeof(sa)); |
1789 | } | 1790 | } |
1790 | #endif /* CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME */ | 1791 | #endif /* FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME */ |