Added Ezra's test to see if you have a buggy resolver or not
authorTheodore Tso <tytso@mit.edu>
Wed, 1 Mar 1995 21:55:04 +0000 (21:55 +0000)
committerTheodore Tso <tytso@mit.edu>
Wed, 1 Mar 1995 21:55:04 +0000 (21:55 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5041 dc483132-0cff-0310-8789-dd5450dbe970

src/tests/ChangeLog
src/tests/configure.in
src/tests/resolve/Makefile.in [new file with mode: 0644]
src/tests/resolve/configure.in [new file with mode: 0644]
src/tests/resolve/resolve.c [new file with mode: 0644]

index a83c8d9e92eca28165458182de49f2848c302856..89aab3e75ff111ef026a23867e2f44eb3a36d4cb 100644 (file)
@@ -1,3 +1,7 @@
+Wed Mar  1 16:31:35 1995  Theodore Y. Ts'o  <tytso@dcl>
+
+       * configure.in: Added resolve subdirectory.
+
 Tue Feb 28 01:23:18 1995  John Gilmore  (gnu at toad.com)
 
        * dump.c, test1.c:  Avoid <krb5/...> includes.
index 87a84c41f3f9fcb4d81e0c51031c820dd64c8f14..2a0d59e4b7cc347227d268e350a8cc93d8a1b8bd 100644 (file)
@@ -1,7 +1,7 @@
 AC_INIT(configure.in)
 WITH_CCOPTS
 AC_SET_BUILDTOP
-CONFIG_DIRS(asn.1 create hammer verify)
+CONFIG_DIRS(resolve asn.1 create hammer verify)
 MAKE_SUBDIRS("making",all)
 MAKE_SUBDIRS("cleaning",clean)
 MAKE_SUBDIRS("installing",install)
diff --git a/src/tests/resolve/Makefile.in b/src/tests/resolve/Makefile.in
new file mode 100644 (file)
index 0000000..8c0c0e6
--- /dev/null
@@ -0,0 +1,20 @@
+CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDES)
+LDFLAGS = -g
+
+OBJS=resolve.o
+SRCS=$(srcdir)/resolve.c
+
+all:: resolve
+
+
+resolve: $(OBJS)
+       $(LD) $(CFLAGS) -o resolve $(OBJS) $(LIBS)
+
+check:: resolve
+       ./resolve
+
+install::
+
+clean::
+       $(RM) resolve
+
diff --git a/src/tests/resolve/configure.in b/src/tests/resolve/configure.in
new file mode 100644 (file)
index 0000000..29ec389
--- /dev/null
@@ -0,0 +1,9 @@
+AC_INIT(resolve.c)
+WITH_CCOPTS
+CONFIG_RULES
+AC_SET_BUILDTOP
+AC_HEADER_STDC
+AC_CHECK_FUNCS(strchr)
+WITH_NETLIB
+AC_CHECK_HEADERS(sys/param.h sys/socket.h)
+V5_AC_OUTPUT_MAKEFILE
diff --git a/src/tests/resolve/resolve.c b/src/tests/resolve/resolve.c
new file mode 100644 (file)
index 0000000..f89ecb1
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * test/resolve/resolve.c
+ *
+ * Copyright 1995 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ *   require a specific license from the United States Government.
+ *   It is the responsibility of any person or organization contemplating
+ *   export to obtain such a license before exporting.
+ * 
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without express
+ * or implied warranty.
+ * 
+ *
+ * A simple program to test the functionality of the resolver library.
+ * It simply will try to get the IP address of the host, and then look 
+ * up the name from the address. If the resulting name does not contain the
+ * domain name, then the resolve library is broken.
+ *
+ * Warning: It is possible to fool this program into thinking everything is 
+ * alright byt a clever use of /etc/hosts - but this is better than nothing.
+ *
+ * Usage:
+ *   resolve [hostname]
+ *
+ *   When invoked with no arguments, gethostname is used for the local host.
+ *
+ */
+
+/* This program tests the resolve library and sees if it is broken... */
+
+#include <stdio.h>
+
+#if STDC_HEADERS
+#include <string.h>
+#else
+#ifndef HAVE_STRCHR
+#define strchr index
+#endif
+char *strchr();
+#endif
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#include <netdb.h>
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+       char myname[MAXHOSTNAMELEN+1];
+       char *ptr;
+       struct hostent *host;
+       int err;
+
+       if(argc > 1) {
+               strncpy(myname, argv[1], MAXHOSTNAMELEN);
+       } else {
+               if(gethostname(myname, MAXHOSTNAMELEN)) {
+                       perror("gethostname failure");
+                       exit(1);
+               }
+       }
+       
+       myname[MAXHOSTNAMELEN] = '\0';  /* for safety */
+       
+       /* Look up the address... */
+       printf("Hostname:  %s\n", myname);
+       
+
+       /* Set the hosts db to close each time - effectively rewinding file */
+       sethostent(0);
+
+       if((host = gethostbyname (myname)) == NULL) {
+               fprintf(stderr, "Could not look up hostname - fatal\n");
+               exit(2);
+       }
+       
+       ptr = host->h_addr_list[0];
+#define UC(a) (((int)a)&0xff)
+       printf("Host address: %d.%d.%d.%d\n", 
+              UC(ptr[0]), UC(ptr[1]), UC(ptr[2]), UC(ptr[3]));
+
+       /* Convert back to full name */
+       if((host = gethostbyaddr(ptr, 4, AF_INET)) == NULL) {
+               fprintf(stderr, "Error looking up IP address - fatal\n");
+               exit(2);
+       }
+       
+       printf("FQDN: %s\n", host->h_name);
+       
+       if(strchr(host->h_name, '.') == NULL) {
+               fprintf(stderr, "\nResolve library did not return a fully qualified domain name\n");
+               fprintf(stderr, "You may have to reconfigure the kerberos distribution to select a\ndifferent set of libraries using --with-netlib[=libs]\n");
+               exit(3);
+       }
+       printf("Resolve library appears to have passed the test\n");
+
+       /* All ok */
+       exit(0);
+
+}
+
+