Article View: news.software.readers
Article #57923[slrn] slrn can't deduce my fqdn, so I can't get customized MsgIDs
From: Daniel Price
Date: Fri, 11 Feb 2000 00:00
Date: Fri, 11 Feb 2000 00:00
159 lines
5437 bytes
5437 bytes
I'm trying to get slrn to create Message-IDs for me, so that I can
score against them, as has be discussed in previous postings.
As far as I can tell, slrn_create_message_id() is returning NULL,
because Slrn_User_Info.posting_host is null:
static char *slrn_create_message_id (void)
{
...
if (Slrn_Generate_Message_Id == 0)
return NULL;
while (1)
{
if ((Slrn_User_Info.posting_host == NULL)
|| ((time_t) -1 == time ((time_t *)&now)))
return NULL;
if (now != last_now) break;
sleep (1);
}
I've checked that Slrn_Generate_Message_Id is '1' in a debugger, and
that Slrn_User_Info.posting_host is indeed NULL. So why is
Slrn_User_Info.posting_host NULL?
This leads to misc.c, where the key bit is:
/* Now get default values for rest. */
host = get_hostname ();
if (host != NULL)
{
if (slrn_is_fqdn (host))
Slrn_User_Info.posting_host = slrn_safe_strmalloc (host);
This is the only place in slrn where Slrn_User_Info.posting_host is ever
set. This code calls get_hostname(), which looks like this:
static char *get_hostname (void)
{
struct hostent *host_entry;
char buf[MAX_HOST_NAME_LEN + 1];
host_entry = NULL;
if ((-1 == gethostname (buf, MAX_HOST_NAME_LEN))
|| (*buf == 0))
return NULL;
/* gethostname may not provide the full name so use gethostbyname
* to get more information. Why isn't there a simplified interface
* to get the FQDN!!!!
*/
host_entry = gethostbyname (buf);
#if defined(TRY_AGAIN) && !defined(MULTINET)
if ((host_entry == NULL) && (h_errno == TRY_AGAIN))
{
sleep (2);
host_entry = gethostbyname (buf);
}
#endif
if ((host_entry != NULL)
&& (host_entry->h_name != NULL)
&& (host_entry->h_name[0] != 0))
{
char **aliases;
if ((0 == slrn_is_fqdn ((char *)host_entry->h_name))
&& (NULL != (aliases = host_entry->h_aliases)))
{
while (*aliases != NULL)
{
if (slrn_is_fqdn (*aliases))
return slrn_safe_strmalloc (*aliases);
aliases++;
}
}
return slrn_safe_strmalloc ((char *)host_entry->h_name);
}
return slrn_safe_strmalloc (buf);
}
I use a tracing tool available in Solaris to see what library calls are being
made at this point in the code:
slrn -> libslang.so:SLmake_string(0x59e94, 0x0, 0x0)
slrn -> libnsl.so.1:gethostname(name = "xanadu", namelen = 0x100) = 0x0
name = (char *) 0xffbef094 "xanadu"
namelen = (int) 256 (0x100)
return = (int) 0 (0x0)
slrn -> libnsl.so.1:gethostbyname(name = "xanadu") = 0x7e2ac
name = (char *) 0xffbef094 "xanadu"
return = (struct hostent *) 0x7e2ac (struct hostent) {
h_name: (char *) 0x7e2cc "xanadu"
h_aliases: (char **) 0x7e2c0
h_addrtype: (int) 2 (0x2)
h_length: (int) 4 (0x4)
h_addr_list: (char **) 0x7e2c4
}
So from this, it is clear that neither gethostname() or gethostbyname() failed.
As a side note, there are no aliases to examine, as shown by running
$ perl
($name, $aliases) = gethostbyname("xanadu");
print "name = '$name'\n";
print "aliases = '$aliases'\n";
^D
name = 'xanadu'
aliases = ''
It is also clear that the if statement:
if ((host_entry != NULL)
&& (host_entry->h_name != NULL)
&& (host_entry->h_name[0] != 0))
succeeded (that is, the branch was taken).
Next up is a call to slrn_is_fqdn("xanadu"). By inspection, this fails, since
"xanadu" doesn't contain a ".". This causes slrn_is_fqdn to return "xanadu"
to its caller (slrn_get_user_info()).
Now what? slrn_get_user_info() checks to see if "xanadu" is fully qualified.
Of course it isn't.
At this point, there is no possible way to set posting_host-- the rest of the
function drives on and ignores posting_host.
So: I dunno. Is this a bug? To my way of thinking, if the user supplied
MY_DOMAIN_NAME in config.h and set USE_DOMAIN_NAME to 1, shouldn't slrn
use that?
Furthermore, shouldn't slrn have a runtime configuration option to set the
domain? This would be very handy for those preparing distributions for
other people at remote sites; in this case, you *can't* compile in
USE_DOMAIN_NAME and MY_DOMAIN_NAME, since you don't know it in advance.
As a side note, wouldn't it be good to have something about Message-ID
generation in the FAQ?
Thanks for your patience,
-dp
--
Daniel Price - Solaris I/O - dp@eng.sun.com
Expressed in this posting are my opinions. They are in no way related to
opinions held by my employer, Sun Microsystems. Statements on Sun products
included here are not gospel and may be fiction rather than truth.
Technical Details
Message-ID:
<880j4i$bev$1@engnews2.Eng.Sun.COM>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <880j4i$bev$1@engnews2.Eng.Sun.COM> Subject: [slrn] slrn can't deduce my fqdn, so I can't get customized MsgIDs Date: Fri, 11 Feb 2000 00:00:00 +0000 From: dp@xanadu.eng.sun.com (Daniel Price) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 584476997 Organization: Sun Microsystems Inc., Mountain View, CA User-Agent: slrn/0.9.6.2 (SunOS) Reply-To: dp@xanadu.eng.sun.com Newsgroups: news.software.readers