From 6a145dfedf241d85fb9f1234d760e1f8d6b1e157 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 27 Aug 1998 17:10:46 +0000 Subject: Compute FQDN when Kerberos is in use. svn path=/trunk/; revision=2061 --- env.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'env.c') 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 */ { -- cgit v1.2.3