]> granicus.if.org Git - php/commitdiff
More cleanup...
authorZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 17:26:57 +0000 (17:26 +0000)
committerZeev Suraski <zeev@php.net>
Thu, 10 Feb 2000 17:26:57 +0000 (17:26 +0000)
main/SAPI.c
main/SAPI.h
main/safe_mode.c
sapi/aolserver/aolserver.c
sapi/apache/mod_php4.c
sapi/cgi/cgi_main.c
sapi/isapi/php4isapi.c
sapi/phttpd/phttpd.c
sapi/roxen/roxen.c
sapi/servlet/servlet.c
sapi/thttpd/thttpd.c

index d1c684f1e1de89446065ff850629938372feb1db..e1b329daee5b672755a433b4aa245003aad0db42 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 #include <ctype.h>
+#include <sys/stat.h>
 
 #include "php.h"
 #include "SAPI.h"
@@ -383,3 +384,21 @@ SAPI_API int sapi_flush()
                return FAILURE;
        }
 }
+
+SAPI_API int sapi_get_uid()
+{
+       SLS_FETCH();
+
+       if (sapi_module.get_uid) {
+               return sapi_module.get_uid(SLS_C);
+       } else {
+               struct stat statbuf;
+
+               if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated, &statbuf)==-1)) {
+                       return -1;
+               }
+
+               stat(SG(request_info).path_translated, &statbuf);
+               return statbuf.st_uid;
+       }
+}
index 2b7053aea7fb5099247fc4e49d69a68d946e7e18..2b65a1a7a759b83b50f5b316a7a091505e8d1aee 100644 (file)
@@ -127,7 +127,7 @@ SAPI_API void sapi_unregister_post_reader(sapi_post_content_type_reader *post_co
 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();
 
 struct _sapi_module_struct {
        char *name;
@@ -140,6 +140,7 @@ struct _sapi_module_struct {
 
        int (*ub_write)(const char *str, unsigned int str_length);
        void (*flush)(void *server_context);
+       int (*get_uid)(SLS_D);
 
        void (*sapi_error)(int type, const char *error_msg, ...);
 
index 9704d856f94f58754b92ac68fef4bd71dd00e636..fea75ed5c867180f78703c8679282d06aab0cc0f 100644 (file)
@@ -110,9 +110,6 @@ PHPAPI int php_checkuid(const char *fn, int mode) {
 
 PHPAPI char *php_get_current_user()
 {
-#if CGI_BINARY || USE_SAPI || FHTTPD
-       struct stat statbuf;
-#endif
        struct passwd *pwd;
        int uid;
        SLS_FETCH();
@@ -124,15 +121,12 @@ PHPAPI char *php_get_current_user()
        /* FIXME: I need to have this somehow handled if
        USE_SAPI is defined, because cgi will also be
        interfaced in USE_SAPI */
-#if CGI_BINARY || USE_SAPI || FHTTPD
-       if (!SG(request_info).path_translated || (stat(SG(request_info).path_translated,&statbuf)==-1)) {
+
+       uid = sapi_get_uid();
+
+       if (uid==-1) {
                return empty_string;
        }
-       uid = statbuf.st_uid;
-#endif
-#if APACHE
-       uid = ((request_rec *) SG(server_context))->finfo.st_uid;
-#endif
 
        if ((pwd=getpwuid(uid))==NULL) {
                return empty_string;
index 7ba56d4e685ae82999b8c2f3bad4b587daa37135..d1b5dc86d8bcf990ec2b1a74e02fbec8e1dd7775 100644 (file)
@@ -302,6 +302,7 @@ static sapi_module_struct sapi_module = {
 
        php_ns_sapi_ub_write,                                   /* unbuffered write */
        NULL,                                                                   /* flush */
+       NULL,                                                                   /* get uid */
 
        php_error,                                                              /* error handler */
 
index 5d05e01f5208bddaef3254f3045cb05d116816a9..edf848dd6a6b7a29c147c547b3dc9ec9186af752 100644 (file)
@@ -300,6 +300,12 @@ static int php_apache_sapi_activate(SLS_D)
 }
 
 
+static int php_apache_get_uid(SLS_D)
+{
+       return ((request_rec *) SG(server_context))->finfo.st_uid;
+}
+
+
 static sapi_module_struct sapi_module = {
        "Apache",                                               /* name */
                                                                        
@@ -311,6 +317,7 @@ static sapi_module_struct sapi_module = {
 
        sapi_apache_ub_write,                   /* unbuffered write */
        sapi_apache_flush,                              /* flush */
+       php_apache_get_uid,                             /* get uid */
 
 
        php_error,                                              /* error handler */
index c036b8c2f1f35add145830ee08aa1e028c79f432..bf6138cd3c17ee076dea3c6f6143f4f9564fde53 100644 (file)
@@ -176,6 +176,7 @@ static int sapi_cgi_deactivate(SLS_D)
 }
 
 
+
 static sapi_module_struct sapi_module = {
        "CGI",                                                  /* name */
                                                                        
@@ -187,6 +188,7 @@ static sapi_module_struct sapi_module = {
 
        sapi_cgibin_ub_write,                   /* unbuffered write */
        sapi_cgibin_flush,                              /* flush */
+       NULL,                                                   /* get uid */
 
        php_error,                                              /* error handler */
 
index 9ef51cbb1f38a6708e9bb898876abf6b05162b01..8c4ff5c6958c14278790d79f2bfdbd2d79d63fcc 100644 (file)
@@ -350,6 +350,7 @@ static sapi_module_struct sapi_module = {
 
        sapi_isapi_ub_write,                    /* unbuffered write */
        NULL,                                                   /* flush */
+       NULL,                                                   /* get uid */
 
        php_error,                                              /* error handler */
 
index 7c98cd70a3e7f48d413cf0e0c306c1b12c158b2f..76184a7e7a7af2ed097c5e705e9edbbf0c9b77cf 100644 (file)
@@ -172,6 +172,7 @@ static sapi_module_struct sapi_module = {
 
     php_phttpd_sapi_ub_write,               /* unbuffered write */
        NULL,                                                                   /* flush */
+       NULL,                                                                   /* get uid */
  
     php_error,                              /* error handler */
  
index cff4324f9d85d85f0b9ca48c9631060b5b454a33..1d4f920e441246d0ddfaebdf915359fa99024ae0 100644 (file)
@@ -526,6 +526,7 @@ static sapi_module_struct sapi_module = {
 
   php_roxen_sapi_ub_write,                                     /* unbuffered write */
   NULL,                                                                                /* flush */
+  NULL,                                                                                /* get uid */
 
   php_error,                                                           /* error handler */
 
index 645528b86c71896e1f4a4de191ee07f901483768..4ba10f9d132440ee3b43872655641f33160434cf 100644 (file)
@@ -221,6 +221,7 @@ static sapi_module_struct sapi_module = {
 
        sapi_servlet_ub_write,                  /* unbuffered write */
        NULL,                                                   /* flush */
+       NULL,                                                   /* get uid */
 
        php_error,                                              /* error handler */
 
index 2a39f189a4b4830f30615457c7a68ad9467f0da5..4fab0c2abfeae72a60aa7aeb21469ceb93ad0c87 100644 (file)
@@ -112,6 +112,7 @@ static sapi_module_struct sapi_module = {
 
        sapi_thttpd_ub_write,
        NULL,
+       NULL,                                                                   /* get uid */
 
        php_error,