summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/SAPI.c7
-rw-r--r--main/SAPI.h4
-rw-r--r--main/main.c6
-rw-r--r--main/php.h2
-rw-r--r--main/safe_mode.c10
-rw-r--r--request_info.c43
-rw-r--r--request_info.h41
7 files changed, 15 insertions, 98 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index 006789a474..04000a8bb4 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -12,7 +12,7 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Design: Shane Caraveo <shane@caraveo.com> |
+ | Original design: Shane Caraveo <shane@caraveo.com> |
| Authors: Andi Gutmans <andi@zend.com> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
@@ -176,6 +176,8 @@ SAPI_API void sapi_activate(SLS_D)
SG(headers_sent) = 0;
SG(read_post_bytes) = 0;
SG(request_info).post_data = NULL;
+ SG(request_info).current_user = NULL;
+ SG(request_info).current_user_length = 0;
if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) {
SG(request_info).headers_only = 1;
@@ -205,6 +207,9 @@ SAPI_API void sapi_deactivate(SLS_D)
if (SG(request_info).post_data) {
efree(SG(request_info).post_data);
}
+ if (SG(request_info).current_user) {
+ efree(SG(request_info).current_user);
+ }
if (sapi_module.deactivate) {
sapi_module.deactivate(SLS_C);
}
diff --git a/main/SAPI.h b/main/SAPI.h
index 8b773e7e03..bb42da48e1 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -79,6 +79,10 @@ typedef struct {
/* this is necessary for the CGI SAPI module */
char *argv0;
+
+ /* this is necessary for Safe Mode */
+ char *current_user;
+ int current_user_length;
} sapi_request_info;
diff --git a/main/main.c b/main/main.c
index 558bae1e3a..03ee7ca637 100644
--- a/main/main.c
+++ b/main/main.c
@@ -625,11 +625,6 @@ int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC)
/* initialize global variables */
PG(header_is_being_sent)=0;
-
- if (php_init_request_info(NULL)) {
- php_printf("Unable to initialize request info.\n");
- return FAILURE;
- }
zend_activate(CLS_C ELS_CC);
sapi_activate(SLS_C);
@@ -674,7 +669,6 @@ void php_request_shutdown(void *dummy)
zend_deactivate(CLS_C ELS_CC);
sapi_deactivate(SLS_C);
- php_destroy_request_info(NULL);
shutdown_memory_manager(CG(unclean_shutdown), 0);
php_unset_timeout();
diff --git a/main/php.h b/main/php.h
index ff8c3c8c43..9d710dbac1 100644
--- a/main/php.h
+++ b/main/php.h
@@ -114,8 +114,6 @@ char *strtok_r(char *s, const char *delim, char **last);
typedef unsigned int socklen_t;
#endif
-#include "request_info.h"
-
#define CREATE_MUTEX(a,b)
#define SET_MUTEX(a)
#define FREE_MUTEX(a)
diff --git a/main/safe_mode.c b/main/safe_mode.c
index f274d23da8..c022d600da 100644
--- a/main/safe_mode.c
+++ b/main/safe_mode.c
@@ -114,8 +114,8 @@ PHPAPI char *php_get_current_user()
struct stat *pstat;
SLS_FETCH();
- if (request_info.current_user) {
- return request_info.current_user;
+ if (SG(request_info).current_user) {
+ return SG(request_info).current_user;
}
/* FIXME: I need to have this somehow handled if
@@ -131,8 +131,8 @@ PHPAPI char *php_get_current_user()
if ((pwd=getpwuid(pstat->st_uid))==NULL) {
return empty_string;
}
- request_info.current_user_length = strlen(pwd->pw_name);
- request_info.current_user = estrndup(pwd->pw_name,request_info.current_user_length);
+ SG(request_info).current_user_length = strlen(pwd->pw_name);
+ SG(request_info).current_user = estrndup(pwd->pw_name, SG(request_info).current_user_length);
- return request_info.current_user;
+ return SG(request_info).current_user;
}
diff --git a/request_info.c b/request_info.c
deleted file mode 100644
index 24e43453d4..0000000000
--- a/request_info.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-#include "php.h"
-#include "SAPI.h"
-
-PHPAPI php_request_info request_info;
-
-int php_destroy_request_info(void *conf)
-{
- STR_FREE(request_info.current_user);
- return SUCCESS;
-}
-
-int php_init_request_info(void *conf)
-{
- request_info.current_user = NULL;
- request_info.current_user_length = 0;
- return SUCCESS;
-}
-
-
-
-/* * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/request_info.h b/request_info.h
deleted file mode 100644
index d05cb7b3c3..0000000000
--- a/request_info.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.0 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_0.txt. |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-#ifndef _REQUEST_INFO_H_
-#define _REQUEST_INFO_H_
-
-typedef struct {
- char *current_user;
- int current_user_length;
- const char *script_filename;
-} php_request_info;
-
-#ifndef THREAD_SAFE
-PHPAPI extern php_request_info request_info;
-#endif
-
-extern int php_init_request_info(void *conf);
-extern int php_destroy_request_info(void *conf);
-
-#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */