summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/passwd.cc
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-03-18 16:27:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-11-17 12:13:31 -0800
commitff499b8904af94ebae9c83e0f2b15afc120c9d75 (patch)
tree57498f34e65371ce80c908a66ad8675e532a94f7 /winsup/cygwin/passwd.cc
parent6900a42323bfe9a909deddb27126a5e4e997d979 (diff)
downloadcygnal-ff499b8904af94ebae9c83e0f2b15afc120c9d75.tar.gz
cygnal-ff499b8904af94ebae9c83e0f2b15afc120c9d75.tar.bz2
cygnal-ff499b8904af94ebae9c83e0f2b15afc120c9d75.zip
Use Windows values in passwd and HOME env var.
In this patch, the path to the Windows command interpreter is reported in the shell field of struct passwd by getpwent by default rather than "/bin/bash". The value of USERPROFILE is used for the home field rather than "/home/<user>". Also, the HOME environment variable is stuffed with a copy of USERPROFILE. The HOME issue solves the following problem: some OSS programs on Windows, such as Vim, respond to a HOME variable. If it has garbage contents that make no sense like "/home/bob", they don't behave well. * winsup/cygwin/grp.cc (pwdgrp::init_grp): Initialize new pwd_sep member. * winsup/cygwin/passwd.cc (pwdgrp::parse_passwd): Use pwd_sep rather than hard-coded colon. (pwdgrp::init_pwd): Initialize pwd_sep. * winsup/cygwin/pwdgrp.h (class pwdgrp): New member, pwd_sep. * winsup/cygwin/uinfo.cc (cygheap_user::ontherange): Copy value of USERPROFILE into HOME. (pwdgrp::next_num, pwdgrp::fetch_account_from_line): Use pwd_sep rather than ':'. (pwdgrp::next_num, pwdgrp::fetch_account_from_windows): Get real Windows shell as default shell field. Get USERPROFILE as home directory. Use '|' as the field separator because these fields contain colons. Set pwd_sep to '|'.
Diffstat (limited to 'winsup/cygwin/passwd.cc')
-rw-r--r--winsup/cygwin/passwd.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index d2f7b2c2e..dfa90acb3 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -27,16 +27,16 @@ bool
pwdgrp::parse_passwd ()
{
pg_pwd &res = passwd ()[curr_lines];
- res.p.pw_name = next_str (':');
- res.p.pw_passwd = next_str (':');
+ res.p.pw_name = next_str (pwd_sep);
+ res.p.pw_passwd = next_str (pwd_sep);
if (!next_num (res.p.pw_uid))
return false;
if (!next_num (res.p.pw_gid))
return false;
res.p.pw_comment = NULL;
- res.p.pw_gecos = next_str (':');
- res.p.pw_dir = next_str (':');
- res.p.pw_shell = next_str (':');
+ res.p.pw_gecos = next_str (pwd_sep);
+ res.p.pw_dir = next_str (pwd_sep);
+ res.p.pw_shell = next_str (pwd_sep);
cygsid csid;
if (csid.getfrompw_gecos (&res.p))
RtlCopySid (SECURITY_MAX_SID_SIZE, res.sid, csid);
@@ -51,6 +51,7 @@ pwdgrp::init_pwd ()
{
pwdgrp_buf_elem_size = sizeof (pg_pwd);
parse = &pwdgrp::parse_passwd;
+ pwd_sep = ':';
}
struct passwd *