Mercurial > noffle
changeset 244:4e69e9b722ae noffle
[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.
author | bears |
---|---|
date | Fri, 15 Mar 2002 10:50:33 +0000 |
parents | 6eb6c912a0e4 |
children | d6e02253fb76 |
files | ChangeLog src/database.c src/protocol.c src/util.c src/util.h |
diffstat | 5 files changed, 50 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- 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 <jim.hague@acm.org> + +* 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ß <mirko.liss@web.de> * src/server.c: While in online mode, new fetched articles returned
--- 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;
--- 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 <stdio.h> #include <ctype.h> -#include <netdb.h> #include <pwd.h> #include <signal.h> #include <sys/types.h> -#include <sys/utsname.h> #include <unistd.h> #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 */
--- 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 <errno.h> #include <ctype.h> +#include <netdb.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/utsname.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> @@ -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(). */
--- 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