summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--win32/build/config.w322
-rw-r--r--win32/build/config.w32.h.in2
-rw-r--r--win32/glob.c8
-rwxr-xr-xwin32/globals.c2
-rw-r--r--win32/php5dll.dsp8
-rw-r--r--win32/php5dllts.dsp8
-rwxr-xr-xwin32/php_win32_globals.h8
-rw-r--r--win32/pwd.c66
-rw-r--r--win32/pwd.h38
13 files changed, 31 insertions, 149 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
+ }
}
/*
diff --git a/win32/build/config.w32 b/win32/build/config.w32
index ef0c3fb2e6..3c37f9b722 100644
--- a/win32/build/config.w32
+++ b/win32/build/config.w32
@@ -264,7 +264,7 @@ ADD_SOURCES("main", "main.c snprintf.c spprintf.c safe_mode.c fopen_wrappers.c \
ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c \
userspace.c transports.c xp_socket.c mmap.c");
-ADD_SOURCES("win32", "crypt_win32.c flock.c glob.c md5crypt.c pwd.c readdir.c \
+ADD_SOURCES("win32", "crypt_win32.c flock.c glob.c md5crypt.c readdir.c \
registry.c select.c sendmail.c time.c wfile.c winutil.c wsyslog.c globals.c");
ADD_SOURCES("regex", "regcomp.c regerror.c regexec.c regfree.c");
diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in
index 512afe9177..8e472f65d2 100644
--- a/win32/build/config.w32.h.in
+++ b/win32/build/config.w32.h.in
@@ -100,7 +100,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/win32/glob.c b/win32/glob.c
index a8c2cd83e2..b369362c19 100644
--- a/win32/glob.c
+++ b/win32/glob.c
@@ -81,8 +81,6 @@
#include <dirent.h>
#include <pwd.h>
#include <unistd.h>
-#else
-#include "win32/pwd.h"
#endif
#include <errno.h>
#include "glob.h"
@@ -359,7 +357,9 @@ globtilde(pattern, patbuf, patbuf_len, pglob)
size_t patbuf_len;
glob_t *pglob;
{
+#ifndef PHP_WIN32
struct passwd *pwd;
+#endif
char *h;
const Char *p;
Char *b, *eb;
@@ -399,10 +399,14 @@ globtilde(pattern, patbuf, patbuf_len, pglob)
/*
* Expand a ~user
*/
+#ifndef PHP_WIN32
if ((pwd = getpwnam((char*) patbuf)) == NULL)
return pattern;
else
h = pwd->pw_dir;
+#else
+ return pattern;
+#endif
}
/* Copy the home directory */
diff --git a/win32/globals.c b/win32/globals.c
index eee53cb5a9..ae9120095c 100755
--- a/win32/globals.c
+++ b/win32/globals.c
@@ -43,8 +43,6 @@ PHP_RSHUTDOWN_FUNCTION(win32_core_globals)
#endif
;
- STR_FREE(wg->login_name);
-
memset(wg, 0, sizeof(*wg));
return SUCCESS;
}
diff --git a/win32/php5dll.dsp b/win32/php5dll.dsp
index 891a0438f0..24e4227a04 100644
--- a/win32/php5dll.dsp
+++ b/win32/php5dll.dsp
@@ -1552,10 +1552,6 @@ SOURCE=..\ext\com\conversion.c
# End Source File
# Begin Source File
-SOURCE=..\win32\pwd.c
-# End Source File
-# Begin Source File
-
SOURCE=..\win32\readdir.c
# End Source File
# Begin Source File
@@ -1628,10 +1624,6 @@ SOURCE=..\ext\com\php_versioning.h
# End Source File
# Begin Source File
-SOURCE=..\win32\pwd.h
-# End Source File
-# Begin Source File
-
SOURCE=..\win32\readdir.h
# End Source File
# Begin Source File
diff --git a/win32/php5dllts.dsp b/win32/php5dllts.dsp
index 3a2c194c6f..d9bf1882a1 100644
--- a/win32/php5dllts.dsp
+++ b/win32/php5dllts.dsp
@@ -2391,10 +2391,6 @@ SOURCE=.\md5crypt.c
# End Source File
# Begin Source File
-SOURCE=..\win32\pwd.c
-# End Source File
-# Begin Source File
-
SOURCE=..\win32\readdir.c
# End Source File
# Begin Source File
@@ -2480,10 +2476,6 @@ SOURCE=..\win32\php_registry.h
# End Source File
# Begin Source File
-SOURCE=..\win32\pwd.h
-# End Source File
-# Begin Source File
-
SOURCE=..\win32\readdir.h
# End Source File
# Begin Source File
diff --git a/win32/php_win32_globals.h b/win32/php_win32_globals.h
index 89caed1a37..c130d5bc50 100755
--- a/win32/php_win32_globals.h
+++ b/win32/php_win32_globals.h
@@ -23,8 +23,6 @@
/* misc globals for thread-safety under win32 */
-#include "pwd.h"
-
typedef struct _php_win32_core_globals php_win32_core_globals;
#ifdef ZTS
@@ -40,12 +38,6 @@ struct _php_win32_core_globals {
char *log_header;
HANDLE log_source;
- /* getpwuid */
- struct passwd pwd;
-
- /* getlogin */
- char *login_name;
-
/* time */
struct timeval starttime;
__int64 lasttime, freq;
diff --git a/win32/pwd.c b/win32/pwd.c
deleted file mode 100644
index 092740e249..0000000000
--- a/win32/pwd.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Sterling Hughes <sterling@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php.h" /*php specific */
-#include <lmaccess.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <lmapibuf.h>
-#include "pwd.h"
-#include "grp.h"
-#include "php_win32_globals.h"
-
-static char *home_dir = ".";
-static char *login_shell = "not command.com!";
-
-struct passwd *
-getpwnam(char *name)
-{
- return (struct passwd *) 0;
-}
-
-
-char *
-getlogin()
-{
- char name[256];
- DWORD max_len = 256;
- TSRMLS_FETCH();
-
- STR_FREE(PW32G(login_name));
- GetUserName(name, &max_len);
- name[max_len] = '\0';
- PW32G(login_name) = estrdup(name);
- return PW32G(login_name);
-}
-
-struct passwd *
-getpwuid(int user_id)
-{
- TSRMLS_FETCH();
- PW32G(pwd).pw_name = getlogin();
- PW32G(pwd).pw_dir = home_dir;
- PW32G(pwd).pw_shell = login_shell;
- PW32G(pwd).pw_uid = 0;
-
- return &PW32G(pwd);
-}
-
diff --git a/win32/pwd.h b/win32/pwd.h
deleted file mode 100644
index 597f60c48c..0000000000
--- a/win32/pwd.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Sterling Hughes <sterling@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PWD_H
-#define PWD_H
-
-struct passwd {
- char *pw_name;
- char *pw_passwd;
- int pw_uid;
- int pw_gid;
- char *pw_comment;
- char *pw_gecos;
- char *pw_dir;
- char *pw_shell;
-};
-
-extern struct passwd *getpwuid(int);
-extern struct passwd *getpwnam(char *name);
-extern char *getlogin(void);
-#endif