aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-19 18:54:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-19 18:54:22 +0000
commit37c3316fd7175f73f6a4f1d9cd29a7bada93d678 (patch)
treeee5fca537694faf5b94d46349005d584ca8a322d
parent52e15dc50b0eaa30109564dcdbb6b6f9557cd1d9 (diff)
downloadbusybox-w32-37c3316fd7175f73f6a4f1d9cd29a7bada93d678.tar.gz
busybox-w32-37c3316fd7175f73f6a4f1d9cd29a7bada93d678.tar.bz2
busybox-w32-37c3316fd7175f73f6a4f1d9cd29a7bada93d678.zip
httpd: get rid of rmt_port and setenv_log
-rw-r--r--networking/httpd.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 23d442f17..560d1f8ee 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -135,10 +135,10 @@ struct globals {
135 int verbose; /* must be int (used by getopt32) */ 135 int verbose; /* must be int (used by getopt32) */
136 smallint flg_deny_all; 136 smallint flg_deny_all;
137 137
138 unsigned rmt_ip; 138 unsigned rmt_ip; /* used for IP-based allow/deny rules */
139// TODO: get rid of rmt_port 139 time_t last_mod;
140 unsigned rmt_port; /* for set env REMOTE_PORT */ 140 off_t ContentLength; /* -1 - unknown */
141 char *rmt_ip_str; /* for set env REMOTE_ADDR */ 141 char *rmt_ip_str; /* for $REMOTE_ADDR and $REMOTE_PORT */
142 const char *bind_addr_or_port; 142 const char *bind_addr_or_port;
143 143
144 const char *g_query; 144 const char *g_query;
@@ -147,8 +147,6 @@ struct globals {
147 147
148 const char *found_mime_type; 148 const char *found_mime_type;
149 const char *found_moved_temporarily; 149 const char *found_moved_temporarily;
150 time_t last_mod;
151 off_t ContentLength; /* -1 - unknown */
152 Htaccess_IP *ip_a_d; /* config allow/deny lines */ 150 Htaccess_IP *ip_a_d; /* config allow/deny lines */
153 151
154 USE_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;) 152 USE_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;)
@@ -174,7 +172,6 @@ struct globals {
174#define verbose (G.verbose ) 172#define verbose (G.verbose )
175#define flg_deny_all (G.flg_deny_all ) 173#define flg_deny_all (G.flg_deny_all )
176#define rmt_ip (G.rmt_ip ) 174#define rmt_ip (G.rmt_ip )
177#define rmt_port (G.rmt_port )
178#define bind_addr_or_port (G.bind_addr_or_port) 175#define bind_addr_or_port (G.bind_addr_or_port)
179#define g_query (G.g_query ) 176#define g_query (G.g_query )
180#define configFile (G.configFile ) 177#define configFile (G.configFile )
@@ -731,12 +728,6 @@ static void setenv1(const char *name, const char *value)
731 value = ""; 728 value = "";
732 setenv(name, value, 1); 729 setenv(name, value, 1);
733} 730}
734static void setenv_long(const char *name, long value)
735{
736 char buf[sizeof(value)*3 + 2];
737 sprintf(buf, "%ld", value);
738 setenv(name, buf, 1);
739}
740#endif 731#endif
741 732
742#if ENABLE_FEATURE_HTTPD_BASIC_AUTH 733#if ENABLE_FEATURE_HTTPD_BASIC_AUTH
@@ -751,7 +742,7 @@ static void setenv_long(const char *name, long value)
751static void decodeBase64(char *Data) 742static void decodeBase64(char *Data)
752{ 743{
753 const unsigned char *in = (const unsigned char *)Data; 744 const unsigned char *in = (const unsigned char *)Data;
754 // The decoded size will be at most 3/4 the size of the encoded 745 /* The decoded size will be at most 3/4 the size of the encoded */
755 unsigned ch = 0; 746 unsigned ch = 0;
756 int i = 0; 747 int i = 0;
757 748
@@ -1027,14 +1018,16 @@ static void send_cgi_and_exit(
1027 cp = NULL; 1018 cp = NULL;
1028 if (cp) *cp = '\0'; /* delete :PORT */ 1019 if (cp) *cp = '\0'; /* delete :PORT */
1029 setenv1("REMOTE_ADDR", p); 1020 setenv1("REMOTE_ADDR", p);
1030 if (cp) *cp = ':'; 1021 if (cp) {
1031 } 1022 *cp = ':';
1032 setenv1("HTTP_USER_AGENT", user_agent);
1033#if ENABLE_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV 1023#if ENABLE_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
1034 setenv_long("REMOTE_PORT", rmt_port); 1024 setenv1("REMOTE_PORT", cp + 1);
1035#endif 1025#endif
1026 }
1027 }
1028 setenv1("HTTP_USER_AGENT", user_agent);
1036 if (bodyLen) 1029 if (bodyLen)
1037 setenv_long("CONTENT_LENGTH", bodyLen); 1030 putenv(xasprintf("CONTENT_LENGTH=%d", bodyLen));
1038 if (cookie) 1031 if (cookie)
1039 setenv1("HTTP_COOKIE", cookie); 1032 setenv1("HTTP_COOKIE", cookie);
1040 if (content_type) 1033 if (content_type)
@@ -1530,8 +1523,6 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
1530 * (IOW, server process doesn't need to waste 8k) */ 1523 * (IOW, server process doesn't need to waste 8k) */
1531 iobuf = xmalloc(MAX_MEMORY_BUF); 1524 iobuf = xmalloc(MAX_MEMORY_BUF);
1532 1525
1533 rmt_port = get_nport(&fromAddr->sa);
1534 rmt_port = ntohs(rmt_port);
1535 rmt_ip = 0; 1526 rmt_ip = 0;
1536 if (fromAddr->sa.sa_family == AF_INET) { 1527 if (fromAddr->sa.sa_family == AF_INET) {
1537 rmt_ip = ntohl(fromAddr->sin.sin_addr.s_addr); 1528 rmt_ip = ntohl(fromAddr->sin.sin_addr.s_addr);