diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-23 22:54:17 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-23 22:55:31 +0100 |
commit | c3e03e28f3e7fa92f8099103c7c70a0d1196b992 (patch) | |
tree | d8e76cf34ff950b79a53829f56c495a6e3bab705 | |
parent | 8f65dd2db3c32e12752592f76833dc66e0bd3f9e (diff) | |
download | gnunet-c3e03e28f3e7fa92f8099103c7c70a0d1196b992.tar.gz gnunet-c3e03e28f3e7fa92f8099103c7c70a0d1196b992.zip |
use of dns2gns proxy instead of DNS interceptor in VPN test
-rwxr-xr-x | contrib/gnunet-gns-import.sh | 2 | ||||
-rw-r--r-- | src/pt/test_gns_vpn.c | 251 | ||||
-rw-r--r-- | src/pt/test_gns_vpn.conf | 4 |
3 files changed, 139 insertions, 118 deletions
diff --git a/contrib/gnunet-gns-import.sh b/contrib/gnunet-gns-import.sh index 8c9d1b9d4..8614821fe 100755 --- a/contrib/gnunet-gns-import.sh +++ b/contrib/gnunet-gns-import.sh | |||
@@ -63,7 +63,7 @@ gnunet-identity -e master-zone -s gns-proxy $options | |||
63 | 63 | ||
64 | # Use master-zone for intercepted DNS queries | 64 | # Use master-zone for intercepted DNS queries |
65 | # (remove this entry to disable DNS interception by GNS service) | 65 | # (remove this entry to disable DNS interception by GNS service) |
66 | gnunet-identity -e master-zone -s gns-intercept $options | 66 | gnunet-identity -e master-zone -s dns2gns $options |
67 | 67 | ||
68 | # 'gns-private' is not yet used (!) | 68 | # 'gns-private' is not yet used (!) |
69 | gnunet-identity -e private-zone -s gns-private $options | 69 | gnunet-identity -e private-zone -s gns-private $options |
diff --git a/src/pt/test_gns_vpn.c b/src/pt/test_gns_vpn.c index 4b7e817e8..53f27610b 100644 --- a/src/pt/test_gns_vpn.c +++ b/src/pt/test_gns_vpn.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2007, 2009, 2011, 2012, 2015 Christian Grothoff | 3 | Copyright (C) 2007, 2009, 2011, 2012, 2015, 2017 Christian Grothoff |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -22,6 +22,19 @@ | |||
22 | * @file test_gns_vpn.c | 22 | * @file test_gns_vpn.c |
23 | * @brief testcase for accessing VPN services via GNS | 23 | * @brief testcase for accessing VPN services via GNS |
24 | * @author Martin Schanzenbach | 24 | * @author Martin Schanzenbach |
25 | * @author Christian Grothoff | ||
26 | * | ||
27 | * This test requires libcurl/libgnurl *with* support for C-ARES. | ||
28 | * This is NOT the default on most platforms, which means the test | ||
29 | * will be skipped in many cases. Compile libcurl/libgnurl with | ||
30 | * "--enable-ares" to get this test to pass. | ||
31 | * | ||
32 | * Furthermore, the test relies on gnunet-dns2gns being able to bind | ||
33 | * to port 53. This means that 'setcap' has to have worked during | ||
34 | * 'make install'. If this failed, but everything else is OK, the | ||
35 | * test may FAIL hard even though it is just an installation issue (we | ||
36 | * cannot conveniently test for the setcap to have worked). However, | ||
37 | * you should get a warning that gnunet-dns2gns failed to 'bind'. | ||
25 | */ | 38 | */ |
26 | #include "platform.h" | 39 | #include "platform.h" |
27 | #if HAVE_CURL_CURL_H | 40 | #if HAVE_CURL_CURL_H |
@@ -39,7 +52,7 @@ | |||
39 | #define PORT 8080 | 52 | #define PORT 8080 |
40 | #define TEST_DOMAIN "www.gnu" | 53 | #define TEST_DOMAIN "www.gnu" |
41 | 54 | ||
42 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) | 55 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
43 | 56 | ||
44 | /** | 57 | /** |
45 | * Return value for #main(). | 58 | * Return value for #main(). |
@@ -96,7 +109,10 @@ static struct CBC cbc; | |||
96 | 109 | ||
97 | 110 | ||
98 | static size_t | 111 | static size_t |
99 | copy_buffer (void *ptr, size_t size, size_t nmemb, void *ctx) | 112 | copy_buffer (void *ptr, |
113 | size_t size, | ||
114 | size_t nmemb, | ||
115 | void *ctx) | ||
100 | { | 116 | { |
101 | struct CBC *cbc = ctx; | 117 | struct CBC *cbc = ctx; |
102 | 118 | ||
@@ -174,6 +190,11 @@ do_shutdown (void *cls) | |||
174 | GNUNET_NAMESTORE_cancel (qe); | 190 | GNUNET_NAMESTORE_cancel (qe); |
175 | qe = NULL; | 191 | qe = NULL; |
176 | } | 192 | } |
193 | if (NULL != namestore) | ||
194 | { | ||
195 | GNUNET_NAMESTORE_disconnect (namestore); | ||
196 | namestore = NULL; | ||
197 | } | ||
177 | GNUNET_free_non_null (url); | 198 | GNUNET_free_non_null (url); |
178 | url = NULL; | 199 | url = NULL; |
179 | } | 200 | } |
@@ -280,6 +301,9 @@ curl_main () | |||
280 | static void | 301 | static void |
281 | start_curl (void *cls) | 302 | start_curl (void *cls) |
282 | { | 303 | { |
304 | CURLcode ec; | ||
305 | |||
306 | curl_task_id = NULL; | ||
283 | GNUNET_asprintf (&url, | 307 | GNUNET_asprintf (&url, |
284 | "http://%s/hello_world", | 308 | "http://%s/hello_world", |
285 | TEST_DOMAIN); | 309 | TEST_DOMAIN); |
@@ -291,7 +315,18 @@ start_curl (void *cls) | |||
291 | curl_easy_setopt (curl, CURLOPT_TIMEOUT, 150L); | 315 | curl_easy_setopt (curl, CURLOPT_TIMEOUT, 150L); |
292 | curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 150L); | 316 | curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT, 150L); |
293 | curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1); | 317 | curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1); |
294 | 318 | if (CURLE_OK != | |
319 | (ec = curl_easy_setopt (curl, | ||
320 | CURLOPT_DNS_SERVERS, | ||
321 | "127.0.0.1:53"))) | ||
322 | { | ||
323 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
324 | "curl build without support for CURLOPT_DNS_SERVERS (%s), cannot run test\n", | ||
325 | curl_easy_strerror (ec)); | ||
326 | global_ret = 77; | ||
327 | GNUNET_SCHEDULER_shutdown (); | ||
328 | return; | ||
329 | } | ||
295 | multi = curl_multi_init (); | 330 | multi = curl_multi_init (); |
296 | GNUNET_assert (multi != NULL); | 331 | GNUNET_assert (multi != NULL); |
297 | GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl)); | 332 | GNUNET_assert (CURLM_OK == curl_multi_add_handle (multi, curl)); |
@@ -302,14 +337,6 @@ start_curl (void *cls) | |||
302 | } | 337 | } |
303 | 338 | ||
304 | 339 | ||
305 | static void | ||
306 | disco_ns (void* cls) | ||
307 | { | ||
308 | GNUNET_NAMESTORE_disconnect (namestore); | ||
309 | namestore = NULL; | ||
310 | } | ||
311 | |||
312 | |||
313 | /** | 340 | /** |
314 | * Callback invoked from the namestore service once record is | 341 | * Callback invoked from the namestore service once record is |
315 | * created. | 342 | * created. |
@@ -328,9 +355,8 @@ commence_testing (void *cls, | |||
328 | const char *emsg) | 355 | const char *emsg) |
329 | { | 356 | { |
330 | qe = NULL; | 357 | qe = NULL; |
331 | GNUNET_SCHEDULER_add_now (&disco_ns, NULL); | 358 | if ( (NULL != emsg) && |
332 | 359 | (GNUNET_YES != success) ) | |
333 | if ((emsg != NULL) && (GNUNET_YES != success)) | ||
334 | { | 360 | { |
335 | fprintf (stderr, | 361 | fprintf (stderr, |
336 | "NS failed to create record %s\n", | 362 | "NS failed to create record %s\n", |
@@ -338,11 +364,14 @@ commence_testing (void *cls, | |||
338 | GNUNET_SCHEDULER_shutdown (); | 364 | GNUNET_SCHEDULER_shutdown (); |
339 | return; | 365 | return; |
340 | } | 366 | } |
367 | |||
341 | /* wait a little bit before downloading, as we just created the record */ | 368 | /* wait a little bit before downloading, as we just created the record */ |
342 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 369 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
343 | (GNUNET_TIME_UNIT_SECONDS, 1), | 370 | "Launching cURL request\n"); |
344 | &start_curl, | 371 | curl_task_id |
345 | NULL); | 372 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
373 | &start_curl, | ||
374 | NULL); | ||
346 | } | 375 | } |
347 | 376 | ||
348 | 377 | ||
@@ -402,7 +431,6 @@ mhd_main () | |||
402 | 431 | ||
403 | 432 | ||
404 | 433 | ||
405 | |||
406 | /** | 434 | /** |
407 | * Open '/dev/null' and make the result the given | 435 | * Open '/dev/null' and make the result the given |
408 | * file descriptor. | 436 | * file descriptor. |
@@ -448,9 +476,8 @@ fork_and_exec (const char *file, | |||
448 | pid = fork (); | 476 | pid = fork (); |
449 | if (-1 == pid) | 477 | if (-1 == pid) |
450 | { | 478 | { |
451 | fprintf (stderr, | 479 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
452 | "fork failed: %s\n", | 480 | "fork"); |
453 | strerror (errno)); | ||
454 | return 1; | 481 | return 1; |
455 | } | 482 | } |
456 | if (0 == pid) | 483 | if (0 == pid) |
@@ -464,10 +491,9 @@ fork_and_exec (const char *file, | |||
464 | open_dev_null (1, O_WRONLY); | 491 | open_dev_null (1, O_WRONLY); |
465 | (void) execv (file, cmd); | 492 | (void) execv (file, cmd); |
466 | /* can only get here on error */ | 493 | /* can only get here on error */ |
467 | fprintf (stderr, | 494 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
468 | "exec `%s' failed: %s\n", | 495 | "exec", |
469 | file, | 496 | file); |
470 | strerror (errno)); | ||
471 | _exit (1); | 497 | _exit (1); |
472 | } | 498 | } |
473 | /* keep running waitpid as long as the only error we get is 'EINTR' */ | 499 | /* keep running waitpid as long as the only error we get is 'EINTR' */ |
@@ -475,13 +501,20 @@ fork_and_exec (const char *file, | |||
475 | (errno == EINTR) ); | 501 | (errno == EINTR) ); |
476 | if (-1 == ret) | 502 | if (-1 == ret) |
477 | { | 503 | { |
478 | fprintf (stderr, | 504 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
479 | "waitpid failed: %s\n", | 505 | "waitpid"); |
480 | strerror (errno)); | ||
481 | return 1; | 506 | return 1; |
482 | } | 507 | } |
483 | if (! (WIFEXITED (status) && (0 == WEXITSTATUS (status)))) | 508 | if (! (WIFEXITED (status) && |
509 | (0 == WEXITSTATUS (status))) ) | ||
510 | { | ||
511 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
512 | "Process `%s` returned status code %d/%d.\n", | ||
513 | file, | ||
514 | WIFEXITED (status), | ||
515 | WEXITSTATUS (status)); | ||
484 | return 1; | 516 | return 1; |
517 | } | ||
485 | /* child process completed and returned success, we're happy */ | 518 | /* child process completed and returned success, we're happy */ |
486 | return 0; | 519 | return 0; |
487 | } | 520 | } |
@@ -572,6 +605,8 @@ identity_cb (void *cls, | |||
572 | &rd.data_size)); | 605 | &rd.data_size)); |
573 | rd.record_type = GNUNET_GNSRECORD_TYPE_VPN; | 606 | rd.record_type = GNUNET_GNSRECORD_TYPE_VPN; |
574 | 607 | ||
608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
609 | "Creating `www` record\n"); | ||
575 | qe = GNUNET_NAMESTORE_records_store (namestore, | 610 | qe = GNUNET_NAMESTORE_records_store (namestore, |
576 | zone_key, | 611 | zone_key, |
577 | "www", | 612 | "www", |
@@ -593,15 +628,18 @@ run (void *cls, | |||
593 | char *bin; | 628 | char *bin; |
594 | char *bin_identity; | 629 | char *bin_identity; |
595 | char *bin_gns; | 630 | char *bin_gns; |
631 | char *bin_arm; | ||
596 | char *config; | 632 | char *config; |
597 | 633 | ||
634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
635 | "Test logic starting...\n"); | ||
598 | if (GNUNET_OK != | 636 | if (GNUNET_OK != |
599 | GNUNET_CONFIGURATION_get_value_string (cfg, | 637 | GNUNET_CONFIGURATION_get_value_string (cfg, |
600 | "arm", | 638 | "arm", |
601 | "CONFIG", | 639 | "CONFIG", |
602 | &config)) | 640 | &config)) |
603 | { | 641 | { |
604 | fprintf (stderr, | 642 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
605 | "Failed to locate configuration file. Skipping test.\n"); | 643 | "Failed to locate configuration file. Skipping test.\n"); |
606 | GNUNET_SCHEDULER_shutdown (); | 644 | GNUNET_SCHEDULER_shutdown (); |
607 | return; | 645 | return; |
@@ -626,18 +664,27 @@ run (void *cls, | |||
626 | { | 664 | { |
627 | "gnunet-identity", | 665 | "gnunet-identity", |
628 | "-e", "master-zone", | 666 | "-e", "master-zone", |
629 | "-s", "gns-intercept", | 667 | "-s", "dns2gns", |
668 | "-c", config, | ||
669 | NULL | ||
670 | }; | ||
671 | char *const arm_args[] = | ||
672 | { | ||
673 | "gnunet-arm", | ||
674 | "-i", "dns2gns", | ||
630 | "-c", config, | 675 | "-c", config, |
631 | NULL | 676 | NULL |
632 | }; | 677 | }; |
633 | char *const gns_args[] = | 678 | char *const gns_args[] = |
634 | { | 679 | { |
635 | "gnunet-gns", | 680 | "gnunet-gns", |
636 | "-u", "www.gns", | 681 | "-u", "www.gnu", |
637 | "-c", config, | 682 | "-c", config, |
638 | NULL | 683 | NULL |
639 | }; | 684 | }; |
640 | GNUNET_TESTING_peer_get_identity (peer, &id); | 685 | |
686 | GNUNET_TESTING_peer_get_identity (peer, | ||
687 | &id); | ||
641 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, | 688 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
642 | NULL); | 689 | NULL); |
643 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 690 | timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
@@ -648,20 +695,24 @@ run (void *cls, | |||
648 | "%s/%s", | 695 | "%s/%s", |
649 | bin, | 696 | bin, |
650 | "gnunet-identity"); | 697 | "gnunet-identity"); |
698 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
699 | "Creating `master-zone` ego\n"); | ||
651 | if (0 != fork_and_exec (bin_identity, identity_args)) | 700 | if (0 != fork_and_exec (bin_identity, identity_args)) |
652 | { | 701 | { |
653 | fprintf (stderr, | 702 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
654 | "Failed to run `gnunet-identity -C. Skipping test.\n"); | 703 | "Failed to run `gnunet-identity -C`. Skipping test.\n"); |
655 | GNUNET_SCHEDULER_shutdown (); | 704 | GNUNET_SCHEDULER_shutdown (); |
656 | GNUNET_free (bin_identity); | 705 | GNUNET_free (bin_identity); |
657 | GNUNET_free (config); | 706 | GNUNET_free (config); |
658 | GNUNET_free (bin); | 707 | GNUNET_free (bin); |
659 | return; | 708 | return; |
660 | } | 709 | } |
710 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
711 | "Setting `master-zone` ego as default for `gns-master` and `dns2gns`\n"); | ||
661 | if (0 != fork_and_exec (bin_identity, identity2_args)) | 712 | if (0 != fork_and_exec (bin_identity, identity2_args)) |
662 | { | 713 | { |
663 | fprintf (stderr, | 714 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
664 | "Failed to run `gnunet-identity -e. Skipping test.\n"); | 715 | "Failed to run `gnunet-identity -e`. Skipping test.\n"); |
665 | GNUNET_SCHEDULER_shutdown (); | 716 | GNUNET_SCHEDULER_shutdown (); |
666 | GNUNET_free (bin_identity); | 717 | GNUNET_free (bin_identity); |
667 | GNUNET_free (config); | 718 | GNUNET_free (config); |
@@ -670,8 +721,8 @@ run (void *cls, | |||
670 | } | 721 | } |
671 | if (0 != fork_and_exec (bin_identity, identity3_args)) | 722 | if (0 != fork_and_exec (bin_identity, identity3_args)) |
672 | { | 723 | { |
673 | fprintf (stderr, | 724 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
674 | "Failed to run `gnunet-identity -e. Skipping test.\n"); | 725 | "Failed to run `gnunet-identity -e`. Skipping test.\n"); |
675 | GNUNET_SCHEDULER_shutdown (); | 726 | GNUNET_SCHEDULER_shutdown (); |
676 | GNUNET_free (bin_identity); | 727 | GNUNET_free (bin_identity); |
677 | GNUNET_free (config); | 728 | GNUNET_free (config); |
@@ -681,14 +732,17 @@ run (void *cls, | |||
681 | GNUNET_free (bin_identity); | 732 | GNUNET_free (bin_identity); |
682 | 733 | ||
683 | /* do lookup just to launch GNS service */ | 734 | /* do lookup just to launch GNS service */ |
735 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
736 | "Resolving `www.gnu` zone entry to launch GNS (will yield no answer yet)\n"); | ||
684 | GNUNET_asprintf (&bin_gns, | 737 | GNUNET_asprintf (&bin_gns, |
685 | "%s/%s", | 738 | "%s/%s", |
686 | bin, | 739 | bin, |
687 | "gnunet-gns"); | 740 | "gnunet-gns"); |
688 | if (0 != fork_and_exec (bin_gns, gns_args)) | 741 | if (0 != fork_and_exec (bin_gns, |
742 | gns_args)) | ||
689 | { | 743 | { |
690 | fprintf (stderr, | 744 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
691 | "Failed to run `gnunet-gns -u. Skipping test.\n"); | 745 | "Failed to run `gnunet-gns -u. Skipping test.\n"); |
692 | GNUNET_SCHEDULER_shutdown (); | 746 | GNUNET_SCHEDULER_shutdown (); |
693 | GNUNET_free (bin_gns); | 747 | GNUNET_free (bin_gns); |
694 | GNUNET_free (config); | 748 | GNUNET_free (config); |
@@ -696,9 +750,27 @@ run (void *cls, | |||
696 | return; | 750 | return; |
697 | } | 751 | } |
698 | GNUNET_free (bin_gns); | 752 | GNUNET_free (bin_gns); |
753 | |||
754 | GNUNET_asprintf (&bin_arm, | ||
755 | "%s/%s", | ||
756 | bin, | ||
757 | "gnunet-arm"); | ||
758 | if (0 != fork_and_exec (bin_arm, | ||
759 | arm_args)) | ||
760 | { | ||
761 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
762 | "Failed to run `gnunet-arm -i dns2gns. Skipping test.\n"); | ||
763 | GNUNET_SCHEDULER_shutdown (); | ||
764 | GNUNET_free (bin_arm); | ||
765 | GNUNET_free (config); | ||
766 | GNUNET_free (bin); | ||
767 | return; | ||
768 | } | ||
769 | GNUNET_free (bin_arm); | ||
770 | |||
699 | GNUNET_free (config); | 771 | GNUNET_free (config); |
700 | GNUNET_free (bin); | 772 | GNUNET_free (bin); |
701 | 773 | sleep (1); /* give dns2gns chance to really run */ | |
702 | 774 | ||
703 | namestore = GNUNET_NAMESTORE_connect (cfg); | 775 | namestore = GNUNET_NAMESTORE_connect (cfg); |
704 | GNUNET_assert (NULL != namestore); | 776 | GNUNET_assert (NULL != namestore); |
@@ -720,39 +792,15 @@ run (void *cls, | |||
720 | 792 | ||
721 | 793 | ||
722 | int | 794 | int |
723 | main (int argc, char *const *argv) | 795 | main (int argc, |
796 | char *const *argv) | ||
724 | { | 797 | { |
725 | char *sbin_iptables; | ||
726 | char *bin_vpn; | 798 | char *bin_vpn; |
727 | char *bin_exit; | 799 | char *bin_exit; |
728 | char *bin_dns; | ||
729 | char *srv_dns; | ||
730 | struct stat s; | ||
731 | gid_t my_gid; | ||
732 | char *const iptables_args[] = | ||
733 | { | ||
734 | "iptables", "-t", "mangle", "-L", "-v", NULL | ||
735 | }; | ||
736 | |||
737 | if (0 == access ("/sbin/iptables", X_OK)) | ||
738 | sbin_iptables = "/sbin/iptables"; | ||
739 | else if (0 == access ("/usr/sbin/iptables", X_OK)) | ||
740 | sbin_iptables = "/usr/sbin/iptables"; | ||
741 | else | ||
742 | { | ||
743 | fprintf (stderr, | ||
744 | "Executable iptables not found in approved directories: %s, skipping\n", | ||
745 | strerror (errno)); | ||
746 | return 77; | ||
747 | } | ||
748 | |||
749 | if (0 != fork_and_exec (sbin_iptables, iptables_args)) | ||
750 | { | ||
751 | fprintf (stderr, | ||
752 | "Failed to run `iptables -t mangle -L -v'. Skipping test.\n"); | ||
753 | return 77; | ||
754 | } | ||
755 | 800 | ||
801 | GNUNET_log_setup ("test-gns-vpn", | ||
802 | "WARNING", | ||
803 | NULL); | ||
756 | if (0 != ACCESS ("/dev/net/tun", R_OK)) | 804 | if (0 != ACCESS ("/dev/net/tun", R_OK)) |
757 | { | 805 | { |
758 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 806 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
@@ -765,59 +813,26 @@ main (int argc, char *const *argv) | |||
765 | 813 | ||
766 | bin_vpn = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-vpn"); | 814 | bin_vpn = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-vpn"); |
767 | bin_exit = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit"); | 815 | bin_exit = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-exit"); |
768 | bin_dns = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-dns"); | ||
769 | srv_dns = GNUNET_OS_get_libexec_binary_path ("gnunet-service-dns"); | ||
770 | if ( (0 != geteuid ()) && | 816 | if ( (0 != geteuid ()) && |
771 | ( (GNUNET_YES != | 817 | ( (GNUNET_YES != |
772 | GNUNET_OS_check_helper_binary (bin_vpn, GNUNET_YES, "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0")) || //ipv4 only please! | 818 | GNUNET_OS_check_helper_binary (bin_vpn, |
819 | GNUNET_YES, | ||
820 | "-d gnunet-vpn - - 169.1.3.3.7 255.255.255.0")) || //ipv4 only please! | ||
773 | (GNUNET_YES != | 821 | (GNUNET_YES != |
774 | GNUNET_OS_check_helper_binary (bin_exit, GNUNET_YES, "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) || //no nat, ipv4 only | 822 | GNUNET_OS_check_helper_binary (bin_exit, |
775 | (GNUNET_YES != | 823 | GNUNET_YES, |
776 | GNUNET_OS_check_helper_binary (bin_dns, GNUNET_YES, NULL))) ) // TODO: once we have a windows-testcase, add test parameters here | 824 | "-d gnunet-vpn - - - 169.1.3.3.7 255.255.255.0")) ) ) //no nat, ipv4 only |
777 | { | 825 | { |
778 | fprintf (stderr, | 826 | fprintf (stderr, |
779 | "WARNING: gnunet-helper-{exit,vpn,dns} binaries in $PATH are not SUID, refusing to run test (as it would have to fail).\n"); | 827 | "WARNING: gnunet-helper-{exit,vpn} binaries in $PATH are not SUID, refusing to run test (as it would have to fail).\n"); |
780 | fprintf (stderr, | 828 | fprintf (stderr, |
781 | "Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n"); | 829 | "Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n"); |
782 | GNUNET_free (bin_vpn); | 830 | GNUNET_free (bin_vpn); |
783 | GNUNET_free (bin_exit); | 831 | GNUNET_free (bin_exit); |
784 | GNUNET_free (bin_dns); | ||
785 | GNUNET_free (srv_dns); | ||
786 | return 77; | 832 | return 77; |
787 | } | 833 | } |
788 | GNUNET_free (bin_vpn); | 834 | GNUNET_free (bin_vpn); |
789 | GNUNET_free (bin_exit); | 835 | GNUNET_free (bin_exit); |
790 | my_gid = getgid (); | ||
791 | if ( (0 != stat (bin_dns, &s)) || | ||
792 | (my_gid == s.st_gid) || | ||
793 | ( (0 == (S_ISUID & s.st_mode)) && (0 != getuid()) ) ) | ||
794 | { | ||
795 | fprintf (stderr, | ||
796 | "WARNING: %s has wrong permissions (%d, %d, %d), refusing to run test (as it would have to fail).\n", | ||
797 | bin_dns, | ||
798 | (0 != stat (bin_dns, &s)), | ||
799 | (my_gid == s.st_gid), | ||
800 | (0 == (S_ISUID & s.st_mode)) || (0 != getuid()) ); | ||
801 | GNUNET_free (bin_dns); | ||
802 | GNUNET_free (srv_dns); | ||
803 | return 77; | ||
804 | } | ||
805 | if ( (0 != stat (srv_dns, &s)) || | ||
806 | (my_gid == s.st_gid) || | ||
807 | (0 == (S_ISGID & s.st_mode)) ) | ||
808 | { | ||
809 | fprintf (stderr, | ||
810 | "WARNING: %s has wrong permissions (%d, %d, %d), refusing to run test (as it would have to fail).\n", | ||
811 | srv_dns, | ||
812 | (0 != stat (bin_dns, &s)), | ||
813 | (my_gid == s.st_gid), | ||
814 | (0 == (S_ISGID & s.st_mode)) ); | ||
815 | GNUNET_free (bin_dns); | ||
816 | GNUNET_free (srv_dns); | ||
817 | return 77; | ||
818 | } | ||
819 | GNUNET_free (bin_dns); | ||
820 | GNUNET_free (srv_dns); | ||
821 | 836 | ||
822 | dest_ip = "169.254.86.1"; | 837 | dest_ip = "169.254.86.1"; |
823 | dest_af = AF_INET; | 838 | dest_af = AF_INET; |
@@ -842,9 +857,11 @@ main (int argc, char *const *argv) | |||
842 | } | 857 | } |
843 | 858 | ||
844 | 859 | ||
845 | if (0 != GNUNET_TESTING_peer_run ("test-gnunet-vpn", | 860 | if (0 != |
846 | "test_gns_vpn.conf", | 861 | GNUNET_TESTING_peer_run ("test_gns_vpn", |
847 | &run, NULL)) | 862 | "test_gns_vpn.conf", |
863 | &run, | ||
864 | NULL)) | ||
848 | return 1; | 865 | return 1; |
849 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-vpn"); | 866 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-vpn"); |
850 | return global_ret; | 867 | return global_ret; |
diff --git a/src/pt/test_gns_vpn.conf b/src/pt/test_gns_vpn.conf index ac9724c04..86642465f 100644 --- a/src/pt/test_gns_vpn.conf +++ b/src/pt/test_gns_vpn.conf | |||
@@ -35,6 +35,10 @@ FORCESTART = YES | |||
35 | AUTOSTART = NO | 35 | AUTOSTART = NO |
36 | FORCESTART = NO | 36 | FORCESTART = NO |
37 | 37 | ||
38 | [zonemaster] | ||
39 | AUTOSTART = YES | ||
40 | FORCESTART = YES | ||
41 | |||
38 | #[vpn] | 42 | #[vpn] |
39 | #PREFIX = valgrind | 43 | #PREFIX = valgrind |
40 | 44 | ||