aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/httpd.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 3ac9b906a..779f070d9 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1417,37 +1417,39 @@ static void send_cgi_and_exit(
1417 * If CGI really wants that, it can always do dup itself. */ 1417 * If CGI really wants that, it can always do dup itself. */
1418 /* dup2(1, 2); */ 1418 /* dup2(1, 2); */
1419 1419
1420 /* script must have absolute path */
1421 script = strrchr(fullpath, '/'); 1420 script = strrchr(fullpath, '/');
1422 //fullpath is a result of concat_path_file and always has '/' 1421 //fullpath is a result of concat_path_file and always has '/'
1423 //if (!script) 1422 //if (!script)
1424 // goto error_execing_cgi; 1423 // goto error_execing_cgi;
1425 *script = '\0'; 1424 *script = '\0';
1426 /* chdiring to script's dir */ 1425 /* chdiring to script's dir */
1427 if (chdir(fullpath) == 0) { 1426 if (chdir(script == fullpath ? "/" : fullpath) == 0) {
1428 char *argv[2]; 1427 char *argv[3];
1428
1429 *script++ = '/'; /* repair fullpath */
1430 /* set argv[0] to name without path */
1431 argv[0] = script;
1432 argv[1] = NULL;
1433
1429#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR 1434#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
1430 char *interpr = NULL; 1435 {
1431 char *suffix = strrchr(purl, '.'); 1436 char *suffix = strrchr(script, '.');
1432 1437
1433 if (suffix) { 1438 if (suffix) {
1434 Htaccess *cur; 1439 Htaccess *cur;
1435 for (cur = script_i; cur; cur = cur->next) { 1440 for (cur = script_i; cur; cur = cur->next) {
1436 if (strcmp(cur->before_colon + 1, suffix) == 0) { 1441 if (strcmp(cur->before_colon + 1, suffix) == 0) {
1437 interpr = cur->after_colon; 1442 /* found interpreter name */
1438 break; 1443 fullpath = cur->after_colon;
1444 argv[0] = cur->after_colon;
1445 argv[1] = script;
1446 argv[2] = NULL;
1447 break;
1448 }
1439 } 1449 }
1440 } 1450 }
1441 } 1451 }
1442#endif 1452#endif
1443 *script = '/';
1444 /* set argv[0] to name without path */
1445 argv[0] = script + 1;
1446 argv[1] = NULL;
1447#if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
1448 if (interpr)
1449 fullpath = interpr;
1450#endif
1451 execv(fullpath, argv); 1453 execv(fullpath, argv);
1452 if (verbose) 1454 if (verbose)
1453 bb_perror_msg("exec %s", fullpath); 1455 bb_perror_msg("exec %s", fullpath);