]> granicus.if.org Git - php/commitdiff
Fix for Bug #26757: session.save_path default is bogus for win32
authorWez Furlong <wez@php.net>
Mon, 29 Mar 2004 21:28:47 +0000 (21:28 +0000)
committerWez Furlong <wez@php.net>
Mon, 29 Mar 2004 21:28:47 +0000 (21:28 +0000)
Based on a patch found in the bug report.
Concept approved by Ilia.

ext/session/mod_files.c
ext/session/session.c
main/php_open_temporary_file.c
main/php_open_temporary_file.h
php.ini-dist
php.ini-recommended

index 8d9a0f9f1231e2787e6181c02c84abc9bf3aac5a..8dcfca7976ed1dc0ebcde7d0784063939df03ad5 100644 (file)
@@ -46,6 +46,7 @@
 #include "php_session.h"
 #include "mod_files.h"
 #include "ext/standard/flock_compat.h"
+#include "php_open_temporary_file.h"
 
 #define FILE_PREFIX "sess_"
 
@@ -234,6 +235,10 @@ PS_OPEN_FUNC(files)
        data = ecalloc(sizeof(*data), 1);
        PS_SET_MOD_DATA(data);
 
+       if (*save_path == '\0') {
+               save_path = php_get_temporary_directory();
+       }
+
        data->fd = -1;
        if ((p = strchr(save_path, ';'))) {
                errno = 0;
index 2356290c9a7f8cea7cd756a8ad6fb30066ad4de3..01b6e79730c0547f5fd164c75cfe58998fbec762 100644 (file)
@@ -120,7 +120,11 @@ static PHP_INI_MH(OnUpdateSerializer)
 PHP_INI_BEGIN()
        STD_PHP_INI_BOOLEAN("session.bug_compat_42",    "1",         PHP_INI_ALL, OnUpdateBool,   bug_compat,         php_ps_globals,    ps_globals)
        STD_PHP_INI_BOOLEAN("session.bug_compat_warn",  "1",         PHP_INI_ALL, OnUpdateBool,   bug_compat_warn,    php_ps_globals,    ps_globals)
+#ifdef PHP_WIN32
+       STD_PHP_INI_ENTRY("session.save_path",          "",      PHP_INI_ALL, OnUpdateString, save_path,          php_ps_globals,    ps_globals)
+#else
        STD_PHP_INI_ENTRY("session.save_path",          "/tmp",      PHP_INI_ALL, OnUpdateString, save_path,          php_ps_globals,    ps_globals)
+#endif
        STD_PHP_INI_ENTRY("session.name",               "PHPSESSID", PHP_INI_ALL, OnUpdateString, session_name,       php_ps_globals,    ps_globals)
        PHP_INI_ENTRY("session.save_handler",           "files",     PHP_INI_ALL, OnUpdateSaveHandler)
        STD_PHP_INI_BOOLEAN("session.auto_start",       "0",         PHP_INI_ALL, OnUpdateBool,   auto_start,         php_ps_globals,    ps_globals)
index b364eb6a6a65034ad09ca157abacfe25a646156a..d1210d8230a3898cff4f77dfc1190c6677c8f1b9 100644 (file)
@@ -166,7 +166,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char **
 /*
  *  Determine where to place temporary files.
  */
-const char* get_temporary_directory()
+PHPAPI const char* php_get_temporary_directory(void)
 {
        /* Cache the chosen temporary directory. */
        static char* temporary_directory;
@@ -233,7 +233,7 @@ PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened
        fd = php_do_open_temporary_file(dir, pfx, opened_path_p TSRMLS_CC);
        if (fd == -1) {
                /* Use default temporary directory. */
-               fd = php_do_open_temporary_file(get_temporary_directory(), pfx, opened_path_p TSRMLS_CC);
+               fd = php_do_open_temporary_file(php_get_temporary_directory(), pfx, opened_path_p TSRMLS_CC);
        }
        return fd;
 }
index dc46d22bdd6bfb0b456c6481a2fdef0c6a0a8426..70dc7a18cb1567aea29b66f149785f59ba297991 100644 (file)
@@ -21,5 +21,6 @@
 
 PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC);
 PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC);
+PHPAPI const char* php_get_temporary_directory(void);
 
 #endif /* PHP_OPEN_TEMPORARY_FILE_H */
index 132b7920ececf8d24cd4b36419e56f3cd3fac50d..bdd57b010231ddacfdca0992bb35b3e95c9ea443 100644 (file)
@@ -819,7 +819,7 @@ session.save_handler = files
 ;         You can use the script in the ext/session dir for that purpose.
 ; NOTE 2: See the section on garbage collection below if you choose to
 ;         use subdirectories for session storage
-session.save_path = /tmp
+;session.save_path = /tmp
 
 ; Whether to use cookies.
 session.use_cookies = 1
index 8d2345b1f0b7284d0a9d0494a317e40776122b82..a5bb15f0ac798ecdbf0e7b0cadbe96eb557d5616 100644 (file)
@@ -825,7 +825,7 @@ session.save_handler = files
 ; Argument passed to save_handler.  In the case of files, this is the path
 ; where data files are stored. Note: Windows users have to change this 
 ; variable in order to use PHP's session functions.
-session.save_path = /tmp
+;session.save_path = /tmp
 
 ; Whether to use cookies.
 session.use_cookies = 1