Problem with gethostid
Corinna Vinschen
corinna-cygwin@cygwin.com
Mon Jan 23 13:04:00 GMT 2012
On Jan 23 10:53, Corinna Vinschen wrote:
> While gethostid is not guaranteed to return a globally unique ID, I
> think I see the potential flaws in the algorithm. It shouldn't be too
> hard to make it a bit more intelligent.
>
> Or, we just replace it with a simple algorithm as it's described in the
> glibc man pages. First it checks if /etc/hostid exists and uses the
> value from there. If not, it calls gethostname and gethostbyname to
> fetch the (or better "a") IPv4 address and tweaks the bits a bit.
I just simplified the gethostid function in Cygwin. It now fetches the
registry value HKLM/Software/Microsoft/Cryptography/MachineGuid and
creates a hash value from it. The MachineGuid is supposed to be
globally unique so there's a low probability for collision, even if the
hostid hash is only 32 bit.
If that's not sufficient, I can also make gethostid depend on /etc/hostid
and the IPv4 address in the first place, as on Linux. I have the code for
that, but given the uniqueness of the MachineGuid I don't see the point
to make the function more complicated than necessary.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list