summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2001-04-16 23:20:47 +0000
committerStig Bakken <ssb@php.net>2001-04-16 23:20:47 +0000
commit0b2641efa6a87d765b936ca5deebc12b554a9652 (patch)
tree9c7c31433da8047cc300c291826d09a8c9f919f3
parentf35cef5928dae36331392f038602653e4da52b02 (diff)
downloadphp-git-0b2641efa6a87d765b936ca5deebc12b554a9652.tar.gz
@Added -C command-line option to avoid chdir to the script's directory (Stig)
-rw-r--r--main/SAPI.h3
-rw-r--r--main/fopen_wrappers.c4
-rw-r--r--sapi/cgi/cgi_main.c8
3 files changed, 12 insertions, 3 deletions
diff --git a/main/SAPI.h b/main/SAPI.h
index 535f24334f..a9ce5922ae 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -25,6 +25,8 @@
#include "zend_operators.h"
#include <sys/stat.h>
+#define SAPI_OPTION_NO_CHDIR 1
+
#define SAPI_POST_BLOCK_SIZE 4000
#ifdef PHP_WIN32
@@ -109,6 +111,7 @@ typedef struct {
char *default_charset;
HashTable *rfc1867_uploaded_files;
long post_max_size;
+ int options;
} sapi_globals_struct;
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 63c0aa78d6..af541f417e 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -348,7 +348,9 @@ PHPAPI FILE *php_fopen_primary_script(void)
STR_FREE(SG(request_info).path_translated); /* for same reason as above */
return NULL;
}
- V_CHDIR_FILE(filename);
+ if (!(SG(options) & SAPI_OPTION_NO_CHDIR)) {
+ V_CHDIR_FILE(filename);
+ }
SG(request_info).path_translated = filename;
return fp;
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 8b9780dd96..58090fee3c 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -80,7 +80,7 @@
extern char *ap_php_optarg;
extern int ap_php_optind;
-#define OPTSTRING "ac:d:ef:g:hilmnqs?vz:"
+#define OPTSTRING "aCc:d:ef:g:hilmnqs?vz:"
static int _print_module_info ( zend_module_entry *module, void *arg ) {
php_printf("%s\n", module->name);
@@ -246,6 +246,7 @@ static void php_cgi_usage(char *argv0)
" -s Display colour syntax highlighted source.\n"
" -f <file> Parse <file>. Implies `-q'\n"
" -v Version number\n"
+ " -C Do not chdir to the script's directory\n"
" -c <path> Look for php.ini file in this directory\n"
#if SUPPORT_INTERACTIVE
" -a Run interactively\n"
@@ -525,7 +526,10 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
#endif
break;
- case 'd': /* define ini entries on command line */
+ case 'C': /* don't chdir to the script directory */
+ SG(options) |= SAPI_OPTION_NO_CHDIR;
+ break;
+ case 'd': /* define ini entries on command line */
define_command_line_ini_entry(ap_php_optarg);
break;