From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: cvs emacs and (system-name) Date: Thu, 19 Apr 2007 17:23:30 -0400 Message-ID: References: <87ps62kcne.fsf@stupidchicken.com> <1todll8uvm.fsf@fencepost.gnu.org> <5qejmhhsbo.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1177017836 16090 80.91.229.12 (19 Apr 2007 21:23:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 19 Apr 2007 21:23:56 +0000 (UTC) Cc: tromey@redhat.com, schwab@suse.de, cyd@stupidchicken.com, rms@gnu.org, emacs-devel@gnu.org To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 19 23:23:49 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hee6U-0003Dy-3t for ged-emacs-devel@m.gmane.org; Thu, 19 Apr 2007 23:23:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HeeBT-0007iv-2b for ged-emacs-devel@m.gmane.org; Thu, 19 Apr 2007 17:28:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HeeBO-0007ia-Rn for emacs-devel@gnu.org; Thu, 19 Apr 2007 17:28:50 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HeeBM-0007iO-JM for emacs-devel@gnu.org; Thu, 19 Apr 2007 17:28:49 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HeeBM-0007iL-Fp for emacs-devel@gnu.org; Thu, 19 Apr 2007 17:28:48 -0400 Original-Received: from mercure.iro.umontreal.ca ([132.204.24.67]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hee6L-000715-8J; Thu, 19 Apr 2007 17:23:37 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 1B7E22CF420; Thu, 19 Apr 2007 17:23:36 -0400 (EDT) Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 40A373FE0; Thu, 19 Apr 2007 17:23:30 -0400 (EDT) Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 268DE6C8C9; Thu, 19 Apr 2007 17:23:30 -0400 (EDT) In-Reply-To: <5qejmhhsbo.fsf@fencepost.gnu.org> (Glenn Morris's message of "Thu\, 19 Apr 2007 01\:00\:11 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.94 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-detected-kernel: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:69661 Archived-At: > ! while (*alias && ( !index (*alias, '.') || > ! !strcmp (*alias, "localhost.localdomain" ) ) ) How 'bout the patch below instead. Stefan PS: Now that I think about it, maybe a better approach is to look for an alias that not only has a "." but additionally has the hostname as prefix. This is what my second patch does. Both patches are guaranteed 100% untested. --- orig/src/sysdep.c +++ mod/src/sysdep.c @@ -2428,7 +2428,13 @@ char *p; #endif - if (!index (fqdn, '.')) + if (!index (fqdn, '.') + /* If the IP address is 127.*.*.*, don't bother looking for + a fqdn in the aliases since the name itself won't matter + much and we may end up with localhost.localdomain + or some other meaningless "fqdn". */ + && !(hp->h_addrtype == AF_INET + && hp->h_addr[0] == 127)) { /* We still don't have a fully qualified domain name. Try to find one in the list of alternate names */ --- orig/src/sysdep.c +++ mod/src/sysdep.c @@ -2428,8 +2428,16 @@ /* We still don't have a fully qualified domain name. Try to find one in the list of alternate names */ char **alias = hp->h_aliases; - while (*alias && !index (*alias, '.')) - alias++; + while (*alias) + { + char *i = index (*alias, '.'); + /* hp->h_name is supposed to be the "official name" so we + should not take any random fully qualified alias. */ + if (i && strlen (fqdn) == i - *alias + && !strncmp (fqdn, *alias, i - *alias)) + break; + alias++; + } if (*alias) fqdn = *alias; }