summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
author"Vladimir N. Oleynik"2006-01-31 13:53:30 +0000
committer"Vladimir N. Oleynik"2006-01-31 13:53:30 +0000
commit4333a09d657348672db61f3063f2d272708c2548 (patch)
tree6888ebd5177a29cdd49320e4cfb5bce9af3b827f /networking
parent1f17d3287adaa01c8605699e80aaaba3a5a01d65 (diff)
downloadbusybox-4333a09d657348672db61f3063f2d272708c2548.zip
busybox-4333a09d657348672db61f3063f2d272708c2548.tar.gz
add feature: support for running scripts through an interpreter. Thanks Florian Schirmer <jolt@tuxbox.org>
Diffstat (limited to 'networking')
-rw-r--r--networking/Config.in12
-rw-r--r--networking/httpd.c44
2 files changed, 51 insertions, 5 deletions
diff --git a/networking/Config.in b/networking/Config.in
index 0f4381b..c027877 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -85,7 +85,6 @@ config CONFIG_FEATURE_HTTPD_AUTH_MD5
Enables basic per url authentication from /etc/httpd.conf
using md5 passwords.
-
if !CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
config CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
bool " Support reloading the global config file using hup signal"
@@ -122,6 +121,17 @@ config CONFIG_FEATURE_HTTPD_CGI
This option allows scripts and executables to be invoked
when specific urls are requested.
+config CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ bool " Enable support for running scripts through an interpreter"
+ default n
+ depends on CONFIG_FEATURE_HTTPD_CGI
+ help
+ This option enables support for running scripts through an
+ interpreter. Turn this on, if you want PHP scripts to work
+ properly. You need to supply an addition line in your httpd
+ config file:
+ *.php:/path/to/your/php
+
config CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
bool " Support the REMOTE_PORT environment variable for CGI"
default n
diff --git a/networking/httpd.c b/networking/httpd.c
index b44adf7..99a87d1 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -54,6 +54,7 @@
* /adm:admin:setup # Require user admin, pwd setup on urls starting with /adm/
* /adm:toor:PaSsWd # or user toor, pwd PaSsWd on urls starting with /adm/
* .au:audio/basic # additional mime type for audio.au files
+ * *.php:/path/php # running cgi.php scripts through an interpreter
*
* A/D may be as a/d or allow/deny - first char case insensitive
* Deny IP rules take precedence over allow rules.
@@ -285,6 +286,9 @@ typedef struct
#endif
volatile int alarm_signaled;
+#ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ Htaccess *script_i; /* config script interpreters */
+#endif
} HttpdConfig;
static HttpdConfig *config;
@@ -529,7 +533,7 @@ static void parse_conf(const char *path, int flag)
config->flg_deny_all = 0;
-#if defined(CONFIG_FEATURE_HTTPD_BASIC_AUTH) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES)
+#if defined(CONFIG_FEATURE_HTTPD_BASIC_AUTH) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR)
/* retain previous auth and mime config only for subdir parse */
if(flag != SUBDIR_PARSE) {
#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
@@ -538,6 +542,9 @@ static void parse_conf(const char *path, int flag)
#ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
free_config_lines(&config->mime_a);
#endif
+#ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ free_config_lines(&config->script_i);
+#endif
}
#endif
@@ -601,6 +608,9 @@ static void parse_conf(const char *path, int flag)
#ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
&& *p0 != '.'
#endif
+#ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ && *p0 != '*'
+#endif
)
continue;
if(*p0 == 'A' || *p0 == 'D') {
@@ -672,7 +682,7 @@ static void parse_conf(const char *path, int flag)
}
#endif
-#if defined(CONFIG_FEATURE_HTTPD_BASIC_AUTH) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES)
+#if defined(CONFIG_FEATURE_HTTPD_BASIC_AUTH) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES) || defined(CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR)
/* storing current config line */
cur = calloc(1, sizeof(Htaccess) + strlen(p0));
if(cur) {
@@ -688,6 +698,14 @@ static void parse_conf(const char *path, int flag)
continue;
}
#endif
+#ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ if(*cf == '*' && cf[1] == '.') {
+ /* config script interpreter line move top for overwrite previous */
+ cur->next = config->script_i;
+ config->script_i = cur;
+ continue;
+ }
+#endif
#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
free(p0);
if(prev == NULL) {
@@ -1219,11 +1237,29 @@ static int sendCgi(const char *url,
if(script) {
*script = '\0';
if(chdir(realpath_buff) == 0) {
- *script = '/';
// now run the program. If it fails,
// use _exit() so no destructors
// get called and make a mess.
- execv(realpath_buff, argp);
+#ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ char *interpr = NULL;
+ char *suffix = strrchr(purl, '.');
+
+ if(suffix) {
+ Htaccess * cur;
+ for (cur = config->script_i; cur; cur = cur->next)
+ if(strcmp(cur->before_colon + 1, suffix) == 0) {
+ interpr = cur->after_colon;
+ break;
+ }
+ }
+#endif
+ *script = '/';
+#ifdef CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
+ if (interpr)
+ execv(interpr, argp);
+ else
+#endif
+ execv(realpath_buff, argp);
}
}
}