Tcl Source Code

Check-in [8243f36918]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:win: TclpGetUserHome should return normalized path (also in case we find domain and NetUserGetInfo returns path), PoC: file normalize ~$::tcl_platform(user)@$::env(USERDOMAIN)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-5-branch
Files: files | file ages | folders
SHA3-256: 8243f36918a7c480274f72cb36f71bf6ee9991d64e856e5f8f488a04c1d8e1dc
User & Date: sebres 2018-05-24 20:12:43
Context
2018-05-24
20:20
fixed typo in winFCmd-12.6.2: unneeded extra-bracket removed check-in: 634425a216 user: sebres tags: core-8-5-branch
20:12
win: TclpGetUserHome should return normalized path (also in case we find domain and NetUserGetInfo r... check-in: 8243f36918 user: sebres tags: core-8-5-branch
2018-05-14
19:14
Unbreak build when HAVE_FTS is not set. Move definitions of Tcl_DirEntry and TclDIR to tclWinPort.h... check-in: 7bc44a586a user: jan.nijtmans tags: core-8-5-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to win/tclWinFile.c.

1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472

1473
1474

1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491




1492
1493
1494
1495
1496
1497
1498
		GetProcAddress(userenvInst, "GetProfilesDirectoryW");
	if ((netUserGetInfoProc != NULL) && (netGetDCNameProc != NULL)
		&& (netApiBufferFreeProc != NULL) && (getProfilesDirectoryProc != NULL)) {
	    USER_INFO_1 *uiPtr, **uiPtrPtr = &uiPtr;
	    Tcl_DString ds;
	    int nameLen, badDomain;
	    char *domain;
	    WCHAR *wName, *wHomeDir, *wDomain, **wDomainPtr = &wDomain;
	    WCHAR buf[MAX_PATH];

	    badDomain = 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 *) wDomainPtr);
		Tcl_DStringFree(&ds);
		nameLen = domain - name;
	    }
	    if (badDomain == 0) {
		Tcl_DStringInit(&ds);
		wName = Tcl_UtfToUniCharDString(name, nameLen, &ds);
		if ((netUserGetInfoProc)(wDomain, wName, 1,
			(LPBYTE *) uiPtrPtr) == 0) {

		    wHomeDir = uiPtr->usri1_home_dir;
		    if ((wHomeDir != NULL) && (wHomeDir[0] != L'\0')) {

			Tcl_UniCharToUtfDString(wHomeDir, lstrlenW(wHomeDir),
				bufferPtr);
		    } else {
			/*
			 * User exists but has no home dir. Return
			 * "{GetProfilesDirectory}/<user>".
			 */
			DWORD i, size = MAX_PATH;
			getProfilesDirectoryProc(buf, &size);
			for (i = 0; i < size; ++i){
			    if (buf[i] == '\\') buf[i] = '/';
			}
			Tcl_UniCharToUtfDString(buf, size-1, bufferPtr);
			Tcl_DStringAppend(bufferPtr, "/", -1);
			Tcl_DStringAppend(bufferPtr, name, -1);
		    }
		    result = Tcl_DStringValue(bufferPtr);




		    (*netApiBufferFreeProc)((void *) uiPtr);
		}
		Tcl_DStringFree(&ds);
	    }
	    if (wDomain != NULL) {
		(*netApiBufferFreeProc)((void *) wDomain);
	    }






|










|








>


>
|
<





<

<
<
<

|
|


>
>
>
>







1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477

1478
1479
1480
1481
1482

1483



1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
		GetProcAddress(userenvInst, "GetProfilesDirectoryW");
	if ((netUserGetInfoProc != NULL) && (netGetDCNameProc != NULL)
		&& (netApiBufferFreeProc != NULL) && (getProfilesDirectoryProc != NULL)) {
	    USER_INFO_1 *uiPtr, **uiPtrPtr = &uiPtr;
	    Tcl_DString ds;
	    int nameLen, badDomain;
	    char *domain;
	    WCHAR *wName, *wHomeDir, *wDomain;
	    WCHAR buf[MAX_PATH];

	    badDomain = 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);
		Tcl_DStringFree(&ds);
		nameLen = domain - name;
	    }
	    if (badDomain == 0) {
		Tcl_DStringInit(&ds);
		wName = Tcl_UtfToUniCharDString(name, nameLen, &ds);
		if ((netUserGetInfoProc)(wDomain, wName, 1,
			(LPBYTE *) uiPtrPtr) == 0) {
		    DWORD i, size = MAX_PATH;
		    wHomeDir = uiPtr->usri1_home_dir;
		    if ((wHomeDir != NULL) && (wHomeDir[0] != L'\0')) {
			size = lstrlenW(wHomeDir);
			Tcl_UniCharToUtfDString(wHomeDir, size, bufferPtr);

		    } else {
			/*
			 * User exists but has no home dir. Return
			 * "{GetProfilesDirectory}/<user>".
			 */

			getProfilesDirectoryProc(buf, &size);



			Tcl_UniCharToUtfDString(buf, size-1, bufferPtr);
			Tcl_DStringAppend(bufferPtr, "/", 1);
			Tcl_DStringAppend(bufferPtr, name, nameLen);
		    }
		    result = Tcl_DStringValue(bufferPtr);
		    /* be sure we returns normalized path */
		    for (i = 0; i < size; ++i){
			if (result[i] == '\\') result[i] = '/';
		    }
		    (*netApiBufferFreeProc)((void *) uiPtr);
		}
		Tcl_DStringFree(&ds);
	    }
	    if (wDomain != NULL) {
		(*netApiBufferFreeProc)((void *) wDomain);
	    }