[PHP-DEV] CVS update: php31/ext/standard From: shane (php-dev <email protected>)
Date: 08/30/98

Date: Sunday August 30, 1998 @ 2:45
Author: shane

Update of /repository/php31/ext/standard
In directory asf:/u2/tmp/cvs-serv20306/ext/standard

Modified Files:
        basic_functions.c dl.c pageinfo.c pageinfo.h
Log Message:
minor fixes. remove pwd.h, it didn't do anything.
added file security functions to implement safe mode on NT with NTFS

Index: php31/ext/standard/basic_functions.c
diff -c php31/ext/standard/basic_functions.c:2.9 php31/ext/standard/basic_functions.c:2.10
*** php31/ext/standard/basic_functions.c:2.9 Thu Aug 27 01:07:26 1998
--- php31/ext/standard/basic_functions.c Sun Aug 30 02:45:19 1998
***************
*** 203,209 ****
  
          {"getmyuid", php3_getmyuid, NULL},
          {"getmypid", php3_getmypid, NULL},
- {"getmyiid", php3_getmyinstanceid, NULL},
          {"getmyinode", php3_getmyinode, NULL},
          {"getlastmod", php3_getlastmod, NULL},
  
--- 203,208 ----
Index: php31/ext/standard/dl.c
diff -c php31/ext/standard/dl.c:2.5 php31/ext/standard/dl.c:2.6
*** php31/ext/standard/dl.c:2.5 Fri Aug 28 16:35:28 1998
--- php31/ext/standard/dl.c Sun Aug 30 02:45:19 1998
***************
*** 88,93 ****
--- 88,94 ----
  
          if (!GLOBAL(php3_ini)->enable_dl) {
                  php3_error(E_ERROR, "Dynamically loaded extentions aren't enabled.");
+ RETURN_FALSE;
          } else {
                  /* obtain arguments */
                  if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &file) == FAILURE) {
***************
*** 99,106 ****
                  /* FIXME HELPME we need to have some way to check if the dl is already
                  loaded before going through all this stuff. */
  
! _php3_dl(file->value.str.val,MODULE_TEMPORARY,return_value,NULL _INLINE_TLS);
          }
  }
  
  
--- 100,109 ----
                  /* FIXME HELPME we need to have some way to check if the dl is already
                  loaded before going through all this stuff. */
  
! if(_php3_dl(file->value.str.val,MODULE_TEMPORARY,return_value,NULL _INLINE_TLS)==FAILURE)
! RETURN_FALSE;
          }
+ RETURN_TRUE;
  }
  
  
***************
*** 168,177 ****
--- 171,184 ----
          if(_php3_load_module(module_entry, handle)==FAILURE){
                  return FAILURE;
          }
+
+ #ifdef THREAD_SAFE
          if(thisdl){
                  thisdl->handle=handle;
                  thisdl->module_entry=module_entry;
          }
+ #endif
+
          return SUCCESS;
  }
  
Index: php31/ext/standard/pageinfo.c
diff -c php31/ext/standard/pageinfo.c:2.0 php31/ext/standard/pageinfo.c:2.1
*** php31/ext/standard/pageinfo.c:2.0 Fri Jul 3 09:14:31 1998
--- php31/ext/standard/pageinfo.c Sun Aug 30 02:45:19 1998
***************
*** 36,42 ****
  #include <stdio.h>
  #include <stdlib.h>
  #if HAVE_PWD_H
! #if MSVC5
  #include "os/nt/pwd.h"
  #else
  #include <pwd.h>
--- 36,42 ----
  #include <stdio.h>
  #include <stdlib.h>
  #if HAVE_PWD_H
! #if (WIN32|WINNT)
  #include "os/nt/pwd.h"
  #else
  #include <pwd.h>
***************
*** 46,53 ****
  #include <unistd.h>
  #endif
  #include <sys/stat.h>
! #if MSVC5
  #include <process.h>
  #endif
  
  #ifndef THREAD_SAFE
--- 46,54 ----
  #include <unistd.h>
  #endif
  #include <sys/stat.h>
! #if (WIN32|WINNT)
  #include <process.h>
+ #include "os/nt/fileaccess.h"
  #endif
  
  #ifndef THREAD_SAFE
***************
*** 56,132 ****
  static long page_mtime = -1;
  #endif
  
! static void _php3_statpage(void)
  {
          char *path;
          struct stat sb;
- TLS_VARS;
          
          if (GLOBAL(sapi_rqst)->page_uid == -1) {
                  path = GLOBAL(sapi_rqst)->filename;
                  if (path != NULL) {
                          if (stat(path, &sb) == -1) {
                                  php3_error(E_WARNING, "Unable to find file: '%s'", path);
                                  return;
                          }
                          GLOBAL(sapi_rqst)->page_uid = sb.st_uid;
                          GLOBAL(sapi_rqst)->page_inode = sb.st_ino;
                          GLOBAL(sapi_rqst)->page_mtime = sb.st_mtime;
                  }
          }
  }
  
  PHPAPI long _php3_getuid(void)
  {
          TLS_VARS;
! if(!GLOBAL(sapi_rqst)->page_uid)_php3_statpage();
          return (GLOBAL(sapi_rqst)->page_uid);
  }
  
  void php3_getmyuid(INTERNAL_FUNCTION_PARAMETERS)
  {
          long uid;
! TLS_VARS;
          
          uid = _php3_getuid();
! if (uid < 0) {
                  RETURN_FALSE;
          } else {
! RETURN_LONG(uid);
          }
! }
!
! void php3_getmypid(INTERNAL_FUNCTION_PARAMETERS)
! {
! int pid;
! TLS_VARS;
!
! pid = getpid();
! if (pid < 0) {
                  RETURN_FALSE;
          } else {
! RETURN_LONG((long) pid);
          }
  }
  
! /*
! returns the thread id of the current request.
! if it cant get the thread id, returns the pid.
! That way, this function can be used for cross-system
! scripts that typicaly use getpid for unique id's.
! Leaving getmypid alone because there may be instances
! where someone in a threaded environment realy wants
! the pid, and not the thread id.
! */
! void php3_getmyinstanceid(INTERNAL_FUNCTION_PARAMETERS)
  {
          int pid;
- TLS_VARS;
  
  #if defined(THREAD_SAFE) && (WIN32|WINNT)
          pid = GetCurrentThreadId();
  #endif
- if(!pid)pid = getpid();
          if (pid < 0) {
                  RETURN_FALSE;
          } else {
--- 57,136 ----
  static long page_mtime = -1;
  #endif
  
! static void _php3_statpage(INLINE_TLS_VOID)
  {
          char *path;
          struct stat sb;
          
+ #if (WIN32|WINNT)
+ if (!GLOBAL(sapi_rqst)->page_uid) {
+ #else
          if (GLOBAL(sapi_rqst)->page_uid == -1) {
+ #endif
                  path = GLOBAL(sapi_rqst)->filename;
                  if (path != NULL) {
                          if (stat(path, &sb) == -1) {
                                  php3_error(E_WARNING, "Unable to find file: '%s'", path);
                                  return;
                          }
+ #if (WIN32|WINNT)
+ GLOBAL(sapi_rqst)->page_uid = GetFileOwner(path);
+ #else
                          GLOBAL(sapi_rqst)->page_uid = sb.st_uid;
+ #endif
                          GLOBAL(sapi_rqst)->page_inode = sb.st_ino;
                          GLOBAL(sapi_rqst)->page_mtime = sb.st_mtime;
                  }
          }
  }
  
+ #if (WIN32|WINNT)
+ PHPAPI PSID _php3_getuid(void)
+ #else
  PHPAPI long _php3_getuid(void)
+ #endif
  {
          TLS_VARS;
! if(!GLOBAL(sapi_rqst)->page_uid)_php3_statpage(_INLINE_TLS_VOID);
          return (GLOBAL(sapi_rqst)->page_uid);
  }
  
  void php3_getmyuid(INTERNAL_FUNCTION_PARAMETERS)
  {
+ #if WIN32|WINNT
+ PSID uid;
+ TCHAR TextualSid[512];
+ DWORD SidSize=512;
+ #else
          long uid;
! #endif
          
          uid = _php3_getuid();
! #if (WIN32|WINNT)
! GetTextualSid(uid,TextualSid,&SidSize);
! if (!uid) {
                  RETURN_FALSE;
          } else {
! RETURN_STRING(TextualSid,strlen(TextualSid));
          }
! #else
! if (uid < 0) {
                  RETURN_FALSE;
          } else {
! RETURN_LONG(uid);
          }
+ #endif
  }
  
! void php3_getmypid(INTERNAL_FUNCTION_PARAMETERS)
  {
          int pid;
  
  #if defined(THREAD_SAFE) && (WIN32|WINNT)
          pid = GetCurrentThreadId();
+ #else
+ pid = getpid();
  #endif
          if (pid < 0) {
                  RETURN_FALSE;
          } else {
***************
*** 138,144 ****
  {
          TLS_VARS;
          
! if(!GLOBAL(sapi_rqst)->page_inode)_php3_statpage();
          if (GLOBAL(sapi_rqst)->page_inode < 0) {
                  RETURN_FALSE;
          } else {
--- 142,148 ----
  {
          TLS_VARS;
          
! if(!GLOBAL(sapi_rqst)->page_inode)_php3_statpage(_INLINE_TLS_VOID);
          if (GLOBAL(sapi_rqst)->page_inode < 0) {
                  RETURN_FALSE;
          } else {
***************
*** 150,156 ****
  {
          TLS_VARS;
          
! if(!GLOBAL(sapi_rqst)->page_mtime)_php3_statpage();
          if (GLOBAL(sapi_rqst)->page_mtime < 0) {
                  RETURN_FALSE;
          } else {
--- 154,160 ----
  {
          TLS_VARS;
          
! if(!GLOBAL(sapi_rqst)->page_mtime)_php3_statpage(_INLINE_TLS_VOID);
          if (GLOBAL(sapi_rqst)->page_mtime < 0) {
                  RETURN_FALSE;
          } else {
Index: php31/ext/standard/pageinfo.h
diff -c php31/ext/standard/pageinfo.h:2.0 php31/ext/standard/pageinfo.h:2.1
*** php31/ext/standard/pageinfo.h:2.0 Fri Jul 3 09:14:31 1998
--- php31/ext/standard/pageinfo.h Sun Aug 30 02:45:20 1998
***************
*** 3,12 ****
  
  extern void php3_getmyuid(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_getmypid(INTERNAL_FUNCTION_PARAMETERS);
- extern void php3_getmyinstanceid(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_getmyinode(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_getlastmod(INTERNAL_FUNCTION_PARAMETERS);
  
  extern PHPAPI long _php3_getuid(void);
  
  #endif
--- 3,15 ----
  
  extern void php3_getmyuid(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_getmypid(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_getmyinode(INTERNAL_FUNCTION_PARAMETERS);
  extern void php3_getlastmod(INTERNAL_FUNCTION_PARAMETERS);
  
+ #if (WIN32|WINNT)
+ extern PHPAPI PSID _php3_getuid(void);
+ #else
  extern PHPAPI long _php3_getuid(void);
+ #endif
  
  #endif

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>