Exemplo n.º 1
0
void execute_line(char *cmdbuf)
{
  int argc;
  char *argv[MAXARGS];

  argc = parse(cmdbuf, argv);
  if (argc == 0)
    return;
  if (!strcmp(argv[0], "noop"))
    test_noop();
  else if (!strcmp(argv[0], "connect") || !strcmp(argv[0], "c"))
    test_connect(argc, argv);
  else if (!strcmp(argv[0], "disconnect") || !strcmp(argv[0], "d"))
    test_disconnect();
  else if (!strcmp(argv[0], "host"))
    test_host();
  else if (!strcmp(argv[0], "motd") || !strcmp(argv[0], "m"))
    test_motd();
  else if (!strcmp(argv[0], "query") || !strcmp(argv[0], "qy"))
    test_query(argc, argv);
  else if (!strcmp(argv[0], "auth") || !strcmp(argv[0], "a"))
    test_krb5_auth();
  else if (!strcmp(argv[0], "proxy") || !strcmp(argv[0], "p"))
    test_proxy(argc, argv);
  else if (!strcmp(argv[0], "access"))
    test_access(argc, argv);
  else if (!strcmp(argv[0], "dcm"))
    test_dcm();
  else if (!strcmp(argv[0], "script") || !strcmp(argv[0], "s"))
    test_script(argc, argv);
  else if (!strcmp(argv[0], "list_requests") ||
	  !strcmp(argv[0], "lr") || !strcmp(argv[0], "?"))
    test_list_requests();
  else if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "Q"))
    quit = 1;
  else if (!strcmp(argv[0], "version") || !strcmp(argv[0], "v"))
    test_version(argc, argv);
  else if (!strcmp(argv[0], "krb4_auth") || !strcmp(argv[0], "4"))
    test_auth();
  else
    {
      fprintf(stderr, "moira: Unknown request \"%s\".  "
	      "Type \"?\" for a request list.\n", argv[0]);
    }
}
Exemplo n.º 2
0
static int childprocess_unittest(void)
{
   resourceusage_t usage = resourceusage_FREE;
   directory_t* dir = 0;
   uint8_t      dirpath[256];

   if (test_initfree())    goto ONERR;

   TEST(0 == init_resourceusage(&usage));

   // prepare
   TEST(0 == newtemp_directory(&dir, "iothread", &(wbuffer_t) wbuffer_INIT_STATIC(sizeof(dirpath), dirpath)));

   if (test_helper())      goto ONERR;
   if (test_initfree())    goto ONERR;
   if (test_noop())        goto ONERR;
   if (test_read(dir))     goto ONERR;
   if (test_write(dir))    goto ONERR;
   if (test_rwerror())     goto ONERR;
   if (test_rwpartial(dir)) goto ONERR;

   // reset
   TEST(0 == delete_directory(&dir));
   TEST(0 == removedirectory_directory(0, (const char*)dirpath));

   TEST(0 == same_resourceusage(&usage));
   TEST(0 == free_resourceusage(&usage));

   return 0;
ONERR:
   if (dir) {
      delete_directory(&dir);
      removedirectory_directory(0, (const char*)dirpath);
   }
   free_resourceusage(&usage);
   return EINVAL;
}
Exemplo n.º 3
0
int
main(int argc, char *argv[]) {
	int ret;
#ifdef USE_ISC_MEM
	isc_mem_t *mem;
	isc_result_t result;
#endif

	(void)argc;
	(void)argv;

#ifdef USE_ISC_MEM
	mem = NULL;
	result = isc_mem_create(0, 0, &mem);
	INSIST(result == ISC_R_SUCCESS);
#endif

	ctx = NULL;
#ifdef USE_ISC_MEM
	ret = lwres_context_create(&ctx, mem, mem_alloc, mem_free, 0);
#else
	ret = lwres_context_create(&ctx, NULL, NULL, NULL, 0);
#endif

	CHECK(ret, "lwres_context_create");

	ret = lwres_conf_parse(ctx, "/etc/resolv.conf");
	CHECK(ret, "lwres_conf_parse");

	lwres_conf_print(ctx, stdout);

	test_noop();

	/*
	 * The following comments about tests all assume your search path is
	 *	nominum.com isc.org flame.org
	 * and ndots is the default of 1.
	 */
	test_gabn("alias-05.test"); /* exact, then search. */
	test_gabn("f.root-servers.net.");
	test_gabn("poofball.flame.org.");
	test_gabn("foo.ip6.int.");
	test_gabn("notthereatall.flame.org");  /* exact, then search (!found)*/
	test_gabn("shell"); /* search (found in nominum.com), then exact */
	test_gabn("kechara"); /* search (found in flame.org), then exact */
	test_gabn("lkasdjlaksjdlkasjdlkasjdlkasjd"); /* search, exact(!found)*/

	test_gnba("198.133.199.1", LWRES_ADDRTYPE_V4);
	test_gnba("204.152.184.79", LWRES_ADDRTYPE_V4);
	test_gnba("3ffe:8050:201:1860:42::1", LWRES_ADDRTYPE_V6);

	lwres_conf_clear(ctx);
	lwres_context_destroy(&ctx);

#ifdef USE_ISC_MEM
	isc_mem_stats(mem, stdout);
	isc_mem_destroy(&mem);
#endif

	return (0);
}
Exemplo n.º 4
0
int
main(void) {
	lwres_result_t ret;

	lwres_udp_port = 9210;
	lwres_resolv_conf = "resolv.conf";

	ret = lwres_context_create(&ctx, NULL, NULL, NULL, 0);
	CHECK(ret, "lwres_context_create");

	ret = lwres_conf_parse(ctx, "resolv.conf");
	CHECK(ret, "lwres_conf_parse");

	test_noop();

	test_gabn("a.example1", LWRES_R_SUCCESS, "10.0.1.1",
		  LWRES_ADDRTYPE_V4);
	test_gabn("a.example1.", LWRES_R_SUCCESS, "10.0.1.1",
		  LWRES_ADDRTYPE_V4);
	test_gabn("a.example2", LWRES_R_SUCCESS, "10.0.2.1",
		  LWRES_ADDRTYPE_V4);
	test_gabn("a.example2.", LWRES_R_SUCCESS, "10.0.2.1",
		  LWRES_ADDRTYPE_V4);
	test_gabn("a.example3", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);
	test_gabn("a.example3.", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);
	test_gabn("a", LWRES_R_SUCCESS, "10.0.1.1", LWRES_ADDRTYPE_V4);
	test_gabn("a.", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);

	test_gabn("a2", LWRES_R_SUCCESS, "10.0.1.1", LWRES_ADDRTYPE_V4);
	test_gabn("a3", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);

	test_gabn("b.example1", LWRES_R_SUCCESS,
		  "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
		  LWRES_ADDRTYPE_V6);
	test_gabn("b.example1.", LWRES_R_SUCCESS,
		  "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
		  LWRES_ADDRTYPE_V6);
	test_gabn("b.example2", LWRES_R_SUCCESS,
		  "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
		  LWRES_ADDRTYPE_V6);
	test_gabn("b.example2.", LWRES_R_SUCCESS,
		  "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
		  LWRES_ADDRTYPE_V6);
	test_gabn("b.example3", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);
	test_gabn("b.example3.", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);
	test_gabn("b", LWRES_R_SUCCESS,
		  "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
		  LWRES_ADDRTYPE_V6);
	test_gabn("b.", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);

	test_gabn("d.example1", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);

	test_gabn("x", LWRES_R_SUCCESS, "10.1.10.1", LWRES_ADDRTYPE_V4);
	test_gabn("x.", LWRES_R_SUCCESS, "10.1.10.1", LWRES_ADDRTYPE_V4);

	test_gnba("10.10.10.1", LWRES_ADDRTYPE_V4, LWRES_R_SUCCESS,
		  "ipv4.example");
	test_gnba("10.10.10.17", LWRES_ADDRTYPE_V4, LWRES_R_NOTFOUND,
		  NULL);
	test_gnba("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
		  LWRES_ADDRTYPE_V6, LWRES_R_SUCCESS, "ip6.int.example");
	test_gnba("0123:4567:89ab:cdef:0123:4567:89ab:cde0",
		  LWRES_ADDRTYPE_V6, LWRES_R_NOTFOUND, NULL);
	test_gnba("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
		  LWRES_ADDRTYPE_V6, LWRES_R_SUCCESS, "ip6.arpa.example");
	test_gnba("1123:4567:89ab:cdef:0123:4567:89ab:cde0",
		  LWRES_ADDRTYPE_V6, LWRES_R_NOTFOUND, NULL);

	test_gethostbyname("a.example1.", "10.0.1.1");
	test_gethostbyname("q.example1.", NULL);

	test_gethostbyname2("a.example1.", "10.0.1.1", AF_INET);
	test_gethostbyname2("b.example1.",
			    "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
			    AF_INET6);
	test_gethostbyname2("q.example1.", NULL, AF_INET);

	test_getipnodebyname("a.example1.", "10.0.1.1", AF_INET, 0, 0);
	test_getipnodebyname("b.example1.",
			     "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
			     AF_INET6, 0, 0);
	test_getipnodebyname("a.example1.",
			     "::ffff:10.0.1.1", AF_INET6, 1, 0);
	test_getipnodebyname("a.example1.",
			     "::ffff:10.0.1.1", AF_INET6, 1, 1);
	test_getipnodebyname("b.example1.",
			     "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
			     AF_INET6, 1, 1);
	test_getipnodebyname("q.example1.", NULL, AF_INET, 0, 0);

	test_gethostbyaddr("10.10.10.1", AF_INET, "ipv4.example");
	test_gethostbyaddr("10.10.10.17", AF_INET, NULL);
	test_gethostbyaddr("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
			   AF_INET6, "ip6.int.example");
	test_gethostbyaddr("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
			   AF_INET6, "ip6.arpa.example");

	test_getipnodebyaddr("10.10.10.1", AF_INET, "ipv4.example");
	test_getipnodebyaddr("10.10.10.17", AF_INET, NULL);
	test_getipnodebyaddr("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
			     AF_INET6, "ip6.int.example");
	test_getipnodebyaddr("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
			     AF_INET6, "ip6.arpa.example");

	test_getaddrinfo("a.example1.", AF_INET, 1, 1, "10.0.1.1");
	test_getaddrinfo("a.example1.", AF_INET, 1, 0, "10.0.1.1");
	test_getaddrinfo("a.example1.", AF_INET, 0, 1, NULL);
	test_getaddrinfo("b.example1.", AF_INET6, 1, 1,
			 "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff");
	test_getaddrinfo("b.example1.", AF_INET6, 1, 0, NULL);
	test_getaddrinfo("b.example1.", AF_INET6, 0, 1,
			 "eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff");

	test_getnameinfo("10.10.10.1", AF_INET, "ipv4.example");
	test_getnameinfo("10.10.10.17", AF_INET, NULL);
	test_getnameinfo("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
			 AF_INET6, "ip6.int.example");
	test_getnameinfo("1123:4567:89ab:cdef:0123:4567:89ab:cdef",
			 AF_INET6, "ip6.arpa.example");
	test_getnameinfo("1122:3344:5566:7788:99aa:bbcc:ddee:ff00",
			 AF_INET6, "dname.example1");

	test_getrrsetbyname("a", 1, 1, 1, 0, 1);
	test_getrrsetbyname("a.example1.", 1, 1, 1, 0, 1);
	test_getrrsetbyname("e.example1.", 1, 1, 1, 1, 1);
	test_getrrsetbyname("e.example1.", 1, 255, 1, 1, 0);
	test_getrrsetbyname("e.example1.", 1, 46, 2, 0, 1);
	test_getrrsetbyname("", 1, 1, 0, 0, 0);

	if (fails == 0)
		printf("I:ok\n");
	return (fails);
}