sendCgi() forked child needs to close opened server socket and accepted socket
Min Hsu
minh1970 at yahoo.com
Sun Nov 5 08:22:18 PST 2006
Hi List,
I have tried to use busybox httpd CGI to launch busybox telnetd and
found
that telnetd inherits httpd's opend server socket and accepted socket,
I
checked the source code of httpd.c and found sendCgi() forked child
does
NOT close these sockets. The following patch will fix this issue.
Regards,
============================================================
--- httpd.c.orig 2006-11-05 10:04:51.000000000 -0600
+++ httpd.c 2006-11-05 10:07:20.000000000 -0600
@@ -161,6 +161,7 @@
#endif
#if ENABLE_FEATURE_HTTPD_WITHOUT_INETD
+ int server_socket;
int accepted_socket;
# define a_c_r config->accepted_socket
# define a_c_w config->accepted_socket
@@ -1038,6 +1039,9 @@
close(fromCgi[0]);
close(fromCgi[1]);
+ close(config->accepted_socket);
+ close(config->server_socket);
+
/*
* Find PATH_INFO.
*/
@@ -1975,6 +1979,7 @@
xchdir(home_httpd);
#if ENABLE_FEATURE_HTTPD_WITHOUT_INETD
server = openServer();
+ config->server_socket = server;
# ifdef CONFIG_FEATURE_HTTPD_SETUID
/* drop privileges */
if (opt & OPT_SETUID) {
____________________________________________________________________________________
Low, Low, Low Rates! Check out Yahoo! Messenger's cheap PC-to-Phone call rates
(http://voice.yahoo.com)
More information about the busybox
mailing list