summaryrefslogtreecommitdiff
path: root/networking/inetd.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-03-17 09:04:04 +0000
committerDenis Vlasenko2008-03-17 09:04:04 +0000
commit85c247161b9e1e7c71ebcb874ed7b6a23b6a5b50 (patch)
tree0b60f25ea0ebfbac5d9b3fa22f123aadaecd6663 /networking/inetd.c
parent081eb71ebd7954a67287816a9a6fff80e8c5319a (diff)
downloadbusybox-85c247161b9e1e7c71ebcb874ed7b6a23b6a5b50.zip
busybox-85c247161b9e1e7c71ebcb874ed7b6a23b6a5b50.tar.gz
*: fix fallout from -Wunused-parameter
function old new delta bbunpack 358 366 +8 passwd_main 1070 1072 +2 handle_incoming_and_exit 2651 2653 +2 getpty 88 86 -2 script_main 975 972 -3 inetd_main 2036 2033 -3 dname_enc 377 373 -4 make_new_session 474 462 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/5 up/down: 12/-24) Total: -12 bytes text data bss dec hex filename 797429 658 7428 805515 c4a8b busybox_old 797417 658 7428 805503 c4a7f busybox_unstripped
Diffstat (limited to 'networking/inetd.c')
-rw-r--r--networking/inetd.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/networking/inetd.c b/networking/inetd.c
index 0ddfa6b..b931aa1 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1331,10 +1331,10 @@ int inetd_main(int argc ATTRIBUTE_UNUSED, char **argv)
continue; /* -> check next fd in fd set */
}
- /* we are either child or didn't fork at all */
+ /* we are either child or didn't vfork at all */
#ifdef INETD_BUILTINS_ENABLED
if (sep->se_builtin) {
- if (pid) { /* "pid" is -1: we did fork */
+ if (pid) { /* "pid" is -1: we did vfork */
close(sep->se_fd); /* listening socket */
logmode = 0; /* make xwrite etc silent */
}
@@ -1343,8 +1343,8 @@ int inetd_main(int argc ATTRIBUTE_UNUSED, char **argv)
sep->se_builtin->bi_stream_fn(ctrl, sep);
else
sep->se_builtin->bi_dgram_fn(ctrl, sep);
- if (pid) /* we did fork */
- _exit(0);
+ if (pid) /* we did vfork */
+ _exit(1);
maybe_close(accepted_fd);
continue; /* -> check next fd in fd set */
}
@@ -1430,11 +1430,15 @@ static void echo_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
xwrite(s, line, sz);
}
#else
+ /* We are after vfork here! */
static const char *const args[] = { "cat", NULL };
- /* no error messages */
+ /* move network socket to stdin */
+ xmove_fd(s, STDIN_FILENO);
+ xdup2(STDIN_FILENO, STDOUT_FILENO);
+ /* no error messages please... */
xmove_fd(xopen("/dev/null", O_WRONLY), STDERR_FILENO);
BB_EXECVP("cat", (char**)args);
- _exit(1);
+ /* on failure we return to main, which does exit(1) */
#endif
}
static void echo_dg(int s, servtab_t *sep)
@@ -1463,11 +1467,15 @@ static void discard_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
while (safe_read(s, line, LINE_SIZE) > 0)
continue;
#else
+ /* We are after vfork here! */
static const char *const args[] = { "dd", "of=/dev/null", NULL };
+ /* move network socket to stdin */
+ xmove_fd(s, STDIN_FILENO);
+ xdup2(STDIN_FILENO, STDOUT_FILENO);
/* no error messages */
xmove_fd(xopen("/dev/null", O_WRONLY), STDERR_FILENO);
BB_EXECVP("dd", (char**)args);
- _exit(1);
+ /* on failure we return to main, which does exit(1) */
#endif
}
/* ARGSUSED */