Tcl Source Code

Check-in [adbe7e0e07]
Login

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

Overview
Comment:Add support for ~domain\user style user names, with new test test filesystem-1.30.3. Warning: does not yet work.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | bug-9e6b569963
Files: files | file ages | folders
SHA3-256: adbe7e0e07719a2a1dc1c19c7f192dd40f4a3920ad0355bbd46cd434a63a99bd
User & Date: fvogel 2018-05-23 21:08:01.914
References
2018-05-23
21:17 Ticket [9e6b569963] file normalize ~user fails on Windows status still Open with 3 other changes artifact: cf84e49b6e user: fvogel
Context
2018-05-24
20:51
Remove test filesystem-1.30.3, this is unstestable check-in: 88b6a0b3db user: fvogel tags: bug-9e6b569963
2018-05-23
21:08
Add support for ~domain\user style user names, with new test test filesystem-1.30.3. Warning: does n... check-in: adbe7e0e07 user: fvogel tags: bug-9e6b569963
2018-05-19
07:10
Add test filesystem-1.30.2 {normalisation of nonexistent user specified as user@domain} check-in: 9d50014a1e user: fvogel tags: bug-9e6b569963
Changes
Unified Diff Ignore Whitespace Patch
Changes to tests/fileSystem.test.
266
267
268
269
270
271
272



273
274
275
276
277
278
279
} -returnCodes error -result {user "noonewiththisname" doesn't exist}
test filesystem-1.30.1 {normalisation of existing user} -body {
    catch {file normalize ~$::tcl_platform(user)}
} -result {0}
test filesystem-1.30.2 {normalisation of nonexistent user specified as user@domain} -body {
    file normalize ~nonexistentuser@nonexistentdomain
} -returnCodes error -result {user "nonexistentuser@nonexistentdomain" doesn't exist}



test filesystem-1.31 {link normalisation: link near filesystem root} {testsetplatform} {
    testsetplatform unix
    file normalize /foo/../bar
} {/bar}
test filesystem-1.32 {link normalisation: link near filesystem root} {testsetplatform} {
    testsetplatform unix
    file normalize /../bar







>
>
>







266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
} -returnCodes error -result {user "noonewiththisname" doesn't exist}
test filesystem-1.30.1 {normalisation of existing user} -body {
    catch {file normalize ~$::tcl_platform(user)}
} -result {0}
test filesystem-1.30.2 {normalisation of nonexistent user specified as user@domain} -body {
    file normalize ~nonexistentuser@nonexistentdomain
} -returnCodes error -result {user "nonexistentuser@nonexistentdomain" doesn't exist}
test filesystem-1.30.3 {normalisation of nonexistent user specified as domain\user} -body {
    file normalize ~nonexistentdomain\\nonexistentuser
} -returnCodes error -result {user "nonexistentdomain\nonexistentuser" doesn't exist}
test filesystem-1.31 {link normalisation: link near filesystem root} {testsetplatform} {
    testsetplatform unix
    file normalize /foo/../bar
} {/bar}
test filesystem-1.32 {link normalisation: link near filesystem root} {testsetplatform} {
    testsetplatform unix
    file normalize /../bar
Changes to win/tclWinFile.c.
1437
1438
1439
1440
1441
1442
1443
1444

1445
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
				 * name of user's home directory. */
{
    const char *result = NULL;
    USER_INFO_1 *uiPtr, **uiPtrPtr = &uiPtr;
    Tcl_DString ds;
    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) {
	Tcl_DStringInit(&ds);
	wName = Tcl_UtfToUniCharDString(domain + 1, -1, &ds);
	badDomain = NetGetDCName(NULL, wName, (LPBYTE *) wDomainPtr);
	Tcl_DStringFree(&ds);
	nameLen = domain - name;










    }
    if (badDomain == 0) {
	Tcl_DStringInit(&ds);
	wName = Tcl_UtfToUniCharDString(name, nameLen, &ds);
        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 {
		/*
		 * User exists but has no home dir. Return
		 * "{GetProfilesDirectory}/<user>".
		 */
		DWORD i, size = MAX_PATH;
		GetProfilesDirectoryW(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);
	    NetApiBufferFree((void *) uiPtr);
	}
	Tcl_DStringFree(&ds);
    }
    if (wDomain != NULL) {







|
>




>









>
>
>
>
>
>
>
>
>
>



|


















|







1437
1438
1439
1440
1441
1442
1443
1444
1445
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
				 * name of user's home directory. */
{
    const char *result = NULL;
    USER_INFO_1 *uiPtr, **uiPtrPtr = &uiPtr;
    Tcl_DString ds;
    int nameLen = -1;
    int badDomain = 0;
    char *domain, *user;
    const char *nameStart;
    WCHAR *wName, *wHomeDir, *wDomain, **wDomainPtr = &wDomain;
    WCHAR buf[MAX_PATH];
    LPCWSTR wServername = NULL;

    nameStart = name;
    Tcl_DStringInit(bufferPtr);
    wDomain = NULL;
    domain = strchr(name, '@');
    if (domain != NULL) {
	Tcl_DStringInit(&ds);
	wName = Tcl_UtfToUniCharDString(domain + 1, -1, &ds);
	badDomain = NetGetDCName(NULL, wName, (LPBYTE *) wDomainPtr);
	Tcl_DStringFree(&ds);
	nameLen = domain - name;
    } else {
        user = strchr(name, '\\');
        if (user != NULL) {
	    Tcl_DStringInit(&ds);
	    wName = Tcl_UtfToUniCharDString(name, user - name, &ds);
	    badDomain = NetGetDCName(NULL, wName, (LPBYTE *) wDomainPtr);
	    Tcl_DStringFree(&ds);
            nameStart = user + 1;
	    nameLen = name + strlen(name) - 1 - user;
        }
    }
    if (badDomain == 0) {
	Tcl_DStringInit(&ds);
	wName = Tcl_UtfToUniCharDString(nameStart, nameLen, &ds);
        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 {
		/*
		 * User exists but has no home dir. Return
		 * "{GetProfilesDirectory}/<user>".
		 */
		DWORD i, size = MAX_PATH;
		GetProfilesDirectoryW(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, nameStart, nameLen);
	    }
	    result = Tcl_DStringValue(bufferPtr);
	    NetApiBufferFree((void *) uiPtr);
	}
	Tcl_DStringFree(&ds);
    }
    if (wDomain != NULL) {