Tcl Source Code

Ticket Change Details
Login
Overview

Artifact ID: 95f90172bc117cc03089161d4b41fdcf9e400cee6367bbfc633dff66eb05949a
Ticket: 9e6b569963ea497e9e623a79d5a5f92c5681bfdb
file normalize ~user fails on Windows
User & Date: fvogel 2018-05-15 14:04:51
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    <code>file normalize ~$::tcl_platform(user)</code>
    
    returns:
    
      - in tclsh86tg, normal user :   user "fvogel" doesn't exist
    
      - in tclsh86tg run as Admin :   C:/Users/l-vogel
    
    The computer is a Win 7 machine connected to a domain controller with an active directory.
    
    This problem was first detected with [https://core.tcl.tk/tk/tktview?name=7c571871e|the Tk test suite test winDialog-5.12.2].
    
    Looking at the code and debugging:
    
    ~fvogel looks at the <code>NetUserGetInfo</code> in <code>TclpGetUserHome</code> in tclWinFile.c
    In the described situation this call returns 2221 (NERR_UserNotFound).
    
    The following patch fixes the issue for me:
    <verbatim>
    Index: win/tclWinFile.c
    ==================================================================
    --- win/tclWinFile.c
    +++ win/tclWinFile.c
    @@ -1442,10 +1442,11 @@
         int nameLen = -1;
         int badDomain = 0;
         char *domain;
         WCHAR *wName, *wHomeDir, *wDomain, **wDomainPtr = &wDomain;
         WCHAR buf[MAX_PATH];
    +    LPCWSTR wServername = NULL;
    
         Tcl_DStringInit(bufferPtr);
         wDomain = NULL;
         domain = strchr(name, '@');
         if (domain != NULL) {
    @@ -1456,11 +1457,12 @@
            nameLen = domain - name;
         }
         if (badDomain == 0) {
            Tcl_DStringInit(&ds);
            wName = Tcl_UtfToUniCharDString(name, nameLen, &ds);
    -       if (NetUserGetInfo(wDomain, wName, 1, (LPBYTE *) uiPtrPtr) == 0) {
    +        NetGetDCName(NULL, wDomain, (LPBYTE *) &wServername);
    +       if (NetUserGetInfo(wServername, wName, 1, (LPBYTE *) uiPtrPtr) == 0) {
                wHomeDir = uiPtr->usri1_home_dir;
                if ((wHomeDir != NULL) && (wHomeDir[0] != L'\0')) {
                    Tcl_UniCharToUtfDString(wHomeDir, lstrlenW(wHomeDir),
                            bufferPtr);
                } else {
    </verbatim>
    
  5. foundin changed to: "All"
  6. is_private changed to: "0"
  7. login: "fvogel"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "a013af67114eccc19ad12b04f14923acea9e96b7"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "fvogel"
  14. subsystem changed to: "37. File System"
  15. title changed to: "file normalize ~user fails on Windows"
  16. type changed to: "Bug"