pajoye                                   Tue, 08 Jun 2010 13:46:19 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=300277

Log:
- [DOC] add session.entropy* support to windows

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/session/tests/020.phpt
    U   php/php-src/branches/PHP_5_3/php.ini-development
    U   php/php-src/branches/PHP_5_3/php.ini-production
    U   php/php-src/trunk/ext/session/session.c
    U   php/php-src/trunk/php.ini-development
    U   php/php-src/trunk/php.ini-production

Modified: php/php-src/branches/PHP_5_3/ext/session/tests/020.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/session/tests/020.phpt     2010-06-08 
13:27:30 UTC (rev 300276)
+++ php/php-src/branches/PHP_5_3/ext/session/tests/020.phpt     2010-06-08 
13:46:19 UTC (rev 300277)
@@ -6,7 +6,7 @@
 session.use_cookies=0
 session.cache_limiter=
 session.use_trans_sid=1
-arg_separator.output="&"
+arg_separator.output=&
 session.name=PHPSESSID
 session.serialize_handler=php
 session.save_handler=files

Modified: php/php-src/branches/PHP_5_3/php.ini-development
===================================================================
--- php/php-src/branches/PHP_5_3/php.ini-development    2010-06-08 13:27:30 UTC 
(rev 300276)
+++ php/php-src/branches/PHP_5_3/php.ini-development    2010-06-08 13:46:19 UTC 
(rev 300277)
@@ -1586,6 +1586,9 @@

 ; Specified here to create the session id.
 ; http://php.net/session.entropy-file
+; On systems that don't have /dev/urandom /dev/arandom can be used
+; On windows, setting the entropy_length setting will activate the
+; Windows random source (using the CryptoAPI)
 ;session.entropy_file = /dev/urandom
 session.entropy_file =


Modified: php/php-src/branches/PHP_5_3/php.ini-production
===================================================================
--- php/php-src/branches/PHP_5_3/php.ini-production     2010-06-08 13:27:30 UTC 
(rev 300276)
+++ php/php-src/branches/PHP_5_3/php.ini-production     2010-06-08 13:46:19 UTC 
(rev 300277)
@@ -1594,8 +1594,10 @@

 ; Specified here to create the session id.
 ; http://php.net/session.entropy-file
+; On systems that don't have /dev/urandom /dev/arandom can be used
+; On windows, setting the entropy_length setting will activate the
+; Windows random source (using the CryptoAPI)
 ;session.entropy_file = /dev/urandom
-session.entropy_file =

 ; http://php.net/session.entropy-length
 ;session.entropy_length = 16

Modified: php/php-src/trunk/ext/session/session.c
===================================================================
--- php/php-src/trunk/ext/session/session.c     2010-06-08 13:27:30 UTC (rev 
300276)
+++ php/php-src/trunk/ext/session/session.c     2010-06-08 13:46:19 UTC (rev 
300277)
@@ -26,9 +26,10 @@
 #include "php.h"

 #ifdef PHP_WIN32
-#include "win32/time.h"
+# include "win32/winutil.h"
+# include "win32/time.h"
 #else
-#include <sys/time.h>
+# include <sys/time.h>
 #endif

 #include <sys/stat.h>
@@ -328,6 +329,28 @@
        efree(buf);

        if (PS(entropy_length) > 0) {
+               unsigned char rbuf[2048];
+
+#ifdef PHP_WIN32
+               size_t toread = PS(entropy_length);
+               __debugbreak();
+               if (php_win32_get_random_bytes(rbuf, (size_t) toread) == 
SUCCESS){
+
+                       switch (PS(hash_func)) {
+                               case PS_HASH_FUNC_MD5:
+                                       PHP_MD5Update(&md5_context, rbuf, 
toread);
+                                       break;
+                               case PS_HASH_FUNC_SHA1:
+                                       PHP_SHA1Update(&sha1_context, rbuf, 
toread);
+                                       break;
+# if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH)
+                               case PS_HASH_FUNC_OTHER:
+                                       PS(hash_ops)->hash_update(hash_context, 
rbuf, toread);
+                                       break;
+# endif /* HAVE_HASH_EXT */
+                       }
+               }
+#else
                int fd;

                fd = VCWD_OPEN(PS(entropy_file), O_RDONLY);
@@ -357,6 +380,7 @@
                        }
                        close(fd);
                }
+#endif
        }

        digest = emalloc(digest_len + 1);

Modified: php/php-src/trunk/php.ini-development
===================================================================
--- php/php-src/trunk/php.ini-development       2010-06-08 13:27:30 UTC (rev 
300276)
+++ php/php-src/trunk/php.ini-development       2010-06-08 13:46:19 UTC (rev 
300277)
@@ -1495,6 +1495,8 @@
 ; Defaults to /dev/urandom
 ; On systems that don't have /dev/urandom but do have /dev/arandom, this will 
default to /dev/arandom
 ; If neither are found at compile time, the default is no entropy file.
+; On windows, setting the entropy_length setting will activate the
+; Windows random source (using the CryptoAPI)
 ;session.entropy_file = /dev/urandom

 ; http://php.net/session.entropy-length

Modified: php/php-src/trunk/php.ini-production
===================================================================
--- php/php-src/trunk/php.ini-production        2010-06-08 13:27:30 UTC (rev 
300276)
+++ php/php-src/trunk/php.ini-production        2010-06-08 13:46:19 UTC (rev 
300277)
@@ -1499,6 +1499,8 @@
 ; Defaults to /dev/urandom
 ; On systems that don't have /dev/urandom but do have /dev/arandom, this will 
default to /dev/arandom
 ; If neither are found at compile time, the default is no entropy file.
+; On windows, setting the entropy_length setting will activate the
+; Windows random source (using the CryptoAPI)
 ;session.entropy_file = /dev/urandom

 ; http://php.net/session.entropy-length

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to