cvs: /php4 SAPI.c SAPI.h safe_mode.c /php4/ext/standard pageinfo.c /php4/sapi/apache mod_php4.c

From: Date: Thu, 10 Feb 2000 18:19:35 +0000
Subject: cvs: /php4 SAPI.c SAPI.h safe_mode.c /php4/ext/standard pageinfo.c /php4/sapi/apache mod_php4.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-10050@lists.php.net to get a copy of this message
zeev Thu Feb 10 10:19:35 2000 EDT Modified files: /php4 SAPI.c SAPI.h safe_mode.c /php4/ext/standard pageinfo.c /php4/sapi/apache mod_php4.c Log: More cleanup! Index: php4/SAPI.c diff -u php4/SAPI.c:1.46 php4/SAPI.c:1.47 --- php4/SAPI.c:1.46 Thu Feb 10 09:54:59 2000 +++ php4/SAPI.c Thu Feb 10 10:19:02 2000 @@ -385,21 +385,17 @@ } } -SAPI_API int sapi_get_uid() +SAPI_API struct stat *sapi_get_stat() { SLS_FETCH(); - if (sapi_module.get_uid) { - return sapi_module.get_uid(SLS_C); + if (sapi_module.get_stat) { + return sapi_module.get_stat(SLS_C); } else { - struct stat statbuf; - - if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated, &statbuf)==-1)) { - return -1; + if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated, &SG(global_stat))==-1)) { + return NULL; } - - stat(SG(request_info).path_translated, &statbuf); - return statbuf.st_uid; + return &SG(global_stat); } } Index: php4/SAPI.h diff -u php4/SAPI.h:1.32 php4/SAPI.h:1.33 --- php4/SAPI.h:1.32 Thu Feb 10 09:54:59 2000 +++ php4/SAPI.h Thu Feb 10 10:19:02 2000 @@ -23,6 +23,7 @@ #include "zend.h" #include "zend_llist.h" #include "zend_operators.h" +#include <sys/stat.h> #define SAPI_POST_BLOCK_SIZE 4000 @@ -84,6 +85,7 @@ sapi_headers_struct sapi_headers; uint read_post_bytes; unsigned char headers_sent; + struct stat global_stat; } sapi_globals_struct; @@ -127,7 +129,7 @@ SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(char *content_type_dup SLS_DC)); SAPI_API int sapi_flush(); -SAPI_API int sapi_get_uid(); +SAPI_API struct stat *sapi_get_stat(); SAPI_API char *sapi_getenv(char *name, int name_len); struct _sapi_module_struct { @@ -141,7 +143,7 @@ int (*ub_write)(const char *str, unsigned int str_length); void (*flush)(void *server_context); - int (*get_uid)(SLS_D); + struct stat *(*get_stat)(SLS_D); char *(*getenv)(char *name, int name_len SLS_DC); void (*sapi_error)(int type, const char *error_msg, ...); Index: php4/safe_mode.c diff -u php4/safe_mode.c:1.13 php4/safe_mode.c:1.14 --- php4/safe_mode.c:1.13 Thu Feb 10 09:26:55 2000 +++ php4/safe_mode.c Thu Feb 10 10:19:02 2000 @@ -15,7 +15,7 @@ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: safe_mode.c,v 1.13 2000/02/10 17:26:55 zeev Exp $ */ +/* $Id: safe_mode.c,v 1.14 2000/02/10 18:19:02 zeev Exp $ */ #include "php.h" @@ -111,7 +111,7 @@ PHPAPI char *php_get_current_user() { struct passwd *pwd; - int uid; + struct stat *pstat; SLS_FETCH(); if (request_info.current_user) { @@ -122,13 +122,13 @@ USE_SAPI is defined, because cgi will also be interfaced in USE_SAPI */ - uid = sapi_get_uid(); + pstat = sapi_get_stat(); - if (uid==-1) { + if (!pstat) { return empty_string; } - if ((pwd=getpwuid(uid))==NULL) { + if ((pwd=getpwuid(pstat->st_uid))==NULL) { return empty_string; } request_info.current_user_length = strlen(pwd->pw_name); Index: php4/ext/standard/pageinfo.c diff -u php4/ext/standard/pageinfo.c:1.13 php4/ext/standard/pageinfo.c:1.14 --- php4/ext/standard/pageinfo.c:1.13 Fri Dec 31 17:31:52 1999 +++ php4/ext/standard/pageinfo.c Thu Feb 10 10:19:03 2000 @@ -15,7 +15,7 @@ | Authors: Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: pageinfo.c,v 1.13 2000/01/01 01:31:52 sas Exp $ */ +/* $Id: pageinfo.c,v 1.14 2000/02/10 18:19:03 zeev Exp $ */ #include "php.h" #include "pageinfo.h" @@ -40,52 +40,24 @@ #include "ext/standard/basic_functions.h" -static void php_statpage(void) +static void php_statpage(BLS_D) { -#if !APACHE - char *path; - struct stat sb; - BLS_FETCH(); -#else - request_rec *r; - BLS_FETCH(); - SLS_FETCH(); - - r = ((request_rec *) SG(server_context)); -#endif - -#if APACHE - /* Apache has already gone through the trouble of doing - the stat(), so the only real overhead is copying three - values. We can afford it, and it means we don't have to - worry about resetting the static variables after every - hit. */ - BG(page_uid) = r ->finfo.st_uid; - BG(page_inode) = r->finfo.st_ino; - BG(page_mtime) = r->finfo.st_mtime; -#else - if (BG(page_uid) == -1) { - SLS_FETCH(); + struct stat *pstat; - path = SG(request_info).path_translated; - if (path != NULL) { - if (stat(path, &sb) == -1) { - php_error(E_WARNING, "Unable to find file: '%s'", path); - return; - } - BG(page_uid) = sb.st_uid; - BG(page_inode) = sb.st_ino; - BG(page_mtime) = sb.st_mtime; - } + pstat = sapi_get_stat(); + + if (BG(page_uid)==-1) { + BG(page_uid) = pstat->st_uid; + BG(page_inode) = pstat->st_ino; + BG(page_mtime) = pstat->st_mtime; } -#endif } long php_getuid(void) { BLS_FETCH(); - php_statpage(); + php_statpage(BLS_C); return (BG(page_uid)); } @@ -125,7 +97,7 @@ { BLS_FETCH(); - php_statpage(); + php_statpage(BLS_C); if (BG(page_inode) < 0) { RETURN_FALSE; } else { @@ -140,7 +112,7 @@ { BLS_FETCH(); - php_statpage(); + php_statpage(BLS_C); if (BG(page_mtime) < 0) { RETURN_FALSE; } else { Index: php4/sapi/apache/mod_php4.c diff -u php4/sapi/apache/mod_php4.c:1.25 php4/sapi/apache/mod_php4.c:1.26 --- php4/sapi/apache/mod_php4.c:1.25 Thu Feb 10 09:55:00 2000 +++ php4/sapi/apache/mod_php4.c Thu Feb 10 10:19:04 2000 @@ -17,7 +17,7 @@ | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php4.c,v 1.25 2000/02/10 17:55:00 zeev Exp $ */ +/* $Id: mod_php4.c,v 1.26 2000/02/10 18:19:04 zeev Exp $ */ #include "zend.h" #include "php.h" @@ -300,9 +300,9 @@ } -static int php_apache_get_uid(SLS_D) +static struct stat *php_apache_get_stat(SLS_D) { - return ((request_rec *) SG(server_context))->finfo.st_uid; + return &((request_rec *) SG(server_context))->finfo; } @@ -325,7 +325,7 @@ sapi_apache_ub_write, /* unbuffered write */ sapi_apache_flush, /* flush */ - php_apache_get_uid, /* get uid */ + php_apache_get_stat, /* get uid */ php_apache_getenv, /* getenv */ php_error, /* error handler */

« previous php.version4 (#10050) next »