# HG changeset patch # User bears # Date 1016189433 0 # Node ID 4e69e9b722aed2efa7d7a2245dc62928070bec00 # Parent 6eb6c912a0e40fb040cb851fefafe1ac1e86d168 [svn] * src/database.c,src/protocol.c,src/util.c,src/util.h: The latest IETF article format draft draft-ietf-usefor-article-06.txt recommends that Xref: references contain the FQDN of the server. We were using the host name without the domain. So split the routine used for obtaining the FQDN from protocol.c into util.c, and use it when adding Xrefs. diff -r 6eb6c912a0e4 -r 4e69e9b722ae ChangeLog --- a/ChangeLog Fri Mar 15 10:49:56 2002 +0000 +++ b/ChangeLog Fri Mar 15 10:50:33 2002 +0000 @@ -1,3 +1,14 @@ +Fri Mar 15 2002 Jim Hague + +* src/database.c,src/protocol.c,src/util.c,src/util.h: The latest IETF + article format draft draft-ietf-usefor-article-06.txt recommends that + Xref: references contain the FQDN of the server. We were using the + host name without the domain. So split the routine used for obtaining + the FQDN from protocol.c into util.c, and use it when adding Xrefs. +* src/group.c: Make comparison against NULL explicit in an if containing + an assignment, as I'm sad enough to think it is safer if it is obvious + that the assignment is meant to be there. + Wed Mar 13 2002 Mirko Liß * src/server.c: While in online mode, new fetched articles returned diff -r 6eb6c912a0e4 -r 4e69e9b722ae src/database.c --- a/src/database.c Fri Mar 15 10:49:56 2002 +0000 +++ b/src/database.c Fri Mar 15 10:50:33 2002 +0000 @@ -1,7 +1,7 @@ /* database.c - $Id: database.c 371 2002-02-26 17:13:31Z bears $ + $Id: database.c 375 2002-03-15 10:50:33Z bears $ Uses GNU gdbm library. Using Berkeley db (included in libc6) was cumbersome. It is based on Berkeley db 1.85, which has severe bugs @@ -85,7 +85,8 @@ if ( db.txt == NULL ) db.txt = new_DynStr( 5000 ); - gethostname( host, MAXCHAR ); + if ( ! Utl_getFQDN( host ) ) + Utl_cpyStr( host, "localhost.localdomain" ); snprintf( db.xrefHost, MAXCHAR, "Xref: %s", host ); return TRUE; diff -r 6eb6c912a0e4 -r 4e69e9b722ae src/protocol.c --- a/src/protocol.c Fri Mar 15 10:49:56 2002 +0000 +++ b/src/protocol.c Fri Mar 15 10:50:33 2002 +0000 @@ -1,7 +1,7 @@ /* protocol.c - $Id: protocol.c 340 2001-12-02 19:32:44Z mirkol $ + $Id: protocol.c 375 2002-03-15 10:50:33Z bears $ */ #if HAVE_CONFIG_H @@ -10,11 +10,9 @@ #include #include -#include #include #include #include -#include #include #include "common.h" #include "configfile.h" @@ -220,31 +218,13 @@ return FALSE; } -static Bool -getFQDN( Str result ) -{ - struct hostent *myHostEnt; - struct utsname myName; - - if ( uname( &myName ) >= 0 - && ( myHostEnt = gethostbyname( myName.nodename ) ) ) - { - Utl_cpyStr( result, myHostEnt->h_name ); - return TRUE; - } - return FALSE; -} - static void getDomain( Str domain, const char *from ) { const char *addTopLevel, *p1, *p2, *p, *domainStart; Str myDomain; - /* get hostname for MsgId from Cfg-File */ - /* more elaborate testing must be left to upstream server */ - Utl_cpyStr( myDomain, Cfg_hostnameMsgId() ); - if ( strlen( myDomain ) != 0 || getFQDN( myDomain ) ) + if ( Utl_getFQDN( myDomain ) ) { p = strstr( myDomain, "." ); if ( p != NULL ) @@ -334,7 +314,7 @@ Utl_cpyStr( domain, Cfg_fromDomain() ); if ( strlen( domain ) == 0 ) - if ( ! getFQDN( domain ) ) + if ( ! Utl_getFQDN( domain ) ) Utl_catStr( domain, "unknown" ); /* Now get pwd for the username */ diff -r 6eb6c912a0e4 -r 4e69e9b722ae src/util.c --- a/src/util.c Fri Mar 15 10:49:56 2002 +0000 +++ b/src/util.c Fri Mar 15 10:50:33 2002 +0000 @@ -1,7 +1,7 @@ /* util.c - $Id: util.c 371 2002-02-26 17:13:31Z bears $ + $Id: util.c 375 2002-03-15 10:50:33Z bears $ */ #if HAVE_CONFIG_H @@ -21,8 +21,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -504,6 +506,31 @@ return oldAct.sa_handler; } +static Bool +getHostFQDN( Str result ) +{ + struct hostent *myHostEnt; + struct utsname myName; + + if ( uname( &myName ) >= 0 + && ( myHostEnt = gethostbyname( myName.nodename ) ) ) + { + Utl_cpyStr( result, myHostEnt->h_name ); + return TRUE; + } + return FALSE; +} + +Bool +Utl_getFQDN( Str result ) +{ + /* get hostname from Cfg-File */ + Utl_cpyStr( result, Cfg_hostnameMsgId() ); + if ( strlen( result ) != 0 ) + return TRUE; + return getHostFQDN( result ); +} + #if defined(UTIL_TEST) /* Test code borrowed from wildmat.c. Yep, still uses gets(). */ diff -r 6eb6c912a0e4 -r 4e69e9b722ae src/util.h --- a/src/util.h Fri Mar 15 10:49:56 2002 +0000 +++ b/src/util.h Fri Mar 15 10:50:33 2002 +0000 @@ -3,7 +3,7 @@ Miscellaneous helper functions. - $Id: util.h 248 2001-01-25 11:00:03Z bears $ + $Id: util.h 375 2002-03-15 10:50:33Z bears $ */ #ifndef UTL_H @@ -106,4 +106,8 @@ sig_t Utl_installSignalHandler( int sig, sig_t handler ); +/* Obtain this system FQDN. */ +Bool +Utl_getFQDN( Str result ); + #endif