diff options
author | sebres <sebres@users.sourceforge.net> | 2018-05-24 20:49:12 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2018-05-24 20:49:12 (GMT) |
commit | 1c13d543f4934c33e441ef5c77a592b9822a8823 (patch) | |
tree | cc133c169e493965a17c40ec42ed5d7587a289fa /win | |
parent | a410c0d8d504868b1dbdcaf70a521859e32327fd (diff) | |
download | tcl-1c13d543f4934c33e441ef5c77a592b9822a8823.zip tcl-1c13d543f4934c33e441ef5c77a592b9822a8823.tar.gz tcl-1c13d543f4934c33e441ef5c77a592b9822a8823.tar.bz2 |
[9e6b569963] win: if user specified without domain (and local user was not found), try to resolve user-home using current domain, so following code's are similar:
file normalize ~$::tcl_platform(user)@$::env(USERDOMAIN)
file normalize ~$::tcl_platform(user)
Diffstat (limited to 'win')
-rwxr-xr-x | win/tclWinFile.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 1acc225..a3fad1d 100755 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1446,30 +1446,41 @@ TclpGetUserHome( GetProcAddress(userenvInst, "GetProfilesDirectoryW"); if ((netUserGetInfoProc != NULL) && (netGetDCNameProc != NULL) && (netApiBufferFreeProc != NULL) && (getProfilesDirectoryProc != NULL)) { - USER_INFO_1 *uiPtr, **uiPtrPtr = &uiPtr; + USER_INFO_1 *uiPtr; Tcl_DString ds; - int nameLen, badDomain; + int nameLen, rc; char *domain; WCHAR *wName, *wHomeDir, *wDomain; WCHAR buf[MAX_PATH]; - badDomain = 0; + rc = 0; nameLen = -1; wDomain = NULL; domain = strchr(name, '@'); if (domain != NULL) { Tcl_DStringInit(&ds); wName = Tcl_UtfToUniCharDString(domain + 1, -1, &ds); - badDomain = (netGetDCNameProc)(NULL, wName, - (LPBYTE *) &wDomain); + rc = (netGetDCNameProc)(NULL, wName, (LPBYTE *) &wDomain); Tcl_DStringFree(&ds); nameLen = domain - name; } - if (badDomain == 0) { + if (rc == 0) { Tcl_DStringInit(&ds); wName = Tcl_UtfToUniCharDString(name, nameLen, &ds); - if ((netUserGetInfoProc)(wDomain, wName, 1, - (LPBYTE *) uiPtrPtr) == 0) { + while ((netUserGetInfoProc)(wDomain, wName, 1, + (LPBYTE *) &uiPtr) != 0) { + /* + * user does not exists - if domain was not specified, + * try again using current domain. + */ + rc = 1; + if (domain != NULL) break; + /* get current domain */ + rc = (netGetDCNameProc)(NULL, NULL, (LPBYTE *) &wDomain); + if (rc != 0) break; + domain = INT2PTR(-1); /* repeat once */ + } + if (rc == 0) { DWORD i, size = MAX_PATH; wHomeDir = uiPtr->usri1_home_dir; if ((wHomeDir != NULL) && (wHomeDir[0] != L'\0')) { |