[MERGE/RFC] hostnames are not always ascii

John Arbash Meinel john at arbash-meinel.com
Tue Aug 19 20:47:07 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark Hammond wrote:
>> So I think this is better than what we have, but we should also change
>> win32utils.get_host_name() to use GetComputerNameEx when we know it is
>> available. (Basically, when we know the unicode api is available should
>> be sufficient.)
>> http://msdn.microsoft.com/en-us/library/ms724301(VS.85).aspx
> 
> The attached patch uses pywin32's win32api.GetComputerNameEx(), which uses
> LoadLibrary to get the unicode version raising NotImplementedError if its
> not found.  As noted in the comments, it passes
> 'ComputerNameDnsFullyQualified', which MSDN documents as:
> 
> """The fully qualified DNS name that uniquely identifies the local computer.
> This name is a combination of the DNS host name and the DNS domain name,
> using the form HostName.DomainName. If the local computer is a node in a
> cluster, lpBuffer receives the fully qualified DNS name of the cluster
> virtual server."""
> 
> For me, this always is a lower-case name, and includes the dns name of the
> Windows domain if the computer is a member of a domain.
>  
> Cheers,
> 
> Mark

In all of this discussion I probed a bit deeper. It seems we want the
ComputerDnsName, but not the FullyQualified one.
Specifically, there are 2 functions:

socket.gethostname()
and
socket.getfqdn()

And we aren't using the latter. Also, ctypes has access to GetComputerNameEx,
we just have to ask for it.

I've attached a version that fits what I was thinking. What do you think Mark?

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIqyM7JdeBCYSNAAMRAhVpAKCVVx+edHRgElyyEgT6TLmQD+FfzgCggqzz
jTRyD9aVDjg9RHFPE6zMe68=
=0PsO
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unicode_hostname2.patch
Type: text/x-diff
Size: 10575 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080819/cb22de4c/attachment-0001.bin 


More information about the bazaar mailing list