diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1998-08-27 17:10:46 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1998-08-27 17:10:46 +0000 |
commit | 6a145dfedf241d85fb9f1234d760e1f8d6b1e157 (patch) | |
tree | 54d7f74f4094999d06d8bb256d333677f23e571d /env.c | |
parent | 543380aa15cd07d4e15298312c633d37878fe6cf (diff) | |
download | fetchmail-6a145dfedf241d85fb9f1234d760e1f8d6b1e157.tar.gz fetchmail-6a145dfedf241d85fb9f1234d760e1f8d6b1e157.tar.bz2 fetchmail-6a145dfedf241d85fb9f1234d760e1f8d6b1e157.zip |
Compute FQDN when Kerberos is in use.
svn path=/trunk/; revision=2061
Diffstat (limited to 'env.c')
-rw-r--r-- | env.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -67,6 +67,40 @@ void envquery(int argc, char **argv) strcat(rcfile, RCFILE_NAME); } +char *host_fqdn(void) +/* get the FQDN of the machine we're running */ +{ + char tmpbuf[HOSTLEN+1]; + + if (gethostname(tmpbuf, sizeof(tmpbuf))) + { + fprintf(stderr, "%s: can't determine your host!", + program_name); + exit(PS_DNS); + } +#ifdef HAVE_GETHOSTBYNAME + /* if we got a . in the hostname assume it is a FQDN */ + if (strchr(tmpbuf, '.') == NULL) + { + struct hostent *hp; + + /* if we got a basename (as we do in Linux) make a FQDN of it */ + hp = gethostbyname(tmpbuf); + if (hp == (struct hostent *) NULL) + { + /* exit with error message */ + fprintf(stderr, + "gethostbyname failed for %s\n", tmpbuf); + exit(PS_DNS); + } + return(xstrdup(hp->h_name)); + } + else +#endif /* HAVE_GETHOSTBYNAME */ + return(xstrdup(tmpbuf)); +} + + char *showproto(int proto) /* protocol index to protocol name mapping */ { |