# include "config.h"
#endif /* HAVE_CONFIG_H */
-#include <windows.h>
-#include <security.h>
+#define _POSIX
+#include <io.h>
+#include <lmcons.h>
#include "Evil.h"
#include "pwd.h"
static struct passwd pw;
struct passwd *
-getpwuid (uid_t uid)
+getpwnam(const char *n)
{
- static char user_name[PATH_MAX];
- TCHAR name[PATH_MAX];
- ULONG length;
+ static char user_name[UNLEN + 1];
+ TCHAR name[UNLEN + 1];
+ DWORD length;
BOOLEAN res;
#ifdef UNICODE
char *a_name;
# endif /* UNICODE */
- length = PATH_MAX;
-#ifdef _WIN32_WINNT
- res = GetUserNameEx(NameDisplay, name, &length);
-#else
- res = GetUserNameEx(NameWindowsCeLocal, name, &length);
-#endif
+ length = UNLEN + 1;
+ res = GetUserName(name, &length);
+ if (!res)
+ return NULL;
+
#ifdef UNICODE
- if (res)
+ a_name = evil_wchar_to_char(name);
+ if (a_name)
{
- a_name = evil_wchar_to_char(name);
- if (a_name)
- {
- int l;
+ int l;
- l = strlen(a_name);
- if (l >= PATH_MAX)
- l = PATH_MAX;
- memcpy(user_name, a_name, l);
- user_name[l] = '\0';
- free(a_name);
- }
- else
- res = 0;
+ l = strlen(a_name);
+ if (l >= PATH_MAX)
+ l = PATH_MAX;
+ memcpy(user_name, a_name, l);
+ user_name[l] = '\0';
+ free(a_name);
}
+ else
+ return NULL;
+#else
+ memcpy(user_name, name, strlen(name) + 1);
#endif /* UNICODE */
+
+ if (strcmp(n, user_name) != 0)
+ return NULL;
+
pw.pw_name = (res ? user_name : NULL);
pw.pw_passwd = NULL;
- pw.pw_uid = uid;
+ pw.pw_uid = 0;
pw.pw_gid = 0;
pw.pw_change = 0;
pw.pw_class = NULL;
return &pw;
}
+
+struct passwd *
+getpwuid(uid_t uid)
+{
+ return getpwnam(getlogin());
+ (void)uid;
+}
struct passwd {
char *pw_name; /**< user name */
char *pw_passwd; /**< encrypted password (always @c NULL) */
- uid_t pw_uid; /**< user uid */
- gid_t pw_gid; /**< user gid (always O) */
+ uid_t pw_uid; /**< user uid (always 0) */
+ gid_t pw_gid; /**< user gid (always 0) */
time_t pw_change; /**< password change time (always 0) */
char *pw_class; /**< user access class (always @c NULL) */
char *pw_gecos; /**< Honeywell login info */
char *pw_dir; /**< home directory */
char *pw_shell; /**< default shell */
- time_t pw_expire; /**< account expiration (always O) */
- int pw_fields; /**< internal: fields filled in (always O) */
+ time_t pw_expire; /**< account expiration (always 0) */
+ int pw_fields; /**< internal: fields filled in (always 0) */
};
/**
* @brief Return a passwd structure.
*
- * @param uid The User ID
+ * @param n The name of the user.
+ * @return A stacally allocated passwd structure.
+ *
+ * This function fills a static buffer @ref passwd with the user name @p n.
+ *
+ * Conformity: None.
+ *
+ * Supported OS: Windows XP.
+ */
+EAPI struct passwd *getpwnam(const char *n);
+
+/**
+ * @brief Return a passwd structure.
+ *
+ * @param uid The User ID.
* @return A stacally allocated passwd structure.
*
* This function fills a static buffer @ref passwd with @p uid and the
*
* Conformity: None.
*
- * Supported OS: Windows XP, CE.
+ * Supported OS: Windows XP.
*/
EAPI struct passwd *getpwuid (uid_t uid);