diff options
Diffstat (limited to 'winsup/cygwin/uinfo.cc')
-rw-r--r-- | winsup/cygwin/uinfo.cc | 30 |
1 files changed, 17 insertions, 13 deletions
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) |