aboutsummaryrefslogtreecommitdiff
path: root/src/pt
diff options
context:
space:
mode:
Diffstat (limited to 'src/pt')
-rw-r--r--src/pt/test_gns_vpn.c72
-rw-r--r--src/pt/test_gns_vpn.conf2
2 files changed, 70 insertions, 4 deletions
diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c
index e87e13d87..e030842b5 100644
--- a/src/pt/test_gns_vpn.c
+++ b/src/pt/test_gns_vpn.c
@@ -320,8 +320,9 @@ commence_testing (void *cls,
320 GNUNET_SCHEDULER_shutdown (); 320 GNUNET_SCHEDULER_shutdown ();
321 return; 321 return;
322 } 322 }
323 /* wait a little bit before downloading, as we just created the record */
323 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 324 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
324 (GNUNET_TIME_UNIT_SECONDS, 10), 325 (GNUNET_TIME_UNIT_SECONDS, 5),
325 &start_curl, 326 &start_curl,
326 NULL); 327 NULL);
327} 328}
@@ -545,7 +546,7 @@ identity_cb (void *cls,
545 GNUNET_asprintf (&rd_string, 546 GNUNET_asprintf (&rd_string,
546 "6 %s %s", 547 "6 %s %s",
547 peername, 548 peername,
548 "www.gnu."); 549 "www");
549 GNUNET_free (peername); 550 GNUNET_free (peername);
550 GNUNET_assert (GNUNET_OK == 551 GNUNET_assert (GNUNET_OK ==
551 GNUNET_GNSRECORD_string_to_value (GNUNET_GNSRECORD_TYPE_VPN, 552 GNUNET_GNSRECORD_string_to_value (GNUNET_GNSRECORD_TYPE_VPN,
@@ -574,6 +575,7 @@ run (void *cls,
574 575
575 char *bin; 576 char *bin;
576 char *bin_identity; 577 char *bin_identity;
578 char *bin_gns;
577 char *config; 579 char *config;
578 580
579 if (GNUNET_OK != 581 if (GNUNET_OK !=
@@ -611,6 +613,13 @@ run (void *cls,
611 "-c", config, 613 "-c", config,
612 NULL 614 NULL
613 }; 615 };
616 char *const gns_args[] =
617 {
618 "gnunet-gns",
619 "-u", "www.gns",
620 "-c", config,
621 NULL
622 };
614 GNUNET_TESTING_peer_get_identity (peer, &id); 623 GNUNET_TESTING_peer_get_identity (peer, &id);
615 GNUNET_SCHEDULER_add_delayed (TIMEOUT, 624 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
616 &do_shutdown, 625 &do_shutdown,
@@ -620,7 +629,6 @@ run (void *cls,
620 "%s/%s", 629 "%s/%s",
621 bin, 630 bin,
622 "gnunet-identity"); 631 "gnunet-identity");
623 GNUNET_free (bin);
624 if (0 != fork_and_exec (bin_identity, identity_args)) 632 if (0 != fork_and_exec (bin_identity, identity_args))
625 { 633 {
626 fprintf (stderr, 634 fprintf (stderr,
@@ -628,6 +636,7 @@ run (void *cls,
628 GNUNET_SCHEDULER_shutdown (); 636 GNUNET_SCHEDULER_shutdown ();
629 GNUNET_free (bin_identity); 637 GNUNET_free (bin_identity);
630 GNUNET_free (config); 638 GNUNET_free (config);
639 GNUNET_free (bin);
631 return; 640 return;
632 } 641 }
633 if (0 != fork_and_exec (bin_identity, identity2_args)) 642 if (0 != fork_and_exec (bin_identity, identity2_args))
@@ -637,6 +646,7 @@ run (void *cls,
637 GNUNET_SCHEDULER_shutdown (); 646 GNUNET_SCHEDULER_shutdown ();
638 GNUNET_free (bin_identity); 647 GNUNET_free (bin_identity);
639 GNUNET_free (config); 648 GNUNET_free (config);
649 GNUNET_free (bin);
640 return; 650 return;
641 } 651 }
642 if (0 != fork_and_exec (bin_identity, identity3_args)) 652 if (0 != fork_and_exec (bin_identity, identity3_args))
@@ -646,16 +656,35 @@ run (void *cls,
646 GNUNET_SCHEDULER_shutdown (); 656 GNUNET_SCHEDULER_shutdown ();
647 GNUNET_free (bin_identity); 657 GNUNET_free (bin_identity);
648 GNUNET_free (config); 658 GNUNET_free (config);
659 GNUNET_free (bin);
649 return; 660 return;
650 } 661 }
651 GNUNET_free (bin_identity); 662 GNUNET_free (bin_identity);
663
664 /* do lookup just to launch GNS service */
665 GNUNET_asprintf (&bin_gns,
666 "%s/%s",
667 bin,
668 "gnunet-gns");
669 if (0 != fork_and_exec (bin_gns, gns_args))
670 {
671 fprintf (stderr,
672 "Failed to run `gnunet-gns -u. Skipping test.\n");
673 GNUNET_SCHEDULER_shutdown ();
674 GNUNET_free (bin_gns);
675 GNUNET_free (config);
676 GNUNET_free (bin);
677 return;
678 }
652 GNUNET_free (config); 679 GNUNET_free (config);
680 GNUNET_free (bin);
681
653 682
654 namestore = GNUNET_NAMESTORE_connect (cfg); 683 namestore = GNUNET_NAMESTORE_connect (cfg);
655 GNUNET_assert (NULL != namestore); 684 GNUNET_assert (NULL != namestore);
656 flags = MHD_USE_DEBUG; 685 flags = MHD_USE_DEBUG;
657 if (GNUNET_YES == use_v6) 686 if (GNUNET_YES == use_v6)
658 flags |= MHD_USE_IPv6; 687 flags |= MHD_USE_DUAL_STACK;
659 mhd = MHD_start_daemon (flags, 688 mhd = MHD_start_daemon (flags,
660 PORT, 689 PORT,
661 NULL, NULL, 690 NULL, NULL,
@@ -677,6 +706,9 @@ main (int argc, char *const *argv)
677 char *bin_vpn; 706 char *bin_vpn;
678 char *bin_exit; 707 char *bin_exit;
679 char *bin_dns; 708 char *bin_dns;
709 char *srv_dns;
710 struct stat s;
711 gid_t my_gid;
680 char *const iptables_args[] = 712 char *const iptables_args[] =
681 { 713 {
682 "iptables", "-t", "mangle", "-L", "-v", NULL 714 "iptables", "-t", "mangle", "-L", "-v", NULL
@@ -714,6 +746,7 @@ main (int argc, char *const *argv)
714 bin_vpn = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-vpn"); 746 bin_vpn = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-vpn");
715 bin_exit = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit"); 747 bin_exit = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit");
716 bin_dns = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-dns"); 748 bin_dns = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-dns");
749 srv_dns = GNUNET_OS_get_libexec_binary_path ("gnunet-service-dns");
717 if ( (0 != geteuid ()) && 750 if ( (0 != geteuid ()) &&
718 ( (GNUNET_YES != 751 ( (GNUNET_YES !=
719 GNUNET_OS_check_helper_binary (bin_vpn, GNUNET_YES, "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0")) || //ipv4 only please! 752 GNUNET_OS_check_helper_binary (bin_vpn, GNUNET_YES, "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0")) || //ipv4 only please!
@@ -729,11 +762,42 @@ main (int argc, char *const *argv)
729 GNUNET_free (bin_vpn); 762 GNUNET_free (bin_vpn);
730 GNUNET_free (bin_exit); 763 GNUNET_free (bin_exit);
731 GNUNET_free (bin_dns); 764 GNUNET_free (bin_dns);
765 GNUNET_free (srv_dns);
732 return 0; 766 return 0;
733 } 767 }
734 GNUNET_free (bin_vpn); 768 GNUNET_free (bin_vpn);
735 GNUNET_free (bin_exit); 769 GNUNET_free (bin_exit);
770 my_gid = getgid ();
771 if ( (0 != stat (bin_dns, &s)) ||
772 (my_gid == s.st_gid) ||
773 ( (0 == (S_ISUID & s.st_mode)) && (0 != getuid()) ) )
774 {
775 fprintf (stderr,
776 "WARNING: %s has wrong permissions (%d, %d, %d), refusing to run test (as it would have to fail).\n",
777 bin_dns,
778 (0 != stat (bin_dns, &s)),
779 (my_gid == s.st_gid),
780 (0 == (S_ISUID & s.st_mode)) || (0 != getuid()) );
781 GNUNET_free (bin_dns);
782 GNUNET_free (srv_dns);
783 return 0;
784 }
785 if ( (0 != stat (srv_dns, &s)) ||
786 (my_gid == s.st_gid) ||
787 (0 == (S_ISGID & s.st_mode)) )
788 {
789 fprintf (stderr,
790 "WARNING: %s has wrong permissions (%d, %d, %d), refusing to run test (as it would have to fail).\n",
791 srv_dns,
792 (0 != stat (bin_dns, &s)),
793 (my_gid == s.st_gid),
794 (0 == (S_ISGID & s.st_mode)) );
795 GNUNET_free (bin_dns);
796 GNUNET_free (srv_dns);
797 return 0;
798 }
736 GNUNET_free (bin_dns); 799 GNUNET_free (bin_dns);
800 GNUNET_free (srv_dns);
737 801
738 dest_ip = "169.254.86.1"; 802 dest_ip = "169.254.86.1";
739 dest_af = AF_INET; 803 dest_af = AF_INET;
diff --git a/src/pt/test_gns_vpn.conf b/src/pt/test_gns_vpn.conf
index a181527a7..2a683ca7f 100644
--- a/src/pt/test_gns_vpn.conf
+++ b/src/pt/test_gns_vpn.conf
@@ -46,6 +46,8 @@ IPV6ADDR = FC2D:FDAA:6A26::1
46IPV6PREFIX = 64 46IPV6PREFIX = 64
47IPV4ADDR = 169.254.20.1 47IPV4ADDR = 169.254.20.1
48IPV4MASK = 255.255.255.0 48IPV4MASK = 255.255.255.0
49#PREFIX = valgrind
50
49 51
50[www.gnunet.] 52[www.gnunet.]
51TCP_REDIRECTS = 80:localhost4:8080 53TCP_REDIRECTS = 80:localhost4:8080