diff options
Diffstat (limited to 'networking/httpd.c')
-rw-r--r-- | networking/httpd.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 6bf103c56..803a98b46 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -250,13 +250,13 @@ struct globals { | |||
250 | const char *found_moved_temporarily; | 250 | const char *found_moved_temporarily; |
251 | Htaccess_IP *ip_a_d; /* config allow/deny lines */ | 251 | Htaccess_IP *ip_a_d; /* config allow/deny lines */ |
252 | 252 | ||
253 | USE_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;) | 253 | IF_FEATURE_HTTPD_BASIC_AUTH(const char *g_realm;) |
254 | USE_FEATURE_HTTPD_BASIC_AUTH(char *remoteuser;) | 254 | IF_FEATURE_HTTPD_BASIC_AUTH(char *remoteuser;) |
255 | USE_FEATURE_HTTPD_CGI(char *referer;) | 255 | IF_FEATURE_HTTPD_CGI(char *referer;) |
256 | USE_FEATURE_HTTPD_CGI(char *user_agent;) | 256 | IF_FEATURE_HTTPD_CGI(char *user_agent;) |
257 | USE_FEATURE_HTTPD_CGI(char *host;) | 257 | IF_FEATURE_HTTPD_CGI(char *host;) |
258 | USE_FEATURE_HTTPD_CGI(char *http_accept;) | 258 | IF_FEATURE_HTTPD_CGI(char *http_accept;) |
259 | USE_FEATURE_HTTPD_CGI(char *http_accept_language;) | 259 | IF_FEATURE_HTTPD_CGI(char *http_accept_language;) |
260 | 260 | ||
261 | off_t file_size; /* -1 - unknown */ | 261 | off_t file_size; /* -1 - unknown */ |
262 | #if ENABLE_FEATURE_HTTPD_RANGES | 262 | #if ENABLE_FEATURE_HTTPD_RANGES |
@@ -326,7 +326,7 @@ enum { | |||
326 | #define proxy (G.proxy ) | 326 | #define proxy (G.proxy ) |
327 | #define INIT_G() do { \ | 327 | #define INIT_G() do { \ |
328 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 328 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
329 | USE_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ | 329 | IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ |
330 | bind_addr_or_port = "80"; \ | 330 | bind_addr_or_port = "80"; \ |
331 | index_page = "index.html"; \ | 331 | index_page = "index.html"; \ |
332 | file_size = -1; \ | 332 | file_size = -1; \ |
@@ -1587,14 +1587,14 @@ static NOINLINE void send_file_and_exit(const char *url, int what) | |||
1587 | while (1) { | 1587 | while (1) { |
1588 | /* sz is rounded down to 64k */ | 1588 | /* sz is rounded down to 64k */ |
1589 | ssize_t sz = MAXINT(ssize_t) - 0xffff; | 1589 | ssize_t sz = MAXINT(ssize_t) - 0xffff; |
1590 | USE_FEATURE_HTTPD_RANGES(if (sz > range_len) sz = range_len;) | 1590 | IF_FEATURE_HTTPD_RANGES(if (sz > range_len) sz = range_len;) |
1591 | count = sendfile(STDOUT_FILENO, fd, &offset, sz); | 1591 | count = sendfile(STDOUT_FILENO, fd, &offset, sz); |
1592 | if (count < 0) { | 1592 | if (count < 0) { |
1593 | if (offset == range_start) | 1593 | if (offset == range_start) |
1594 | break; /* fall back to read/write loop */ | 1594 | break; /* fall back to read/write loop */ |
1595 | goto fin; | 1595 | goto fin; |
1596 | } | 1596 | } |
1597 | USE_FEATURE_HTTPD_RANGES(range_len -= sz;) | 1597 | IF_FEATURE_HTTPD_RANGES(range_len -= sz;) |
1598 | if (count == 0 || range_len == 0) | 1598 | if (count == 0 || range_len == 0) |
1599 | log_and_exit(); | 1599 | log_and_exit(); |
1600 | } | 1600 | } |
@@ -1602,16 +1602,16 @@ static NOINLINE void send_file_and_exit(const char *url, int what) | |||
1602 | #endif | 1602 | #endif |
1603 | while ((count = safe_read(fd, iobuf, IOBUF_SIZE)) > 0) { | 1603 | while ((count = safe_read(fd, iobuf, IOBUF_SIZE)) > 0) { |
1604 | ssize_t n; | 1604 | ssize_t n; |
1605 | USE_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;) | 1605 | IF_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;) |
1606 | n = full_write(STDOUT_FILENO, iobuf, count); | 1606 | n = full_write(STDOUT_FILENO, iobuf, count); |
1607 | if (count != n) | 1607 | if (count != n) |
1608 | break; | 1608 | break; |
1609 | USE_FEATURE_HTTPD_RANGES(range_len -= count;) | 1609 | IF_FEATURE_HTTPD_RANGES(range_len -= count;) |
1610 | if (range_len == 0) | 1610 | if (range_len == 0) |
1611 | break; | 1611 | break; |
1612 | } | 1612 | } |
1613 | if (count < 0) { | 1613 | if (count < 0) { |
1614 | USE_FEATURE_HTTPD_USE_SENDFILE(fin:) | 1614 | IF_FEATURE_HTTPD_USE_SENDFILE(fin:) |
1615 | if (verbose > 1) | 1615 | if (verbose > 1) |
1616 | bb_perror_msg("error"); | 1616 | bb_perror_msg("error"); |
1617 | } | 1617 | } |
@@ -1839,12 +1839,12 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) | |||
1839 | 1839 | ||
1840 | /* Find end of URL and parse HTTP version, if any */ | 1840 | /* Find end of URL and parse HTTP version, if any */ |
1841 | http_major_version = '0'; | 1841 | http_major_version = '0'; |
1842 | USE_FEATURE_HTTPD_PROXY(http_minor_version = '0';) | 1842 | IF_FEATURE_HTTPD_PROXY(http_minor_version = '0';) |
1843 | tptr = strchrnul(urlp, ' '); | 1843 | tptr = strchrnul(urlp, ' '); |
1844 | /* Is it " HTTP/"? */ | 1844 | /* Is it " HTTP/"? */ |
1845 | if (tptr[0] && strncmp(tptr + 1, HTTP_200, 5) == 0) { | 1845 | if (tptr[0] && strncmp(tptr + 1, HTTP_200, 5) == 0) { |
1846 | http_major_version = tptr[6]; | 1846 | http_major_version = tptr[6]; |
1847 | USE_FEATURE_HTTPD_PROXY(http_minor_version = tptr[8];) | 1847 | IF_FEATURE_HTTPD_PROXY(http_minor_version = tptr[8];) |
1848 | } | 1848 | } |
1849 | *tptr = '\0'; | 1849 | *tptr = '\0'; |
1850 | 1850 | ||
@@ -2252,10 +2252,10 @@ enum { | |||
2252 | c_opt_config_file = 0, | 2252 | c_opt_config_file = 0, |
2253 | d_opt_decode_url, | 2253 | d_opt_decode_url, |
2254 | h_opt_home_httpd, | 2254 | h_opt_home_httpd, |
2255 | USE_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,) | 2255 | IF_FEATURE_HTTPD_ENCODE_URL_STR(e_opt_encode_url,) |
2256 | USE_FEATURE_HTTPD_BASIC_AUTH( r_opt_realm ,) | 2256 | IF_FEATURE_HTTPD_BASIC_AUTH( r_opt_realm ,) |
2257 | USE_FEATURE_HTTPD_AUTH_MD5( m_opt_md5 ,) | 2257 | IF_FEATURE_HTTPD_AUTH_MD5( m_opt_md5 ,) |
2258 | USE_FEATURE_HTTPD_SETUID( u_opt_setuid ,) | 2258 | IF_FEATURE_HTTPD_SETUID( u_opt_setuid ,) |
2259 | p_opt_port , | 2259 | p_opt_port , |
2260 | p_opt_inetd , | 2260 | p_opt_inetd , |
2261 | p_opt_foreground, | 2261 | p_opt_foreground, |
@@ -2263,10 +2263,10 @@ enum { | |||
2263 | OPT_CONFIG_FILE = 1 << c_opt_config_file, | 2263 | OPT_CONFIG_FILE = 1 << c_opt_config_file, |
2264 | OPT_DECODE_URL = 1 << d_opt_decode_url, | 2264 | OPT_DECODE_URL = 1 << d_opt_decode_url, |
2265 | OPT_HOME_HTTPD = 1 << h_opt_home_httpd, | 2265 | OPT_HOME_HTTPD = 1 << h_opt_home_httpd, |
2266 | OPT_ENCODE_URL = USE_FEATURE_HTTPD_ENCODE_URL_STR((1 << e_opt_encode_url)) + 0, | 2266 | OPT_ENCODE_URL = IF_FEATURE_HTTPD_ENCODE_URL_STR((1 << e_opt_encode_url)) + 0, |
2267 | OPT_REALM = USE_FEATURE_HTTPD_BASIC_AUTH( (1 << r_opt_realm )) + 0, | 2267 | OPT_REALM = IF_FEATURE_HTTPD_BASIC_AUTH( (1 << r_opt_realm )) + 0, |
2268 | OPT_MD5 = USE_FEATURE_HTTPD_AUTH_MD5( (1 << m_opt_md5 )) + 0, | 2268 | OPT_MD5 = IF_FEATURE_HTTPD_AUTH_MD5( (1 << m_opt_md5 )) + 0, |
2269 | OPT_SETUID = USE_FEATURE_HTTPD_SETUID( (1 << u_opt_setuid )) + 0, | 2269 | OPT_SETUID = IF_FEATURE_HTTPD_SETUID( (1 << u_opt_setuid )) + 0, |
2270 | OPT_PORT = 1 << p_opt_port, | 2270 | OPT_PORT = 1 << p_opt_port, |
2271 | OPT_INETD = 1 << p_opt_inetd, | 2271 | OPT_INETD = 1 << p_opt_inetd, |
2272 | OPT_FOREGROUND = 1 << p_opt_foreground, | 2272 | OPT_FOREGROUND = 1 << p_opt_foreground, |
@@ -2280,10 +2280,10 @@ int httpd_main(int argc UNUSED_PARAM, char **argv) | |||
2280 | int server_socket = server_socket; /* for gcc */ | 2280 | int server_socket = server_socket; /* for gcc */ |
2281 | unsigned opt; | 2281 | unsigned opt; |
2282 | char *url_for_decode; | 2282 | char *url_for_decode; |
2283 | USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;) | 2283 | IF_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;) |
2284 | USE_FEATURE_HTTPD_SETUID(const char *s_ugid = NULL;) | 2284 | IF_FEATURE_HTTPD_SETUID(const char *s_ugid = NULL;) |
2285 | USE_FEATURE_HTTPD_SETUID(struct bb_uidgid_t ugid;) | 2285 | IF_FEATURE_HTTPD_SETUID(struct bb_uidgid_t ugid;) |
2286 | USE_FEATURE_HTTPD_AUTH_MD5(const char *pass;) | 2286 | IF_FEATURE_HTTPD_AUTH_MD5(const char *pass;) |
2287 | 2287 | ||
2288 | INIT_G(); | 2288 | INIT_G(); |
2289 | 2289 | ||
@@ -2299,16 +2299,16 @@ int httpd_main(int argc UNUSED_PARAM, char **argv) | |||
2299 | * If user gives relative path in -h, | 2299 | * If user gives relative path in -h, |
2300 | * $SCRIPT_FILENAME will not be set. */ | 2300 | * $SCRIPT_FILENAME will not be set. */ |
2301 | opt = getopt32(argv, "c:d:h:" | 2301 | opt = getopt32(argv, "c:d:h:" |
2302 | USE_FEATURE_HTTPD_ENCODE_URL_STR("e:") | 2302 | IF_FEATURE_HTTPD_ENCODE_URL_STR("e:") |
2303 | USE_FEATURE_HTTPD_BASIC_AUTH("r:") | 2303 | IF_FEATURE_HTTPD_BASIC_AUTH("r:") |
2304 | USE_FEATURE_HTTPD_AUTH_MD5("m:") | 2304 | IF_FEATURE_HTTPD_AUTH_MD5("m:") |
2305 | USE_FEATURE_HTTPD_SETUID("u:") | 2305 | IF_FEATURE_HTTPD_SETUID("u:") |
2306 | "p:ifv", | 2306 | "p:ifv", |
2307 | &configFile, &url_for_decode, &home_httpd | 2307 | &configFile, &url_for_decode, &home_httpd |
2308 | USE_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode) | 2308 | IF_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode) |
2309 | USE_FEATURE_HTTPD_BASIC_AUTH(, &g_realm) | 2309 | IF_FEATURE_HTTPD_BASIC_AUTH(, &g_realm) |
2310 | USE_FEATURE_HTTPD_AUTH_MD5(, &pass) | 2310 | IF_FEATURE_HTTPD_AUTH_MD5(, &pass) |
2311 | USE_FEATURE_HTTPD_SETUID(, &s_ugid) | 2311 | IF_FEATURE_HTTPD_SETUID(, &s_ugid) |
2312 | , &bind_addr_or_port | 2312 | , &bind_addr_or_port |
2313 | , &verbose | 2313 | , &verbose |
2314 | ); | 2314 | ); |