summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/config.w32.h2
-rw-r--r--main/fopen_wrappers.c4
-rw-r--r--main/php.h1
-rw-r--r--main/safe_mode.c31
4 files changed, 23 insertions, 15 deletions
diff --git a/main/config.w32.h b/main/config.w32.h
index 50f783940a..7292eed378 100644
--- a/main/config.w32.h
+++ b/main/config.w32.h
@@ -162,7 +162,7 @@
#define HAVE_ASSERT_H 1
#define HAVE_FCNTL_H 1
#define HAVE_GRP_H 0
-#define HAVE_PWD_H 1
+#undef HAVE_PWD_H
#define HAVE_STRING_H 1
#undef HAVE_SYS_FILE_H
#undef HAVE_SYS_SOCKET_H
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 22c8c1f714..4c946a4ea2 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -46,12 +46,8 @@
#include "php_network.h"
#if HAVE_PWD_H
-#ifdef PHP_WIN32
-#include "win32/pwd.h"
-#else
#include <pwd.h>
#endif
-#endif
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
diff --git a/main/php.h b/main/php.h
index 0b4fd3306a..6ff3bfe7da 100644
--- a/main/php.h
+++ b/main/php.h
@@ -199,7 +199,6 @@ char *strerror(int);
#if HAVE_PWD_H
# ifdef PHP_WIN32
-#include "win32/pwd.h"
#include "win32/param.h"
# else
#include <pwd.h>
diff --git a/main/safe_mode.c b/main/safe_mode.c
index 3753e90ffb..e66b43f12d 100644
--- a/main/safe_mode.c
+++ b/main/safe_mode.c
@@ -197,7 +197,6 @@ PHPAPI int php_checkuid(const char *filename, const char *fopen_mode, int mode)
PHPAPI char *php_get_current_user()
{
- struct passwd *pwd;
struct stat *pstat;
TSRMLS_FETCH();
@@ -213,15 +212,29 @@ PHPAPI char *php_get_current_user()
if (!pstat) {
return "";
- }
+ } else {
+#ifdef PHP_WIN32
+ char name[256];
+ DWORD len = sizeof(name)-1;
- if ((pwd=getpwuid(pstat->st_uid))==NULL) {
- return "";
- }
- 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 SG(request_info).current_user;
+ if (!GetUserName(name, &len)) {
+ return "";
+ }
+ name[len] = '\0';
+ SG(request_info).current_user_length = len;
+ SG(request_info).current_user = estrndup(name, len);
+ return SG(request_info).current_user;
+#else
+ struct passwd *pwd;
+
+ if ((pwd=getpwuid(pstat->st_uid))==NULL) {
+ return "";
+ }
+ 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 SG(request_info).current_user;
+#endif
+ }
}
/*