summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@univ-evry.fr>2015-02-24 15:17:29 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-24 17:21:44 +0100
commitc029a8db5208f502d6d258eb924685e4954bbf90 (patch)
treedc9cd0864d08706781869a221f012ce3b68a73d4
parent43629a95f378a79be5844998be1fb367f512821f (diff)
downloadefl-c029a8db5208f502d6d258eb924685e4954bbf90.tar.gz
evil: fix gecos field of struct pw
@fix
-rw-r--r--src/lib/evil/evil_pwd.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/evil/evil_pwd.c b/src/lib/evil/evil_pwd.c
index 14463c6561..5b323f48ab 100644
--- a/src/lib/evil/evil_pwd.c
+++ b/src/lib/evil/evil_pwd.c
@@ -10,12 +10,13 @@
#include "pwd.h"
-static struct passwd pw;
+static struct passwd pw = { NULL, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, 0, 0 };
struct passwd *
getpwnam(const char *n)
{
static char user_name[UNLEN + 1];
+ static char user_gecos[UNLEN + 4];
TCHAR name[UNLEN + 1];
DWORD length;
BOOLEAN res;
@@ -23,6 +24,9 @@ getpwnam(const char *n)
char *a_name;
# endif /* UNICODE */
+ if (!n)
+ return NULL;
+
length = UNLEN + 1;
res = GetUserName(name, &length);
if (!res)
@@ -50,19 +54,13 @@ getpwnam(const char *n)
if (strcmp(n, user_name) != 0)
return NULL;
- pw.pw_name = (res ? user_name : NULL);
- pw.pw_passwd = NULL;
- pw.pw_uid = 0;
- pw.pw_gid = 0;
- pw.pw_change = 0;
- pw.pw_class = NULL;
- pw.pw_gecos = (res ? user_name : NULL);
+ pw.pw_name = user_name;
+ snprintf(user_gecos, sizeof(user_gecos), "%s,,,", user_name);
+ pw.pw_gecos = user_gecos;
pw.pw_dir = (char *)evil_homedir_get();
pw.pw_shell = getenv("SHELL");
if (!pw.pw_shell)
pw.pw_shell = "sh";
- pw.pw_expire = 0;
- pw.pw_fields = 0;
return &pw;
}