diff options
author | Rob Landley <rob@landley.net> | 2006-04-28 19:38:04 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-04-28 19:38:04 +0000 |
commit | a2d9a1752c4a59adc94307c584f949b24bd10338 (patch) | |
tree | 5e51df91f30752db400655b99f798969191b32bb /networking/httpd.c | |
parent | 0e6a3e14e41f6ce7407f9d47eec9db257eb6b125 (diff) | |
download | busybox-w32-a2d9a1752c4a59adc94307c584f949b24bd10338.tar.gz busybox-w32-a2d9a1752c4a59adc94307c584f949b24bd10338.tar.bz2 busybox-w32-a2d9a1752c4a59adc94307c584f949b24bd10338.zip |
More usage.h cleanups, with collateral changes to httpd. Specifically,
most of our CONFIG entries switch stuff on instead of off when enabled, so fix
the gratuitously reversed INETD thing.
Diffstat (limited to 'networking/httpd.c')
-rw-r--r-- | networking/httpd.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 97bec6e4b..73a9461fa 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -183,7 +183,7 @@ typedef struct | |||
183 | Htaccess *mime_a; /* config mime types */ | 183 | Htaccess *mime_a; /* config mime types */ |
184 | #endif | 184 | #endif |
185 | 185 | ||
186 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 186 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
187 | int accepted_socket; | 187 | int accepted_socket; |
188 | # define a_c_r config->accepted_socket | 188 | # define a_c_r config->accepted_socket |
189 | # define a_c_w config->accepted_socket | 189 | # define a_c_w config->accepted_socket |
@@ -776,7 +776,7 @@ static void addEnv(const char *name_before_underline, | |||
776 | } | 776 | } |
777 | } | 777 | } |
778 | 778 | ||
779 | #if defined(CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV) || !defined(CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY) | 779 | #if defined(CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV) || defined(CONFIG_FEATURE_HTTPD_WITHOUT_INETD) |
780 | /* set environs SERVER_PORT and REMOTE_PORT */ | 780 | /* set environs SERVER_PORT and REMOTE_PORT */ |
781 | static void addEnvPort(const char *port_name) | 781 | static void addEnvPort(const char *port_name) |
782 | { | 782 | { |
@@ -848,7 +848,7 @@ static void decodeBase64(char *Data) | |||
848 | #endif | 848 | #endif |
849 | 849 | ||
850 | 850 | ||
851 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 851 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
852 | /**************************************************************************** | 852 | /**************************************************************************** |
853 | * | 853 | * |
854 | > $Function: openServer() | 854 | > $Function: openServer() |
@@ -885,7 +885,7 @@ static int openServer(void) | |||
885 | signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ | 885 | signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ |
886 | return fd; | 886 | return fd; |
887 | } | 887 | } |
888 | #endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */ | 888 | #endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */ |
889 | 889 | ||
890 | /**************************************************************************** | 890 | /**************************************************************************** |
891 | * | 891 | * |
@@ -1163,7 +1163,7 @@ static int sendCgi(const char *url, | |||
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | } | 1165 | } |
1166 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1166 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
1167 | config->accepted_socket = 1; /* send to stdout */ | 1167 | config->accepted_socket = 1; /* send to stdout */ |
1168 | #endif | 1168 | #endif |
1169 | sendHeaders(HTTP_NOT_FOUND); | 1169 | sendHeaders(HTTP_NOT_FOUND); |
@@ -1728,7 +1728,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1728 | config->last_mod = sb.st_mtime; | 1728 | config->last_mod = sb.st_mtime; |
1729 | } | 1729 | } |
1730 | sendFile(test); | 1730 | sendFile(test); |
1731 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1731 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
1732 | /* unset if non inetd looped */ | 1732 | /* unset if non inetd looped */ |
1733 | config->ContentLength = -1; | 1733 | config->ContentLength = -1; |
1734 | #endif | 1734 | #endif |
@@ -1741,7 +1741,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1741 | } while (0); | 1741 | } while (0); |
1742 | 1742 | ||
1743 | 1743 | ||
1744 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1744 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
1745 | /* from inetd don`t looping: freeing, closing automatic from exit always */ | 1745 | /* from inetd don`t looping: freeing, closing automatic from exit always */ |
1746 | # if DEBUG | 1746 | # if DEBUG |
1747 | fprintf(stderr, "closing socket\n"); | 1747 | fprintf(stderr, "closing socket\n"); |
@@ -1754,7 +1754,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1754 | free(config->remoteuser); | 1754 | free(config->remoteuser); |
1755 | #endif | 1755 | #endif |
1756 | # endif | 1756 | # endif |
1757 | #endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */ | 1757 | #endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */ |
1758 | shutdown(a_c_w, SHUT_WR); | 1758 | shutdown(a_c_w, SHUT_WR); |
1759 | 1759 | ||
1760 | /* Properly wait for remote to closed */ | 1760 | /* Properly wait for remote to closed */ |
@@ -1768,9 +1768,9 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1768 | } while (retval > 0 && (read (a_c_r, buf, sizeof (config->buf)) > 0)); | 1768 | } while (retval > 0 && (read (a_c_r, buf, sizeof (config->buf)) > 0)); |
1769 | 1769 | ||
1770 | shutdown(a_c_r, SHUT_RD); | 1770 | shutdown(a_c_r, SHUT_RD); |
1771 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1771 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
1772 | close(config->accepted_socket); | 1772 | close(config->accepted_socket); |
1773 | #endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */ | 1773 | #endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */ |
1774 | } | 1774 | } |
1775 | 1775 | ||
1776 | /**************************************************************************** | 1776 | /**************************************************************************** |
@@ -1788,7 +1788,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ | |||
1788 | * $Return: (int) . . . . Always 0. | 1788 | * $Return: (int) . . . . Always 0. |
1789 | * | 1789 | * |
1790 | ****************************************************************************/ | 1790 | ****************************************************************************/ |
1791 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1791 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
1792 | static int miniHttpd(int server) | 1792 | static int miniHttpd(int server) |
1793 | { | 1793 | { |
1794 | fd_set readfd, portfd; | 1794 | fd_set readfd, portfd; |
@@ -1874,7 +1874,7 @@ static int miniHttpd(void) | |||
1874 | handleIncoming(); | 1874 | handleIncoming(); |
1875 | return 0; | 1875 | return 0; |
1876 | } | 1876 | } |
1877 | #endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */ | 1877 | #endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */ |
1878 | 1878 | ||
1879 | #ifdef CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP | 1879 | #ifdef CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP |
1880 | static void sighup_handler(int sig) | 1880 | static void sighup_handler(int sig) |
@@ -1899,7 +1899,7 @@ enum httpd_opts_nums { | |||
1899 | USE_FEATURE_HTTPD_BASIC_AUTH(r_opt_realm,) | 1899 | USE_FEATURE_HTTPD_BASIC_AUTH(r_opt_realm,) |
1900 | USE_FEATURE_HTTPD_AUTH_MD5(m_opt_md5,) | 1900 | USE_FEATURE_HTTPD_AUTH_MD5(m_opt_md5,) |
1901 | USE_FEATURE_HTTPD_SETUID(u_opt_setuid,) | 1901 | USE_FEATURE_HTTPD_SETUID(u_opt_setuid,) |
1902 | SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(p_opt_port,) | 1902 | USE_FEATURE_HTTPD_WITHOUT_INETD(p_opt_port,) |
1903 | }; | 1903 | }; |
1904 | 1904 | ||
1905 | static const char httpd_opts[]="c:d:h:" | 1905 | static const char httpd_opts[]="c:d:h:" |
@@ -1907,7 +1907,7 @@ static const char httpd_opts[]="c:d:h:" | |||
1907 | USE_FEATURE_HTTPD_BASIC_AUTH("r:") | 1907 | USE_FEATURE_HTTPD_BASIC_AUTH("r:") |
1908 | USE_FEATURE_HTTPD_AUTH_MD5("m:") | 1908 | USE_FEATURE_HTTPD_AUTH_MD5("m:") |
1909 | USE_FEATURE_HTTPD_SETUID("u:") | 1909 | USE_FEATURE_HTTPD_SETUID("u:") |
1910 | SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:"); | 1910 | USE_FEATURE_HTTPD_WITHOUT_INETD("p:"); |
1911 | 1911 | ||
1912 | #define OPT_CONFIG_FILE (1<<c_opt_config_file) | 1912 | #define OPT_CONFIG_FILE (1<<c_opt_config_file) |
1913 | #define OPT_DECODE_URL (1<<d_opt_decode_url) | 1913 | #define OPT_DECODE_URL (1<<d_opt_decode_url) |
@@ -1925,8 +1925,8 @@ static const char httpd_opts[]="c:d:h:" | |||
1925 | #define OPT_SETUID USE_FEATURE_HTTPD_SETUID((1<<u_opt_setuid)) \ | 1925 | #define OPT_SETUID USE_FEATURE_HTTPD_SETUID((1<<u_opt_setuid)) \ |
1926 | SKIP_FEATURE_HTTPD_SETUID(0) | 1926 | SKIP_FEATURE_HTTPD_SETUID(0) |
1927 | 1927 | ||
1928 | #define OPT_PORT SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<p_opt_port)) \ | 1928 | #define OPT_PORT USE_FEATURE_HTTPD_WITHOUT_INETD((1<<p_opt_port)) \ |
1929 | USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0) | 1929 | SKIP_FEATURE_HTTPD_WITHOUT_INETD(0) |
1930 | 1930 | ||
1931 | 1931 | ||
1932 | int httpd_main(int argc, char *argv[]) | 1932 | int httpd_main(int argc, char *argv[]) |
@@ -1935,8 +1935,8 @@ int httpd_main(int argc, char *argv[]) | |||
1935 | const char *home_httpd = home; | 1935 | const char *home_httpd = home; |
1936 | char *url_for_decode; | 1936 | char *url_for_decode; |
1937 | USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;) | 1937 | USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;) |
1938 | SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_port;) | 1938 | USE_FEATURE_HTTPD_WITHOUT_INETD(const char *s_port;) |
1939 | SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(int server;) | 1939 | USE_FEATURE_HTTPD_WITHOUT_INETD(int server;) |
1940 | 1940 | ||
1941 | USE_FEATURE_HTTPD_SETUID(const char *s_uid;) | 1941 | USE_FEATURE_HTTPD_SETUID(const char *s_uid;) |
1942 | USE_FEATURE_HTTPD_SETUID(long uid = -1;) | 1942 | USE_FEATURE_HTTPD_SETUID(long uid = -1;) |
@@ -1948,7 +1948,7 @@ int httpd_main(int argc, char *argv[]) | |||
1948 | config->realm = "Web Server Authentication"; | 1948 | config->realm = "Web Server Authentication"; |
1949 | #endif | 1949 | #endif |
1950 | 1950 | ||
1951 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1951 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
1952 | config->port = 80; | 1952 | config->port = 80; |
1953 | #endif | 1953 | #endif |
1954 | 1954 | ||
@@ -1960,7 +1960,7 @@ int httpd_main(int argc, char *argv[]) | |||
1960 | USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm)) | 1960 | USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm)) |
1961 | USE_FEATURE_HTTPD_AUTH_MD5(, &pass) | 1961 | USE_FEATURE_HTTPD_AUTH_MD5(, &pass) |
1962 | USE_FEATURE_HTTPD_SETUID(, &s_uid) | 1962 | USE_FEATURE_HTTPD_SETUID(, &s_uid) |
1963 | SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_port) | 1963 | USE_FEATURE_HTTPD_WITHOUT_INETD(, &s_port) |
1964 | ); | 1964 | ); |
1965 | 1965 | ||
1966 | if(opt & OPT_DECODE_URL) { | 1966 | if(opt & OPT_DECODE_URL) { |
@@ -1979,7 +1979,7 @@ int httpd_main(int argc, char *argv[]) | |||
1979 | return 0; | 1979 | return 0; |
1980 | } | 1980 | } |
1981 | #endif | 1981 | #endif |
1982 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1982 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
1983 | if(opt & OPT_PORT) | 1983 | if(opt & OPT_PORT) |
1984 | config->port = bb_xgetlarg(s_port, 10, 1, 0xffff); | 1984 | config->port = bb_xgetlarg(s_port, 10, 1, 0xffff); |
1985 | #ifdef CONFIG_FEATURE_HTTPD_SETUID | 1985 | #ifdef CONFIG_FEATURE_HTTPD_SETUID |
@@ -1996,7 +1996,7 @@ int httpd_main(int argc, char *argv[]) | |||
1996 | #endif | 1996 | #endif |
1997 | 1997 | ||
1998 | bb_xchdir(home_httpd); | 1998 | bb_xchdir(home_httpd); |
1999 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 1999 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
2000 | server = openServer(); | 2000 | server = openServer(); |
2001 | # ifdef CONFIG_FEATURE_HTTPD_SETUID | 2001 | # ifdef CONFIG_FEATURE_HTTPD_SETUID |
2002 | /* drop privileges */ | 2002 | /* drop privileges */ |
@@ -2014,7 +2014,7 @@ int httpd_main(int argc, char *argv[]) | |||
2014 | clearenv(); | 2014 | clearenv(); |
2015 | if(p) | 2015 | if(p) |
2016 | setenv("PATH", p, 1); | 2016 | setenv("PATH", p, 1); |
2017 | # ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 2017 | # ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
2018 | addEnvPort("SERVER"); | 2018 | addEnvPort("SERVER"); |
2019 | # endif | 2019 | # endif |
2020 | } | 2020 | } |
@@ -2026,7 +2026,7 @@ int httpd_main(int argc, char *argv[]) | |||
2026 | parse_conf(default_path_httpd_conf, FIRST_PARSE); | 2026 | parse_conf(default_path_httpd_conf, FIRST_PARSE); |
2027 | #endif | 2027 | #endif |
2028 | 2028 | ||
2029 | #ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY | 2029 | #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD |
2030 | # if !DEBUG | 2030 | # if !DEBUG |
2031 | bb_xdaemon(1, 0); /* don`t change curent directory */ | 2031 | bb_xdaemon(1, 0); /* don`t change curent directory */ |
2032 | # endif | 2032 | # endif |