diff options
author | Denys Vlasenko | 2009-09-12 17:57:19 +0200 |
---|---|---|
committer | Denys Vlasenko | 2009-09-12 17:57:19 +0200 |
commit | d7686c8c2c849c775007c5de19901ab6b38bd039 (patch) | |
tree | 8d4017407166a4f16a0fecd7921a8d03975636bf /networking | |
parent | e7aa0d9eca180f77ed4226ecaa1e8961d842add7 (diff) | |
download | busybox-1_15_1.zip busybox-1_15_1.tar.gz |
Apply post-1.15.0 fixes; bump version to 1.15.11_15_1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r-- | networking/httpd.c | 30 | ||||
-rw-r--r-- | networking/inetd.c | 25 |
2 files changed, 30 insertions, 25 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 956eeca..bc081c1 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -2101,8 +2101,12 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) } send_cgi_and_exit(urlcopy, prequest, length, cookie, content_type); } +#endif + + if (urlp[-1] == '/') + strcpy(urlp, index_page); + if (stat(tptr, &sb) == 0) { #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR - { char *suffix = strrchr(tptr, '.'); if (suffix) { Htaccess *cur; @@ -2112,16 +2116,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) } } } - } #endif - if (prequest != request_GET && prequest != request_HEAD) { - send_headers_and_exit(HTTP_NOT_IMPLEMENTED); - } -#endif /* FEATURE_HTTPD_CGI */ - - if (urlp[-1] == '/') - strcpy(urlp, index_page); - if (stat(tptr, &sb) == 0) { file_size = sb.st_size; last_mod = sb.st_mtime; } @@ -2135,19 +2130,18 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) send_cgi_and_exit("/cgi-bin/index.cgi", prequest, length, cookie, content_type); } } -#endif - /* else { - * fall through to send_file, it errors out if open fails - * } - */ + /* else fall through to send_file, it errors out if open fails: */ + if (prequest != request_GET && prequest != request_HEAD) { + /* POST for files does not make sense */ + send_headers_and_exit(HTTP_NOT_IMPLEMENTED); + } send_file_and_exit(tptr, -#if ENABLE_FEATURE_HTTPD_CGI (prequest != request_HEAD ? SEND_HEADERS_AND_BODY : SEND_HEADERS) + ); #else - SEND_HEADERS_AND_BODY + send_file_and_exit(tptr, SEND_HEADERS_AND_BODY); #endif - ); } /* diff --git a/networking/inetd.c b/networking/inetd.c index 331c494..391bb9b 100644 --- a/networking/inetd.c +++ b/networking/inetd.c @@ -1031,10 +1031,10 @@ static void reap_child(int sig UNUSED_PARAM) continue; /* One of our "wait" services */ if (WIFEXITED(status) && WEXITSTATUS(status)) - bb_error_msg("%s: exit status 0x%x", + bb_error_msg("%s: exit status %u", sep->se_program, WEXITSTATUS(status)); else if (WIFSIGNALED(status)) - bb_error_msg("%s: exit signal 0x%x", + bb_error_msg("%s: exit signal %u", sep->se_program, WTERMSIG(status)); sep->se_wait = 1; add_fd_to_set(sep->se_fd); @@ -1119,7 +1119,12 @@ int inetd_main(int argc UNUSED_PARAM, char **argv) else bb_sanitize_stdio(); if (!(opt & 4)) { - openlog(applet_name, LOG_PID, LOG_DAEMON); + /* LOG_NDELAY: connect to syslog daemon NOW. + * Otherwise, we may open syslog socket + * in vforked child, making opened fds and syslog() + * internal state inconsistent. + * This was observed to leak file descriptors. */ + openlog(applet_name, LOG_PID | LOG_NDELAY, LOG_DAEMON); logmode = LOGMODE_SYSLOG; } @@ -1355,17 +1360,23 @@ int inetd_main(int argc UNUSED_PARAM, char **argv) if (rlim_ofile.rlim_cur != rlim_ofile_cur) if (setrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0) bb_perror_msg("setrlimit"); - closelog(); + + /* closelog(); - WRONG. we are after vfork, + * this may confuse syslog() internal state. + * Let's hope libc sets syslog fd to CLOEXEC... + */ xmove_fd(ctrl, STDIN_FILENO); xdup2(STDIN_FILENO, STDOUT_FILENO); /* manpages of inetd I managed to find either say * that stderr is also redirected to the network, * or do not talk about redirection at all (!) */ - xdup2(STDIN_FILENO, STDERR_FILENO); - /* NB: among others, this loop closes listening socket + if (!sep->se_wait) /* only for usual "tcp nowait" */ + xdup2(STDIN_FILENO, STDERR_FILENO); + /* NB: among others, this loop closes listening sockets * for nowait stream children */ for (sep2 = serv_list; sep2; sep2 = sep2->se_next) - maybe_close(sep2->se_fd); + if (sep2->se_fd != ctrl) + maybe_close(sep2->se_fd); sigaction_set(SIGPIPE, &saved_pipe_handler); restore_sigmask(&omask); BB_EXECVP(sep->se_program, sep->se_argv); |