|
2026-10-22
| ||
| 17:19 | • Ticket [da235271f1] info hostname on Windows is limited to max NetBIOS name le... artifact: 51e3b22b22 user: serhiy.storchaka | |
|
2026-10-15
| ||
| 11:39 | • Closed ticket [da235271f1]. artifact: 051d34bc8b user: serhiy.storchaka | |
|
2020-04-30
| ||
| 15:43 | • Ticket [da235271f1]: 4 changes artifact: a0881b1b0e user: oehhar | |
| 15:35 | Win: use physical host DNS name instead cluster name. Ticket [da235271f1] check-in: 2ba1cd687f user: oehhar tags: core-8-6-branch | |
|
2020-04-23
| ||
| 12:37 | • Ticket [da235271f1] info hostname on Windows is limited to max NetBIOS name le... artifact: 5100337dd7 user: apnadkarni | |
|
2020-02-25
| ||
| 13:27 | • Ticket [da235271f1]: 4 changes artifact: ca10369b04 user: oehhar | |
|
2020-02-21
| ||
| 17:27 | • Ticket [da235271f1]: 3 changes artifact: 8677bb0b6a user: anonymous | |
| 09:44 | • Ticket [da235271f1]: 4 changes artifact: dd35cc9d30 user: oehhar | |
| 09:30 | • Pending ticket [da235271f1]. artifact: b586dae029 user: jan.nijtmans | |
| 09:25 | Fix [da235271f1]: [info hostname] on Windows is limited to max NetBIOS name length check-in: 632704e948 user: jan.nijtmans tags: core-8-6-branch | |
| 09:03 | • Ticket [da235271f1] info hostname on Windows is limited to max NetBIOS name le... artifact: c9b00da9c1 user: oehhar | |
| 09:00 | Win: Change order of checking hostname: first DNS, then netbios. Bug [da235271f1] closed check-in: 7fedbce431 user: oehhar tags: bug-da235271f1-win-netbios-host-prefered | |
| 01:41 | • New ticket [da235271f1] info hostname on Windows is limited to max NetBIOS nam... artifact: da1e885bec user: anonymous | |
[info hostname] on Windows is limited to max NetBIOS name length
I have a Windows host named "emake-ericm-11-2-x-202002210019-win2k12".
Using [info hostname] on this system gives me a result of "emake-ericm-11-".
This appears to be because in InitializeHostName() (in win/tclWinSock.c), Tcl
uses GetComputerNameW() to get the hostname:
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcomputernamew
GetComputerNameW() is defined to return the NetBIOS name of the host, which is
limited to MAX_COMPUTERNAME_LENGTH, which is only 15 characters, at least on
some versions of Windows.
The documentation for [info hostname] states:
Returns the name of the computer on which this invocation is being executed.
Note that this name is not guaranteed to be the fully qualified domain name
of the host. Where machines have several different names (as is common
on systems with both TCP/IP (DNS) and NetBIOS-based networking installed,)
it is the name that is suitable for TCP/IP networking that is returned.
This seems to be in contradiction to the implementation, which returns the
NetBIOS name, not the DNS name. Tcl should instead use GetComputerNameExW,
which retrieves the DNS name of the host, or at least should try that first
and only fall back to GetComputerNameW if GetComputerNameExW has failed.
https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getcomputernameexw
2ba1cd687fWin: use physical host DNS name instead cluster name. Ticket [da235271f1] check-in2020-04-30 15:35:25632704e948Fix [da235271f1]: [info hostname] on Windows is limited to max NetBIOS name length check-in2020-02-21 09:25:037fedbce431Win: Change order of checking hostname: first DNS, then netbios. Bug [da235271f1] check-in2020-02-21 09:00:03
Yes, tahnk you for the proposal.
I suppose, the code is from the aera where Netbios name was prefered and DNS was (not jet) present in the Microsoft world.
What do you think about the code in branch [bug-da235271f1-win-netbios-host-prefered].
Would this fix your issue ?
Thank you, Harald
@Harald. You were faster then me, I only saw your commit after I committed my solutions. @emelski: Do you prefer to use GetComputerNameExW(), or do you prefer Harald's solution (using hostname()). My preference whould be GetComputerNameExW(), since it - theoretically - can handle more than ASCII.
Jan,
thank you for the great fix.
I suppose, this is ok.
Don't you think, the order should be inverted and the netbios name should be taken as fallback?
So first call it with ComputerNameDnsFullyQualified, then with ComputerNameNetBIOS?
Thank you, Harald
Sorry, I don't know how to view the patches you have created -- I tried looking in https://core.tcl-lang.org/tcl/brlist but I couldn't find them. In any case, I think GetComputerNameExW is the right method to use, and it should try DNS first and then NetBIOS. The entire problem here is that Tcl is preferring the NetBIOS name instead of the DNS name. I'm not even sure it's possible to get a name longer than 15 characters from NetBIOS -- that is, I don't know if that is a limit inherent to NetBIOS or if that is "just" a limit of GetComputerNameW. It seems best therefore to default to the DNS name, and only try for the NetBIOS name if there is no DNS name. - emelski
Please first log in as anonymous (or your login if you have one):
https://core.tcl-lang.org/tcl/login
When logged in, there is a "ZIP Archive" link in the page of each checkin:
Jan: [632704e948]
Harald: [7fedbce431]
We are interseted, if this solves your issue.
Thank you, Harald
I would suggest the use of ComputerNamePhysicalDnsFullyQualified instead of ComputerNameDnsFullyQualified in the call to GetComputerNameExW. The latter will return the virtual name of the cluster if part of one whereas I think [info hostname] should return the real name of this system, not the cluster's DNS name. /Ashok
Thank you, Ashok. I think, that is reasonable.
Performed Actions:
- Ashok's proposal is in branch [core-8-6-branch] with checkin [2ba1cd687f].
- Close branch [bug-da235271f1-win-netbios-host-prefered].
May I ask the original author again, if the issue is fixed by this modification ? Otherwise, I may close the ticket next week.
Thank you all, Harald
Fixed by [632704e948] and [2ba1cd687f], first released in 8.6.11.