diff options
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/grp.cc | 1 | ||||
-rw-r--r-- | winsup/cygwin/passwd.cc | 11 | ||||
-rw-r--r-- | winsup/cygwin/pwdgrp.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/uinfo.cc | 30 |
4 files changed, 25 insertions, 18 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index d66acad99..40f85feec 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -57,6 +57,7 @@ pwdgrp::init_grp () { pwdgrp_buf_elem_size = sizeof (pg_grp); parse = &pwdgrp::parse_group; + pwd_sep = ':'; } struct group * 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 * diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h index 0705f7528..639773683 100644 --- a/winsup/cygwin/pwdgrp.h +++ b/winsup/cygwin/pwdgrp.h @@ -63,6 +63,7 @@ class pwdgrp unsigned pwdgrp_buf_elem_size; void *pwdgrp_buf; bool (pwdgrp::*parse) (); + char pwd_sep; UNICODE_STRING path; OBJECT_ATTRIBUTES attr; LARGE_INTEGER last_modified; diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 323222a47..830ca9c97 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -377,11 +377,9 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw) } else { - char home[strlen (name ()) + 8]; - - debug_printf ("Set HOME to default /home/USER"); - __small_sprintf (home, "/home/%s", name ()); - setenv ("HOME", home, 1); + char *usrpro = getenv("USERPROFILE"); + if (usrpro) + setenv("HOME", usrpro, 1); } } } @@ -592,7 +590,7 @@ pwdgrp::next_str (char c) bool pwdgrp::next_num (unsigned long& n) { - char *p = next_str (':'); + char *p = next_str (pwd_sep); char *cp; n = strtoul (p, &cp, 10); return p != cp && !*cp; @@ -1677,19 +1675,19 @@ pwdgrp::fetch_account_from_line (fetch_user_arg_t &arg, const char *line) { case SID_arg: /* Ignore fields, just scan for SID string. */ - if (!(p = strstr (line, arg.name)) || p[arg.len] != ':') + if (!(p = strstr (line, arg.name)) || p[arg.len] != pwd_sep) return NULL; break; case NAME_arg: /* First field is always name. */ - if (!strncasematch (line, arg.name, arg.len) || line[arg.len] != ':') + if (!strncasematch (line, arg.name, arg.len) || line[arg.len] != pwd_sep) return NULL; break; case ID_arg: /* Skip to third field. */ - if (!(p = strchr (line, ':')) || !(p = strchr (p + 1, ':'))) + if (!(p = strchr (line, pwd_sep)) || !(p = strchr (p + 1, pwd_sep))) return NULL; - if (strtoul (p + 1, &e, 10) != arg.id || !e || *e != ':') + if (strtoul (p + 1, &e, 10) != arg.id || !e || *e != pwd_sep) return NULL; break; default: @@ -2521,6 +2519,7 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) tmp_pathbuf tp; char *linebuf = tp.c_get (); char *line = NULL; + char *userprofile = getenv("USERPROFILE"); WCHAR posix_name[UNLEN + 1 + DNLEN + 1]; p = posix_name; @@ -2530,6 +2529,8 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) p = wcpcpy (wcpcpy (p, dom), cygheap->pg.nss_separator ()); wcpcpy (p, name); + pwd_sep = ':'; + if (is_group ()) __small_sprintf (linebuf, "%W:%s:%u:", posix_name, sid.string ((char *) sidstr), uid); @@ -2542,13 +2543,16 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) dom, name, sid.string ((char *) sidstr)); else - __small_sprintf (linebuf, "%W:*:%u:%u:%s%sU-%W\\%W,%s:%s%W:%s", + { + __small_sprintf (linebuf, "%W|*|%u|%u|%s%sU-%W\\%W,%s|%s|%s", posix_name, uid, gid, gecos ?: "", gecos ? "," : "", dom, name, sid.string ((char *) sidstr), - home ?: "/home/", home ? L"" : name, - shell ?: "/bin/bash"); + home ? home : (userprofile ? userprofile : ""), + shell ?: get_cmd_exe_path()); + pwd_sep = '|'; + } if (gecos) free (gecos); if (home) |