sixd Mon Aug 6 20:31:40 2007 UTC Modified files: /php-src/ext/oci8 oci8.c php_oci8_int.h Log: flush persistent connection after password change http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8.c?r1=1.335&r2=1.336&diff_format=u Index: php-src/ext/oci8/oci8.c diff -u php-src/ext/oci8/oci8.c:1.335 php-src/ext/oci8/oci8.c:1.336 --- php-src/ext/oci8/oci8.c:1.335 Thu Aug 2 22:49:58 2007 +++ php-src/ext/oci8/oci8.c Mon Aug 6 20:31:40 2007 @@ -26,7 +26,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.335 2007/08/02 22:49:58 sixd Exp $ */ +/* $Id: oci8.c,v 1.336 2007/08/06 20:31:40 sixd Exp $ */ /* TODO * * file://localhost/www/docs/oci10/ociaahan.htm#423823 - implement lob_empty() with OCI_ATTR_LOBEMPTY @@ -674,7 +674,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); php_info_print_table_row(2, "Version", "1.2.2"); - php_info_print_table_row(2, "Revision", "$Revision: 1.335 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.336 $"); snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent)); php_info_print_table_row(2, "Active Persistent Connections", buf); @@ -1238,6 +1238,9 @@ connection->next_ping = 0; } + /* mark password as unchanged by PHP during the duration of the database session */ + connection->passwd_changed = 0; + smart_str_free_ex(&hashed_details, 0); /* allocate environment handle */ @@ -1609,6 +1612,7 @@ PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } + connection->passwd_changed = 1; return 0; } /* }}} */ @@ -1848,7 +1852,7 @@ if (connection->used_this_request) { if ((PG(connection_status) & PHP_CONNECTION_TIMEOUT) || OCI_G(in_call)) { - return 1; + return ZEND_HASH_APPLY_REMOVE; } if (connection->descriptors) { @@ -1861,6 +1865,18 @@ php_oci_connection_rollback(connection TSRMLS_CC); } + /* If oci_password_change() changed the password of a + * persistent connection, close the connection and remove + * it from the persistent connection cache. This means + * subsequent scripts will be prevented from being able to + * present the old (now invalid) password to a usable + * connection to the database; they must use the new + * password. + */ + if (connection->passwd_changed) { + return ZEND_HASH_APPLY_REMOVE; + } + if (OCI_G(persistent_timeout) > 0) { connection->idle_expiry = timestamp + OCI_G(persistent_timeout); } @@ -1876,11 +1892,11 @@ } else if (OCI_G(persistent_timeout) != -1) { if (connection->idle_expiry < timestamp) { /* connection has timed out */ - return 1; + return ZEND_HASH_APPLY_REMOVE; } } } - return 0; + return ZEND_HASH_APPLY_KEEP; } /* }}} */ #ifdef ZTS http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.36&r2=1.37&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.36 php-src/ext/oci8/php_oci8_int.h:1.37 --- php-src/ext/oci8/php_oci8_int.h:1.36 Tue Jul 31 19:19:39 2007 +++ php-src/ext/oci8/php_oci8_int.h Mon Aug 6 20:31:40 2007 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_oci8_int.h,v 1.36 2007/07/31 19:19:39 tony2001 Exp $ */ +/* $Id: php_oci8_int.h,v 1.37 2007/08/06 20:31:40 sixd Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -117,6 +117,7 @@ unsigned is_persistent:1; /* self-descriptive */ unsigned used_this_request:1; /* helps to determine if we should reset connection's next ping time and check its timeout */ unsigned needs_commit:1; /* helps to determine if we should rollback this connection on close/shutdown */ + unsigned passwd_changed:1; /* helps determine if a persistent connection hash should be invalidated after a password change */ int rsrc_id; /* resource ID */ time_t idle_expiry; /* time when the connection will be considered as expired */ time_t next_ping; /* time of the next ping */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php