aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-10-31 09:15:05 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-10-31 09:15:05 +0000
commitf2ac1a162054f0f7646b35d3a03d623c58a24c20 (patch)
tree55b60da9bd2080693e6ac4d138bfc7c491fec645
parent0a0036407218d7f9588d2b6b796b2a6f779bf700 (diff)
downloadgnunet-f2ac1a162054f0f7646b35d3a03d623c58a24c20.tar.gz
gnunet-f2ac1a162054f0f7646b35d3a03d623c58a24c20.zip
locate helpers in libexec
-rw-r--r--src/include/gnunet_testbed_service.h4
-rw-r--r--src/mesh/gnunet-regex-profiler.c2
-rw-r--r--src/testbed/gnunet-testbed-profiler.c2
-rw-r--r--src/testbed/test_testbed_api_3peers_3controllers.c59
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c59
-rw-r--r--src/testbed/testbed.conf.in2
-rw-r--r--src/testbed/testbed_api.c16
-rw-r--r--src/testbed/testbed_api.h7
-rw-r--r--src/testbed/testbed_api_hosts.c20
9 files changed, 54 insertions, 117 deletions
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h
index c2c6812f4..d9aa6dd4a 100644
--- a/src/include/gnunet_testbed_service.h
+++ b/src/include/gnunet_testbed_service.h
@@ -136,11 +136,13 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host);
136 * Checks whether a host can be used to start testbed service 136 * Checks whether a host can be used to start testbed service
137 * 137 *
138 * @param host the host to check 138 * @param host the host to check
139 * @param config the configuration handle to lookup the path of the testbed helper
139 * @return GNUNET_YES if testbed service can be started on the given host 140 * @return GNUNET_YES if testbed service can be started on the given host
140 * remotely; GNUNET_NO if not 141 * remotely; GNUNET_NO if not
141 */ 142 */
142int 143int
143GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host); 144GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
145 const struct GNUNET_CONFIGURATION_Handle *config);
144 146
145 147
146/** 148/**
diff --git a/src/mesh/gnunet-regex-profiler.c b/src/mesh/gnunet-regex-profiler.c
index 7d1ad1035..0e7b7391a 100644
--- a/src/mesh/gnunet-regex-profiler.c
+++ b/src/mesh/gnunet-regex-profiler.c
@@ -1676,7 +1676,7 @@ run (void *cls, char *const *args, const char *cfgfile,
1676 } 1676 }
1677 for (nhost = 0; nhost < num_hosts; nhost++) 1677 for (nhost = 0; nhost < num_hosts; nhost++)
1678 { 1678 {
1679 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost])) 1679 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost], config))
1680 { 1680 {
1681 fprintf (stderr, _("Host %s cannot start testbed\n"), 1681 fprintf (stderr, _("Host %s cannot start testbed\n"),
1682 GNUNET_TESTBED_host_get_hostname (hosts[nhost])); 1682 GNUNET_TESTBED_host_get_hostname (hosts[nhost]));
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c
index 0d9143a86..6a5b3cf71 100644
--- a/src/testbed/gnunet-testbed-profiler.c
+++ b/src/testbed/gnunet-testbed-profiler.c
@@ -718,7 +718,7 @@ run (void *cls, char *const *args, const char *cfgfile,
718 } 718 }
719 for (nhost = 0; nhost < num_hosts; nhost++) 719 for (nhost = 0; nhost < num_hosts; nhost++)
720 { 720 {
721 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost])) 721 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost], config))
722 { 722 {
723 fprintf (stderr, _("Host %s cannot start testbed\n"), 723 fprintf (stderr, _("Host %s cannot start testbed\n"),
724 GNUNET_TESTBED_host_get_hostname_ (hosts[nhost])); 724 GNUNET_TESTBED_host_get_hostname_ (hosts[nhost]));
diff --git a/src/testbed/test_testbed_api_3peers_3controllers.c b/src/testbed/test_testbed_api_3peers_3controllers.c
index 206944ae8..f67042296 100644
--- a/src/testbed/test_testbed_api_3peers_3controllers.c
+++ b/src/testbed/test_testbed_api_3peers_3controllers.c
@@ -680,6 +680,16 @@ run (void *cls, char *const *args, const char *cfgfile,
680{ 680{
681 host = GNUNET_TESTBED_host_create (NULL, NULL, 0); 681 host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
682 GNUNET_assert (NULL != host); 682 GNUNET_assert (NULL != host);
683 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (host, config))
684 {
685 GNUNET_TESTBED_host_destroy (host);
686 host = NULL;
687 (void) PRINTF ("%s",
688 "Unable to run the test as this system is not configured "
689 "to use password less SSH logins to localhost.\n"
690 "Marking test as successful\n");
691 return;
692 }
683 cfg = GNUNET_CONFIGURATION_dup (config); 693 cfg = GNUNET_CONFIGURATION_dup (config);
684 cp1 = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, 694 cp1 = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
685 NULL); 695 NULL);
@@ -691,46 +701,6 @@ run (void *cls, char *const *args, const char *cfgfile,
691 701
692 702
693/** 703/**
694 * Function to check if
695 * 1. Password-less SSH logins to given ip work
696 * 2. gnunet-helper-testbed is found on the PATH on the remote side
697 *
698 * @param host_str numeric representation of the host's ip
699 * @return GNUNET_YES if password-less SSH login to the given host works;
700 * GNUNET_NO if not
701 */
702static int
703check_ssh (char *host_str)
704{
705 char *const remote_args[] = {
706 "ssh", "-o", "BatchMode=yes", "-o", "CheckHostIP=no",
707 "-o", "NoHostAuthenticationForLocalhost=yes", "-q",
708 host_str, "which", "gnunet-helper-testbed", NULL
709 };
710 // FIXME: the above no longer works with libexec/-installation!
711 struct GNUNET_OS_Process *auxp;
712 enum GNUNET_OS_ProcessStatusType type;
713 unsigned long code;
714 int ret;
715
716 auxp =
717 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
718 NULL, "ssh", remote_args);
719 GNUNET_assert (NULL != auxp);
720 do
721 {
722 ret = GNUNET_OS_process_status (auxp, &type, &code);
723 GNUNET_assert (GNUNET_SYSERR != ret);
724 (void) usleep (300);
725 }
726 while (GNUNET_NO == ret);
727 (void) GNUNET_OS_process_wait (auxp);
728 GNUNET_OS_process_destroy (auxp);
729 return (0 != code) ? GNUNET_NO : GNUNET_YES;
730}
731
732
733/**
734 * Main function 704 * Main function
735 */ 705 */
736int 706int
@@ -745,8 +715,6 @@ main (int argc, char **argv)
745 }; 715 };
746 int ret; 716 int ret;
747 717
748 if (GNUNET_YES != check_ssh ("127.0.0.1"))
749 goto error_exit;
750 result = INIT; 718 result = INIT;
751 ret = 719 ret =
752 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 720 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
@@ -755,13 +723,6 @@ main (int argc, char **argv)
755 if ((GNUNET_OK != ret) || (SUCCESS != result)) 723 if ((GNUNET_OK != ret) || (SUCCESS != result))
756 return 1; 724 return 1;
757 return 0; 725 return 0;
758
759 error_exit:
760 (void) PRINTF ("%s",
761 "Unable to run the test as this system is not configured "
762 "to use password less SSH logins to localhost.\n"
763 "Marking test as successful\n");
764 return 0;
765} 726}
766 727
767/* end of test_testbed_api_3peers_3controllers.c */ 728/* end of test_testbed_api_3peers_3controllers.c */
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c
index abde65166..471fb8630 100644
--- a/src/testbed/test_testbed_api_controllerlink.c
+++ b/src/testbed/test_testbed_api_controllerlink.c
@@ -633,6 +633,16 @@ run (void *cls, char *const *args, const char *cfgfile,
633{ 633{
634 host = GNUNET_TESTBED_host_create (NULL, NULL, 0); 634 host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
635 GNUNET_assert (NULL != host); 635 GNUNET_assert (NULL != host);
636 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (host, config))
637 {
638 GNUNET_TESTBED_host_destroy (host);
639 host = NULL;
640 (void) PRINTF ("%s",
641 "Unable to run the test as this system is not configured "
642 "to use password less SSH logins to localhost.\n"
643 "Marking test as successful\n");
644 return;
645 }
636 cfg = GNUNET_CONFIGURATION_dup (config); 646 cfg = GNUNET_CONFIGURATION_dup (config);
637 cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, 647 cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
638 NULL); 648 NULL);
@@ -644,46 +654,6 @@ run (void *cls, char *const *args, const char *cfgfile,
644 654
645 655
646/** 656/**
647 * Function to check if
648 * 1. Password-less SSH logins to given ip work
649 * 2. gnunet-helper-testbed is found on the PATH on the remote side
650 *
651 * @param host_str numeric representation of the host's ip
652 * @return GNUNET_YES if password-less SSH login to the given host works;
653 * GNUNET_NO if not
654 */
655static int
656check_ssh (char *host_str)
657{
658 char *const remote_args[] = {
659 "ssh", "-o", "BatchMode=yes", "-o", "CheckHostIP=no",
660 "-o", "NoHostAuthenticationForLocalhost=yes", "-q",
661 host_str, "which", "gnunet-helper-testbed", NULL
662 };
663 // FIXME: the above no longer works with libexec/-installation!
664 struct GNUNET_OS_Process *auxp;
665 enum GNUNET_OS_ProcessStatusType type;
666 unsigned long code;
667 int ret;
668
669 auxp =
670 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
671 NULL, "ssh", remote_args);
672 GNUNET_assert (NULL != auxp);
673 do
674 {
675 ret = GNUNET_OS_process_status (auxp, &type, &code);
676 GNUNET_assert (GNUNET_SYSERR != ret);
677 (void) usleep (300);
678 }
679 while (GNUNET_NO == ret);
680 (void) GNUNET_OS_process_wait (auxp);
681 GNUNET_OS_process_destroy (auxp);
682 return (0 != code) ? GNUNET_NO : GNUNET_YES;
683}
684
685
686/**
687 * Main function 657 * Main function
688 */ 658 */
689int 659int
@@ -698,8 +668,6 @@ main (int argc, char **argv)
698 }; 668 };
699 int ret; 669 int ret;
700 670
701 if (GNUNET_YES != check_ssh ("127.0.0.1"))
702 goto error_exit;
703 result = INIT; 671 result = INIT;
704 ret = 672 ret =
705 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 673 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
@@ -708,13 +676,6 @@ main (int argc, char **argv)
708 if ((GNUNET_OK != ret) || (SLAVE3_LINK_SUCCESS != result)) 676 if ((GNUNET_OK != ret) || (SLAVE3_LINK_SUCCESS != result))
709 return 1; 677 return 1;
710 return 0; 678 return 0;
711
712 error_exit:
713 (void) PRINTF ("%s",
714 "Unable to run the test as this system is not configured "
715 "to use password less SSH logins to localhost.\n"
716 "Marking test as successful\n");
717 return 0;
718} 679}
719 680
720/* end of test_testbed_api_controllerlink.c */ 681/* end of test_testbed_api_controllerlink.c */
diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in
index 418f11cd3..0da161c67 100644
--- a/src/testbed/testbed.conf.in
+++ b/src/testbed/testbed.conf.in
@@ -4,6 +4,8 @@ AUTOSTART = NO
4HOSTNAME = localhost 4HOSTNAME = localhost
5HOME = $SERVICEHOME 5HOME = $SERVICEHOME
6BINARY = gnunet-service-testbed 6BINARY = gnunet-service-testbed
7# Set this to the path where the testbed helper is installed
8# HELPER_BINARY_PATH = @prefix@/lib/gnunet/libexec/gnunet-helper-testbed
7ACCEPT_FROM = 127.0.0.1; 9ACCEPT_FROM = 127.0.0.1;
8ACCEPT_FROM6 = ::1; 10ACCEPT_FROM6 = ::1;
9UNIXPATH = /tmp/gnunet-service-testbed.sock 11UNIXPATH = /tmp/gnunet-service-testbed.sock
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 9696785f3..5bba87c19 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -68,13 +68,6 @@
68 68
69 69
70/** 70/**
71 * Testbed Helper binary name
72 */
73#define HELPER_TESTBED_BINARY "gnunet-helper-testbed"
74#define HELPER_TESTBED_BINARY_SSH ". ~/.bashrc; gnunet-helper-testbed"
75
76
77/**
78 * Handle for controller process 71 * Handle for controller process
79 */ 72 */
80struct GNUNET_TESTBED_ControllerProc 73struct GNUNET_TESTBED_ControllerProc
@@ -1464,6 +1457,7 @@ GNUNET_TESTBED_controller_start (const char *controller_ip,
1464 } 1457 }
1465 else 1458 else
1466 { 1459 {
1460 char *helper_binary_path;
1467 char *remote_args[10]; 1461 char *remote_args[10];
1468 unsigned int argp; 1462 unsigned int argp;
1469 const char *username; 1463 const char *username;
@@ -1485,13 +1479,17 @@ GNUNET_TESTBED_controller_start (const char *controller_ip,
1485 remote_args[argp++] = "-o"; 1479 remote_args[argp++] = "-o";
1486 remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes"; 1480 remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes";
1487 remote_args[argp++] = cp->dst; 1481 remote_args[argp++] = cp->dst;
1488 // FIXME: lib/gnunet/libexec/-prefix missing here!!! 1482 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed",
1489 remote_args[argp++] = HELPER_TESTBED_BINARY_SSH; 1483 "HELPER_BINARY_PATH",
1484 &helper_binary_path))
1485 helper_binary_path = GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
1486 remote_args[argp++] = helper_binary_path;
1490 remote_args[argp++] = NULL; 1487 remote_args[argp++] = NULL;
1491 GNUNET_assert (argp == 10); 1488 GNUNET_assert (argp == 10);
1492 cp->helper = 1489 cp->helper =
1493 GNUNET_HELPER_start (GNUNET_NO, "ssh", remote_args, &helper_mst, 1490 GNUNET_HELPER_start (GNUNET_NO, "ssh", remote_args, &helper_mst,
1494 &helper_exp_cb, cp); 1491 &helper_exp_cb, cp);
1492 GNUNET_free (helper_binary_path);
1495 } 1493 }
1496 if (NULL == cp->helper) 1494 if (NULL == cp->helper)
1497 { 1495 {
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index ba9ee0dcf..f492133e2 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -30,6 +30,13 @@
30#include "gnunet_testbed_service.h" 30#include "gnunet_testbed_service.h"
31#include "testbed.h" 31#include "testbed.h"
32 32
33
34/**
35 * Testbed Helper binary name
36 */
37#define HELPER_TESTBED_BINARY "gnunet-helper-testbed"
38
39
33/** 40/**
34 * Enumeration of operations 41 * Enumeration of operations
35 */ 42 */
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 387da99e0..42b8e3864 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -485,13 +485,16 @@ GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host,
485 * Checks whether a host can be used to start testbed service 485 * Checks whether a host can be used to start testbed service
486 * 486 *
487 * @param host the host to check 487 * @param host the host to check
488 * @param config the configuration handle to lookup the path of the testbed helper
488 * @return GNUNET_YES if testbed service can be started on the given host 489 * @return GNUNET_YES if testbed service can be started on the given host
489 * remotely; GNUNET_NO if not 490 * remotely; GNUNET_NO if not
490 */ 491 */
491int 492int
492GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host) 493GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host,
494 const struct GNUNET_CONFIGURATION_Handle *config)
493{ 495{
494 char *remote_args[11]; 496 char *remote_args[11];
497 char *helper_binary_path;
495 char *portstr; 498 char *portstr;
496 char *ssh_addr; 499 char *ssh_addr;
497 const char *hostname; 500 const char *hostname;
@@ -508,6 +511,10 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
508 ssh_addr = GNUNET_strdup (hostname); 511 ssh_addr = GNUNET_strdup (hostname);
509 else 512 else
510 GNUNET_asprintf (&ssh_addr, "%s@%s", host->username, hostname); 513 GNUNET_asprintf (&ssh_addr, "%s@%s", host->username, hostname);
514 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (config, "testbed",
515 "HELPER_BINARY_PATH",
516 &helper_binary_path))
517 helper_binary_path = GNUNET_OS_get_libexec_binary_path (HELPER_TESTBED_BINARY);
511 argp = 0; 518 argp = 0;
512 remote_args[argp++] = "ssh"; 519 remote_args[argp++] = "ssh";
513 GNUNET_asprintf (&portstr, "%u", host->port); 520 GNUNET_asprintf (&portstr, "%u", host->port);
@@ -518,13 +525,12 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
518 remote_args[argp++] = "-o"; 525 remote_args[argp++] = "-o";
519 remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes"; 526 remote_args[argp++] = "NoHostAuthenticationForLocalhost=yes";
520 remote_args[argp++] = ssh_addr; 527 remote_args[argp++] = ssh_addr;
521 // FIXME: this no longer works with 'libexec/' paths! 528 remote_args[argp++] = "stat";
522 remote_args[argp++] = "which"; 529 remote_args[argp++] = helper_binary_path;
523 remote_args[argp++] = "gnunet-helper-testbed";
524 remote_args[argp++] = NULL; 530 remote_args[argp++] = NULL;
525 GNUNET_assert (argp == 11); 531 GNUNET_assert (argp == 11);
526 auxp = 532 auxp =
527 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, 533 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ERR, NULL,
528 NULL, "ssh", remote_args); 534 NULL, "ssh", remote_args);
529 if (NULL == auxp) 535 if (NULL == auxp)
530 { 536 {
@@ -538,11 +544,11 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host)
538 GNUNET_assert (GNUNET_SYSERR != ret); 544 GNUNET_assert (GNUNET_SYSERR != ret);
539 (void) usleep (300); 545 (void) usleep (300);
540 } 546 }
541 while (GNUNET_NO == ret); 547 while (GNUNET_NO == ret);
542 //(void) GNUNET_OS_process_wait (auxp);
543 GNUNET_OS_process_destroy (auxp); 548 GNUNET_OS_process_destroy (auxp);
544 GNUNET_free (ssh_addr); 549 GNUNET_free (ssh_addr);
545 GNUNET_free (portstr); 550 GNUNET_free (portstr);
551 GNUNET_free (helper_binary_path);
546 return (0 != code) ? GNUNET_NO : GNUNET_YES; 552 return (0 != code) ? GNUNET_NO : GNUNET_YES;
547} 553}
548 554