aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/inetd.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/networking/inetd.c b/networking/inetd.c
index eb19d1630..d71a1159c 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1413,6 +1413,10 @@ int inetd_main(int argc ATTRIBUTE_UNUSED, char **argv)
1413 } /* for (;;) */ 1413 } /* for (;;) */
1414} 1414}
1415 1415
1416#if !BB_MMU
1417static const char *const cat_args[] = { "cat", NULL };
1418#endif
1419
1416/* 1420/*
1417 * Internet services provided internally by inetd: 1421 * Internet services provided internally by inetd:
1418 */ 1422 */
@@ -1430,13 +1434,13 @@ static void echo_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
1430 } 1434 }
1431#else 1435#else
1432 /* We are after vfork here! */ 1436 /* We are after vfork here! */
1433 static const char *const args[] = { "cat", NULL }; 1437 /* move network socket to stdin/stdout */
1434 /* move network socket to stdin */
1435 xmove_fd(s, STDIN_FILENO); 1438 xmove_fd(s, STDIN_FILENO);
1436 xdup2(STDIN_FILENO, STDOUT_FILENO); 1439 xdup2(STDIN_FILENO, STDOUT_FILENO);
1437 /* no error messages please... */ 1440 /* no error messages please... */
1438 xmove_fd(xopen("/dev/null", O_WRONLY), STDERR_FILENO); 1441 close(STDERR_FILENO);
1439 BB_EXECVP("cat", (char**)args); 1442 xopen("/dev/null", O_WRONLY);
1443 BB_EXECVP("cat", (char**)cat_args);
1440 /* on failure we return to main, which does exit(1) */ 1444 /* on failure we return to main, which does exit(1) */
1441#endif 1445#endif
1442} 1446}
@@ -1467,13 +1471,14 @@ static void discard_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
1467 continue; 1471 continue;
1468#else 1472#else
1469 /* We are after vfork here! */ 1473 /* We are after vfork here! */
1470 static const char *const args[] = { "dd", "of=/dev/null", NULL };
1471 /* move network socket to stdin */ 1474 /* move network socket to stdin */
1472 xmove_fd(s, STDIN_FILENO); 1475 xmove_fd(s, STDIN_FILENO);
1473 xdup2(STDIN_FILENO, STDOUT_FILENO); 1476 /* discard output */
1474 /* no error messages */ 1477 close(STDOUT_FILENO);
1475 xmove_fd(xopen("/dev/null", O_WRONLY), STDERR_FILENO); 1478 xopen("/dev/null", O_WRONLY);
1476 BB_EXECVP("dd", (char**)args); 1479 /* no error messages please... */
1480 xdup2(STDOUT_FILENO, STDERR_FILENO);
1481 BB_EXECVP("cat", (char**)cat_args);
1477 /* on failure we return to main, which does exit(1) */ 1482 /* on failure we return to main, which does exit(1) */
1478#endif 1483#endif
1479} 1484}