diff options
author | Vincent Torri <vincent.torri@univ-evry.fr> | 2015-02-24 15:17:29 +0100 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-02-24 17:21:44 +0100 |
commit | c029a8db5208f502d6d258eb924685e4954bbf90 (patch) | |
tree | dc9cd0864d08706781869a221f012ce3b68a73d4 /src/lib/evil/evil_pwd.c | |
parent | 43629a95f378a79be5844998be1fb367f512821f (diff) | |
download | efl-c029a8db5208f502d6d258eb924685e4954bbf90.tar.gz |
evil: fix gecos field of struct pw
@fix
Diffstat (limited to 'src/lib/evil/evil_pwd.c')
-rw-r--r-- | src/lib/evil/evil_pwd.c | 18 |
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; } |