CVS update: php31/main
| From: | shane | Date: | Sun, 23 Aug 1998 06:29:13 +0000 |
| Subject: | CVS update: php31/main | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-522@lists.php.net to get a copy of this message | ||
Date: Sunday August 23, 1998 @ 2:29
Author: shane
Update of /repository/php31/main
In directory asf:/tmp/cvs-serv4028/main
Modified Files:
head.c main.c
Log Message:
optimize authentication and move it back into php core.
Index: php31/main/head.c
diff -c php31/main/head.c:2.3 php31/main/head.c:2.4
*** php31/main/head.c:2.3 Fri Aug 14 13:30:06 1998
--- php31/main/head.c Sun Aug 23 02:29:13 1998
***************
*** 26,32 ****
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: head.c,v 2.3 1998/08/14 17:30:06 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 26,32 ----
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: head.c,v 2.4 1998/08/23 06:29:13 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 40,45 ****
--- 40,46 ----
#include "ext/standard/datetime.h"
#include "head.h"
#include "post.h"
+ #include "ext/standard/base64.h"
#ifdef TM_IN_SYS_TIME
#include <sys/time.h>
#else
***************
*** 275,280 ****
--- 276,324 ----
}
}
+ void php3_treat_headers(INLINE_TLS_VOID)
+ {
+ int len;
+ char *escaped_str, *decoded, *r, *password, *authinfo, *auth;
+
+ if (!GLOBAL(sapi_rqst)->authorization){
+ return;
+ }
+ authinfo=GLOBAL(sapi_rqst)->authorization;
+
+ if (strncmp("Basic ", authinfo, 6)) {
+ return;
+ }
+ auth = authinfo + 6;
+ decoded = _php3_base64_decode(auth, strlen(auth), &len);
+ r = strchr(decoded, ':');
+ if (r) {
+ *r = '\0';
+ password = r + 1;
+
+ if (decoded) {
+ if (GLOBAL(php3_ini)->magic_quotes_gpc) {
+ len = strlen(decoded);
+ escaped_str = _php3_addslashes(decoded, 0, &len, 0);
+ SET_VAR_STRINGL("PHP_AUTH_USER", escaped_str, len);
+ } else {
+ SET_VAR_STRING("PHP_AUTH_USER", estrdup(decoded));
+ }
+ }
+ if (password) {
+ if (GLOBAL(php3_ini)->magic_quotes_gpc) {
+ len = strlen(password);
+ escaped_str = _php3_addslashes(password, 0, &len, 0);
+ SET_VAR_STRINGL("PHP_AUTH_PW", escaped_str, len);
+ } else {
+ SET_VAR_STRING("PHP_AUTH_PW", estrdup(password));
+ }
+ }
+ *r = ':';
+ efree(decoded);
+ }
+ SET_VAR_STRING("PHP_AUTH_TYPE", estrdup("Basic"));
+ }
function_entry php3_header_functions[] = {
{"setcookie", php3_SetCookie, NULL},
Index: php31/main/main.c
diff -c php31/main/main.c:2.21 php31/main/main.c:2.22
*** php31/main/main.c:2.21 Sat Aug 22 19:33:10 1998
--- php31/main/main.c Sun Aug 23 02:29:13 1998
***************
*** 29,35 ****
+----------------------------------------------------------------------+
*/
! /* $Id: main.c,v 2.21 1998/08/22 23:33:10 shane Exp $ */
/* #define CRASH_DETECTION */
--- 29,35 ----
+----------------------------------------------------------------------+
*/
! /* $Id: main.c,v 2.22 1998/08/23 06:29:13 shane Exp $ */
/* #define CRASH_DETECTION */
***************
*** 129,134 ****
--- 129,135 ----
void _php3_build_argv(char *);
static void php3_timeout(int dummy);
static void php3_set_timeout(long seconds INLINE_TLS);
+ extern void php3_treat_headers(INLINE_TLS_VOID);
#if defined(CRASH_DETECTION)
/******************************************************************************
***************
*** 1590,1596 ****
return FAILURE;
}
! GLOBAL(sapi_rqst)->treat_headers(SAPI_GLOBAL_PASS_V);
#if defined(CRASH_DETECTION)
debug_log("%d:request startup success\n",GetCurrentThreadId());
--- 1591,1598 ----
return FAILURE;
}
! // GLOBAL(sapi_rqst)->treat_headers(SAPI_GLOBAL_PASS_V);
! php3_treat_headers(_INLINE_TLS_VOID);
#if defined(CRASH_DETECTION)
debug_log("%d:request startup success\n",GetCurrentThreadId());
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net