aboutsummaryrefslogtreecommitdiffstats
path: root/env.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-08-27 17:10:46 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-08-27 17:10:46 +0000
commit6a145dfedf241d85fb9f1234d760e1f8d6b1e157 (patch)
tree54d7f74f4094999d06d8bb256d333677f23e571d /env.c
parent543380aa15cd07d4e15298312c633d37878fe6cf (diff)
downloadfetchmail-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.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/env.c b/env.c
index 3e86ac45..16254ddd 100644
--- a/env.c
+++ b/env.c
@@ -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 */
{