svn commit: trunk/busybox/networking
vodz at busybox.net
vodz at busybox.net
Tue Jan 31 13:53:32 UTC 2006
Author: vodz
Date: 2006-01-31 05:53:30 -0800 (Tue, 31 Jan 2006)
New Revision: 13759
Log:
add feature: support for running scripts through an interpreter. Thanks Florian Schirmer <jolt at tuxbox.org>
Modified:
trunk/busybox/networking/Config.in
trunk/busybox/networking/httpd.c
Changeset:
Modified: trunk/busybox/networking/Config.in
===================================================================
--- trunk/busybox/networking/Config.in 2006-01-31 12:36:51 UTC (rev 13758)
+++ trunk/busybox/networking/Config.in 2006-01-31 13:53:30 UTC (rev 13759)
@@ -85,7 +85,6 @@
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 @@
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
Modified: trunk/busybox/networking/httpd.c
===================================================================
--- trunk/busybox/networking/httpd.c 2006-01-31 12:36:51 UTC (rev 13758)
+++ trunk/busybox/networking/httpd.c 2006-01-31 13:53:30 UTC (rev 13759)
@@ -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 @@
#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 @@
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 @@
#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 @@
#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 @@
}
#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 @@
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 @@
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);
}
}
}
More information about the busybox-cvs
mailing list