summaryrefslogtreecommitdiff
path: root/main/php_open_temporary_file.c
diff options
context:
space:
mode:
authorALeX Kazik <git@kazik.de>2013-01-18 17:13:39 +0100
committerStanislav Malyshev <stas@php.net>2013-01-28 22:37:43 -0800
commit475a644bd84c071da04b4272b829a187a2c6d282 (patch)
tree0fdffe041ec37fbacf13d56d9c9b842a0f17073c /main/php_open_temporary_file.c
parenta9d013bb020591cb6306afa2748da80f68b81f56 (diff)
downloadphp-git-475a644bd84c071da04b4272b829a187a2c6d282.tar.gz
Implemented Feature #60524 (sys_temp_dir)
Added a new configuration directive which allows it to change the temporary directory, the default behavior is unchanged. This is a useful option if you use all/some hosts inside of one .ini file with sections and want to change the temp dir per user (maybe it's not allowed to write outside the users home directory). Since the TMPDIR variable affects the whole php that way can not be used for this scenario. (see https://bugs.php.net/bug.php?id=60524)
Diffstat (limited to 'main/php_open_temporary_file.c')
-rw-r--r--main/php_open_temporary_file.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index b43d6a7835..5d5e5b98d7 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -196,6 +196,21 @@ PHPAPI const char* php_get_temporary_directory(void)
return temporary_directory;
}
+ /* Is there a temporary directory "sys_temp_dir" in .ini defined? */
+ {
+ char *sys_temp_dir = PG(sys_temp_dir);
+ if (sys_temp_dir) {
+ int len = strlen(sys_temp_dir);
+ if (len >= 2 && sys_temp_dir[len - 1] == DEFAULT_SLASH) {
+ temporary_directory = zend_strndup(sys_temp_dir, len - 1);
+ return temporary_directory;
+ } else if (len >= 1 && sys_temp_dir[len - 1] != DEFAULT_SLASH) {
+ temporary_directory = zend_strndup(sys_temp_dir, len);
+ return temporary_directory;
+ }
+ }
+ }
+
#ifdef PHP_WIN32
/* We can't count on the environment variables TEMP or TMP,
* and so must make the Win32 API call to get the default