summaryrefslogtreecommitdiff
path: root/src/lib/evil
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 /src/lib/evil
parent43629a95f378a79be5844998be1fb367f512821f (diff)
evil: fix gecos field of struct pw
@fix
Diffstat (limited to 'src/lib/evil')
-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 @@
10#include "pwd.h" 10#include "pwd.h"
11 11
12 12
13static struct passwd pw; 13static struct passwd pw = { NULL, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, 0, 0 };
14 14
15struct passwd * 15struct passwd *
16getpwnam(const char *n) 16getpwnam(const char *n)
17{ 17{
18 static char user_name[UNLEN + 1]; 18 static char user_name[UNLEN + 1];
19 static char user_gecos[UNLEN + 4];
19 TCHAR name[UNLEN + 1]; 20 TCHAR name[UNLEN + 1];
20 DWORD length; 21 DWORD length;
21 BOOLEAN res; 22 BOOLEAN res;
@@ -23,6 +24,9 @@ getpwnam(const char *n)
23 char *a_name; 24 char *a_name;
24# endif /* UNICODE */ 25# endif /* UNICODE */
25 26
27 if (!n)
28 return NULL;
29
26 length = UNLEN + 1; 30 length = UNLEN + 1;
27 res = GetUserName(name, &length); 31 res = GetUserName(name, &length);
28 if (!res) 32 if (!res)
@@ -50,19 +54,13 @@ getpwnam(const char *n)
50 if (strcmp(n, user_name) != 0) 54 if (strcmp(n, user_name) != 0)
51 return NULL; 55 return NULL;
52 56
53 pw.pw_name = (res ? user_name : NULL); 57 pw.pw_name = user_name;
54 pw.pw_passwd = NULL; 58 snprintf(user_gecos, sizeof(user_gecos), "%s,,,", user_name);
55 pw.pw_uid = 0; 59 pw.pw_gecos = user_gecos;
56 pw.pw_gid = 0;
57 pw.pw_change = 0;
58 pw.pw_class = NULL;
59 pw.pw_gecos = (res ? user_name : NULL);
60 pw.pw_dir = (char *)evil_homedir_get(); 60 pw.pw_dir = (char *)evil_homedir_get();
61 pw.pw_shell = getenv("SHELL"); 61 pw.pw_shell = getenv("SHELL");
62 if (!pw.pw_shell) 62 if (!pw.pw_shell)
63 pw.pw_shell = "sh"; 63 pw.pw_shell = "sh";
64 pw.pw_expire = 0;
65 pw.pw_fields = 0;
66 64
67 return &pw; 65 return &pw;
68} 66}