aboutsummaryrefslogtreecommitdiff
path: root/networking/httpd.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-07-28 07:40:39 +0000
committerEric Andersen <andersen@codepoet.org>2003-07-28 07:40:39 +0000
commit35e643b39f6cc77b702c714cfa8e70f1e10601a9 (patch)
treead6b608081a4dde117563a1f1e9a6e3892a8752c /networking/httpd.c
parent4f4631732cab5886105d8809d4e9b17711def65b (diff)
downloadbusybox-w32-35e643b39f6cc77b702c714cfa8e70f1e10601a9.tar.gz
busybox-w32-35e643b39f6cc77b702c714cfa8e70f1e10601a9.tar.bz2
busybox-w32-35e643b39f6cc77b702c714cfa8e70f1e10601a9.zip
last_patch95 from vodz:
Hi. Last patch have new libbb function vfork_rexec() for can use daemon() to uClinux system. This patched daemons: syslog, klogd, inetd, crond. This not tested! I havn`t this systems. Also. Previous patch for feature request MD5 crypt password for httpd don`t sended to this mailist on 07/15/03 (mailist have Pytom module problem?). The previous patch included, and have testing. --w vodz
Diffstat (limited to 'networking/httpd.c')
-rw-r--r--networking/httpd.c64
1 files changed, 57 insertions, 7 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index d3d88fcb6..d58414b55 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -153,12 +153,14 @@ static const char home[] = "./";
153/* Config options, disable this for do very small module */ 153/* Config options, disable this for do very small module */
154//#define CONFIG_FEATURE_HTTPD_CGI 154//#define CONFIG_FEATURE_HTTPD_CGI
155//#define CONFIG_FEATURE_HTTPD_BASIC_AUTH 155//#define CONFIG_FEATURE_HTTPD_BASIC_AUTH
156//#define CONFIG_FEATURE_HTTPD_AUTH_MD5
156 157
157#ifdef HTTPD_STANDALONE 158#ifdef HTTPD_STANDALONE
158/* standalone, enable all features */ 159/* standalone, enable all features */
159#undef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY 160#undef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
160/* unset config option for remove warning as redefined */ 161/* unset config option for remove warning as redefined */
161#undef CONFIG_FEATURE_HTTPD_BASIC_AUTH 162#undef CONFIG_FEATURE_HTTPD_BASIC_AUTH
163#undef CONFIG_FEATURE_HTTPD_AUTH_MD5
162#undef CONFIG_FEATURE_HTTPD_SET_CGI_VARS_TO_ENV 164#undef CONFIG_FEATURE_HTTPD_SET_CGI_VARS_TO_ENV
163#undef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR 165#undef CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
164#undef CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV 166#undef CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
@@ -168,6 +170,7 @@ static const char home[] = "./";
168#undef CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP 170#undef CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
169/* enable all features now */ 171/* enable all features now */
170#define CONFIG_FEATURE_HTTPD_BASIC_AUTH 172#define CONFIG_FEATURE_HTTPD_BASIC_AUTH
173#define CONFIG_FEATURE_HTTPD_AUTH_MD5
171#define CONFIG_FEATURE_HTTPD_SET_CGI_VARS_TO_ENV 174#define CONFIG_FEATURE_HTTPD_SET_CGI_VARS_TO_ENV
172#define CONFIG_FEATURE_HTTPD_ENCODE_URL_STR 175#define CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
173#define CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV 176#define CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
@@ -425,11 +428,11 @@ static void parse_conf(const char *path, int flag)
425 } 428 }
426 429
427 while((f = fopen(cf, "r")) == NULL) { 430 while((f = fopen(cf, "r")) == NULL) {
428 if(flag != FIRST_PARSE) { 431 if(flag == SUBDIR_PARSE || flag == FIND_FROM_HTTPD_ROOT) {
429 /* config file not found, no changes to config */ 432 /* config file not found, no changes to config */
430 return; 433 return;
431 } 434 }
432 if(config->configFile) /* if -c option given */ 435 if(config->configFile && flag == FIRST_PARSE) /* if -c option given */
433 bb_perror_msg_and_die("%s", cf); 436 bb_perror_msg_and_die("%s", cf);
434 flag = FIND_FROM_HTTPD_ROOT; 437 flag = FIND_FROM_HTTPD_ROOT;
435 cf = httpd_conf; 438 cf = httpd_conf;
@@ -1326,10 +1329,38 @@ static int checkPerm(const char *path, const char *request)
1326 if(strncmp(p0, path, l) == 0 && 1329 if(strncmp(p0, path, l) == 0 &&
1327 (l == 1 || path[l] == '/' || path[l] == 0)) { 1330 (l == 1 || path[l] == '/' || path[l] == 0)) {
1328 /* path match found. Check request */ 1331 /* path match found. Check request */
1332
1333 /* for check next /path:user:password */
1334 prev = p0;
1335#ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
1336 {
1337 char *cipher;
1338 char *pp;
1339 char *u = strchr(request, ':');
1340
1341 if(u == NULL) {
1342 /* bad request, ':' required */
1343 continue;
1344 }
1345 if(strncmp(p, request, u-request) != 0) {
1346 /* user uncompared */
1347 continue;
1348 }
1349 pp = strchr(p, ':');
1350 if(pp && pp[1] == '$' && pp[2] == '1' &&
1351 pp[3] == '$' && pp[4]) {
1352 pp++;
1353 cipher = pw_encrypt(u+1, pp);
1354 if (strcmp(cipher, pp) == 0)
1355 return 1; /* Ok */
1356 /* unauthorized */
1357 continue;
1358 }
1359 }
1360#endif
1329 if (strcmp(p, request) == 0) 1361 if (strcmp(p, request) == 0)
1330 return 1; /* Ok */ 1362 return 1; /* Ok */
1331 /* unauthorized, but check next /path:user:password */ 1363 /* unauthorized */
1332 prev = p0;
1333 } 1364 }
1334 } 1365 }
1335 } /* for */ 1366 } /* for */
@@ -1731,7 +1762,12 @@ static const char httpd_opts[]="c:d:h:"
1731#endif 1762#endif
1732#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 1763#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
1733 "r:" 1764 "r:"
1734#define OPT_INC_2 1 1765# ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
1766 "m:"
1767# define OPT_INC_2 2
1768# else
1769# define OPT_INC_2 1
1770#endif
1735#else 1771#else
1736#define OPT_INC_2 0 1772#define OPT_INC_2 0
1737#endif 1773#endif
@@ -1740,14 +1776,15 @@ static const char httpd_opts[]="c:d:h:"
1740#ifdef CONFIG_FEATURE_HTTPD_SETUID 1776#ifdef CONFIG_FEATURE_HTTPD_SETUID
1741 "u:" 1777 "u:"
1742#endif 1778#endif
1743#endif 1779#endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */
1744 ; 1780 ;
1745 1781
1746#define OPT_CONFIG_FILE (1<<0) 1782#define OPT_CONFIG_FILE (1<<0)
1747#define OPT_DECODE_URL (1<<1) 1783#define OPT_DECODE_URL (1<<1)
1748#define OPT_HOME_HTTPD (1<<2) 1784#define OPT_HOME_HTTPD (1<<2)
1749#define OPT_ENCODE_URL (1<<(2+OPT_INC_1)) 1785#define OPT_ENCODE_URL (1<<(2+OPT_INC_1))
1750#define OPT_REALM (1<<(2+OPT_INC_1+OPT_INC_2)) 1786#define OPT_REALM (1<<(3+OPT_INC_1))
1787#define OPT_MD5 (1<<(4+OPT_INC_1))
1751#define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2)) 1788#define OPT_PORT (1<<(3+OPT_INC_1+OPT_INC_2))
1752#define OPT_DEBUG (1<<(4+OPT_INC_1+OPT_INC_2)) 1789#define OPT_DEBUG (1<<(4+OPT_INC_1+OPT_INC_2))
1753#define OPT_SETUID (1<<(5+OPT_INC_1+OPT_INC_2)) 1790#define OPT_SETUID (1<<(5+OPT_INC_1+OPT_INC_2))
@@ -1778,6 +1815,10 @@ int httpd_main(int argc, char *argv[])
1778 long uid = -1; 1815 long uid = -1;
1779#endif 1816#endif
1780 1817
1818#ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
1819 const char *pass;
1820#endif
1821
1781 config = xcalloc(1, sizeof(*config)); 1822 config = xcalloc(1, sizeof(*config));
1782#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 1823#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
1783 config->realm = "Web Server Authentication"; 1824 config->realm = "Web Server Authentication";
@@ -1796,6 +1837,9 @@ int httpd_main(int argc, char *argv[])
1796#endif 1837#endif
1797#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 1838#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
1798 , &(config->realm) 1839 , &(config->realm)
1840# ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
1841 , &pass
1842# endif
1799#endif 1843#endif
1800#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY 1844#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
1801 , &s_port 1845 , &s_port
@@ -1815,6 +1859,12 @@ int httpd_main(int argc, char *argv[])
1815 return 0; 1859 return 0;
1816 } 1860 }
1817#endif 1861#endif
1862#ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
1863 if(opt & OPT_MD5) {
1864 printf("%s\n", pw_encrypt(pass, "$1$"));
1865 return 0;
1866 }
1867#endif
1818#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY 1868#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
1819 if(opt & OPT_PORT) 1869 if(opt & OPT_PORT)
1820 config->port = bb_xgetlarg(s_port, 10, 1, 0xffff); 1870 config->port = bb_xgetlarg(s_port, 10, 1, 0xffff);