Mercurial > noffle
comparison src/protocol.c @ 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 | 0eaf93997170 |
children | 7a830ce3211e |
comparison
equal
deleted
inserted
replaced
243:6eb6c912a0e4 | 244:4e69e9b722ae |
---|---|
1 /* | 1 /* |
2 protocol.c | 2 protocol.c |
3 | 3 |
4 $Id: protocol.c 340 2001-12-02 19:32:44Z mirkol $ | 4 $Id: protocol.c 375 2002-03-15 10:50:33Z bears $ |
5 */ | 5 */ |
6 | 6 |
7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
8 #include <config.h> | 8 #include <config.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 #include <ctype.h> | 12 #include <ctype.h> |
13 #include <netdb.h> | |
14 #include <pwd.h> | 13 #include <pwd.h> |
15 #include <signal.h> | 14 #include <signal.h> |
16 #include <sys/types.h> | 15 #include <sys/types.h> |
17 #include <sys/utsname.h> | |
18 #include <unistd.h> | 16 #include <unistd.h> |
19 #include "common.h" | 17 #include "common.h" |
20 #include "configfile.h" | 18 #include "configfile.h" |
21 #include "dynamicstring.h" | 19 #include "dynamicstring.h" |
22 #include "log.h" | 20 #include "log.h" |
218 return TRUE; | 216 return TRUE; |
219 } | 217 } |
220 return FALSE; | 218 return FALSE; |
221 } | 219 } |
222 | 220 |
223 static Bool | |
224 getFQDN( Str result ) | |
225 { | |
226 struct hostent *myHostEnt; | |
227 struct utsname myName; | |
228 | |
229 if ( uname( &myName ) >= 0 | |
230 && ( myHostEnt = gethostbyname( myName.nodename ) ) ) | |
231 { | |
232 Utl_cpyStr( result, myHostEnt->h_name ); | |
233 return TRUE; | |
234 } | |
235 return FALSE; | |
236 } | |
237 | |
238 static void | 221 static void |
239 getDomain( Str domain, const char *from ) | 222 getDomain( Str domain, const char *from ) |
240 { | 223 { |
241 const char *addTopLevel, *p1, *p2, *p, *domainStart; | 224 const char *addTopLevel, *p1, *p2, *p, *domainStart; |
242 Str myDomain; | 225 Str myDomain; |
243 | 226 |
244 /* get hostname for MsgId from Cfg-File */ | 227 if ( Utl_getFQDN( myDomain ) ) |
245 /* more elaborate testing must be left to upstream server */ | |
246 Utl_cpyStr( myDomain, Cfg_hostnameMsgId() ); | |
247 if ( strlen( myDomain ) != 0 || getFQDN( myDomain ) ) | |
248 { | 228 { |
249 p = strstr( myDomain, "." ); | 229 p = strstr( myDomain, "." ); |
250 if ( p != NULL ) | 230 if ( p != NULL ) |
251 domainStart = p + 1; | 231 domainStart = p + 1; |
252 else | 232 else |
332 | 312 |
333 /* First get the domain to use. If config empty, use FQDN */ | 313 /* First get the domain to use. If config empty, use FQDN */ |
334 Utl_cpyStr( domain, Cfg_fromDomain() ); | 314 Utl_cpyStr( domain, Cfg_fromDomain() ); |
335 | 315 |
336 if ( strlen( domain ) == 0 ) | 316 if ( strlen( domain ) == 0 ) |
337 if ( ! getFQDN( domain ) ) | 317 if ( ! Utl_getFQDN( domain ) ) |
338 Utl_catStr( domain, "unknown" ); | 318 Utl_catStr( domain, "unknown" ); |
339 | 319 |
340 /* Now get pwd for the username */ | 320 /* Now get pwd for the username */ |
341 pwd = getpwuid( getuid() ); | 321 pwd = getpwuid( getuid() ); |
342 if ( pwd == NULL ) | 322 if ( pwd == NULL ) |