delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Spam-Check-By: | sourceware.org |
Date: | Mon, 23 Jan 2012 14:03:51 +0100 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: Problem with gethostid |
Message-ID: | <20120123130351.GD2456@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <CAJOtW+7yt4ox1KG5jsy3Zrc5LAUbLVjzbrzefwhGMwXxMFpWMw AT mail DOT gmail DOT com> <20120123095322 DOT GB2456 AT calimero DOT vinschen DOT de> |
MIME-Version: | 1.0 |
In-Reply-To: | <20120123095322.GB2456@calimero.vinschen.de> |
User-Agent: | Mutt/1.5.21 (2010-09-15) |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |