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 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: <20120123095322 DOT GB2456 AT calimero DOT vinschen DOT de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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 Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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