CVS update: php31/main
| From: | shane | Date: | Sun, 30 Aug 1998 06:45:23 +0000 |
| Subject: | CVS update: php31/main | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-660@lists.php.net to get a copy of this message | ||
Date: Sunday August 30, 1998 @ 2:45
Author: shane
Update of /repository/php31/main
In directory asf:/u2/tmp/cvs-serv20306/main
Modified Files:
main.c php3_hash.c phpsapi_core.dsp safe_mode.c
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/main/main.c
diff -c php31/main/main.c:2.29 php31/main/main.c:2.30
*** php31/main/main.c:2.29 Fri Aug 28 16:40:28 1998
--- php31/main/main.c Sun Aug 30 02:45:21 1998
***************
*** 29,35 ****
+----------------------------------------------------------------------+
*/
! /* $Id: main.c,v 2.29 1998/08/28 20:40:28 shane Exp $ */
/* #define CRASH_DETECTION */
--- 29,35 ----
+----------------------------------------------------------------------+
*/
! /* $Id: main.c,v 2.30 1998/08/30 06:45:21 shane Exp $ */
/* #define CRASH_DETECTION */
***************
*** 1659,1666 ****
--- 1659,1686 ----
#if defined(CRASH_DETECTION)
debug_log("%d:begin parse\n",GetCurrentThreadId());
#endif
+
+ #if defined(USE_EXCEPTION)
+ __try{
+ /*use an exception handler here to try and protect
+ against dl's that may be bad*/
+ #endif
+
if(in)GLOBAL(phpin)=in;
php3_parse(GLOBAL(phpin) _INLINE_TLS);
+
+ #if defined(USE_EXCEPTION)
+ } __except(EXCEPTION_EXECUTE_HANDLER) {
+ int i=0; /*dummy statement*/
+ #if MSVC5
+ char logmessage[80];
+ snprintf(logmessage, 79, "%d:php3_parse exception\n", GetCurrentThreadId());
+ OutputDebugString(logmessage);
+ #endif
+ /*lets let this request try to shut down normaly*/
+ }
+ #endif
+
#if defined(CRASH_DETECTION)
debug_log("%d:parse done\n",GetCurrentThreadId());
#endif
Index: php31/main/php3_hash.c
diff -c php31/main/php3_hash.c:2.1 php31/main/php3_hash.c:2.2
*** php31/main/php3_hash.c:2.1 Thu Aug 13 19:51:12 1998
--- php31/main/php3_hash.c Sun Aug 30 02:45:22 1998
***************
*** 29,35 ****
*/
! /* $Id: php3_hash.c,v 2.1 1998/08/13 23:51:12 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 29,35 ----
*/
! /* $Id: php3_hash.c,v 2.2 1998/08/30 06:45:22 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 942,947 ****
--- 942,948 ----
if (p) {
if (p->arKey) {
+ /*FIXME 11 bytes a leaking*/
*str_index = (char *) pemalloc(p->nKeyLength,ht->persistent);
memcpy(*str_index, p->arKey, p->nKeyLength);
return HASH_KEY_IS_STRING;
Index: php31/main/phpsapi_core.dsp
diff -c php31/main/phpsapi_core.dsp:2.8 php31/main/phpsapi_core.dsp:2.9
*** php31/main/phpsapi_core.dsp:2.8 Thu Aug 27 17:06:47 1998
--- php31/main/phpsapi_core.dsp Sun Aug 30 02:45:23 1998
***************
*** 317,343 ****
# End Source File
# Begin Source File
! SOURCE=..\os\nt\flock.c
! # End Source File
! # Begin Source File
!
! SOURCE=..\os\nt\flock.h
# End Source File
# Begin Source File
! SOURCE=..\os\nt\grp.h
# End Source File
# Begin Source File
! SOURCE=..\os\nt\param.h
# End Source File
# Begin Source File
! SOURCE=..\os\nt\pwd.c
# End Source File
# Begin Source File
! SOURCE=..\os\nt\pwd.h
# End Source File
# Begin Source File
--- 317,339 ----
# End Source File
# Begin Source File
! SOURCE=..\os\nt\fileaccess.c
# End Source File
# Begin Source File
! SOURCE=..\os\nt\fileaccess.h
# End Source File
# Begin Source File
! SOURCE=..\os\nt\flock.c
# End Source File
# Begin Source File
! SOURCE=..\os\nt\flock.h
# End Source File
# Begin Source File
! SOURCE=..\os\nt\param.h
# End Source File
# Begin Source File
***************
*** 354,363 ****
# Begin Source File
SOURCE=..\os\nt\sendmail.h
- # End Source File
- # Begin Source File
-
- SOURCE=..\os\nt\signal.h
# End Source File
# Begin Source File
--- 350,355 ----
Index: php31/main/safe_mode.c
diff -c php31/main/safe_mode.c:2.0 php31/main/safe_mode.c:2.1
*** php31/main/safe_mode.c:2.0 Fri Jul 3 09:17:30 1998
--- php31/main/safe_mode.c Sun Aug 30 02:45:23 1998
***************
*** 26,32 ****
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: safe_mode.c,v 2.0 1998/07/03 13:17:30 rasmus Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
--- 26,32 ----
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: safe_mode.c,v 2.1 1998/08/30 06:45:23 shane Exp $ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
***************
*** 41,46 ****
--- 41,49 ----
#include <sys/stat.h>
#include "ext/standard/pageinfo.h"
#include "safe_mode.h"
+ #if (WIN32|WINNT)
+ #include "os/nt/fileaccess.h"
+ #endif
/*
* _php3_checkuid
***************
*** 55,61 ****
--- 58,68 ----
PHPAPI int _php3_checkuid(const char *fn, int mode) {
struct stat sb;
int ret;
+ #if (WIN32|WINNT)
+ PSID uid=NULL, duid=NULL;
+ #else
long uid=0L, duid=0L;
+ #endif
char *s;
if (!fn) return(0); /* path must be provided */
***************
*** 72,79 ****
--- 79,94 ----
ret = stat(fn,&sb);
if (ret<0 && mode < 2) return(mode);
if (ret>-1) {
+ #if (WIN32|WINNT)
+ uid=GetFileOwner((LPTSTR)fn);
+ if (EqualSid(uid,_php3_getuid())){
+ LocalFree(uid);
+ return(1);
+ }
+ #else
uid=sb.st_uid;
if (uid==_php3_getuid()) return(1);
+ #endif
}
}
s = strrchr(fn,'/');
***************
*** 88,132 ****
if (s) {
*s='\0';
ret = stat(fn,&sb);
*s='/';
if (ret<0) return(0);
duid = sb.st_uid;
} else {
s = emalloc(MAXPATHLEN+1);
if (!getcwd(s,MAXPATHLEN)) return(0);
ret = stat(s,&sb);
efree(s);
if (ret<0) return(0);
duid = sb.st_uid;
}
if (duid == _php3_getuid()) return(1);
! else return(0);
}
PHPAPI char *_php3_get_current_user()
{
struct stat statbuf;
struct passwd *pwd;
! int uid;
TLS_VARS;
if (GLOBAL(sapi_rqst)->current_user) {
return GLOBAL(sapi_rqst)->current_user;
}
! /* FIXME: Apache was getting this from php3_rqst->finfo.st_uid */
! if (!GLOBAL(sapi_rqst)->filename || (stat(GLOBAL(sapi_rqst)->filename,&statbuf)==-1)) {
return empty_string;
}
- uid = statbuf.st_uid;
if ((pwd=getpwuid(uid))==NULL) {
return empty_string;
}
GLOBAL(sapi_rqst)->current_user_length = strlen(pwd->pw_name);
GLOBAL(sapi_rqst)->current_user =
estrndup(pwd->pw_name,GLOBAL(sapi_rqst)->current_user_length);
return GLOBAL(sapi_rqst)->current_user;
}
--- 103,183 ----
if (s) {
*s='\0';
+ #if (WIN32|WINNT)
+ duid=GetFileOwner((LPTSTR)fn);
+ *s='/';
+ #else
ret = stat(fn,&sb);
*s='/';
if (ret<0) return(0);
duid = sb.st_uid;
+ #endif
} else {
s = emalloc(MAXPATHLEN+1);
if (!getcwd(s,MAXPATHLEN)) return(0);
+ #if (WIN32|WINNT)
+ duid=GetFileOwner((LPTSTR)fn);
+ efree(s);
+ #else
ret = stat(s,&sb);
efree(s);
if (ret<0) return(0);
duid = sb.st_uid;
+ #endif
}
+ #if (WIN32|WINNT)
+ if (EqualSid(duid,_php3_getuid())){
+ LocalFree(duid);
+ return(1);
+ }
+ #else
if (duid == _php3_getuid()) return(1);
! #endif
! return(0);
}
PHPAPI char *_php3_get_current_user()
{
+ #if (WIN32|WINNT)
+ PSID uid=NULL;
+ char *username=NULL;
+ #else
struct stat statbuf;
struct passwd *pwd;
! long uid;
! #endif
TLS_VARS;
if (GLOBAL(sapi_rqst)->current_user) {
return GLOBAL(sapi_rqst)->current_user;
}
! #if (WIN32|WINNT)
! if (!GLOBAL(sapi_rqst)->filename ||
!(uid=GetFileOwner((LPTSTR)GLOBAL(sapi_rqst)->filename))) {
return empty_string;
}
+ username=GetACLUserName(uid);
+ GLOBAL(sapi_rqst)->current_user_length = strlen(username);
+ GLOBAL(sapi_rqst)->current_user =
estrndup(username,GLOBAL(sapi_rqst)->current_user_length);
+ free(username);
+ LocalFree(uid);
+ #else
+ if(sapi_info->page_uid<0){
+ if (!GLOBAL(sapi_rqst)->filename || (stat(GLOBAL(sapi_rqst)->filename,&statbuf)==-1))
{
+ return empty_string;
+ }
+ uid = statbuf.st_uid;
+ }else{
+ uid=sapi_info->page_uid;
+ }
if ((pwd=getpwuid(uid))==NULL) {
return empty_string;
}
GLOBAL(sapi_rqst)->current_user_length = strlen(pwd->pw_name);
GLOBAL(sapi_rqst)->current_user =
estrndup(pwd->pw_name,GLOBAL(sapi_rqst)->current_user_length);
+ #endif
return GLOBAL(sapi_rqst)->current_user;
}
--
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